@prismshadow/penguin-server 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +4 -4
  2. package/dist/api/types.d.ts +528 -39
  3. package/dist/auth-token.d.ts +29 -0
  4. package/dist/auth-token.js +51 -0
  5. package/dist/auth-token.js.map +1 -0
  6. package/dist/chunk-K4ZSUT72.js +34 -0
  7. package/dist/chunk-K4ZSUT72.js.map +1 -0
  8. package/dist/chunk-OTYHSDV7.js +374 -0
  9. package/dist/chunk-OTYHSDV7.js.map +1 -0
  10. package/dist/{chunk-WKJ3ANJP.js → chunk-WL5FUO3A.js} +92 -381
  11. package/dist/chunk-WL5FUO3A.js.map +1 -0
  12. package/dist/extension/index.d.ts +212 -0
  13. package/dist/extension/index.js +1 -0
  14. package/dist/extension/index.js.map +1 -0
  15. package/dist/index.js +7337 -1774
  16. package/dist/index.js.map +1 -1
  17. package/dist/initial-password.d.ts +9 -12
  18. package/dist/initial-password.js +3 -7
  19. package/dist/install.ps1 +729 -0
  20. package/dist/install.sh +785 -0
  21. package/dist/reset-admin-password.d.ts +4 -7
  22. package/dist/reset-admin-password.js +11 -9
  23. package/dist/reset-admin-password.js.map +1 -1
  24. package/dist/secret-file.d.ts +3 -0
  25. package/dist/secret-file.js +17 -0
  26. package/dist/secret-file.js.map +1 -0
  27. package/package.json +19 -3
  28. package/web-dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  29. package/web-dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  30. package/web-dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  31. package/web-dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  32. package/web-dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  33. package/web-dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  34. package/web-dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  35. package/web-dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  36. package/web-dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  37. package/web-dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  38. package/web-dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  39. package/web-dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  40. package/web-dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  41. package/web-dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  42. package/web-dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  43. package/web-dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  44. package/web-dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  45. package/web-dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  46. package/web-dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  47. package/web-dist/assets/{addon-fit-BXTX0Xqu.js → addon-fit-BjXzaLkS.js} +1 -1
  48. package/web-dist/assets/{addon-web-links-KebkunbU.js → addon-web-links-D4HvCIde.js} +1 -1
  49. package/web-dist/assets/{highlighter-B3HctNDB.js → highlighter-Di8euoN5.js} +1 -1
  50. package/web-dist/assets/index-C6i84Esu.js +451 -0
  51. package/web-dist/assets/index-DW00p4Ny.css +1 -0
  52. package/web-dist/assets/{xterm-fEUfDV0F.js → xterm-XhYBaOEK.js} +1 -1
  53. package/web-dist/index.html +2 -2
  54. package/dist/chunk-UUJCF46V.js +0 -50
  55. package/dist/chunk-UUJCF46V.js.map +0 -1
  56. package/dist/chunk-WKJ3ANJP.js.map +0 -1
  57. package/web-dist/assets/index-BbLm3DrY.css +0 -1
  58. package/web-dist/assets/index-DwgTjTHO.js +0 -189
@@ -1,189 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cpp-DIPi6g--.js","assets/c-BIGW1oBm.js","assets/sql-CRqJ_cUM.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/php-Csjmro_R.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/ruby-B13GW9FM.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/shellscript-Yzrsuije.js","assets/yaml-Buea-lGh.js"])))=>i.map(i=>d[i]);
2
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(o){if(o.ep)return;o.ep=!0;const c=n(o);fetch(o.href,c)}})();function vx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ig={exports:{}},$c={};var R1;function U3(){if(R1)return $c;R1=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,o,c){var u=null;if(c!==void 0&&(u=""+c),o.key!==void 0&&(u=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:s,key:u,ref:o!==void 0?o:null,props:c}}return $c.Fragment=t,$c.jsx=n,$c.jsxs=n,$c}var I1;function P3(){return I1||(I1=1,ig.exports=U3()),ig.exports}var a=P3(),og={exports:{}},kt={};var L1;function z3(){if(L1)return kt;L1=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function w(A){return A===null||typeof A!="object"?null:(A=v&&A[v]||A["@@iterator"],typeof A=="function"?A:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,N={};function T(A,Q,j){this.props=A,this.context=Q,this.refs=N,this.updater=j||S}T.prototype.isReactComponent={},T.prototype.setState=function(A,Q){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,Q,"setState")},T.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function _(){}_.prototype=T.prototype;function R(A,Q,j){this.props=A,this.context=Q,this.refs=N,this.updater=j||S}var D=R.prototype=new _;D.constructor=R,C(D,T.prototype),D.isPureReactComponent=!0;var z=Array.isArray;function E(){}var L={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function V(A,Q,j){var U=j.ref;return{$$typeof:e,type:A,key:Q,ref:U!==void 0?U:null,props:j}}function P(A,Q){return V(A.type,Q,A.props)}function B(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function Y(A){var Q={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(j){return Q[j]})}var q=/\/+/g;function K(A,Q){return typeof A=="object"&&A!==null&&A.key!=null?Y(""+A.key):Q.toString(36)}function H(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(E,E):(A.status="pending",A.then(function(Q){A.status==="pending"&&(A.status="fulfilled",A.value=Q)},function(Q){A.status==="pending"&&(A.status="rejected",A.reason=Q)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function $(A,Q,j,U,ee){var re=typeof A;(re==="undefined"||re==="boolean")&&(A=null);var ke=!1;if(A===null)ke=!0;else switch(re){case"bigint":case"string":case"number":ke=!0;break;case"object":switch(A.$$typeof){case e:case t:ke=!0;break;case x:return ke=A._init,$(ke(A._payload),Q,j,U,ee)}}if(ke)return ee=ee(A),ke=U===""?"."+K(A,0):U,z(ee)?(j="",ke!=null&&(j=ke.replace(q,"$&/")+"/"),$(ee,Q,j,"",function(Se){return Se})):ee!=null&&(B(ee)&&(ee=P(ee,j+(ee.key==null||A&&A.key===ee.key?"":(""+ee.key).replace(q,"$&/")+"/")+ke)),Q.push(ee)),1;ke=0;var be=U===""?".":U+":";if(z(A))for(var ye=0;ye<A.length;ye++)U=A[ye],re=be+K(U,ye),ke+=$(U,Q,j,re,ee);else if(ye=w(A),typeof ye=="function")for(A=ye.call(A),ye=0;!(U=A.next()).done;)U=U.value,re=be+K(U,ye++),ke+=$(U,Q,j,re,ee);else if(re==="object"){if(typeof A.then=="function")return $(H(A),Q,j,U,ee);throw Q=String(A),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.")}return ke}function X(A,Q,j){if(A==null)return A;var U=[],ee=0;return $(A,U,"","",function(re){return Q.call(j,re,ee++)}),U}function le(A){if(A._status===-1){var Q=A._result;Q=Q(),Q.then(function(j){(A._status===0||A._status===-1)&&(A._status=1,A._result=j)},function(j){(A._status===0||A._status===-1)&&(A._status=2,A._result=j)}),A._status===-1&&(A._status=0,A._result=Q)}if(A._status===1)return A._result.default;throw A._result}var ie=typeof reportError=="function"?reportError:function(A){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof A=="object"&&A!==null&&typeof A.message=="string"?String(A.message):String(A),error:A});if(!window.dispatchEvent(Q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",A);return}console.error(A)},I={map:X,forEach:function(A,Q,j){X(A,function(){Q.apply(this,arguments)},j)},count:function(A){var Q=0;return X(A,function(){Q++}),Q},toArray:function(A){return X(A,function(Q){return Q})||[]},only:function(A){if(!B(A))throw Error("React.Children.only expected to receive a single React element child.");return A}};return kt.Activity=g,kt.Children=I,kt.Component=T,kt.Fragment=n,kt.Profiler=o,kt.PureComponent=R,kt.StrictMode=s,kt.Suspense=p,kt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,kt.__COMPILER_RUNTIME={__proto__:null,c:function(A){return L.H.useMemoCache(A)}},kt.cache=function(A){return function(){return A.apply(null,arguments)}},kt.cacheSignal=function(){return null},kt.cloneElement=function(A,Q,j){if(A==null)throw Error("The argument must be a React element, but you passed "+A+".");var U=C({},A.props),ee=A.key;if(Q!=null)for(re in Q.key!==void 0&&(ee=""+Q.key),Q)!F.call(Q,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&Q.ref===void 0||(U[re]=Q[re]);var re=arguments.length-2;if(re===1)U.children=j;else if(1<re){for(var ke=Array(re),be=0;be<re;be++)ke[be]=arguments[be+2];U.children=ke}return V(A.type,ee,U)},kt.createContext=function(A){return A={$$typeof:u,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null},A.Provider=A,A.Consumer={$$typeof:c,_context:A},A},kt.createElement=function(A,Q,j){var U,ee={},re=null;if(Q!=null)for(U in Q.key!==void 0&&(re=""+Q.key),Q)F.call(Q,U)&&U!=="key"&&U!=="__self"&&U!=="__source"&&(ee[U]=Q[U]);var ke=arguments.length-2;if(ke===1)ee.children=j;else if(1<ke){for(var be=Array(ke),ye=0;ye<ke;ye++)be[ye]=arguments[ye+2];ee.children=be}if(A&&A.defaultProps)for(U in ke=A.defaultProps,ke)ee[U]===void 0&&(ee[U]=ke[U]);return V(A,re,ee)},kt.createRef=function(){return{current:null}},kt.forwardRef=function(A){return{$$typeof:f,render:A}},kt.isValidElement=B,kt.lazy=function(A){return{$$typeof:x,_payload:{_status:-1,_result:A},_init:le}},kt.memo=function(A,Q){return{$$typeof:h,type:A,compare:Q===void 0?null:Q}},kt.startTransition=function(A){var Q=L.T,j={};L.T=j;try{var U=A(),ee=L.S;ee!==null&&ee(j,U),typeof U=="object"&&U!==null&&typeof U.then=="function"&&U.then(E,ie)}catch(re){ie(re)}finally{Q!==null&&j.types!==null&&(Q.types=j.types),L.T=Q}},kt.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},kt.use=function(A){return L.H.use(A)},kt.useActionState=function(A,Q,j){return L.H.useActionState(A,Q,j)},kt.useCallback=function(A,Q){return L.H.useCallback(A,Q)},kt.useContext=function(A){return L.H.useContext(A)},kt.useDebugValue=function(){},kt.useDeferredValue=function(A,Q){return L.H.useDeferredValue(A,Q)},kt.useEffect=function(A,Q){return L.H.useEffect(A,Q)},kt.useEffectEvent=function(A){return L.H.useEffectEvent(A)},kt.useId=function(){return L.H.useId()},kt.useImperativeHandle=function(A,Q,j){return L.H.useImperativeHandle(A,Q,j)},kt.useInsertionEffect=function(A,Q){return L.H.useInsertionEffect(A,Q)},kt.useLayoutEffect=function(A,Q){return L.H.useLayoutEffect(A,Q)},kt.useMemo=function(A,Q){return L.H.useMemo(A,Q)},kt.useOptimistic=function(A,Q){return L.H.useOptimistic(A,Q)},kt.useReducer=function(A,Q,j){return L.H.useReducer(A,Q,j)},kt.useRef=function(A){return L.H.useRef(A)},kt.useState=function(A){return L.H.useState(A)},kt.useSyncExternalStore=function(A,Q,j){return L.H.useSyncExternalStore(A,Q,j)},kt.useTransition=function(){return L.H.useTransition()},kt.version="19.2.7",kt}var O1;function kx(){return O1||(O1=1,og.exports=z3()),og.exports}var y=kx();const hm=vx(y);var lg={exports:{}},Uc={},cg={exports:{}},ug={};var D1;function B3(){return D1||(D1=1,(function(e){function t($,X){var le=$.length;$.push(X);e:for(;0<le;){var ie=le-1>>>1,I=$[ie];if(0<o(I,X))$[ie]=X,$[le]=I,le=ie;else break e}}function n($){return $.length===0?null:$[0]}function s($){if($.length===0)return null;var X=$[0],le=$.pop();if(le!==X){$[0]=le;e:for(var ie=0,I=$.length,A=I>>>1;ie<A;){var Q=2*(ie+1)-1,j=$[Q],U=Q+1,ee=$[U];if(0>o(j,le))U<I&&0>o(ee,j)?($[ie]=ee,$[U]=le,ie=U):($[ie]=j,$[Q]=le,ie=Q);else if(U<I&&0>o(ee,le))$[ie]=ee,$[U]=le,ie=U;else break e}}return X}function o($,X){var le=$.sortIndex-X.sortIndex;return le!==0?le:$.id-X.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();e.unstable_now=function(){return u.now()-f}}var p=[],h=[],x=1,g=null,v=3,w=!1,S=!1,C=!1,N=!1,T=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function D($){for(var X=n(h);X!==null;){if(X.callback===null)s(h);else if(X.startTime<=$)s(h),X.sortIndex=X.expirationTime,t(p,X);else break;X=n(h)}}function z($){if(C=!1,D($),!S)if(n(p)!==null)S=!0,E||(E=!0,Y());else{var X=n(h);X!==null&&H(z,X.startTime-$)}}var E=!1,L=-1,F=5,V=-1;function P(){return N?!0:!(e.unstable_now()-V<F)}function B(){if(N=!1,E){var $=e.unstable_now();V=$;var X=!0;try{e:{S=!1,C&&(C=!1,_(L),L=-1),w=!0;var le=v;try{t:{for(D($),g=n(p);g!==null&&!(g.expirationTime>$&&P());){var ie=g.callback;if(typeof ie=="function"){g.callback=null,v=g.priorityLevel;var I=ie(g.expirationTime<=$);if($=e.unstable_now(),typeof I=="function"){g.callback=I,D($),X=!0;break t}g===n(p)&&s(p),D($)}else s(p);g=n(p)}if(g!==null)X=!0;else{var A=n(h);A!==null&&H(z,A.startTime-$),X=!1}}break e}finally{g=null,v=le,w=!1}X=void 0}}finally{X?Y():E=!1}}}var Y;if(typeof R=="function")Y=function(){R(B)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,K=q.port2;q.port1.onmessage=B,Y=function(){K.postMessage(null)}}else Y=function(){T(B,0)};function H($,X){L=T(function(){$(e.unstable_now())},X)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return v},e.unstable_next=function($){switch(v){case 1:case 2:case 3:var X=3;break;default:X=v}var le=v;v=X;try{return $()}finally{v=le}},e.unstable_requestPaint=function(){N=!0},e.unstable_runWithPriority=function($,X){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var le=v;v=$;try{return X()}finally{v=le}},e.unstable_scheduleCallback=function($,X,le){var ie=e.unstable_now();switch(typeof le=="object"&&le!==null?(le=le.delay,le=typeof le=="number"&&0<le?ie+le:ie):le=ie,$){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=le+I,$={id:x++,callback:X,priorityLevel:$,startTime:le,expirationTime:I,sortIndex:-1},le>ie?($.sortIndex=le,t(h,$),n(p)===null&&$===n(h)&&(C?(_(L),L=-1):C=!0,H(z,le-ie))):($.sortIndex=I,t(p,$),S||w||(S=!0,E||(E=!0,Y()))),$},e.unstable_shouldYield=P,e.unstable_wrapCallback=function($){var X=v;return function(){var le=v;v=X;try{return $.apply(this,arguments)}finally{v=le}}}})(ug)),ug}var $1;function H3(){return $1||($1=1,cg.exports=B3()),cg.exports}var dg={exports:{}},vr={};var U1;function F3(){if(U1)return vr;U1=1;var e=kx();function t(p){var h="https://react.dev/errors/"+p;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)h+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+p+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(p,h,x){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:p,containerInfo:h,implementation:x}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(p,h){if(p==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return vr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,vr.createPortal=function(p,h){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return c(p,h,null,x)},vr.flushSync=function(p){var h=u.T,x=s.p;try{if(u.T=null,s.p=2,p)return p()}finally{u.T=h,s.p=x,s.d.f()}},vr.preconnect=function(p,h){typeof p=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,s.d.C(p,h))},vr.prefetchDNS=function(p){typeof p=="string"&&s.d.D(p)},vr.preinit=function(p,h){if(typeof p=="string"&&h&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin),v=typeof h.integrity=="string"?h.integrity:void 0,w=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;x==="style"?s.d.S(p,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:v,fetchPriority:w}):x==="script"&&s.d.X(p,{crossOrigin:g,integrity:v,fetchPriority:w,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},vr.preinitModule=function(p,h){if(typeof p=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var x=f(h.as,h.crossOrigin);s.d.M(p,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&s.d.M(p)},vr.preload=function(p,h){if(typeof p=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var x=h.as,g=f(x,h.crossOrigin);s.d.L(p,x,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},vr.preloadModule=function(p,h){if(typeof p=="string")if(h){var x=f(h.as,h.crossOrigin);s.d.m(p,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else s.d.m(p)},vr.requestFormReset=function(p){s.d.r(p)},vr.unstable_batchedUpdates=function(p,h){return p(h)},vr.useFormState=function(p,h,x){return u.H.useFormState(p,h,x)},vr.useFormStatus=function(){return u.H.useHostTransitionStatus()},vr.version="19.2.7",vr}var P1;function $j(){if(P1)return dg.exports;P1=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),dg.exports=F3(),dg.exports}var z1;function q3(){if(z1)return Uc;z1=1;var e=H3(),t=kx(),n=$j();function s(r){var i="https://react.dev/errors/"+r;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)i+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+r+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function c(r){var i=r,l=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(l=i.return),r=i.return;while(r)}return i.tag===3?l:null}function u(r){if(r.tag===13){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function f(r){if(r.tag===31){var i=r.memoizedState;if(i===null&&(r=r.alternate,r!==null&&(i=r.memoizedState)),i!==null)return i.dehydrated}return null}function p(r){if(c(r)!==r)throw Error(s(188))}function h(r){var i=r.alternate;if(!i){if(i=c(r),i===null)throw Error(s(188));return i!==r?null:r}for(var l=r,m=i;;){var b=l.return;if(b===null)break;var k=b.alternate;if(k===null){if(m=b.return,m!==null){l=m;continue}break}if(b.child===k.child){for(k=b.child;k;){if(k===l)return p(b),r;if(k===m)return p(b),i;k=k.sibling}throw Error(s(188))}if(l.return!==m.return)l=b,m=k;else{for(var M=!1,O=b.child;O;){if(O===l){M=!0,l=b,m=k;break}if(O===m){M=!0,m=b,l=k;break}O=O.sibling}if(!M){for(O=k.child;O;){if(O===l){M=!0,l=k,m=b;break}if(O===m){M=!0,m=k,l=b;break}O=O.sibling}if(!M)throw Error(s(189))}}if(l.alternate!==m)throw Error(s(190))}if(l.tag!==3)throw Error(s(188));return l.stateNode.current===l?r:i}function x(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r;for(r=r.child;r!==null;){if(i=x(r),i!==null)return i;r=r.sibling}return null}var g=Object.assign,v=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),R=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),B=Symbol.iterator;function Y(r){return r===null||typeof r!="object"?null:(r=B&&r[B]||r["@@iterator"],typeof r=="function"?r:null)}var q=Symbol.for("react.client.reference");function K(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===q?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case C:return"Fragment";case T:return"Profiler";case N:return"StrictMode";case z:return"Suspense";case E:return"SuspenseList";case V:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case S:return"Portal";case R:return r.displayName||"Context";case _:return(r._context.displayName||"Context")+".Consumer";case D:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case L:return i=r.displayName||null,i!==null?i:K(r.type)||"Memo";case F:i=r._payload,r=r._init;try{return K(r(i))}catch{}}return null}var H=Array.isArray,$=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,le={pending:!1,data:null,method:null,action:null},ie=[],I=-1;function A(r){return{current:r}}function Q(r){0>I||(r.current=ie[I],ie[I]=null,I--)}function j(r,i){I++,ie[I]=r.current,r.current=i}var U=A(null),ee=A(null),re=A(null),ke=A(null);function be(r,i){switch(j(re,i),j(ee,r),j(U,null),i.nodeType){case 9:case 11:r=(r=i.documentElement)&&(r=r.namespaceURI)?t1(r):0;break;default:if(r=i.tagName,i=i.namespaceURI)i=t1(i),r=n1(i,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}Q(U),j(U,r)}function ye(){Q(U),Q(ee),Q(re)}function Se(r){r.memoizedState!==null&&j(ke,r);var i=U.current,l=n1(i,r.type);i!==l&&(j(ee,r),j(U,l))}function Me(r){ee.current===r&&(Q(U),Q(ee)),ke.current===r&&(Q(ke),Ic._currentValue=le)}var ze,De;function ct(r){if(ze===void 0)try{throw Error()}catch(l){var i=l.stack.trim().match(/\n( *(at )?)/);ze=i&&i[1]||"",De=-1<l.stack.indexOf(`
3
- at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
4
- `+ze+r+De}var bt=!1;function he(r,i){if(!r||bt)return"";bt=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var m={DetermineComponentFrameRoot:function(){try{if(i){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(xe){var fe=xe}Reflect.construct(r,[],Ne)}else{try{Ne.call()}catch(xe){fe=xe}r.call(Ne.prototype)}}else{try{throw Error()}catch(xe){fe=xe}(Ne=r())&&typeof Ne.catch=="function"&&Ne.catch(function(){})}}catch(xe){if(xe&&fe&&typeof xe.stack=="string")return[xe.stack,fe.stack]}return[null,null]}};m.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(m.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(m.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var k=m.DetermineComponentFrameRoot(),M=k[0],O=k[1];if(M&&O){var Z=M.split(`
5
- `),ue=O.split(`
6
- `);for(b=m=0;m<Z.length&&!Z[m].includes("DetermineComponentFrameRoot");)m++;for(;b<ue.length&&!ue[b].includes("DetermineComponentFrameRoot");)b++;if(m===Z.length||b===ue.length)for(m=Z.length-1,b=ue.length-1;1<=m&&0<=b&&Z[m]!==ue[b];)b--;for(;1<=m&&0<=b;m--,b--)if(Z[m]!==ue[b]){if(m!==1||b!==1)do if(m--,b--,0>b||Z[m]!==ue[b]){var we=`
7
- `+Z[m].replace(" at new "," at ");return r.displayName&&we.includes("<anonymous>")&&(we=we.replace("<anonymous>",r.displayName)),we}while(1<=m&&0<=b);break}}}finally{bt=!1,Error.prepareStackTrace=l}return(l=r?r.displayName||r.name:"")?ct(l):""}function ne(r,i){switch(r.tag){case 26:case 27:case 5:return ct(r.type);case 16:return ct("Lazy");case 13:return r.child!==i&&i!==null?ct("Suspense Fallback"):ct("Suspense");case 19:return ct("SuspenseList");case 0:case 15:return he(r.type,!1);case 11:return he(r.type.render,!1);case 1:return he(r.type,!0);case 31:return ct("Activity");default:return""}}function oe(r){try{var i="",l=null;do i+=ne(r,l),l=r,r=r.return;while(r);return i}catch(m){return`
8
- Error generating stack: `+m.message+`
9
- `+m.stack}}var J=Object.prototype.hasOwnProperty,ht=e.unstable_scheduleCallback,ve=e.unstable_cancelCallback,Xe=e.unstable_shouldYield,Ge=e.unstable_requestPaint,He=e.unstable_now,Pe=e.unstable_getCurrentPriorityLevel,W=e.unstable_ImmediatePriority,me=e.unstable_UserBlockingPriority,Ue=e.unstable_NormalPriority,pe=e.unstable_LowPriority,$e=e.unstable_IdlePriority,nt=e.log,gt=e.unstable_setDisableYieldValue,Ke=null,dt=null;function pt(r){if(typeof nt=="function"&&gt(r),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(Ke,r)}catch{}}var wt=Math.clz32?Math.clz32:Sn,st=Math.log,Bt=Math.LN2;function Sn(r){return r>>>=0,r===0?32:31-(st(r)/Bt|0)|0}var Dn=256,Vt=262144,ar=4194304;function zn(r){var i=r&42;if(i!==0)return i;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&261888;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function Xt(r,i,l){var m=r.pendingLanes;if(m===0)return 0;var b=0,k=r.suspendedLanes,M=r.pingedLanes;r=r.warmLanes;var O=m&134217727;return O!==0?(m=O&~k,m!==0?b=zn(m):(M&=O,M!==0?b=zn(M):l||(l=O&~r,l!==0&&(b=zn(l))))):(O=m&~k,O!==0?b=zn(O):M!==0?b=zn(M):l||(l=m&~r,l!==0&&(b=zn(l)))),b===0?0:i!==0&&i!==b&&(i&k)===0&&(k=b&-b,l=i&-i,k>=l||k===32&&(l&4194048)!==0)?i:b}function Cn(r,i){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&i)===0}function lr(r,i){switch(r){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Mt(){var r=ar;return ar<<=1,(ar&62914560)===0&&(ar=4194304),r}function Pr(r){for(var i=[],l=0;31>l;l++)i.push(r);return i}function Bn(r,i){r.pendingLanes|=i,i!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Nr(r,i,l,m,b,k){var M=r.pendingLanes;r.pendingLanes=l,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=l,r.entangledLanes&=l,r.errorRecoveryDisabledLanes&=l,r.shellSuspendCounter=0;var O=r.entanglements,Z=r.expirationTimes,ue=r.hiddenUpdates;for(l=M&~l;0<l;){var we=31-wt(l),Ne=1<<we;O[we]=0,Z[we]=-1;var fe=ue[we];if(fe!==null)for(ue[we]=null,we=0;we<fe.length;we++){var xe=fe[we];xe!==null&&(xe.lane&=-536870913)}l&=~Ne}m!==0&&Tr(r,m,0),k!==0&&b===0&&r.tag!==0&&(r.suspendedLanes|=k&~(M&~i))}function Tr(r,i,l){r.pendingLanes|=i,r.suspendedLanes&=~i;var m=31-wt(i);r.entangledLanes|=i,r.entanglements[m]=r.entanglements[m]|1073741824|l&261930}function Te(r,i){var l=r.entangledLanes|=i;for(r=r.entanglements;l;){var m=31-wt(l),b=1<<m;b&i|r[m]&i&&(r[m]|=i),l&=~b}}function Ie(r,i){var l=i&-i;return l=(l&42)!==0?1:ut(l),(l&(r.suspendedLanes|i))!==0?0:l}function ut(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function St(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function gn(){var r=X.p;return r!==0?r:(r=window.event,r===void 0?32:C1(r.type))}function Nn(r,i){var l=X.p;try{return X.p=r,i()}finally{X.p=l}}var Hn=Math.random().toString(36).slice(2),Dt="__reactFiber$"+Hn,Rn="__reactProps$"+Hn,zr="__reactContainer$"+Hn,cr="__reactEvents$"+Hn,Js="__reactListeners$"+Hn,Mr="__reactHandles$"+Hn,ta="__reactResources$"+Hn,Br="__reactMarker$"+Hn;function is(r){delete r[Dt],delete r[Rn],delete r[cr],delete r[Js],delete r[Mr]}function Hr(r){var i=r[Dt];if(i)return i;for(var l=r.parentNode;l;){if(i=l[zr]||l[Dt]){if(l=i.alternate,i.child!==null||l!==null&&l.child!==null)for(r=c1(r);r!==null;){if(l=r[Dt])return l;r=c1(r)}return i}r=l,l=r.parentNode}return null}function fn(r){if(r=r[Dt]||r[zr]){var i=r.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return r}return null}function Fr(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r.stateNode;throw Error(s(33))}function qr(r){var i=r[ta];return i||(i=r[ta]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function pn(r){r[Br]=!0}var na=new Set,Jn={};function Er(r,i){ur(r,i),ur(r+"Capture",i)}function ur(r,i){for(Jn[r]=i,r=0;r<i.length;r++)na.add(i[r])}var os=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ls={},ra={};function cs(r){return J.call(ra,r)?!0:J.call(ls,r)?!1:os.test(r)?ra[r]=!0:(ls[r]=!0,!1)}function ka(r,i,l){if(cs(i))if(l===null)r.removeAttribute(i);else{switch(typeof l){case"undefined":case"function":case"symbol":r.removeAttribute(i);return;case"boolean":var m=i.toLowerCase().slice(0,5);if(m!=="data-"&&m!=="aria-"){r.removeAttribute(i);return}}r.setAttribute(i,""+l)}}function Ar(r,i,l){if(l===null)r.removeAttribute(i);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(i);return}r.setAttribute(i,""+l)}}function er(r,i,l,m){if(m===null)r.removeAttribute(l);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(l);return}r.setAttributeNS(i,l,""+m)}}function Tn(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function Vr(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function wa(r,i,l){var m=Object.getOwnPropertyDescriptor(r.constructor.prototype,i);if(!r.hasOwnProperty(i)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var b=m.get,k=m.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return b.call(this)},set:function(M){l=""+M,k.call(this,M)}}),Object.defineProperty(r,i,{enumerable:m.enumerable}),{getValue:function(){return l},setValue:function(M){l=""+M},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function Mn(r){if(!r._valueTracker){var i=Vr(r)?"checked":"value";r._valueTracker=wa(r,i,""+r[i])}}function Gr(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var l=i.getValue(),m="";return r&&(m=Vr(r)?r.checked?"true":"false":r.value),r=m,r!==l?(i.setValue(r),!0):!1}function En(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}var us=/[\n"\\]/g;function hn(r){return r.replace(us,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Sa(r,i,l,m,b,k,M,O){r.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?r.type=M:r.removeAttribute("type"),i!=null?M==="number"?(i===0&&r.value===""||r.value!=i)&&(r.value=""+Tn(i)):r.value!==""+Tn(i)&&(r.value=""+Tn(i)):M!=="submit"&&M!=="reset"||r.removeAttribute("value"),i!=null?Ga(r,M,Tn(i)):l!=null?Ga(r,M,Tn(l)):m!=null&&r.removeAttribute("value"),b==null&&k!=null&&(r.defaultChecked=!!k),b!=null&&(r.checked=b&&typeof b!="function"&&typeof b!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?r.name=""+Tn(O):r.removeAttribute("name")}function Ts(r,i,l,m,b,k,M,O){if(k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"&&(r.type=k),i!=null||l!=null){if(!(k!=="submit"&&k!=="reset"||i!=null)){Mn(r);return}l=l!=null?""+Tn(l):"",i=i!=null?""+Tn(i):l,O||i===r.value||(r.value=i),r.defaultValue=i}m=m??b,m=typeof m!="function"&&typeof m!="symbol"&&!!m,r.checked=O?r.checked:!!m,r.defaultChecked=!!m,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(r.name=M),Mn(r)}function Ga(r,i,l){i==="number"&&En(r.ownerDocument)===r||r.defaultValue===""+l||(r.defaultValue=""+l)}function Ct(r,i,l,m){if(r=r.options,i){i={};for(var b=0;b<l.length;b++)i["$"+l[b]]=!0;for(l=0;l<r.length;l++)b=i.hasOwnProperty("$"+r[l].value),r[l].selected!==b&&(r[l].selected=b),b&&m&&(r[l].defaultSelected=!0)}else{for(l=""+Tn(l),i=null,b=0;b<r.length;b++){if(r[b].value===l){r[b].selected=!0,m&&(r[b].defaultSelected=!0);return}i!==null||r[b].disabled||(i=r[b])}i!==null&&(i.selected=!0)}}function ds(r,i,l){if(i!=null&&(i=""+Tn(i),i!==r.value&&(r.value=i),l==null)){r.defaultValue!==i&&(r.defaultValue=i);return}r.defaultValue=l!=null?""+Tn(l):""}function ja(r,i,l,m){if(i==null){if(m!=null){if(l!=null)throw Error(s(92));if(H(m)){if(1<m.length)throw Error(s(93));m=m[0]}l=m}l==null&&(l=""),i=l}l=Tn(i),r.defaultValue=l,m=r.textContent,m===l&&m!==""&&m!==null&&(r.value=m),Mn(r)}function br(r,i){if(i){var l=r.firstChild;if(l&&l===r.lastChild&&l.nodeType===3){l.nodeValue=i;return}}r.textContent=i}var Ca=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function de(r,i,l){var m=i.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?m?r.setProperty(i,""):i==="float"?r.cssFloat="":r[i]="":m?r.setProperty(i,l):typeof l!="number"||l===0||Ca.has(i)?i==="float"?r.cssFloat=l:r[i]=(""+l).trim():r[i]=l+"px"}function Re(r,i,l){if(i!=null&&typeof i!="object")throw Error(s(62));if(r=r.style,l!=null){for(var m in l)!l.hasOwnProperty(m)||i!=null&&i.hasOwnProperty(m)||(m.indexOf("--")===0?r.setProperty(m,""):m==="float"?r.cssFloat="":r[m]="");for(var b in i)m=i[b],i.hasOwnProperty(b)&&l[b]!==m&&de(r,b,m)}else for(var k in i)i.hasOwnProperty(k)&&de(r,k,i[k])}function Qe(r){if(r.indexOf("-")===-1)return!1;switch(r){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 mt=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Et=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Pt(r){return Et.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function Wt(){}var Ka=null;function _r(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Rr=null,Ir=null;function Ui(r){var i=fn(r);if(i&&(r=i.stateNode)){var l=r[Rn]||null;e:switch(r=i.stateNode,i.type){case"input":if(Sa(r,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),i=l.name,l.type==="radio"&&i!=null){for(l=r;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+hn(""+i)+'"][type="radio"]'),i=0;i<l.length;i++){var m=l[i];if(m!==r&&m.form===r.form){var b=m[Rn]||null;if(!b)throw Error(s(90));Sa(m,b.value,b.defaultValue,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name)}}for(i=0;i<l.length;i++)m=l[i],m.form===r.form&&Gr(m)}break e;case"textarea":ds(r,l.value,l.defaultValue);break e;case"select":i=l.value,i!=null&&Ct(r,!!l.multiple,i,!1)}}}var ae=!1;function _e(r,i,l){if(ae)return r(i,l);ae=!0;try{var m=r(i);return m}finally{if(ae=!1,(Rr!==null||Ir!==null)&&(Kd(),Rr&&(i=Rr,r=Ir,Ir=Rr=null,Ui(i),r)))for(i=0;i<r.length;i++)Ui(r[i])}}function et(r,i){var l=r.stateNode;if(l===null)return null;var m=l[Rn]||null;if(m===null)return null;l=m[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(r=r.type,m=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!m;break e;default:r=!1}if(r)return null;if(l&&typeof l!="function")throw Error(s(231,i,typeof l));return l}var qe=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vt=!1;if(qe)try{var xn={};Object.defineProperty(xn,"passive",{get:function(){vt=!0}}),window.addEventListener("test",xn,xn),window.removeEventListener("test",xn,xn)}catch{vt=!1}var tr=null,Pi=null,ei=null;function id(){if(ei)return ei;var r,i=Pi,l=i.length,m,b="value"in tr?tr.value:tr.textContent,k=b.length;for(r=0;r<l&&i[r]===b[r];r++);var M=l-r;for(m=1;m<=M&&i[l-m]===b[k-m];m++);return ei=b.slice(r,1<m?1-m:void 0)}function zi(r){var i=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&i===13&&(r=13)):r=i,r===10&&(r=13),32<=r||r===13?r:0}function Lo(){return!0}function Oo(){return!1}function nr(r){function i(l,m,b,k,M){this._reactName=l,this._targetInst=b,this.type=m,this.nativeEvent=k,this.target=M,this.currentTarget=null;for(var O in r)r.hasOwnProperty(O)&&(l=r[O],this[O]=l?l(k):k[O]);return this.isDefaultPrevented=(k.defaultPrevented!=null?k.defaultPrevented:k.returnValue===!1)?Lo:Oo,this.isPropagationStopped=Oo,this}return g(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Lo)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Lo)},persist:function(){},isPersistent:Lo}),i}var Ms={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bi=nr(Ms),Hi=g({},Ms,{view:0,detail:0}),Do=nr(Hi),ms,Fi,qi,$o=g({},Hi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:it,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==qi&&(qi&&r.type==="mousemove"?(ms=r.screenX-qi.screenX,Fi=r.screenY-qi.screenY):Fi=ms=0,qi=r),ms)},movementY:function(r){return"movementY"in r?r.movementY:Fi}}),od=nr($o),ld=g({},$o,{dataTransfer:0}),sp=nr(ld),ip=g({},Hi,{relatedTarget:0}),Ql=nr(ip),cd=g({},Ms,{animationName:0,elapsedTime:0,pseudoElement:0}),ud=nr(cd),op=g({},Ms,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),lp=nr(op),Zl=g({},Ms,{data:0}),Jl=nr(Zl),cp={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},G={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Ce={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ze(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=Ce[r])?!!i[r]:!1}function it(){return Ze}var tt=g({},Hi,{key:function(r){if(r.key){var i=cp[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=zi(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?G[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:it,charCode:function(r){return r.type==="keypress"?zi(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?zi(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),Je=nr(tt),ft=g({},$o,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),An=nr(ft),Ht=g({},Hi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:it}),dr=nr(Ht),ti=g({},Ms,{propertyName:0,elapsedTime:0,pseudoElement:0}),Na=nr(ti),Vi=g({},$o,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),dd=nr(Vi),up=g({},Ms,{newState:0,oldState:0}),dp=nr(up),Ta=[9,13,27,32],mp=qe&&"CompositionEvent"in window,ec=null;qe&&"documentMode"in document&&(ec=document.documentMode);var o4=qe&&"TextEvent"in window&&!ec,ob=qe&&(!mp||ec&&8<ec&&11>=ec),lb=" ",cb=!1;function ub(r,i){switch(r){case"keyup":return Ta.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function db(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Uo=!1;function l4(r,i){switch(r){case"compositionend":return db(i);case"keypress":return i.which!==32?null:(cb=!0,lb);case"textInput":return r=i.data,r===lb&&cb?null:r;default:return null}}function c4(r,i){if(Uo)return r==="compositionend"||!mp&&ub(r,i)?(r=id(),ei=Pi=tr=null,Uo=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return ob&&i.locale!=="ko"?null:i.data;default:return null}}var u4={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function mb(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!u4[r.type]:i==="textarea"}function fb(r,i,l,m){Rr?Ir?Ir.push(m):Ir=[m]:Rr=m,i=em(i,"onChange"),0<i.length&&(l=new Bi("onChange","change",null,l,m),r.push({event:l,listeners:i}))}var tc=null,nc=null;function d4(r){Yk(r,0)}function md(r){var i=Fr(r);if(Gr(i))return r}function pb(r,i){if(r==="change")return i}var hb=!1;if(qe){var fp;if(qe){var pp="oninput"in document;if(!pp){var gb=document.createElement("div");gb.setAttribute("oninput","return;"),pp=typeof gb.oninput=="function"}fp=pp}else fp=!1;hb=fp&&(!document.documentMode||9<document.documentMode)}function xb(){tc&&(tc.detachEvent("onpropertychange",yb),nc=tc=null)}function yb(r){if(r.propertyName==="value"&&md(nc)){var i=[];fb(i,nc,r,_r(r)),_e(d4,i)}}function m4(r,i,l){r==="focusin"?(xb(),tc=i,nc=l,tc.attachEvent("onpropertychange",yb)):r==="focusout"&&xb()}function f4(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return md(nc)}function p4(r,i){if(r==="click")return md(i)}function h4(r,i){if(r==="input"||r==="change")return md(i)}function g4(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var aa=typeof Object.is=="function"?Object.is:g4;function rc(r,i){if(aa(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var l=Object.keys(r),m=Object.keys(i);if(l.length!==m.length)return!1;for(m=0;m<l.length;m++){var b=l[m];if(!J.call(i,b)||!aa(r[b],i[b]))return!1}return!0}function bb(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function vb(r,i){var l=bb(r);r=0;for(var m;l;){if(l.nodeType===3){if(m=r+l.textContent.length,r<=i&&m>=i)return{node:l,offset:i-r};r=m}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=bb(l)}}function kb(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?kb(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function wb(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var i=En(r.document);i instanceof r.HTMLIFrameElement;){try{var l=typeof i.contentWindow.location.href=="string"}catch{l=!1}if(l)r=i.contentWindow;else break;i=En(r.document)}return i}function hp(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i&&(i==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||i==="textarea"||r.contentEditable==="true")}var x4=qe&&"documentMode"in document&&11>=document.documentMode,Po=null,gp=null,ac=null,xp=!1;function Sb(r,i,l){var m=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;xp||Po==null||Po!==En(m)||(m=Po,"selectionStart"in m&&hp(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),ac&&rc(ac,m)||(ac=m,m=em(gp,"onSelect"),0<m.length&&(i=new Bi("onSelect","select",null,i,l),r.push({event:i,listeners:m}),i.target=Po)))}function Gi(r,i){var l={};return l[r.toLowerCase()]=i.toLowerCase(),l["Webkit"+r]="webkit"+i,l["Moz"+r]="moz"+i,l}var zo={animationend:Gi("Animation","AnimationEnd"),animationiteration:Gi("Animation","AnimationIteration"),animationstart:Gi("Animation","AnimationStart"),transitionrun:Gi("Transition","TransitionRun"),transitionstart:Gi("Transition","TransitionStart"),transitioncancel:Gi("Transition","TransitionCancel"),transitionend:Gi("Transition","TransitionEnd")},yp={},jb={};qe&&(jb=document.createElement("div").style,"AnimationEvent"in window||(delete zo.animationend.animation,delete zo.animationiteration.animation,delete zo.animationstart.animation),"TransitionEvent"in window||delete zo.transitionend.transition);function Ki(r){if(yp[r])return yp[r];if(!zo[r])return r;var i=zo[r],l;for(l in i)if(i.hasOwnProperty(l)&&l in jb)return yp[r]=i[l];return r}var Cb=Ki("animationend"),Nb=Ki("animationiteration"),Tb=Ki("animationstart"),y4=Ki("transitionrun"),b4=Ki("transitionstart"),v4=Ki("transitioncancel"),Mb=Ki("transitionend"),Eb=new Map,bp="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");bp.push("scrollEnd");function Wa(r,i){Eb.set(r,i),Er(i,[r])}var fd=typeof reportError=="function"?reportError:function(r){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof r=="object"&&r!==null&&typeof r.message=="string"?String(r.message):String(r),error:r});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",r);return}console.error(r)},Ma=[],Bo=0,vp=0;function pd(){for(var r=Bo,i=vp=Bo=0;i<r;){var l=Ma[i];Ma[i++]=null;var m=Ma[i];Ma[i++]=null;var b=Ma[i];Ma[i++]=null;var k=Ma[i];if(Ma[i++]=null,m!==null&&b!==null){var M=m.pending;M===null?b.next=b:(b.next=M.next,M.next=b),m.pending=b}k!==0&&Ab(l,b,k)}}function hd(r,i,l,m){Ma[Bo++]=r,Ma[Bo++]=i,Ma[Bo++]=l,Ma[Bo++]=m,vp|=m,r.lanes|=m,r=r.alternate,r!==null&&(r.lanes|=m)}function kp(r,i,l,m){return hd(r,i,l,m),gd(r)}function Wi(r,i){return hd(r,null,null,i),gd(r)}function Ab(r,i,l){r.lanes|=l;var m=r.alternate;m!==null&&(m.lanes|=l);for(var b=!1,k=r.return;k!==null;)k.childLanes|=l,m=k.alternate,m!==null&&(m.childLanes|=l),k.tag===22&&(r=k.stateNode,r===null||r._visibility&1||(b=!0)),r=k,k=k.return;return r.tag===3?(k=r.stateNode,b&&i!==null&&(b=31-wt(l),r=k.hiddenUpdates,m=r[b],m===null?r[b]=[i]:m.push(i),i.lane=l|536870912),k):null}function gd(r){if(50<Nc)throw Nc=0,Ah=null,Error(s(185));for(var i=r.return;i!==null;)r=i,i=r.return;return r.tag===3?r.stateNode:null}var Ho={};function k4(r,i,l,m){this.tag=r,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function sa(r,i,l,m){return new k4(r,i,l,m)}function wp(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Es(r,i){var l=r.alternate;return l===null?(l=sa(r.tag,i,r.key,r.mode),l.elementType=r.elementType,l.type=r.type,l.stateNode=r.stateNode,l.alternate=r,r.alternate=l):(l.pendingProps=i,l.type=r.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=r.flags&65011712,l.childLanes=r.childLanes,l.lanes=r.lanes,l.child=r.child,l.memoizedProps=r.memoizedProps,l.memoizedState=r.memoizedState,l.updateQueue=r.updateQueue,i=r.dependencies,l.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},l.sibling=r.sibling,l.index=r.index,l.ref=r.ref,l.refCleanup=r.refCleanup,l}function _b(r,i){r.flags&=65011714;var l=r.alternate;return l===null?(r.childLanes=0,r.lanes=i,r.child=null,r.subtreeFlags=0,r.memoizedProps=null,r.memoizedState=null,r.updateQueue=null,r.dependencies=null,r.stateNode=null):(r.childLanes=l.childLanes,r.lanes=l.lanes,r.child=l.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=l.memoizedProps,r.memoizedState=l.memoizedState,r.updateQueue=l.updateQueue,r.type=l.type,i=l.dependencies,r.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),r}function xd(r,i,l,m,b,k){var M=0;if(m=r,typeof r=="function")wp(r)&&(M=1);else if(typeof r=="string")M=N3(r,l,U.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case V:return r=sa(31,l,i,b),r.elementType=V,r.lanes=k,r;case C:return Yi(l.children,b,k,i);case N:M=8,b|=24;break;case T:return r=sa(12,l,i,b|2),r.elementType=T,r.lanes=k,r;case z:return r=sa(13,l,i,b),r.elementType=z,r.lanes=k,r;case E:return r=sa(19,l,i,b),r.elementType=E,r.lanes=k,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case R:M=10;break e;case _:M=9;break e;case D:M=11;break e;case L:M=14;break e;case F:M=16,m=null;break e}M=29,l=Error(s(130,r===null?"null":typeof r,"")),m=null}return i=sa(M,l,i,b),i.elementType=r,i.type=m,i.lanes=k,i}function Yi(r,i,l,m){return r=sa(7,r,m,i),r.lanes=l,r}function Sp(r,i,l){return r=sa(6,r,null,i),r.lanes=l,r}function Rb(r){var i=sa(18,null,null,0);return i.stateNode=r,i}function jp(r,i,l){return i=sa(4,r.children!==null?r.children:[],r.key,i),i.lanes=l,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}var Ib=new WeakMap;function Ea(r,i){if(typeof r=="object"&&r!==null){var l=Ib.get(r);return l!==void 0?l:(i={value:r,source:i,stack:oe(i)},Ib.set(r,i),i)}return{value:r,source:i,stack:oe(i)}}var Fo=[],qo=0,yd=null,sc=0,Aa=[],_a=0,ni=null,fs=1,ps="";function As(r,i){Fo[qo++]=sc,Fo[qo++]=yd,yd=r,sc=i}function Lb(r,i,l){Aa[_a++]=fs,Aa[_a++]=ps,Aa[_a++]=ni,ni=r;var m=fs;r=ps;var b=32-wt(m)-1;m&=~(1<<b),l+=1;var k=32-wt(i)+b;if(30<k){var M=b-b%5;k=(m&(1<<M)-1).toString(32),m>>=M,b-=M,fs=1<<32-wt(i)+b|l<<b|m,ps=k+r}else fs=1<<k|l<<b|m,ps=r}function Cp(r){r.return!==null&&(As(r,1),Lb(r,1,0))}function Np(r){for(;r===yd;)yd=Fo[--qo],Fo[qo]=null,sc=Fo[--qo],Fo[qo]=null;for(;r===ni;)ni=Aa[--_a],Aa[_a]=null,ps=Aa[--_a],Aa[_a]=null,fs=Aa[--_a],Aa[_a]=null}function Ob(r,i){Aa[_a++]=fs,Aa[_a++]=ps,Aa[_a++]=ni,fs=i.id,ps=i.overflow,ni=r}var mr=null,yn=null,$t=!1,ri=null,Ra=!1,Tp=Error(s(519));function ai(r){var i=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ic(Ea(i,r)),Tp}function Db(r){var i=r.stateNode,l=r.type,m=r.memoizedProps;switch(i[Dt]=r,i[Rn]=m,l){case"dialog":_t("cancel",i),_t("close",i);break;case"iframe":case"object":case"embed":_t("load",i);break;case"video":case"audio":for(l=0;l<Mc.length;l++)_t(Mc[l],i);break;case"source":_t("error",i);break;case"img":case"image":case"link":_t("error",i),_t("load",i);break;case"details":_t("toggle",i);break;case"input":_t("invalid",i),Ts(i,m.value,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name,!0);break;case"select":_t("invalid",i);break;case"textarea":_t("invalid",i),ja(i,m.value,m.defaultValue,m.children)}l=m.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||i.textContent===""+l||m.suppressHydrationWarning===!0||Jk(i.textContent,l)?(m.popover!=null&&(_t("beforetoggle",i),_t("toggle",i)),m.onScroll!=null&&_t("scroll",i),m.onScrollEnd!=null&&_t("scrollend",i),m.onClick!=null&&(i.onclick=Wt),i=!0):i=!1,i||ai(r,!0)}function $b(r){for(mr=r.return;mr;)switch(mr.tag){case 5:case 31:case 13:Ra=!1;return;case 27:case 3:Ra=!0;return;default:mr=mr.return}}function Vo(r){if(r!==mr)return!1;if(!$t)return $b(r),$t=!0,!1;var i=r.tag,l;if((l=i!==3&&i!==27)&&((l=i===5)&&(l=r.type,l=!(l!=="form"&&l!=="button")||Vh(r.type,r.memoizedProps)),l=!l),l&&yn&&ai(r),$b(r),i===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));yn=l1(r)}else if(i===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));yn=l1(r)}else i===27?(i=yn,yi(r.type)?(r=Xh,Xh=null,yn=r):yn=i):yn=mr?La(r.stateNode.nextSibling):null;return!0}function Xi(){yn=mr=null,$t=!1}function Mp(){var r=ri;return r!==null&&(Xr===null?Xr=r:Xr.push.apply(Xr,r),ri=null),r}function ic(r){ri===null?ri=[r]:ri.push(r)}var Ep=A(null),Qi=null,_s=null;function si(r,i,l){j(Ep,i._currentValue),i._currentValue=l}function Rs(r){r._currentValue=Ep.current,Q(Ep)}function Ap(r,i,l){for(;r!==null;){var m=r.alternate;if((r.childLanes&i)!==i?(r.childLanes|=i,m!==null&&(m.childLanes|=i)):m!==null&&(m.childLanes&i)!==i&&(m.childLanes|=i),r===l)break;r=r.return}}function _p(r,i,l,m){var b=r.child;for(b!==null&&(b.return=r);b!==null;){var k=b.dependencies;if(k!==null){var M=b.child;k=k.firstContext;e:for(;k!==null;){var O=k;k=b;for(var Z=0;Z<i.length;Z++)if(O.context===i[Z]){k.lanes|=l,O=k.alternate,O!==null&&(O.lanes|=l),Ap(k.return,l,r),m||(M=null);break e}k=O.next}}else if(b.tag===18){if(M=b.return,M===null)throw Error(s(341));M.lanes|=l,k=M.alternate,k!==null&&(k.lanes|=l),Ap(M,l,r),M=null}else M=b.child;if(M!==null)M.return=b;else for(M=b;M!==null;){if(M===r){M=null;break}if(b=M.sibling,b!==null){b.return=M.return,M=b;break}M=M.return}b=M}}function Go(r,i,l,m){r=null;for(var b=i,k=!1;b!==null;){if(!k){if((b.flags&524288)!==0)k=!0;else if((b.flags&262144)!==0)break}if(b.tag===10){var M=b.alternate;if(M===null)throw Error(s(387));if(M=M.memoizedProps,M!==null){var O=b.type;aa(b.pendingProps.value,M.value)||(r!==null?r.push(O):r=[O])}}else if(b===ke.current){if(M=b.alternate,M===null)throw Error(s(387));M.memoizedState.memoizedState!==b.memoizedState.memoizedState&&(r!==null?r.push(Ic):r=[Ic])}b=b.return}r!==null&&_p(i,r,l,m),i.flags|=262144}function bd(r){for(r=r.firstContext;r!==null;){if(!aa(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function Zi(r){Qi=r,_s=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function fr(r){return Ub(Qi,r)}function vd(r,i){return Qi===null&&Zi(r),Ub(r,i)}function Ub(r,i){var l=i._currentValue;if(i={context:i,memoizedValue:l,next:null},_s===null){if(r===null)throw Error(s(308));_s=i,r.dependencies={lanes:0,firstContext:i},r.flags|=524288}else _s=_s.next=i;return l}var w4=typeof AbortController<"u"?AbortController:function(){var r=[],i=this.signal={aborted:!1,addEventListener:function(l,m){r.push(m)}};this.abort=function(){i.aborted=!0,r.forEach(function(l){return l()})}},S4=e.unstable_scheduleCallback,j4=e.unstable_NormalPriority,Fn={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Rp(){return{controller:new w4,data:new Map,refCount:0}}function oc(r){r.refCount--,r.refCount===0&&S4(j4,function(){r.controller.abort()})}var lc=null,Ip=0,Ko=0,Wo=null;function C4(r,i){if(lc===null){var l=lc=[];Ip=0,Ko=Dh(),Wo={status:"pending",value:void 0,then:function(m){l.push(m)}}}return Ip++,i.then(Pb,Pb),i}function Pb(){if(--Ip===0&&lc!==null){Wo!==null&&(Wo.status="fulfilled");var r=lc;lc=null,Ko=0,Wo=null;for(var i=0;i<r.length;i++)(0,r[i])()}}function N4(r,i){var l=[],m={status:"pending",value:null,reason:null,then:function(b){l.push(b)}};return r.then(function(){m.status="fulfilled",m.value=i;for(var b=0;b<l.length;b++)(0,l[b])(i)},function(b){for(m.status="rejected",m.reason=b,b=0;b<l.length;b++)(0,l[b])(void 0)}),m}var zb=$.S;$.S=function(r,i){Sk=He(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&C4(r,i),zb!==null&&zb(r,i)};var Ji=A(null);function Lp(){var r=Ji.current;return r!==null?r:cn.pooledCache}function kd(r,i){i===null?j(Ji,Ji.current):j(Ji,i.pool)}function Bb(){var r=Lp();return r===null?null:{parent:Fn._currentValue,pool:r}}var Yo=Error(s(460)),Op=Error(s(474)),wd=Error(s(542)),Sd={then:function(){}};function Hb(r){return r=r.status,r==="fulfilled"||r==="rejected"}function Fb(r,i,l){switch(l=r[l],l===void 0?r.push(i):l!==i&&(i.then(Wt,Wt),i=l),i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,Vb(r),r;default:if(typeof i.status=="string")i.then(Wt,Wt);else{if(r=cn,r!==null&&100<r.shellSuspendCounter)throw Error(s(482));r=i,r.status="pending",r.then(function(m){if(i.status==="pending"){var b=i;b.status="fulfilled",b.value=m}},function(m){if(i.status==="pending"){var b=i;b.status="rejected",b.reason=m}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,Vb(r),r}throw to=i,Yo}}function eo(r){try{var i=r._init;return i(r._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(to=l,Yo):l}}var to=null;function qb(){if(to===null)throw Error(s(459));var r=to;return to=null,r}function Vb(r){if(r===Yo||r===wd)throw Error(s(483))}var Xo=null,cc=0;function jd(r){var i=cc;return cc+=1,Xo===null&&(Xo=[]),Fb(Xo,r,i)}function uc(r,i){i=i.props.ref,r.ref=i!==void 0?i:null}function Cd(r,i){throw i.$$typeof===v?Error(s(525)):(r=Object.prototype.toString.call(i),Error(s(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r)))}function Gb(r){function i(se,te){if(r){var ce=se.deletions;ce===null?(se.deletions=[te],se.flags|=16):ce.push(te)}}function l(se,te){if(!r)return null;for(;te!==null;)i(se,te),te=te.sibling;return null}function m(se){for(var te=new Map;se!==null;)se.key!==null?te.set(se.key,se):te.set(se.index,se),se=se.sibling;return te}function b(se,te){return se=Es(se,te),se.index=0,se.sibling=null,se}function k(se,te,ce){return se.index=ce,r?(ce=se.alternate,ce!==null?(ce=ce.index,ce<te?(se.flags|=67108866,te):ce):(se.flags|=67108866,te)):(se.flags|=1048576,te)}function M(se){return r&&se.alternate===null&&(se.flags|=67108866),se}function O(se,te,ce,je){return te===null||te.tag!==6?(te=Sp(ce,se.mode,je),te.return=se,te):(te=b(te,ce),te.return=se,te)}function Z(se,te,ce,je){var rt=ce.type;return rt===C?we(se,te,ce.props.children,je,ce.key):te!==null&&(te.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===F&&eo(rt)===te.type)?(te=b(te,ce.props),uc(te,ce),te.return=se,te):(te=xd(ce.type,ce.key,ce.props,null,se.mode,je),uc(te,ce),te.return=se,te)}function ue(se,te,ce,je){return te===null||te.tag!==4||te.stateNode.containerInfo!==ce.containerInfo||te.stateNode.implementation!==ce.implementation?(te=jp(ce,se.mode,je),te.return=se,te):(te=b(te,ce.children||[]),te.return=se,te)}function we(se,te,ce,je,rt){return te===null||te.tag!==7?(te=Yi(ce,se.mode,je,rt),te.return=se,te):(te=b(te,ce),te.return=se,te)}function Ne(se,te,ce){if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return te=Sp(""+te,se.mode,ce),te.return=se,te;if(typeof te=="object"&&te!==null){switch(te.$$typeof){case w:return ce=xd(te.type,te.key,te.props,null,se.mode,ce),uc(ce,te),ce.return=se,ce;case S:return te=jp(te,se.mode,ce),te.return=se,te;case F:return te=eo(te),Ne(se,te,ce)}if(H(te)||Y(te))return te=Yi(te,se.mode,ce,null),te.return=se,te;if(typeof te.then=="function")return Ne(se,jd(te),ce);if(te.$$typeof===R)return Ne(se,vd(se,te),ce);Cd(se,te)}return null}function fe(se,te,ce,je){var rt=te!==null?te.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return rt!==null?null:O(se,te,""+ce,je);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:return ce.key===rt?Z(se,te,ce,je):null;case S:return ce.key===rt?ue(se,te,ce,je):null;case F:return ce=eo(ce),fe(se,te,ce,je)}if(H(ce)||Y(ce))return rt!==null?null:we(se,te,ce,je,null);if(typeof ce.then=="function")return fe(se,te,jd(ce),je);if(ce.$$typeof===R)return fe(se,te,vd(se,ce),je);Cd(se,ce)}return null}function xe(se,te,ce,je,rt){if(typeof je=="string"&&je!==""||typeof je=="number"||typeof je=="bigint")return se=se.get(ce)||null,O(te,se,""+je,rt);if(typeof je=="object"&&je!==null){switch(je.$$typeof){case w:return se=se.get(je.key===null?ce:je.key)||null,Z(te,se,je,rt);case S:return se=se.get(je.key===null?ce:je.key)||null,ue(te,se,je,rt);case F:return je=eo(je),xe(se,te,ce,je,rt)}if(H(je)||Y(je))return se=se.get(ce)||null,we(te,se,je,rt,null);if(typeof je.then=="function")return xe(se,te,ce,jd(je),rt);if(je.$$typeof===R)return xe(se,te,ce,vd(te,je),rt);Cd(te,je)}return null}function Ve(se,te,ce,je){for(var rt=null,Ft=null,We=te,Nt=te=0,Ot=null;We!==null&&Nt<ce.length;Nt++){We.index>Nt?(Ot=We,We=null):Ot=We.sibling;var qt=fe(se,We,ce[Nt],je);if(qt===null){We===null&&(We=Ot);break}r&&We&&qt.alternate===null&&i(se,We),te=k(qt,te,Nt),Ft===null?rt=qt:Ft.sibling=qt,Ft=qt,We=Ot}if(Nt===ce.length)return l(se,We),$t&&As(se,Nt),rt;if(We===null){for(;Nt<ce.length;Nt++)We=Ne(se,ce[Nt],je),We!==null&&(te=k(We,te,Nt),Ft===null?rt=We:Ft.sibling=We,Ft=We);return $t&&As(se,Nt),rt}for(We=m(We);Nt<ce.length;Nt++)Ot=xe(We,se,Nt,ce[Nt],je),Ot!==null&&(r&&Ot.alternate!==null&&We.delete(Ot.key===null?Nt:Ot.key),te=k(Ot,te,Nt),Ft===null?rt=Ot:Ft.sibling=Ot,Ft=Ot);return r&&We.forEach(function(Si){return i(se,Si)}),$t&&As(se,Nt),rt}function lt(se,te,ce,je){if(ce==null)throw Error(s(151));for(var rt=null,Ft=null,We=te,Nt=te=0,Ot=null,qt=ce.next();We!==null&&!qt.done;Nt++,qt=ce.next()){We.index>Nt?(Ot=We,We=null):Ot=We.sibling;var Si=fe(se,We,qt.value,je);if(Si===null){We===null&&(We=Ot);break}r&&We&&Si.alternate===null&&i(se,We),te=k(Si,te,Nt),Ft===null?rt=Si:Ft.sibling=Si,Ft=Si,We=Ot}if(qt.done)return l(se,We),$t&&As(se,Nt),rt;if(We===null){for(;!qt.done;Nt++,qt=ce.next())qt=Ne(se,qt.value,je),qt!==null&&(te=k(qt,te,Nt),Ft===null?rt=qt:Ft.sibling=qt,Ft=qt);return $t&&As(se,Nt),rt}for(We=m(We);!qt.done;Nt++,qt=ce.next())qt=xe(We,se,Nt,qt.value,je),qt!==null&&(r&&qt.alternate!==null&&We.delete(qt.key===null?Nt:qt.key),te=k(qt,te,Nt),Ft===null?rt=qt:Ft.sibling=qt,Ft=qt);return r&&We.forEach(function($3){return i(se,$3)}),$t&&As(se,Nt),rt}function rn(se,te,ce,je){if(typeof ce=="object"&&ce!==null&&ce.type===C&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case w:e:{for(var rt=ce.key;te!==null;){if(te.key===rt){if(rt=ce.type,rt===C){if(te.tag===7){l(se,te.sibling),je=b(te,ce.props.children),je.return=se,se=je;break e}}else if(te.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===F&&eo(rt)===te.type){l(se,te.sibling),je=b(te,ce.props),uc(je,ce),je.return=se,se=je;break e}l(se,te);break}else i(se,te);te=te.sibling}ce.type===C?(je=Yi(ce.props.children,se.mode,je,ce.key),je.return=se,se=je):(je=xd(ce.type,ce.key,ce.props,null,se.mode,je),uc(je,ce),je.return=se,se=je)}return M(se);case S:e:{for(rt=ce.key;te!==null;){if(te.key===rt)if(te.tag===4&&te.stateNode.containerInfo===ce.containerInfo&&te.stateNode.implementation===ce.implementation){l(se,te.sibling),je=b(te,ce.children||[]),je.return=se,se=je;break e}else{l(se,te);break}else i(se,te);te=te.sibling}je=jp(ce,se.mode,je),je.return=se,se=je}return M(se);case F:return ce=eo(ce),rn(se,te,ce,je)}if(H(ce))return Ve(se,te,ce,je);if(Y(ce)){if(rt=Y(ce),typeof rt!="function")throw Error(s(150));return ce=rt.call(ce),lt(se,te,ce,je)}if(typeof ce.then=="function")return rn(se,te,jd(ce),je);if(ce.$$typeof===R)return rn(se,te,vd(se,ce),je);Cd(se,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint"?(ce=""+ce,te!==null&&te.tag===6?(l(se,te.sibling),je=b(te,ce),je.return=se,se=je):(l(se,te),je=Sp(ce,se.mode,je),je.return=se,se=je),M(se)):l(se,te)}return function(se,te,ce,je){try{cc=0;var rt=rn(se,te,ce,je);return Xo=null,rt}catch(We){if(We===Yo||We===wd)throw We;var Ft=sa(29,We,null,se.mode);return Ft.lanes=je,Ft.return=se,Ft}}}var no=Gb(!0),Kb=Gb(!1),ii=!1;function Dp(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function $p(r,i){r=r.updateQueue,i.updateQueue===r&&(i.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function oi(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function li(r,i,l){var m=r.updateQueue;if(m===null)return null;if(m=m.shared,(Gt&2)!==0){var b=m.pending;return b===null?i.next=i:(i.next=b.next,b.next=i),m.pending=i,i=gd(r),Ab(r,null,l),i}return hd(r,m,i,l),gd(r)}function dc(r,i,l){if(i=i.updateQueue,i!==null&&(i=i.shared,(l&4194048)!==0)){var m=i.lanes;m&=r.pendingLanes,l|=m,i.lanes=l,Te(r,l)}}function Up(r,i){var l=r.updateQueue,m=r.alternate;if(m!==null&&(m=m.updateQueue,l===m)){var b=null,k=null;if(l=l.firstBaseUpdate,l!==null){do{var M={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};k===null?b=k=M:k=k.next=M,l=l.next}while(l!==null);k===null?b=k=i:k=k.next=i}else b=k=i;l={baseState:m.baseState,firstBaseUpdate:b,lastBaseUpdate:k,shared:m.shared,callbacks:m.callbacks},r.updateQueue=l;return}r=l.lastBaseUpdate,r===null?l.firstBaseUpdate=i:r.next=i,l.lastBaseUpdate=i}var Pp=!1;function mc(){if(Pp){var r=Wo;if(r!==null)throw r}}function fc(r,i,l,m){Pp=!1;var b=r.updateQueue;ii=!1;var k=b.firstBaseUpdate,M=b.lastBaseUpdate,O=b.shared.pending;if(O!==null){b.shared.pending=null;var Z=O,ue=Z.next;Z.next=null,M===null?k=ue:M.next=ue,M=Z;var we=r.alternate;we!==null&&(we=we.updateQueue,O=we.lastBaseUpdate,O!==M&&(O===null?we.firstBaseUpdate=ue:O.next=ue,we.lastBaseUpdate=Z))}if(k!==null){var Ne=b.baseState;M=0,we=ue=Z=null,O=k;do{var fe=O.lane&-536870913,xe=fe!==O.lane;if(xe?(Lt&fe)===fe:(m&fe)===fe){fe!==0&&fe===Ko&&(Pp=!0),we!==null&&(we=we.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var Ve=r,lt=O;fe=i;var rn=l;switch(lt.tag){case 1:if(Ve=lt.payload,typeof Ve=="function"){Ne=Ve.call(rn,Ne,fe);break e}Ne=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=lt.payload,fe=typeof Ve=="function"?Ve.call(rn,Ne,fe):Ve,fe==null)break e;Ne=g({},Ne,fe);break e;case 2:ii=!0}}fe=O.callback,fe!==null&&(r.flags|=64,xe&&(r.flags|=8192),xe=b.callbacks,xe===null?b.callbacks=[fe]:xe.push(fe))}else xe={lane:fe,tag:O.tag,payload:O.payload,callback:O.callback,next:null},we===null?(ue=we=xe,Z=Ne):we=we.next=xe,M|=fe;if(O=O.next,O===null){if(O=b.shared.pending,O===null)break;xe=O,O=xe.next,xe.next=null,b.lastBaseUpdate=xe,b.shared.pending=null}}while(!0);we===null&&(Z=Ne),b.baseState=Z,b.firstBaseUpdate=ue,b.lastBaseUpdate=we,k===null&&(b.shared.lanes=0),fi|=M,r.lanes=M,r.memoizedState=Ne}}function Wb(r,i){if(typeof r!="function")throw Error(s(191,r));r.call(i)}function Yb(r,i){var l=r.callbacks;if(l!==null)for(r.callbacks=null,r=0;r<l.length;r++)Wb(l[r],i)}var Qo=A(null),Nd=A(0);function Xb(r,i){r=Bs,j(Nd,r),j(Qo,i),Bs=r|i.baseLanes}function zp(){j(Nd,Bs),j(Qo,Qo.current)}function Bp(){Bs=Nd.current,Q(Qo),Q(Nd)}var ia=A(null),Ia=null;function ci(r){var i=r.alternate;j($n,$n.current&1),j(ia,r),Ia===null&&(i===null||Qo.current!==null||i.memoizedState!==null)&&(Ia=r)}function Hp(r){j($n,$n.current),j(ia,r),Ia===null&&(Ia=r)}function Qb(r){r.tag===22?(j($n,$n.current),j(ia,r),Ia===null&&(Ia=r)):ui()}function ui(){j($n,$n.current),j(ia,ia.current)}function oa(r){Q(ia),Ia===r&&(Ia=null),Q($n)}var $n=A(0);function Td(r){for(var i=r;i!==null;){if(i.tag===13){var l=i.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Wh(l)||Yh(l)))return i}else if(i.tag===19&&(i.memoizedProps.revealOrder==="forwards"||i.memoizedProps.revealOrder==="backwards"||i.memoizedProps.revealOrder==="unstable_legacy-backwards"||i.memoizedProps.revealOrder==="together")){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var Is=0,jt=null,tn=null,qn=null,Md=!1,Zo=!1,ro=!1,Ed=0,pc=0,Jo=null,T4=0;function In(){throw Error(s(321))}function Fp(r,i){if(i===null)return!1;for(var l=0;l<i.length&&l<r.length;l++)if(!aa(r[l],i[l]))return!1;return!0}function qp(r,i,l,m,b,k){return Is=k,jt=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,$.H=r===null||r.memoizedState===null?Lv:sh,ro=!1,k=l(m,b),ro=!1,Zo&&(k=Jb(i,l,m,b)),Zb(r),k}function Zb(r){$.H=xc;var i=tn!==null&&tn.next!==null;if(Is=0,qn=tn=jt=null,Md=!1,pc=0,Jo=null,i)throw Error(s(300));r===null||Vn||(r=r.dependencies,r!==null&&bd(r)&&(Vn=!0))}function Jb(r,i,l,m){jt=r;var b=0;do{if(Zo&&(Jo=null),pc=0,Zo=!1,25<=b)throw Error(s(301));if(b+=1,qn=tn=null,r.updateQueue!=null){var k=r.updateQueue;k.lastEffect=null,k.events=null,k.stores=null,k.memoCache!=null&&(k.memoCache.index=0)}$.H=Ov,k=i(l,m)}while(Zo);return k}function M4(){var r=$.H,i=r.useState()[0];return i=typeof i.then=="function"?hc(i):i,r=r.useState()[0],(tn!==null?tn.memoizedState:null)!==r&&(jt.flags|=1024),i}function Vp(){var r=Ed!==0;return Ed=0,r}function Gp(r,i,l){i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~l}function Kp(r){if(Md){for(r=r.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}Md=!1}Is=0,qn=tn=jt=null,Zo=!1,pc=Ed=0,Jo=null}function Lr(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return qn===null?jt.memoizedState=qn=r:qn=qn.next=r,qn}function Un(){if(tn===null){var r=jt.alternate;r=r!==null?r.memoizedState:null}else r=tn.next;var i=qn===null?jt.memoizedState:qn.next;if(i!==null)qn=i,tn=r;else{if(r===null)throw jt.alternate===null?Error(s(467)):Error(s(310));tn=r,r={memoizedState:tn.memoizedState,baseState:tn.baseState,baseQueue:tn.baseQueue,queue:tn.queue,next:null},qn===null?jt.memoizedState=qn=r:qn=qn.next=r}return qn}function Ad(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function hc(r){var i=pc;return pc+=1,Jo===null&&(Jo=[]),r=Fb(Jo,r,i),i=jt,(qn===null?i.memoizedState:qn.next)===null&&(i=i.alternate,$.H=i===null||i.memoizedState===null?Lv:sh),r}function _d(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return hc(r);if(r.$$typeof===R)return fr(r)}throw Error(s(438,String(r)))}function Wp(r){var i=null,l=jt.updateQueue;if(l!==null&&(i=l.memoCache),i==null){var m=jt.alternate;m!==null&&(m=m.updateQueue,m!==null&&(m=m.memoCache,m!=null&&(i={data:m.data.map(function(b){return b.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),l===null&&(l=Ad(),jt.updateQueue=l),l.memoCache=i,l=i.data[i.index],l===void 0)for(l=i.data[i.index]=Array(r),m=0;m<r;m++)l[m]=P;return i.index++,l}function Ls(r,i){return typeof i=="function"?i(r):i}function Rd(r){var i=Un();return Yp(i,tn,r)}function Yp(r,i,l){var m=r.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=l;var b=r.baseQueue,k=m.pending;if(k!==null){if(b!==null){var M=b.next;b.next=k.next,k.next=M}i.baseQueue=b=k,m.pending=null}if(k=r.baseState,b===null)r.memoizedState=k;else{i=b.next;var O=M=null,Z=null,ue=i,we=!1;do{var Ne=ue.lane&-536870913;if(Ne!==ue.lane?(Lt&Ne)===Ne:(Is&Ne)===Ne){var fe=ue.revertLane;if(fe===0)Z!==null&&(Z=Z.next={lane:0,revertLane:0,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),Ne===Ko&&(we=!0);else if((Is&fe)===fe){ue=ue.next,fe===Ko&&(we=!0);continue}else Ne={lane:0,revertLane:ue.revertLane,gesture:null,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},Z===null?(O=Z=Ne,M=k):Z=Z.next=Ne,jt.lanes|=fe,fi|=fe;Ne=ue.action,ro&&l(k,Ne),k=ue.hasEagerState?ue.eagerState:l(k,Ne)}else fe={lane:Ne,revertLane:ue.revertLane,gesture:ue.gesture,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null},Z===null?(O=Z=fe,M=k):Z=Z.next=fe,jt.lanes|=Ne,fi|=Ne;ue=ue.next}while(ue!==null&&ue!==i);if(Z===null?M=k:Z.next=O,!aa(k,r.memoizedState)&&(Vn=!0,we&&(l=Wo,l!==null)))throw l;r.memoizedState=k,r.baseState=M,r.baseQueue=Z,m.lastRenderedState=k}return b===null&&(m.lanes=0),[r.memoizedState,m.dispatch]}function Xp(r){var i=Un(),l=i.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=r;var m=l.dispatch,b=l.pending,k=i.memoizedState;if(b!==null){l.pending=null;var M=b=b.next;do k=r(k,M.action),M=M.next;while(M!==b);aa(k,i.memoizedState)||(Vn=!0),i.memoizedState=k,i.baseQueue===null&&(i.baseState=k),l.lastRenderedState=k}return[k,m]}function ev(r,i,l){var m=jt,b=Un(),k=$t;if(k){if(l===void 0)throw Error(s(407));l=l()}else l=i();var M=!aa((tn||b).memoizedState,l);if(M&&(b.memoizedState=l,Vn=!0),b=b.queue,Jp(rv.bind(null,m,b,r),[r]),b.getSnapshot!==i||M||qn!==null&&qn.memoizedState.tag&1){if(m.flags|=2048,el(9,{destroy:void 0},nv.bind(null,m,b,l,i),null),cn===null)throw Error(s(349));k||(Is&127)!==0||tv(m,i,l)}return l}function tv(r,i,l){r.flags|=16384,r={getSnapshot:i,value:l},i=jt.updateQueue,i===null?(i=Ad(),jt.updateQueue=i,i.stores=[r]):(l=i.stores,l===null?i.stores=[r]:l.push(r))}function nv(r,i,l,m){i.value=l,i.getSnapshot=m,av(i)&&sv(r)}function rv(r,i,l){return l(function(){av(i)&&sv(r)})}function av(r){var i=r.getSnapshot;r=r.value;try{var l=i();return!aa(r,l)}catch{return!0}}function sv(r){var i=Wi(r,2);i!==null&&Qr(i,r,2)}function Qp(r){var i=Lr();if(typeof r=="function"){var l=r;if(r=l(),ro){pt(!0);try{l()}finally{pt(!1)}}}return i.memoizedState=i.baseState=r,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:r},i}function iv(r,i,l,m){return r.baseState=l,Yp(r,tn,typeof m=="function"?m:Ls)}function E4(r,i,l,m,b){if(Od(r))throw Error(s(485));if(r=i.action,r!==null){var k={payload:b,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(M){k.listeners.push(M)}};$.T!==null?l(!0):k.isTransition=!1,m(k),l=i.pending,l===null?(k.next=i.pending=k,ov(i,k)):(k.next=l.next,i.pending=l.next=k)}}function ov(r,i){var l=i.action,m=i.payload,b=r.state;if(i.isTransition){var k=$.T,M={};$.T=M;try{var O=l(b,m),Z=$.S;Z!==null&&Z(M,O),lv(r,i,O)}catch(ue){Zp(r,i,ue)}finally{k!==null&&M.types!==null&&(k.types=M.types),$.T=k}}else try{k=l(b,m),lv(r,i,k)}catch(ue){Zp(r,i,ue)}}function lv(r,i,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(m){cv(r,i,m)},function(m){return Zp(r,i,m)}):cv(r,i,l)}function cv(r,i,l){i.status="fulfilled",i.value=l,uv(i),r.state=l,i=r.pending,i!==null&&(l=i.next,l===i?r.pending=null:(l=l.next,i.next=l,ov(r,l)))}function Zp(r,i,l){var m=r.pending;if(r.pending=null,m!==null){m=m.next;do i.status="rejected",i.reason=l,uv(i),i=i.next;while(i!==m)}r.action=null}function uv(r){r=r.listeners;for(var i=0;i<r.length;i++)(0,r[i])()}function dv(r,i){return i}function mv(r,i){if($t){var l=cn.formState;if(l!==null){e:{var m=jt;if($t){if(yn){t:{for(var b=yn,k=Ra;b.nodeType!==8;){if(!k){b=null;break t}if(b=La(b.nextSibling),b===null){b=null;break t}}k=b.data,b=k==="F!"||k==="F"?b:null}if(b){yn=La(b.nextSibling),m=b.data==="F!";break e}}ai(m)}m=!1}m&&(i=l[0])}}return l=Lr(),l.memoizedState=l.baseState=i,m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:dv,lastRenderedState:i},l.queue=m,l=_v.bind(null,jt,m),m.dispatch=l,m=Qp(!1),k=ah.bind(null,jt,!1,m.queue),m=Lr(),b={state:i,dispatch:null,action:r,pending:null},m.queue=b,l=E4.bind(null,jt,b,k,l),b.dispatch=l,m.memoizedState=r,[i,l,!1]}function fv(r){var i=Un();return pv(i,tn,r)}function pv(r,i,l){if(i=Yp(r,i,dv)[0],r=Rd(Ls)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var m=hc(i)}catch(M){throw M===Yo?wd:M}else m=i;i=Un();var b=i.queue,k=b.dispatch;return l!==i.memoizedState&&(jt.flags|=2048,el(9,{destroy:void 0},A4.bind(null,b,l),null)),[m,k,r]}function A4(r,i){r.action=i}function hv(r){var i=Un(),l=tn;if(l!==null)return pv(i,l,r);Un(),i=i.memoizedState,l=Un();var m=l.queue.dispatch;return l.memoizedState=r,[i,m,!1]}function el(r,i,l,m){return r={tag:r,create:l,deps:m,inst:i,next:null},i=jt.updateQueue,i===null&&(i=Ad(),jt.updateQueue=i),l=i.lastEffect,l===null?i.lastEffect=r.next=r:(m=l.next,l.next=r,r.next=m,i.lastEffect=r),r}function gv(){return Un().memoizedState}function Id(r,i,l,m){var b=Lr();jt.flags|=r,b.memoizedState=el(1|i,{destroy:void 0},l,m===void 0?null:m)}function Ld(r,i,l,m){var b=Un();m=m===void 0?null:m;var k=b.memoizedState.inst;tn!==null&&m!==null&&Fp(m,tn.memoizedState.deps)?b.memoizedState=el(i,k,l,m):(jt.flags|=r,b.memoizedState=el(1|i,k,l,m))}function xv(r,i){Id(8390656,8,r,i)}function Jp(r,i){Ld(2048,8,r,i)}function _4(r){jt.flags|=4;var i=jt.updateQueue;if(i===null)i=Ad(),jt.updateQueue=i,i.events=[r];else{var l=i.events;l===null?i.events=[r]:l.push(r)}}function yv(r){var i=Un().memoizedState;return _4({ref:i,nextImpl:r}),function(){if((Gt&2)!==0)throw Error(s(440));return i.impl.apply(void 0,arguments)}}function bv(r,i){return Ld(4,2,r,i)}function vv(r,i){return Ld(4,4,r,i)}function kv(r,i){if(typeof i=="function"){r=r();var l=i(r);return function(){typeof l=="function"?l():i(null)}}if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function wv(r,i,l){l=l!=null?l.concat([r]):null,Ld(4,4,kv.bind(null,i,r),l)}function eh(){}function Sv(r,i){var l=Un();i=i===void 0?null:i;var m=l.memoizedState;return i!==null&&Fp(i,m[1])?m[0]:(l.memoizedState=[r,i],r)}function jv(r,i){var l=Un();i=i===void 0?null:i;var m=l.memoizedState;if(i!==null&&Fp(i,m[1]))return m[0];if(m=r(),ro){pt(!0);try{r()}finally{pt(!1)}}return l.memoizedState=[m,i],m}function th(r,i,l){return l===void 0||(Is&1073741824)!==0&&(Lt&261930)===0?r.memoizedState=i:(r.memoizedState=l,r=Ck(),jt.lanes|=r,fi|=r,l)}function Cv(r,i,l,m){return aa(l,i)?l:Qo.current!==null?(r=th(r,l,m),aa(r,i)||(Vn=!0),r):(Is&42)===0||(Is&1073741824)!==0&&(Lt&261930)===0?(Vn=!0,r.memoizedState=l):(r=Ck(),jt.lanes|=r,fi|=r,i)}function Nv(r,i,l,m,b){var k=X.p;X.p=k!==0&&8>k?k:8;var M=$.T,O={};$.T=O,ah(r,!1,i,l);try{var Z=b(),ue=$.S;if(ue!==null&&ue(O,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var we=N4(Z,m);gc(r,i,we,ua(r))}else gc(r,i,m,ua(r))}catch(Ne){gc(r,i,{then:function(){},status:"rejected",reason:Ne},ua())}finally{X.p=k,M!==null&&O.types!==null&&(M.types=O.types),$.T=M}}function R4(){}function nh(r,i,l,m){if(r.tag!==5)throw Error(s(476));var b=Tv(r).queue;Nv(r,b,i,le,l===null?R4:function(){return Mv(r),l(m)})}function Tv(r){var i=r.memoizedState;if(i!==null)return i;i={memoizedState:le,baseState:le,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:le},next:null};var l={};return i.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:l},next:null},r.memoizedState=i,r=r.alternate,r!==null&&(r.memoizedState=i),i}function Mv(r){var i=Tv(r);i.next===null&&(i=r.alternate.memoizedState),gc(r,i.next.queue,{},ua())}function rh(){return fr(Ic)}function Ev(){return Un().memoizedState}function Av(){return Un().memoizedState}function I4(r){for(var i=r.return;i!==null;){switch(i.tag){case 24:case 3:var l=ua();r=oi(l);var m=li(i,r,l);m!==null&&(Qr(m,i,l),dc(m,i,l)),i={cache:Rp()},r.payload=i;return}i=i.return}}function L4(r,i,l){var m=ua();l={lane:m,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Od(r)?Rv(i,l):(l=kp(r,i,l,m),l!==null&&(Qr(l,r,m),Iv(l,i,m)))}function _v(r,i,l){var m=ua();gc(r,i,l,m)}function gc(r,i,l,m){var b={lane:m,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Od(r))Rv(i,b);else{var k=r.alternate;if(r.lanes===0&&(k===null||k.lanes===0)&&(k=i.lastRenderedReducer,k!==null))try{var M=i.lastRenderedState,O=k(M,l);if(b.hasEagerState=!0,b.eagerState=O,aa(O,M))return hd(r,i,b,0),cn===null&&pd(),!1}catch{}if(l=kp(r,i,b,m),l!==null)return Qr(l,r,m),Iv(l,i,m),!0}return!1}function ah(r,i,l,m){if(m={lane:2,revertLane:Dh(),gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},Od(r)){if(i)throw Error(s(479))}else i=kp(r,l,m,2),i!==null&&Qr(i,r,2)}function Od(r){var i=r.alternate;return r===jt||i!==null&&i===jt}function Rv(r,i){Zo=Md=!0;var l=r.pending;l===null?i.next=i:(i.next=l.next,l.next=i),r.pending=i}function Iv(r,i,l){if((l&4194048)!==0){var m=i.lanes;m&=r.pendingLanes,l|=m,i.lanes=l,Te(r,l)}}var xc={readContext:fr,use:_d,useCallback:In,useContext:In,useEffect:In,useImperativeHandle:In,useLayoutEffect:In,useInsertionEffect:In,useMemo:In,useReducer:In,useRef:In,useState:In,useDebugValue:In,useDeferredValue:In,useTransition:In,useSyncExternalStore:In,useId:In,useHostTransitionStatus:In,useFormState:In,useActionState:In,useOptimistic:In,useMemoCache:In,useCacheRefresh:In};xc.useEffectEvent=In;var Lv={readContext:fr,use:_d,useCallback:function(r,i){return Lr().memoizedState=[r,i===void 0?null:i],r},useContext:fr,useEffect:xv,useImperativeHandle:function(r,i,l){l=l!=null?l.concat([r]):null,Id(4194308,4,kv.bind(null,i,r),l)},useLayoutEffect:function(r,i){return Id(4194308,4,r,i)},useInsertionEffect:function(r,i){Id(4,2,r,i)},useMemo:function(r,i){var l=Lr();i=i===void 0?null:i;var m=r();if(ro){pt(!0);try{r()}finally{pt(!1)}}return l.memoizedState=[m,i],m},useReducer:function(r,i,l){var m=Lr();if(l!==void 0){var b=l(i);if(ro){pt(!0);try{l(i)}finally{pt(!1)}}}else b=i;return m.memoizedState=m.baseState=b,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:b},m.queue=r,r=r.dispatch=L4.bind(null,jt,r),[m.memoizedState,r]},useRef:function(r){var i=Lr();return r={current:r},i.memoizedState=r},useState:function(r){r=Qp(r);var i=r.queue,l=_v.bind(null,jt,i);return i.dispatch=l,[r.memoizedState,l]},useDebugValue:eh,useDeferredValue:function(r,i){var l=Lr();return th(l,r,i)},useTransition:function(){var r=Qp(!1);return r=Nv.bind(null,jt,r.queue,!0,!1),Lr().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,i,l){var m=jt,b=Lr();if($t){if(l===void 0)throw Error(s(407));l=l()}else{if(l=i(),cn===null)throw Error(s(349));(Lt&127)!==0||tv(m,i,l)}b.memoizedState=l;var k={value:l,getSnapshot:i};return b.queue=k,xv(rv.bind(null,m,k,r),[r]),m.flags|=2048,el(9,{destroy:void 0},nv.bind(null,m,k,l,i),null),l},useId:function(){var r=Lr(),i=cn.identifierPrefix;if($t){var l=ps,m=fs;l=(m&~(1<<32-wt(m)-1)).toString(32)+l,i="_"+i+"R_"+l,l=Ed++,0<l&&(i+="H"+l.toString(32)),i+="_"}else l=T4++,i="_"+i+"r_"+l.toString(32)+"_";return r.memoizedState=i},useHostTransitionStatus:rh,useFormState:mv,useActionState:mv,useOptimistic:function(r){var i=Lr();i.memoizedState=i.baseState=r;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=l,i=ah.bind(null,jt,!0,l),l.dispatch=i,[r,i]},useMemoCache:Wp,useCacheRefresh:function(){return Lr().memoizedState=I4.bind(null,jt)},useEffectEvent:function(r){var i=Lr(),l={impl:r};return i.memoizedState=l,function(){if((Gt&2)!==0)throw Error(s(440));return l.impl.apply(void 0,arguments)}}},sh={readContext:fr,use:_d,useCallback:Sv,useContext:fr,useEffect:Jp,useImperativeHandle:wv,useInsertionEffect:bv,useLayoutEffect:vv,useMemo:jv,useReducer:Rd,useRef:gv,useState:function(){return Rd(Ls)},useDebugValue:eh,useDeferredValue:function(r,i){var l=Un();return Cv(l,tn.memoizedState,r,i)},useTransition:function(){var r=Rd(Ls)[0],i=Un().memoizedState;return[typeof r=="boolean"?r:hc(r),i]},useSyncExternalStore:ev,useId:Ev,useHostTransitionStatus:rh,useFormState:fv,useActionState:fv,useOptimistic:function(r,i){var l=Un();return iv(l,tn,r,i)},useMemoCache:Wp,useCacheRefresh:Av};sh.useEffectEvent=yv;var Ov={readContext:fr,use:_d,useCallback:Sv,useContext:fr,useEffect:Jp,useImperativeHandle:wv,useInsertionEffect:bv,useLayoutEffect:vv,useMemo:jv,useReducer:Xp,useRef:gv,useState:function(){return Xp(Ls)},useDebugValue:eh,useDeferredValue:function(r,i){var l=Un();return tn===null?th(l,r,i):Cv(l,tn.memoizedState,r,i)},useTransition:function(){var r=Xp(Ls)[0],i=Un().memoizedState;return[typeof r=="boolean"?r:hc(r),i]},useSyncExternalStore:ev,useId:Ev,useHostTransitionStatus:rh,useFormState:hv,useActionState:hv,useOptimistic:function(r,i){var l=Un();return tn!==null?iv(l,tn,r,i):(l.baseState=r,[r,l.queue.dispatch])},useMemoCache:Wp,useCacheRefresh:Av};Ov.useEffectEvent=yv;function ih(r,i,l,m){i=r.memoizedState,l=l(m,i),l=l==null?i:g({},i,l),r.memoizedState=l,r.lanes===0&&(r.updateQueue.baseState=l)}var oh={enqueueSetState:function(r,i,l){r=r._reactInternals;var m=ua(),b=oi(m);b.payload=i,l!=null&&(b.callback=l),i=li(r,b,m),i!==null&&(Qr(i,r,m),dc(i,r,m))},enqueueReplaceState:function(r,i,l){r=r._reactInternals;var m=ua(),b=oi(m);b.tag=1,b.payload=i,l!=null&&(b.callback=l),i=li(r,b,m),i!==null&&(Qr(i,r,m),dc(i,r,m))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var l=ua(),m=oi(l);m.tag=2,i!=null&&(m.callback=i),i=li(r,m,l),i!==null&&(Qr(i,r,l),dc(i,r,l))}};function Dv(r,i,l,m,b,k,M){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(m,k,M):i.prototype&&i.prototype.isPureReactComponent?!rc(l,m)||!rc(b,k):!0}function $v(r,i,l,m){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(l,m),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(l,m),i.state!==r&&oh.enqueueReplaceState(i,i.state,null)}function ao(r,i){var l=i;if("ref"in i){l={};for(var m in i)m!=="ref"&&(l[m]=i[m])}if(r=r.defaultProps){l===i&&(l=g({},l));for(var b in r)l[b]===void 0&&(l[b]=r[b])}return l}function Uv(r){fd(r)}function Pv(r){console.error(r)}function zv(r){fd(r)}function Dd(r,i){try{var l=r.onUncaughtError;l(i.value,{componentStack:i.stack})}catch(m){setTimeout(function(){throw m})}}function Bv(r,i,l){try{var m=r.onCaughtError;m(l.value,{componentStack:l.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(b){setTimeout(function(){throw b})}}function lh(r,i,l){return l=oi(l),l.tag=3,l.payload={element:null},l.callback=function(){Dd(r,i)},l}function Hv(r){return r=oi(r),r.tag=3,r}function Fv(r,i,l,m){var b=l.type.getDerivedStateFromError;if(typeof b=="function"){var k=m.value;r.payload=function(){return b(k)},r.callback=function(){Bv(i,l,m)}}var M=l.stateNode;M!==null&&typeof M.componentDidCatch=="function"&&(r.callback=function(){Bv(i,l,m),typeof b!="function"&&(pi===null?pi=new Set([this]):pi.add(this));var O=m.stack;this.componentDidCatch(m.value,{componentStack:O!==null?O:""})})}function O4(r,i,l,m,b){if(l.flags|=32768,m!==null&&typeof m=="object"&&typeof m.then=="function"){if(i=l.alternate,i!==null&&Go(i,l,b,!0),l=ia.current,l!==null){switch(l.tag){case 31:case 13:return Ia===null?Wd():l.alternate===null&&Ln===0&&(Ln=3),l.flags&=-257,l.flags|=65536,l.lanes=b,m===Sd?l.flags|=16384:(i=l.updateQueue,i===null?l.updateQueue=new Set([m]):i.add(m),Ih(r,m,b)),!1;case 22:return l.flags|=65536,m===Sd?l.flags|=16384:(i=l.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([m])},l.updateQueue=i):(l=i.retryQueue,l===null?i.retryQueue=new Set([m]):l.add(m)),Ih(r,m,b)),!1}throw Error(s(435,l.tag))}return Ih(r,m,b),Wd(),!1}if($t)return i=ia.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=b,m!==Tp&&(r=Error(s(422),{cause:m}),ic(Ea(r,l)))):(m!==Tp&&(i=Error(s(423),{cause:m}),ic(Ea(i,l))),r=r.current.alternate,r.flags|=65536,b&=-b,r.lanes|=b,m=Ea(m,l),b=lh(r.stateNode,m,b),Up(r,b),Ln!==4&&(Ln=2)),!1;var k=Error(s(520),{cause:m});if(k=Ea(k,l),Cc===null?Cc=[k]:Cc.push(k),Ln!==4&&(Ln=2),i===null)return!0;m=Ea(m,l),l=i;do{switch(l.tag){case 3:return l.flags|=65536,r=b&-b,l.lanes|=r,r=lh(l.stateNode,m,r),Up(l,r),!1;case 1:if(i=l.type,k=l.stateNode,(l.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||k!==null&&typeof k.componentDidCatch=="function"&&(pi===null||!pi.has(k))))return l.flags|=65536,b&=-b,l.lanes|=b,b=Hv(b),Fv(b,r,l,m),Up(l,b),!1}l=l.return}while(l!==null);return!1}var ch=Error(s(461)),Vn=!1;function pr(r,i,l,m){i.child=r===null?Kb(i,null,l,m):no(i,r.child,l,m)}function qv(r,i,l,m,b){l=l.render;var k=i.ref;if("ref"in m){var M={};for(var O in m)O!=="ref"&&(M[O]=m[O])}else M=m;return Zi(i),m=qp(r,i,l,M,k,b),O=Vp(),r!==null&&!Vn?(Gp(r,i,b),Os(r,i,b)):($t&&O&&Cp(i),i.flags|=1,pr(r,i,m,b),i.child)}function Vv(r,i,l,m,b){if(r===null){var k=l.type;return typeof k=="function"&&!wp(k)&&k.defaultProps===void 0&&l.compare===null?(i.tag=15,i.type=k,Gv(r,i,k,m,b)):(r=xd(l.type,null,m,i,i.mode,b),r.ref=i.ref,r.return=i,i.child=r)}if(k=r.child,!xh(r,b)){var M=k.memoizedProps;if(l=l.compare,l=l!==null?l:rc,l(M,m)&&r.ref===i.ref)return Os(r,i,b)}return i.flags|=1,r=Es(k,m),r.ref=i.ref,r.return=i,i.child=r}function Gv(r,i,l,m,b){if(r!==null){var k=r.memoizedProps;if(rc(k,m)&&r.ref===i.ref)if(Vn=!1,i.pendingProps=m=k,xh(r,b))(r.flags&131072)!==0&&(Vn=!0);else return i.lanes=r.lanes,Os(r,i,b)}return uh(r,i,l,m,b)}function Kv(r,i,l,m){var b=m.children,k=r!==null?r.memoizedState:null;if(r===null&&i.stateNode===null&&(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.mode==="hidden"){if((i.flags&128)!==0){if(k=k!==null?k.baseLanes|l:l,r!==null){for(m=i.child=r.child,b=0;m!==null;)b=b|m.lanes|m.childLanes,m=m.sibling;m=b&~k}else m=0,i.child=null;return Wv(r,i,k,l,m)}if((l&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},r!==null&&kd(i,k!==null?k.cachePool:null),k!==null?Xb(i,k):zp(),Qb(i);else return m=i.lanes=536870912,Wv(r,i,k!==null?k.baseLanes|l:l,l,m)}else k!==null?(kd(i,k.cachePool),Xb(i,k),ui(),i.memoizedState=null):(r!==null&&kd(i,null),zp(),ui());return pr(r,i,b,l),i.child}function yc(r,i){return r!==null&&r.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function Wv(r,i,l,m,b){var k=Lp();return k=k===null?null:{parent:Fn._currentValue,pool:k},i.memoizedState={baseLanes:l,cachePool:k},r!==null&&kd(i,null),zp(),Qb(i),r!==null&&Go(r,i,m,!0),i.childLanes=b,null}function $d(r,i){return i=Pd({mode:i.mode,children:i.children},r.mode),i.ref=r.ref,r.child=i,i.return=r,i}function Yv(r,i,l){return no(i,r.child,null,l),r=$d(i,i.pendingProps),r.flags|=2,oa(i),i.memoizedState=null,r}function D4(r,i,l){var m=i.pendingProps,b=(i.flags&128)!==0;if(i.flags&=-129,r===null){if($t){if(m.mode==="hidden")return r=$d(i,m),i.lanes=536870912,yc(null,r);if(Hp(i),(r=yn)?(r=o1(r,Ra),r=r!==null&&r.data==="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:ni!==null?{id:fs,overflow:ps}:null,retryLane:536870912,hydrationErrors:null},l=Rb(r),l.return=i,i.child=l,mr=i,yn=null)):r=null,r===null)throw ai(i);return i.lanes=536870912,null}return $d(i,m)}var k=r.memoizedState;if(k!==null){var M=k.dehydrated;if(Hp(i),b)if(i.flags&256)i.flags&=-257,i=Yv(r,i,l);else if(i.memoizedState!==null)i.child=r.child,i.flags|=128,i=null;else throw Error(s(558));else if(Vn||Go(r,i,l,!1),b=(l&r.childLanes)!==0,Vn||b){if(m=cn,m!==null&&(M=Ie(m,l),M!==0&&M!==k.retryLane))throw k.retryLane=M,Wi(r,M),Qr(m,r,M),ch;Wd(),i=Yv(r,i,l)}else r=k.treeContext,yn=La(M.nextSibling),mr=i,$t=!0,ri=null,Ra=!1,r!==null&&Ob(i,r),i=$d(i,m),i.flags|=4096;return i}return r=Es(r.child,{mode:m.mode,children:m.children}),r.ref=i.ref,i.child=r,r.return=i,r}function Ud(r,i){var l=i.ref;if(l===null)r!==null&&r.ref!==null&&(i.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(s(284));(r===null||r.ref!==l)&&(i.flags|=4194816)}}function uh(r,i,l,m,b){return Zi(i),l=qp(r,i,l,m,void 0,b),m=Vp(),r!==null&&!Vn?(Gp(r,i,b),Os(r,i,b)):($t&&m&&Cp(i),i.flags|=1,pr(r,i,l,b),i.child)}function Xv(r,i,l,m,b,k){return Zi(i),i.updateQueue=null,l=Jb(i,m,l,b),Zb(r),m=Vp(),r!==null&&!Vn?(Gp(r,i,k),Os(r,i,k)):($t&&m&&Cp(i),i.flags|=1,pr(r,i,l,k),i.child)}function Qv(r,i,l,m,b){if(Zi(i),i.stateNode===null){var k=Ho,M=l.contextType;typeof M=="object"&&M!==null&&(k=fr(M)),k=new l(m,k),i.memoizedState=k.state!==null&&k.state!==void 0?k.state:null,k.updater=oh,i.stateNode=k,k._reactInternals=i,k=i.stateNode,k.props=m,k.state=i.memoizedState,k.refs={},Dp(i),M=l.contextType,k.context=typeof M=="object"&&M!==null?fr(M):Ho,k.state=i.memoizedState,M=l.getDerivedStateFromProps,typeof M=="function"&&(ih(i,l,M,m),k.state=i.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof k.getSnapshotBeforeUpdate=="function"||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(M=k.state,typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount(),M!==k.state&&oh.enqueueReplaceState(k,k.state,null),fc(i,m,k,b),mc(),k.state=i.memoizedState),typeof k.componentDidMount=="function"&&(i.flags|=4194308),m=!0}else if(r===null){k=i.stateNode;var O=i.memoizedProps,Z=ao(l,O);k.props=Z;var ue=k.context,we=l.contextType;M=Ho,typeof we=="object"&&we!==null&&(M=fr(we));var Ne=l.getDerivedStateFromProps;we=typeof Ne=="function"||typeof k.getSnapshotBeforeUpdate=="function",O=i.pendingProps!==O,we||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(O||ue!==M)&&$v(i,k,m,M),ii=!1;var fe=i.memoizedState;k.state=fe,fc(i,m,k,b),mc(),ue=i.memoizedState,O||fe!==ue||ii?(typeof Ne=="function"&&(ih(i,l,Ne,m),ue=i.memoizedState),(Z=ii||Dv(i,l,Z,m,fe,ue,M))?(we||typeof k.UNSAFE_componentWillMount!="function"&&typeof k.componentWillMount!="function"||(typeof k.componentWillMount=="function"&&k.componentWillMount(),typeof k.UNSAFE_componentWillMount=="function"&&k.UNSAFE_componentWillMount()),typeof k.componentDidMount=="function"&&(i.flags|=4194308)):(typeof k.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=m,i.memoizedState=ue),k.props=m,k.state=ue,k.context=M,m=Z):(typeof k.componentDidMount=="function"&&(i.flags|=4194308),m=!1)}else{k=i.stateNode,$p(r,i),M=i.memoizedProps,we=ao(l,M),k.props=we,Ne=i.pendingProps,fe=k.context,ue=l.contextType,Z=Ho,typeof ue=="object"&&ue!==null&&(Z=fr(ue)),O=l.getDerivedStateFromProps,(ue=typeof O=="function"||typeof k.getSnapshotBeforeUpdate=="function")||typeof k.UNSAFE_componentWillReceiveProps!="function"&&typeof k.componentWillReceiveProps!="function"||(M!==Ne||fe!==Z)&&$v(i,k,m,Z),ii=!1,fe=i.memoizedState,k.state=fe,fc(i,m,k,b),mc();var xe=i.memoizedState;M!==Ne||fe!==xe||ii||r!==null&&r.dependencies!==null&&bd(r.dependencies)?(typeof O=="function"&&(ih(i,l,O,m),xe=i.memoizedState),(we=ii||Dv(i,l,we,m,fe,xe,Z)||r!==null&&r.dependencies!==null&&bd(r.dependencies))?(ue||typeof k.UNSAFE_componentWillUpdate!="function"&&typeof k.componentWillUpdate!="function"||(typeof k.componentWillUpdate=="function"&&k.componentWillUpdate(m,xe,Z),typeof k.UNSAFE_componentWillUpdate=="function"&&k.UNSAFE_componentWillUpdate(m,xe,Z)),typeof k.componentDidUpdate=="function"&&(i.flags|=4),typeof k.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof k.componentDidUpdate!="function"||M===r.memoizedProps&&fe===r.memoizedState||(i.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||M===r.memoizedProps&&fe===r.memoizedState||(i.flags|=1024),i.memoizedProps=m,i.memoizedState=xe),k.props=m,k.state=xe,k.context=Z,m=we):(typeof k.componentDidUpdate!="function"||M===r.memoizedProps&&fe===r.memoizedState||(i.flags|=4),typeof k.getSnapshotBeforeUpdate!="function"||M===r.memoizedProps&&fe===r.memoizedState||(i.flags|=1024),m=!1)}return k=m,Ud(r,i),m=(i.flags&128)!==0,k||m?(k=i.stateNode,l=m&&typeof l.getDerivedStateFromError!="function"?null:k.render(),i.flags|=1,r!==null&&m?(i.child=no(i,r.child,null,b),i.child=no(i,null,l,b)):pr(r,i,l,b),i.memoizedState=k.state,r=i.child):r=Os(r,i,b),r}function Zv(r,i,l,m){return Xi(),i.flags|=256,pr(r,i,l,m),i.child}var dh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mh(r){return{baseLanes:r,cachePool:Bb()}}function fh(r,i,l){return r=r!==null?r.childLanes&~l:0,i&&(r|=ca),r}function Jv(r,i,l){var m=i.pendingProps,b=!1,k=(i.flags&128)!==0,M;if((M=k)||(M=r!==null&&r.memoizedState===null?!1:($n.current&2)!==0),M&&(b=!0,i.flags&=-129),M=(i.flags&32)!==0,i.flags&=-33,r===null){if($t){if(b?ci(i):ui(),(r=yn)?(r=o1(r,Ra),r=r!==null&&r.data!=="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:ni!==null?{id:fs,overflow:ps}:null,retryLane:536870912,hydrationErrors:null},l=Rb(r),l.return=i,i.child=l,mr=i,yn=null)):r=null,r===null)throw ai(i);return Yh(r)?i.lanes=32:i.lanes=536870912,null}var O=m.children;return m=m.fallback,b?(ui(),b=i.mode,O=Pd({mode:"hidden",children:O},b),m=Yi(m,b,l,null),O.return=i,m.return=i,O.sibling=m,i.child=O,m=i.child,m.memoizedState=mh(l),m.childLanes=fh(r,M,l),i.memoizedState=dh,yc(null,m)):(ci(i),ph(i,O))}var Z=r.memoizedState;if(Z!==null&&(O=Z.dehydrated,O!==null)){if(k)i.flags&256?(ci(i),i.flags&=-257,i=hh(r,i,l)):i.memoizedState!==null?(ui(),i.child=r.child,i.flags|=128,i=null):(ui(),O=m.fallback,b=i.mode,m=Pd({mode:"visible",children:m.children},b),O=Yi(O,b,l,null),O.flags|=2,m.return=i,O.return=i,m.sibling=O,i.child=m,no(i,r.child,null,l),m=i.child,m.memoizedState=mh(l),m.childLanes=fh(r,M,l),i.memoizedState=dh,i=yc(null,m));else if(ci(i),Yh(O)){if(M=O.nextSibling&&O.nextSibling.dataset,M)var ue=M.dgst;M=ue,m=Error(s(419)),m.stack="",m.digest=M,ic({value:m,source:null,stack:null}),i=hh(r,i,l)}else if(Vn||Go(r,i,l,!1),M=(l&r.childLanes)!==0,Vn||M){if(M=cn,M!==null&&(m=Ie(M,l),m!==0&&m!==Z.retryLane))throw Z.retryLane=m,Wi(r,m),Qr(M,r,m),ch;Wh(O)||Wd(),i=hh(r,i,l)}else Wh(O)?(i.flags|=192,i.child=r.child,i=null):(r=Z.treeContext,yn=La(O.nextSibling),mr=i,$t=!0,ri=null,Ra=!1,r!==null&&Ob(i,r),i=ph(i,m.children),i.flags|=4096);return i}return b?(ui(),O=m.fallback,b=i.mode,Z=r.child,ue=Z.sibling,m=Es(Z,{mode:"hidden",children:m.children}),m.subtreeFlags=Z.subtreeFlags&65011712,ue!==null?O=Es(ue,O):(O=Yi(O,b,l,null),O.flags|=2),O.return=i,m.return=i,m.sibling=O,i.child=m,yc(null,m),m=i.child,O=r.child.memoizedState,O===null?O=mh(l):(b=O.cachePool,b!==null?(Z=Fn._currentValue,b=b.parent!==Z?{parent:Z,pool:Z}:b):b=Bb(),O={baseLanes:O.baseLanes|l,cachePool:b}),m.memoizedState=O,m.childLanes=fh(r,M,l),i.memoizedState=dh,yc(r.child,m)):(ci(i),l=r.child,r=l.sibling,l=Es(l,{mode:"visible",children:m.children}),l.return=i,l.sibling=null,r!==null&&(M=i.deletions,M===null?(i.deletions=[r],i.flags|=16):M.push(r)),i.child=l,i.memoizedState=null,l)}function ph(r,i){return i=Pd({mode:"visible",children:i},r.mode),i.return=r,r.child=i}function Pd(r,i){return r=sa(22,r,null,i),r.lanes=0,r}function hh(r,i,l){return no(i,r.child,null,l),r=ph(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function ek(r,i,l){r.lanes|=i;var m=r.alternate;m!==null&&(m.lanes|=i),Ap(r.return,i,l)}function gh(r,i,l,m,b,k){var M=r.memoizedState;M===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:m,tail:l,tailMode:b,treeForkCount:k}:(M.isBackwards=i,M.rendering=null,M.renderingStartTime=0,M.last=m,M.tail=l,M.tailMode=b,M.treeForkCount=k)}function tk(r,i,l){var m=i.pendingProps,b=m.revealOrder,k=m.tail;m=m.children;var M=$n.current,O=(M&2)!==0;if(O?(M=M&1|2,i.flags|=128):M&=1,j($n,M),pr(r,i,m,l),m=$t?sc:0,!O&&r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&ek(r,l,i);else if(r.tag===19)ek(r,l,i);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break e;for(;r.sibling===null;){if(r.return===null||r.return===i)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}switch(b){case"forwards":for(l=i.child,b=null;l!==null;)r=l.alternate,r!==null&&Td(r)===null&&(b=l),l=l.sibling;l=b,l===null?(b=i.child,i.child=null):(b=l.sibling,l.sibling=null),gh(i,!1,b,l,k,m);break;case"backwards":case"unstable_legacy-backwards":for(l=null,b=i.child,i.child=null;b!==null;){if(r=b.alternate,r!==null&&Td(r)===null){i.child=b;break}r=b.sibling,b.sibling=l,l=b,b=r}gh(i,!0,l,null,k,m);break;case"together":gh(i,!1,null,null,void 0,m);break;default:i.memoizedState=null}return i.child}function Os(r,i,l){if(r!==null&&(i.dependencies=r.dependencies),fi|=i.lanes,(l&i.childLanes)===0)if(r!==null){if(Go(r,i,l,!1),(l&i.childLanes)===0)return null}else return null;if(r!==null&&i.child!==r.child)throw Error(s(153));if(i.child!==null){for(r=i.child,l=Es(r,r.pendingProps),i.child=l,l.return=i;r.sibling!==null;)r=r.sibling,l=l.sibling=Es(r,r.pendingProps),l.return=i;l.sibling=null}return i.child}function xh(r,i){return(r.lanes&i)!==0?!0:(r=r.dependencies,!!(r!==null&&bd(r)))}function $4(r,i,l){switch(i.tag){case 3:be(i,i.stateNode.containerInfo),si(i,Fn,r.memoizedState.cache),Xi();break;case 27:case 5:Se(i);break;case 4:be(i,i.stateNode.containerInfo);break;case 10:si(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,Hp(i),null;break;case 13:var m=i.memoizedState;if(m!==null)return m.dehydrated!==null?(ci(i),i.flags|=128,null):(l&i.child.childLanes)!==0?Jv(r,i,l):(ci(i),r=Os(r,i,l),r!==null?r.sibling:null);ci(i);break;case 19:var b=(r.flags&128)!==0;if(m=(l&i.childLanes)!==0,m||(Go(r,i,l,!1),m=(l&i.childLanes)!==0),b){if(m)return tk(r,i,l);i.flags|=128}if(b=i.memoizedState,b!==null&&(b.rendering=null,b.tail=null,b.lastEffect=null),j($n,$n.current),m)break;return null;case 22:return i.lanes=0,Kv(r,i,l,i.pendingProps);case 24:si(i,Fn,r.memoizedState.cache)}return Os(r,i,l)}function nk(r,i,l){if(r!==null)if(r.memoizedProps!==i.pendingProps)Vn=!0;else{if(!xh(r,l)&&(i.flags&128)===0)return Vn=!1,$4(r,i,l);Vn=(r.flags&131072)!==0}else Vn=!1,$t&&(i.flags&1048576)!==0&&Lb(i,sc,i.index);switch(i.lanes=0,i.tag){case 16:e:{var m=i.pendingProps;if(r=eo(i.elementType),i.type=r,typeof r=="function")wp(r)?(m=ao(r,m),i.tag=1,i=Qv(null,i,r,m,l)):(i.tag=0,i=uh(null,i,r,m,l));else{if(r!=null){var b=r.$$typeof;if(b===D){i.tag=11,i=qv(null,i,r,m,l);break e}else if(b===L){i.tag=14,i=Vv(null,i,r,m,l);break e}}throw i=K(r)||r,Error(s(306,i,""))}}return i;case 0:return uh(r,i,i.type,i.pendingProps,l);case 1:return m=i.type,b=ao(m,i.pendingProps),Qv(r,i,m,b,l);case 3:e:{if(be(i,i.stateNode.containerInfo),r===null)throw Error(s(387));m=i.pendingProps;var k=i.memoizedState;b=k.element,$p(r,i),fc(i,m,null,l);var M=i.memoizedState;if(m=M.cache,si(i,Fn,m),m!==k.cache&&_p(i,[Fn],l,!0),mc(),m=M.element,k.isDehydrated)if(k={element:m,isDehydrated:!1,cache:M.cache},i.updateQueue.baseState=k,i.memoizedState=k,i.flags&256){i=Zv(r,i,m,l);break e}else if(m!==b){b=Ea(Error(s(424)),i),ic(b),i=Zv(r,i,m,l);break e}else for(r=i.stateNode.containerInfo,r.nodeType===9?r=r.body:r=r.nodeName==="HTML"?r.ownerDocument.body:r,yn=La(r.firstChild),mr=i,$t=!0,ri=null,Ra=!0,l=Kb(i,null,m,l),i.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Xi(),m===b){i=Os(r,i,l);break e}pr(r,i,m,l)}i=i.child}return i;case 26:return Ud(r,i),r===null?(l=f1(i.type,null,i.pendingProps,null))?i.memoizedState=l:$t||(l=i.type,r=i.pendingProps,m=tm(re.current).createElement(l),m[Dt]=i,m[Rn]=r,hr(m,l,r),pn(m),i.stateNode=m):i.memoizedState=f1(i.type,r.memoizedProps,i.pendingProps,r.memoizedState),null;case 27:return Se(i),r===null&&$t&&(m=i.stateNode=u1(i.type,i.pendingProps,re.current),mr=i,Ra=!0,b=yn,yi(i.type)?(Xh=b,yn=La(m.firstChild)):yn=b),pr(r,i,i.pendingProps.children,l),Ud(r,i),r===null&&(i.flags|=4194304),i.child;case 5:return r===null&&$t&&((b=m=yn)&&(m=f3(m,i.type,i.pendingProps,Ra),m!==null?(i.stateNode=m,mr=i,yn=La(m.firstChild),Ra=!1,b=!0):b=!1),b||ai(i)),Se(i),b=i.type,k=i.pendingProps,M=r!==null?r.memoizedProps:null,m=k.children,Vh(b,k)?m=null:M!==null&&Vh(b,M)&&(i.flags|=32),i.memoizedState!==null&&(b=qp(r,i,M4,null,null,l),Ic._currentValue=b),Ud(r,i),pr(r,i,m,l),i.child;case 6:return r===null&&$t&&((r=l=yn)&&(l=p3(l,i.pendingProps,Ra),l!==null?(i.stateNode=l,mr=i,yn=null,r=!0):r=!1),r||ai(i)),null;case 13:return Jv(r,i,l);case 4:return be(i,i.stateNode.containerInfo),m=i.pendingProps,r===null?i.child=no(i,null,m,l):pr(r,i,m,l),i.child;case 11:return qv(r,i,i.type,i.pendingProps,l);case 7:return pr(r,i,i.pendingProps,l),i.child;case 8:return pr(r,i,i.pendingProps.children,l),i.child;case 12:return pr(r,i,i.pendingProps.children,l),i.child;case 10:return m=i.pendingProps,si(i,i.type,m.value),pr(r,i,m.children,l),i.child;case 9:return b=i.type._context,m=i.pendingProps.children,Zi(i),b=fr(b),m=m(b),i.flags|=1,pr(r,i,m,l),i.child;case 14:return Vv(r,i,i.type,i.pendingProps,l);case 15:return Gv(r,i,i.type,i.pendingProps,l);case 19:return tk(r,i,l);case 31:return D4(r,i,l);case 22:return Kv(r,i,l,i.pendingProps);case 24:return Zi(i),m=fr(Fn),r===null?(b=Lp(),b===null&&(b=cn,k=Rp(),b.pooledCache=k,k.refCount++,k!==null&&(b.pooledCacheLanes|=l),b=k),i.memoizedState={parent:m,cache:b},Dp(i),si(i,Fn,b)):((r.lanes&l)!==0&&($p(r,i),fc(i,null,null,l),mc()),b=r.memoizedState,k=i.memoizedState,b.parent!==m?(b={parent:m,cache:m},i.memoizedState=b,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=b),si(i,Fn,m)):(m=k.cache,si(i,Fn,m),m!==b.cache&&_p(i,[Fn],l,!0))),pr(r,i,i.pendingProps.children,l),i.child;case 29:throw i.pendingProps}throw Error(s(156,i.tag))}function Ds(r){r.flags|=4}function yh(r,i,l,m,b){if((i=(r.mode&32)!==0)&&(i=!1),i){if(r.flags|=16777216,(b&335544128)===b)if(r.stateNode.complete)r.flags|=8192;else if(Ek())r.flags|=8192;else throw to=Sd,Op}else r.flags&=-16777217}function rk(r,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!y1(i))if(Ek())r.flags|=8192;else throw to=Sd,Op}function zd(r,i){i!==null&&(r.flags|=4),r.flags&16384&&(i=r.tag!==22?Mt():536870912,r.lanes|=i,al|=i)}function bc(r,i){if(!$t)switch(r.tailMode){case"hidden":i=r.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?r.tail=null:l.sibling=null;break;case"collapsed":l=r.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:m.sibling=null}}function bn(r){var i=r.alternate!==null&&r.alternate.child===r.child,l=0,m=0;if(i)for(var b=r.child;b!==null;)l|=b.lanes|b.childLanes,m|=b.subtreeFlags&65011712,m|=b.flags&65011712,b.return=r,b=b.sibling;else for(b=r.child;b!==null;)l|=b.lanes|b.childLanes,m|=b.subtreeFlags,m|=b.flags,b.return=r,b=b.sibling;return r.subtreeFlags|=m,r.childLanes=l,i}function U4(r,i,l){var m=i.pendingProps;switch(Np(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bn(i),null;case 1:return bn(i),null;case 3:return l=i.stateNode,m=null,r!==null&&(m=r.memoizedState.cache),i.memoizedState.cache!==m&&(i.flags|=2048),Rs(Fn),ye(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(r===null||r.child===null)&&(Vo(i)?Ds(i):r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Mp())),bn(i),null;case 26:var b=i.type,k=i.memoizedState;return r===null?(Ds(i),k!==null?(bn(i),rk(i,k)):(bn(i),yh(i,b,null,m,l))):k?k!==r.memoizedState?(Ds(i),bn(i),rk(i,k)):(bn(i),i.flags&=-16777217):(r=r.memoizedProps,r!==m&&Ds(i),bn(i),yh(i,b,r,m,l)),null;case 27:if(Me(i),l=re.current,b=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==m&&Ds(i);else{if(!m){if(i.stateNode===null)throw Error(s(166));return bn(i),null}r=U.current,Vo(i)?Db(i):(r=u1(b,m,l),i.stateNode=r,Ds(i))}return bn(i),null;case 5:if(Me(i),b=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==m&&Ds(i);else{if(!m){if(i.stateNode===null)throw Error(s(166));return bn(i),null}if(k=U.current,Vo(i))Db(i);else{var M=tm(re.current);switch(k){case 1:k=M.createElementNS("http://www.w3.org/2000/svg",b);break;case 2:k=M.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;default:switch(b){case"svg":k=M.createElementNS("http://www.w3.org/2000/svg",b);break;case"math":k=M.createElementNS("http://www.w3.org/1998/Math/MathML",b);break;case"script":k=M.createElement("div"),k.innerHTML="<script><\/script>",k=k.removeChild(k.firstChild);break;case"select":k=typeof m.is=="string"?M.createElement("select",{is:m.is}):M.createElement("select"),m.multiple?k.multiple=!0:m.size&&(k.size=m.size);break;default:k=typeof m.is=="string"?M.createElement(b,{is:m.is}):M.createElement(b)}}k[Dt]=i,k[Rn]=m;e:for(M=i.child;M!==null;){if(M.tag===5||M.tag===6)k.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===i)break e;for(;M.sibling===null;){if(M.return===null||M.return===i)break e;M=M.return}M.sibling.return=M.return,M=M.sibling}i.stateNode=k;e:switch(hr(k,b,m),b){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}m&&Ds(i)}}return bn(i),yh(i,i.type,r===null?null:r.memoizedProps,i.pendingProps,l),null;case 6:if(r&&i.stateNode!=null)r.memoizedProps!==m&&Ds(i);else{if(typeof m!="string"&&i.stateNode===null)throw Error(s(166));if(r=re.current,Vo(i)){if(r=i.stateNode,l=i.memoizedProps,m=null,b=mr,b!==null)switch(b.tag){case 27:case 5:m=b.memoizedProps}r[Dt]=i,r=!!(r.nodeValue===l||m!==null&&m.suppressHydrationWarning===!0||Jk(r.nodeValue,l)),r||ai(i,!0)}else r=tm(r).createTextNode(m),r[Dt]=i,i.stateNode=r}return bn(i),null;case 31:if(l=i.memoizedState,r===null||r.memoizedState!==null){if(m=Vo(i),l!==null){if(r===null){if(!m)throw Error(s(318));if(r=i.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(557));r[Dt]=i}else Xi(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;bn(i),r=!1}else l=Mp(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=l),r=!0;if(!r)return i.flags&256?(oa(i),i):(oa(i),null);if((i.flags&128)!==0)throw Error(s(558))}return bn(i),null;case 13:if(m=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(b=Vo(i),m!==null&&m.dehydrated!==null){if(r===null){if(!b)throw Error(s(318));if(b=i.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(s(317));b[Dt]=i}else Xi(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;bn(i),b=!1}else b=Mp(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=b),b=!0;if(!b)return i.flags&256?(oa(i),i):(oa(i),null)}return oa(i),(i.flags&128)!==0?(i.lanes=l,i):(l=m!==null,r=r!==null&&r.memoizedState!==null,l&&(m=i.child,b=null,m.alternate!==null&&m.alternate.memoizedState!==null&&m.alternate.memoizedState.cachePool!==null&&(b=m.alternate.memoizedState.cachePool.pool),k=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(k=m.memoizedState.cachePool.pool),k!==b&&(m.flags|=2048)),l!==r&&l&&(i.child.flags|=8192),zd(i,i.updateQueue),bn(i),null);case 4:return ye(),r===null&&zh(i.stateNode.containerInfo),bn(i),null;case 10:return Rs(i.type),bn(i),null;case 19:if(Q($n),m=i.memoizedState,m===null)return bn(i),null;if(b=(i.flags&128)!==0,k=m.rendering,k===null)if(b)bc(m,!1);else{if(Ln!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(k=Td(r),k!==null){for(i.flags|=128,bc(m,!1),r=k.updateQueue,i.updateQueue=r,zd(i,r),i.subtreeFlags=0,r=l,l=i.child;l!==null;)_b(l,r),l=l.sibling;return j($n,$n.current&1|2),$t&&As(i,m.treeForkCount),i.child}r=r.sibling}m.tail!==null&&He()>Vd&&(i.flags|=128,b=!0,bc(m,!1),i.lanes=4194304)}else{if(!b)if(r=Td(k),r!==null){if(i.flags|=128,b=!0,r=r.updateQueue,i.updateQueue=r,zd(i,r),bc(m,!0),m.tail===null&&m.tailMode==="hidden"&&!k.alternate&&!$t)return bn(i),null}else 2*He()-m.renderingStartTime>Vd&&l!==536870912&&(i.flags|=128,b=!0,bc(m,!1),i.lanes=4194304);m.isBackwards?(k.sibling=i.child,i.child=k):(r=m.last,r!==null?r.sibling=k:i.child=k,m.last=k)}return m.tail!==null?(r=m.tail,m.rendering=r,m.tail=r.sibling,m.renderingStartTime=He(),r.sibling=null,l=$n.current,j($n,b?l&1|2:l&1),$t&&As(i,m.treeForkCount),r):(bn(i),null);case 22:case 23:return oa(i),Bp(),m=i.memoizedState!==null,r!==null?r.memoizedState!==null!==m&&(i.flags|=8192):m&&(i.flags|=8192),m?(l&536870912)!==0&&(i.flags&128)===0&&(bn(i),i.subtreeFlags&6&&(i.flags|=8192)):bn(i),l=i.updateQueue,l!==null&&zd(i,l.retryQueue),l=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),m=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(m=i.memoizedState.cachePool.pool),m!==l&&(i.flags|=2048),r!==null&&Q(Ji),null;case 24:return l=null,r!==null&&(l=r.memoizedState.cache),i.memoizedState.cache!==l&&(i.flags|=2048),Rs(Fn),bn(i),null;case 25:return null;case 30:return null}throw Error(s(156,i.tag))}function P4(r,i){switch(Np(i),i.tag){case 1:return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return Rs(Fn),ye(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 26:case 27:case 5:return Me(i),null;case 31:if(i.memoizedState!==null){if(oa(i),i.alternate===null)throw Error(s(340));Xi()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 13:if(oa(i),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(s(340));Xi()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return Q($n),null;case 4:return ye(),null;case 10:return Rs(i.type),null;case 22:case 23:return oa(i),Bp(),r!==null&&Q(Ji),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 24:return Rs(Fn),null;case 25:return null;default:return null}}function ak(r,i){switch(Np(i),i.tag){case 3:Rs(Fn),ye();break;case 26:case 27:case 5:Me(i);break;case 4:ye();break;case 31:i.memoizedState!==null&&oa(i);break;case 13:oa(i);break;case 19:Q($n);break;case 10:Rs(i.type);break;case 22:case 23:oa(i),Bp(),r!==null&&Q(Ji);break;case 24:Rs(Fn)}}function vc(r,i){try{var l=i.updateQueue,m=l!==null?l.lastEffect:null;if(m!==null){var b=m.next;l=b;do{if((l.tag&r)===r){m=void 0;var k=l.create,M=l.inst;m=k(),M.destroy=m}l=l.next}while(l!==b)}}catch(O){Zt(i,i.return,O)}}function di(r,i,l){try{var m=i.updateQueue,b=m!==null?m.lastEffect:null;if(b!==null){var k=b.next;m=k;do{if((m.tag&r)===r){var M=m.inst,O=M.destroy;if(O!==void 0){M.destroy=void 0,b=i;var Z=l,ue=O;try{ue()}catch(we){Zt(b,Z,we)}}}m=m.next}while(m!==k)}}catch(we){Zt(i,i.return,we)}}function sk(r){var i=r.updateQueue;if(i!==null){var l=r.stateNode;try{Yb(i,l)}catch(m){Zt(r,r.return,m)}}}function ik(r,i,l){l.props=ao(r.type,r.memoizedProps),l.state=r.memoizedState;try{l.componentWillUnmount()}catch(m){Zt(r,i,m)}}function kc(r,i){try{var l=r.ref;if(l!==null){switch(r.tag){case 26:case 27:case 5:var m=r.stateNode;break;case 30:m=r.stateNode;break;default:m=r.stateNode}typeof l=="function"?r.refCleanup=l(m):l.current=m}}catch(b){Zt(r,i,b)}}function hs(r,i){var l=r.ref,m=r.refCleanup;if(l!==null)if(typeof m=="function")try{m()}catch(b){Zt(r,i,b)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(b){Zt(r,i,b)}else l.current=null}function ok(r){var i=r.type,l=r.memoizedProps,m=r.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":l.autoFocus&&m.focus();break e;case"img":l.src?m.src=l.src:l.srcSet&&(m.srcset=l.srcSet)}}catch(b){Zt(r,r.return,b)}}function bh(r,i,l){try{var m=r.stateNode;o3(m,r.type,l,i),m[Rn]=i}catch(b){Zt(r,r.return,b)}}function lk(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&yi(r.type)||r.tag===4}function vh(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||lk(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&yi(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function kh(r,i,l){var m=r.tag;if(m===5||m===6)r=r.stateNode,i?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(r,i):(i=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,i.appendChild(r),l=l._reactRootContainer,l!=null||i.onclick!==null||(i.onclick=Wt));else if(m!==4&&(m===27&&yi(r.type)&&(l=r.stateNode,i=null),r=r.child,r!==null))for(kh(r,i,l),r=r.sibling;r!==null;)kh(r,i,l),r=r.sibling}function Bd(r,i,l){var m=r.tag;if(m===5||m===6)r=r.stateNode,i?l.insertBefore(r,i):l.appendChild(r);else if(m!==4&&(m===27&&yi(r.type)&&(l=r.stateNode),r=r.child,r!==null))for(Bd(r,i,l),r=r.sibling;r!==null;)Bd(r,i,l),r=r.sibling}function ck(r){var i=r.stateNode,l=r.memoizedProps;try{for(var m=r.type,b=i.attributes;b.length;)i.removeAttributeNode(b[0]);hr(i,m,l),i[Dt]=r,i[Rn]=l}catch(k){Zt(r,r.return,k)}}var $s=!1,Gn=!1,wh=!1,uk=typeof WeakSet=="function"?WeakSet:Set,sr=null;function z4(r,i){if(r=r.containerInfo,Fh=lm,r=wb(r),hp(r)){if("selectionStart"in r)var l={start:r.selectionStart,end:r.selectionEnd};else e:{l=(l=r.ownerDocument)&&l.defaultView||window;var m=l.getSelection&&l.getSelection();if(m&&m.rangeCount!==0){l=m.anchorNode;var b=m.anchorOffset,k=m.focusNode;m=m.focusOffset;try{l.nodeType,k.nodeType}catch{l=null;break e}var M=0,O=-1,Z=-1,ue=0,we=0,Ne=r,fe=null;t:for(;;){for(var xe;Ne!==l||b!==0&&Ne.nodeType!==3||(O=M+b),Ne!==k||m!==0&&Ne.nodeType!==3||(Z=M+m),Ne.nodeType===3&&(M+=Ne.nodeValue.length),(xe=Ne.firstChild)!==null;)fe=Ne,Ne=xe;for(;;){if(Ne===r)break t;if(fe===l&&++ue===b&&(O=M),fe===k&&++we===m&&(Z=M),(xe=Ne.nextSibling)!==null)break;Ne=fe,fe=Ne.parentNode}Ne=xe}l=O===-1||Z===-1?null:{start:O,end:Z}}else l=null}l=l||{start:0,end:0}}else l=null;for(qh={focusedElem:r,selectionRange:l},lm=!1,sr=i;sr!==null;)if(i=sr,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,sr=r;else for(;sr!==null;){switch(i=sr,k=i.alternate,r=i.flags,i.tag){case 0:if((r&4)!==0&&(r=i.updateQueue,r=r!==null?r.events:null,r!==null))for(l=0;l<r.length;l++)b=r[l],b.ref.impl=b.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&k!==null){r=void 0,l=i,b=k.memoizedProps,k=k.memoizedState,m=l.stateNode;try{var Ve=ao(l.type,b);r=m.getSnapshotBeforeUpdate(Ve,k),m.__reactInternalSnapshotBeforeUpdate=r}catch(lt){Zt(l,l.return,lt)}}break;case 3:if((r&1024)!==0){if(r=i.stateNode.containerInfo,l=r.nodeType,l===9)Kh(r);else if(l===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":Kh(r);break;default:r.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((r&1024)!==0)throw Error(s(163))}if(r=i.sibling,r!==null){r.return=i.return,sr=r;break}sr=i.return}}function dk(r,i,l){var m=l.flags;switch(l.tag){case 0:case 11:case 15:Ps(r,l),m&4&&vc(5,l);break;case 1:if(Ps(r,l),m&4)if(r=l.stateNode,i===null)try{r.componentDidMount()}catch(M){Zt(l,l.return,M)}else{var b=ao(l.type,i.memoizedProps);i=i.memoizedState;try{r.componentDidUpdate(b,i,r.__reactInternalSnapshotBeforeUpdate)}catch(M){Zt(l,l.return,M)}}m&64&&sk(l),m&512&&kc(l,l.return);break;case 3:if(Ps(r,l),m&64&&(r=l.updateQueue,r!==null)){if(i=null,l.child!==null)switch(l.child.tag){case 27:case 5:i=l.child.stateNode;break;case 1:i=l.child.stateNode}try{Yb(r,i)}catch(M){Zt(l,l.return,M)}}break;case 27:i===null&&m&4&&ck(l);case 26:case 5:Ps(r,l),i===null&&m&4&&ok(l),m&512&&kc(l,l.return);break;case 12:Ps(r,l);break;case 31:Ps(r,l),m&4&&pk(r,l);break;case 13:Ps(r,l),m&4&&hk(r,l),m&64&&(r=l.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(l=Y4.bind(null,l),h3(r,l))));break;case 22:if(m=l.memoizedState!==null||$s,!m){i=i!==null&&i.memoizedState!==null||Gn,b=$s;var k=Gn;$s=m,(Gn=i)&&!k?zs(r,l,(l.subtreeFlags&8772)!==0):Ps(r,l),$s=b,Gn=k}break;case 30:break;default:Ps(r,l)}}function mk(r){var i=r.alternate;i!==null&&(r.alternate=null,mk(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&is(i)),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}var jn=null,Kr=!1;function Us(r,i,l){for(l=l.child;l!==null;)fk(r,i,l),l=l.sibling}function fk(r,i,l){if(dt&&typeof dt.onCommitFiberUnmount=="function")try{dt.onCommitFiberUnmount(Ke,l)}catch{}switch(l.tag){case 26:Gn||hs(l,i),Us(r,i,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Gn||hs(l,i);var m=jn,b=Kr;yi(l.type)&&(jn=l.stateNode,Kr=!1),Us(r,i,l),Ac(l.stateNode),jn=m,Kr=b;break;case 5:Gn||hs(l,i);case 6:if(m=jn,b=Kr,jn=null,Us(r,i,l),jn=m,Kr=b,jn!==null)if(Kr)try{(jn.nodeType===9?jn.body:jn.nodeName==="HTML"?jn.ownerDocument.body:jn).removeChild(l.stateNode)}catch(k){Zt(l,i,k)}else try{jn.removeChild(l.stateNode)}catch(k){Zt(l,i,k)}break;case 18:jn!==null&&(Kr?(r=jn,s1(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,l.stateNode),ml(r)):s1(jn,l.stateNode));break;case 4:m=jn,b=Kr,jn=l.stateNode.containerInfo,Kr=!0,Us(r,i,l),jn=m,Kr=b;break;case 0:case 11:case 14:case 15:di(2,l,i),Gn||di(4,l,i),Us(r,i,l);break;case 1:Gn||(hs(l,i),m=l.stateNode,typeof m.componentWillUnmount=="function"&&ik(l,i,m)),Us(r,i,l);break;case 21:Us(r,i,l);break;case 22:Gn=(m=Gn)||l.memoizedState!==null,Us(r,i,l),Gn=m;break;default:Us(r,i,l)}}function pk(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{ml(r)}catch(l){Zt(i,i.return,l)}}}function hk(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{ml(r)}catch(l){Zt(i,i.return,l)}}function B4(r){switch(r.tag){case 31:case 13:case 19:var i=r.stateNode;return i===null&&(i=r.stateNode=new uk),i;case 22:return r=r.stateNode,i=r._retryCache,i===null&&(i=r._retryCache=new uk),i;default:throw Error(s(435,r.tag))}}function Hd(r,i){var l=B4(r);i.forEach(function(m){if(!l.has(m)){l.add(m);var b=X4.bind(null,r,m);m.then(b,b)}})}function Wr(r,i){var l=i.deletions;if(l!==null)for(var m=0;m<l.length;m++){var b=l[m],k=r,M=i,O=M;e:for(;O!==null;){switch(O.tag){case 27:if(yi(O.type)){jn=O.stateNode,Kr=!1;break e}break;case 5:jn=O.stateNode,Kr=!1;break e;case 3:case 4:jn=O.stateNode.containerInfo,Kr=!0;break e}O=O.return}if(jn===null)throw Error(s(160));fk(k,M,b),jn=null,Kr=!1,k=b.alternate,k!==null&&(k.return=null),b.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)gk(i,r),i=i.sibling}var Ya=null;function gk(r,i){var l=r.alternate,m=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Wr(i,r),Yr(r),m&4&&(di(3,r,r.return),vc(3,r),di(5,r,r.return));break;case 1:Wr(i,r),Yr(r),m&512&&(Gn||l===null||hs(l,l.return)),m&64&&$s&&(r=r.updateQueue,r!==null&&(m=r.callbacks,m!==null&&(l=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=l===null?m:l.concat(m))));break;case 26:var b=Ya;if(Wr(i,r),Yr(r),m&512&&(Gn||l===null||hs(l,l.return)),m&4){var k=l!==null?l.memoizedState:null;if(m=r.memoizedState,l===null)if(m===null)if(r.stateNode===null){e:{m=r.type,l=r.memoizedProps,b=b.ownerDocument||b;t:switch(m){case"title":k=b.getElementsByTagName("title")[0],(!k||k[Br]||k[Dt]||k.namespaceURI==="http://www.w3.org/2000/svg"||k.hasAttribute("itemprop"))&&(k=b.createElement(m),b.head.insertBefore(k,b.querySelector("head > title"))),hr(k,m,l),k[Dt]=r,pn(k),m=k;break e;case"link":var M=g1("link","href",b).get(m+(l.href||""));if(M){for(var O=0;O<M.length;O++)if(k=M[O],k.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&k.getAttribute("rel")===(l.rel==null?null:l.rel)&&k.getAttribute("title")===(l.title==null?null:l.title)&&k.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){M.splice(O,1);break t}}k=b.createElement(m),hr(k,m,l),b.head.appendChild(k);break;case"meta":if(M=g1("meta","content",b).get(m+(l.content||""))){for(O=0;O<M.length;O++)if(k=M[O],k.getAttribute("content")===(l.content==null?null:""+l.content)&&k.getAttribute("name")===(l.name==null?null:l.name)&&k.getAttribute("property")===(l.property==null?null:l.property)&&k.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&k.getAttribute("charset")===(l.charSet==null?null:l.charSet)){M.splice(O,1);break t}}k=b.createElement(m),hr(k,m,l),b.head.appendChild(k);break;default:throw Error(s(468,m))}k[Dt]=r,pn(k),m=k}r.stateNode=m}else x1(b,r.type,r.stateNode);else r.stateNode=h1(b,m,r.memoizedProps);else k!==m?(k===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):k.count--,m===null?x1(b,r.type,r.stateNode):h1(b,m,r.memoizedProps)):m===null&&r.stateNode!==null&&bh(r,r.memoizedProps,l.memoizedProps)}break;case 27:Wr(i,r),Yr(r),m&512&&(Gn||l===null||hs(l,l.return)),l!==null&&m&4&&bh(r,r.memoizedProps,l.memoizedProps);break;case 5:if(Wr(i,r),Yr(r),m&512&&(Gn||l===null||hs(l,l.return)),r.flags&32){b=r.stateNode;try{br(b,"")}catch(Ve){Zt(r,r.return,Ve)}}m&4&&r.stateNode!=null&&(b=r.memoizedProps,bh(r,b,l!==null?l.memoizedProps:b)),m&1024&&(wh=!0);break;case 6:if(Wr(i,r),Yr(r),m&4){if(r.stateNode===null)throw Error(s(162));m=r.memoizedProps,l=r.stateNode;try{l.nodeValue=m}catch(Ve){Zt(r,r.return,Ve)}}break;case 3:if(am=null,b=Ya,Ya=nm(i.containerInfo),Wr(i,r),Ya=b,Yr(r),m&4&&l!==null&&l.memoizedState.isDehydrated)try{ml(i.containerInfo)}catch(Ve){Zt(r,r.return,Ve)}wh&&(wh=!1,xk(r));break;case 4:m=Ya,Ya=nm(r.stateNode.containerInfo),Wr(i,r),Yr(r),Ya=m;break;case 12:Wr(i,r),Yr(r);break;case 31:Wr(i,r),Yr(r),m&4&&(m=r.updateQueue,m!==null&&(r.updateQueue=null,Hd(r,m)));break;case 13:Wr(i,r),Yr(r),r.child.flags&8192&&r.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(qd=He()),m&4&&(m=r.updateQueue,m!==null&&(r.updateQueue=null,Hd(r,m)));break;case 22:b=r.memoizedState!==null;var Z=l!==null&&l.memoizedState!==null,ue=$s,we=Gn;if($s=ue||b,Gn=we||Z,Wr(i,r),Gn=we,$s=ue,Yr(r),m&8192)e:for(i=r.stateNode,i._visibility=b?i._visibility&-2:i._visibility|1,b&&(l===null||Z||$s||Gn||so(r)),l=null,i=r;;){if(i.tag===5||i.tag===26){if(l===null){Z=l=i;try{if(k=Z.stateNode,b)M=k.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none";else{O=Z.stateNode;var Ne=Z.memoizedProps.style,fe=Ne!=null&&Ne.hasOwnProperty("display")?Ne.display:null;O.style.display=fe==null||typeof fe=="boolean"?"":(""+fe).trim()}}catch(Ve){Zt(Z,Z.return,Ve)}}}else if(i.tag===6){if(l===null){Z=i;try{Z.stateNode.nodeValue=b?"":Z.memoizedProps}catch(Ve){Zt(Z,Z.return,Ve)}}}else if(i.tag===18){if(l===null){Z=i;try{var xe=Z.stateNode;b?i1(xe,!0):i1(Z.stateNode,!1)}catch(Ve){Zt(Z,Z.return,Ve)}}}else if((i.tag!==22&&i.tag!==23||i.memoizedState===null||i===r)&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;l===i&&(l=null),i=i.return}l===i&&(l=null),i.sibling.return=i.return,i=i.sibling}m&4&&(m=r.updateQueue,m!==null&&(l=m.retryQueue,l!==null&&(m.retryQueue=null,Hd(r,l))));break;case 19:Wr(i,r),Yr(r),m&4&&(m=r.updateQueue,m!==null&&(r.updateQueue=null,Hd(r,m)));break;case 30:break;case 21:break;default:Wr(i,r),Yr(r)}}function Yr(r){var i=r.flags;if(i&2){try{for(var l,m=r.return;m!==null;){if(lk(m)){l=m;break}m=m.return}if(l==null)throw Error(s(160));switch(l.tag){case 27:var b=l.stateNode,k=vh(r);Bd(r,k,b);break;case 5:var M=l.stateNode;l.flags&32&&(br(M,""),l.flags&=-33);var O=vh(r);Bd(r,O,M);break;case 3:case 4:var Z=l.stateNode.containerInfo,ue=vh(r);kh(r,ue,Z);break;default:throw Error(s(161))}}catch(we){Zt(r,r.return,we)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function xk(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var i=r;xk(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),r=r.sibling}}function Ps(r,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)dk(r,i.alternate,i),i=i.sibling}function so(r){for(r=r.child;r!==null;){var i=r;switch(i.tag){case 0:case 11:case 14:case 15:di(4,i,i.return),so(i);break;case 1:hs(i,i.return);var l=i.stateNode;typeof l.componentWillUnmount=="function"&&ik(i,i.return,l),so(i);break;case 27:Ac(i.stateNode);case 26:case 5:hs(i,i.return),so(i);break;case 22:i.memoizedState===null&&so(i);break;case 30:so(i);break;default:so(i)}r=r.sibling}}function zs(r,i,l){for(l=l&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var m=i.alternate,b=r,k=i,M=k.flags;switch(k.tag){case 0:case 11:case 15:zs(b,k,l),vc(4,k);break;case 1:if(zs(b,k,l),m=k,b=m.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(ue){Zt(m,m.return,ue)}if(m=k,b=m.updateQueue,b!==null){var O=m.stateNode;try{var Z=b.shared.hiddenCallbacks;if(Z!==null)for(b.shared.hiddenCallbacks=null,b=0;b<Z.length;b++)Wb(Z[b],O)}catch(ue){Zt(m,m.return,ue)}}l&&M&64&&sk(k),kc(k,k.return);break;case 27:ck(k);case 26:case 5:zs(b,k,l),l&&m===null&&M&4&&ok(k),kc(k,k.return);break;case 12:zs(b,k,l);break;case 31:zs(b,k,l),l&&M&4&&pk(b,k);break;case 13:zs(b,k,l),l&&M&4&&hk(b,k);break;case 22:k.memoizedState===null&&zs(b,k,l),kc(k,k.return);break;case 30:break;default:zs(b,k,l)}i=i.sibling}}function Sh(r,i){var l=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(l=r.memoizedState.cachePool.pool),r=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(r=i.memoizedState.cachePool.pool),r!==l&&(r!=null&&r.refCount++,l!=null&&oc(l))}function jh(r,i){r=null,i.alternate!==null&&(r=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==r&&(i.refCount++,r!=null&&oc(r))}function Xa(r,i,l,m){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)yk(r,i,l,m),i=i.sibling}function yk(r,i,l,m){var b=i.flags;switch(i.tag){case 0:case 11:case 15:Xa(r,i,l,m),b&2048&&vc(9,i);break;case 1:Xa(r,i,l,m);break;case 3:Xa(r,i,l,m),b&2048&&(r=null,i.alternate!==null&&(r=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==r&&(i.refCount++,r!=null&&oc(r)));break;case 12:if(b&2048){Xa(r,i,l,m),r=i.stateNode;try{var k=i.memoizedProps,M=k.id,O=k.onPostCommit;typeof O=="function"&&O(M,i.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(Z){Zt(i,i.return,Z)}}else Xa(r,i,l,m);break;case 31:Xa(r,i,l,m);break;case 13:Xa(r,i,l,m);break;case 23:break;case 22:k=i.stateNode,M=i.alternate,i.memoizedState!==null?k._visibility&2?Xa(r,i,l,m):wc(r,i):k._visibility&2?Xa(r,i,l,m):(k._visibility|=2,tl(r,i,l,m,(i.subtreeFlags&10256)!==0||!1)),b&2048&&Sh(M,i);break;case 24:Xa(r,i,l,m),b&2048&&jh(i.alternate,i);break;default:Xa(r,i,l,m)}}function tl(r,i,l,m,b){for(b=b&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var k=r,M=i,O=l,Z=m,ue=M.flags;switch(M.tag){case 0:case 11:case 15:tl(k,M,O,Z,b),vc(8,M);break;case 23:break;case 22:var we=M.stateNode;M.memoizedState!==null?we._visibility&2?tl(k,M,O,Z,b):wc(k,M):(we._visibility|=2,tl(k,M,O,Z,b)),b&&ue&2048&&Sh(M.alternate,M);break;case 24:tl(k,M,O,Z,b),b&&ue&2048&&jh(M.alternate,M);break;default:tl(k,M,O,Z,b)}i=i.sibling}}function wc(r,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var l=r,m=i,b=m.flags;switch(m.tag){case 22:wc(l,m),b&2048&&Sh(m.alternate,m);break;case 24:wc(l,m),b&2048&&jh(m.alternate,m);break;default:wc(l,m)}i=i.sibling}}var Sc=8192;function nl(r,i,l){if(r.subtreeFlags&Sc)for(r=r.child;r!==null;)bk(r,i,l),r=r.sibling}function bk(r,i,l){switch(r.tag){case 26:nl(r,i,l),r.flags&Sc&&r.memoizedState!==null&&T3(l,Ya,r.memoizedState,r.memoizedProps);break;case 5:nl(r,i,l);break;case 3:case 4:var m=Ya;Ya=nm(r.stateNode.containerInfo),nl(r,i,l),Ya=m;break;case 22:r.memoizedState===null&&(m=r.alternate,m!==null&&m.memoizedState!==null?(m=Sc,Sc=16777216,nl(r,i,l),Sc=m):nl(r,i,l));break;default:nl(r,i,l)}}function vk(r){var i=r.alternate;if(i!==null&&(r=i.child,r!==null)){i.child=null;do i=r.sibling,r.sibling=null,r=i;while(r!==null)}}function jc(r){var i=r.deletions;if((r.flags&16)!==0){if(i!==null)for(var l=0;l<i.length;l++){var m=i[l];sr=m,wk(m,r)}vk(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)kk(r),r=r.sibling}function kk(r){switch(r.tag){case 0:case 11:case 15:jc(r),r.flags&2048&&di(9,r,r.return);break;case 3:jc(r);break;case 12:jc(r);break;case 22:var i=r.stateNode;r.memoizedState!==null&&i._visibility&2&&(r.return===null||r.return.tag!==13)?(i._visibility&=-3,Fd(r)):jc(r);break;default:jc(r)}}function Fd(r){var i=r.deletions;if((r.flags&16)!==0){if(i!==null)for(var l=0;l<i.length;l++){var m=i[l];sr=m,wk(m,r)}vk(r)}for(r=r.child;r!==null;){switch(i=r,i.tag){case 0:case 11:case 15:di(8,i,i.return),Fd(i);break;case 22:l=i.stateNode,l._visibility&2&&(l._visibility&=-3,Fd(i));break;default:Fd(i)}r=r.sibling}}function wk(r,i){for(;sr!==null;){var l=sr;switch(l.tag){case 0:case 11:case 15:di(8,l,i);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var m=l.memoizedState.cachePool.pool;m!=null&&m.refCount++}break;case 24:oc(l.memoizedState.cache)}if(m=l.child,m!==null)m.return=l,sr=m;else e:for(l=r;sr!==null;){m=sr;var b=m.sibling,k=m.return;if(mk(m),m===l){sr=null;break e}if(b!==null){b.return=k,sr=b;break e}sr=k}}}var H4={getCacheForType:function(r){var i=fr(Fn),l=i.data.get(r);return l===void 0&&(l=r(),i.data.set(r,l)),l},cacheSignal:function(){return fr(Fn).controller.signal}},F4=typeof WeakMap=="function"?WeakMap:Map,Gt=0,cn=null,At=null,Lt=0,Qt=0,la=null,mi=!1,rl=!1,Ch=!1,Bs=0,Ln=0,fi=0,io=0,Nh=0,ca=0,al=0,Cc=null,Xr=null,Th=!1,qd=0,Sk=0,Vd=1/0,Gd=null,pi=null,rr=0,hi=null,sl=null,Hs=0,Mh=0,Eh=null,jk=null,Nc=0,Ah=null;function ua(){return(Gt&2)!==0&&Lt!==0?Lt&-Lt:$.T!==null?Dh():gn()}function Ck(){if(ca===0)if((Lt&536870912)===0||$t){var r=Vt;Vt<<=1,(Vt&3932160)===0&&(Vt=262144),ca=r}else ca=536870912;return r=ia.current,r!==null&&(r.flags|=32),ca}function Qr(r,i,l){(r===cn&&(Qt===2||Qt===9)||r.cancelPendingCommit!==null)&&(il(r,0),gi(r,Lt,ca,!1)),Bn(r,l),((Gt&2)===0||r!==cn)&&(r===cn&&((Gt&2)===0&&(io|=l),Ln===4&&gi(r,Lt,ca,!1)),gs(r))}function Nk(r,i,l){if((Gt&6)!==0)throw Error(s(327));var m=!l&&(i&127)===0&&(i&r.expiredLanes)===0||Cn(r,i),b=m?G4(r,i):Rh(r,i,!0),k=m;do{if(b===0){rl&&!m&&gi(r,i,0,!1);break}else{if(l=r.current.alternate,k&&!q4(l)){b=Rh(r,i,!1),k=!1;continue}if(b===2){if(k=i,r.errorRecoveryDisabledLanes&k)var M=0;else M=r.pendingLanes&-536870913,M=M!==0?M:M&536870912?536870912:0;if(M!==0){i=M;e:{var O=r;b=Cc;var Z=O.current.memoizedState.isDehydrated;if(Z&&(il(O,M).flags|=256),M=Rh(O,M,!1),M!==2){if(Ch&&!Z){O.errorRecoveryDisabledLanes|=k,io|=k,b=4;break e}k=Xr,Xr=b,k!==null&&(Xr===null?Xr=k:Xr.push.apply(Xr,k))}b=M}if(k=!1,b!==2)continue}}if(b===1){il(r,0),gi(r,i,0,!0);break}e:{switch(m=r,k=b,k){case 0:case 1:throw Error(s(345));case 4:if((i&4194048)!==i)break;case 6:gi(m,i,ca,!mi);break e;case 2:Xr=null;break;case 3:case 5:break;default:throw Error(s(329))}if((i&62914560)===i&&(b=qd+300-He(),10<b)){if(gi(m,i,ca,!mi),Xt(m,0,!0)!==0)break e;Hs=i,m.timeoutHandle=r1(Tk.bind(null,m,l,Xr,Gd,Th,i,ca,io,al,mi,k,"Throttled",-0,0),b);break e}Tk(m,l,Xr,Gd,Th,i,ca,io,al,mi,k,null,-0,0)}}break}while(!0);gs(r)}function Tk(r,i,l,m,b,k,M,O,Z,ue,we,Ne,fe,xe){if(r.timeoutHandle=-1,Ne=i.subtreeFlags,Ne&8192||(Ne&16785408)===16785408){Ne={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Wt},bk(i,k,Ne);var Ve=(k&62914560)===k?qd-He():(k&4194048)===k?Sk-He():0;if(Ve=M3(Ne,Ve),Ve!==null){Hs=k,r.cancelPendingCommit=Ve(Ok.bind(null,r,i,k,l,m,b,M,O,Z,we,Ne,null,fe,xe)),gi(r,k,M,!ue);return}}Ok(r,i,k,l,m,b,M,O,Z)}function q4(r){for(var i=r;;){var l=i.tag;if((l===0||l===11||l===15)&&i.flags&16384&&(l=i.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var m=0;m<l.length;m++){var b=l[m],k=b.getSnapshot;b=b.value;try{if(!aa(k(),b))return!1}catch{return!1}}if(l=i.child,i.subtreeFlags&16384&&l!==null)l.return=i,i=l;else{if(i===r)break;for(;i.sibling===null;){if(i.return===null||i.return===r)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function gi(r,i,l,m){i&=~Nh,i&=~io,r.suspendedLanes|=i,r.pingedLanes&=~i,m&&(r.warmLanes|=i),m=r.expirationTimes;for(var b=i;0<b;){var k=31-wt(b),M=1<<k;m[k]=-1,b&=~M}l!==0&&Tr(r,l,i)}function Kd(){return(Gt&6)===0?(Tc(0),!1):!0}function _h(){if(At!==null){if(Qt===0)var r=At.return;else r=At,_s=Qi=null,Kp(r),Xo=null,cc=0,r=At;for(;r!==null;)ak(r.alternate,r),r=r.return;At=null}}function il(r,i){var l=r.timeoutHandle;l!==-1&&(r.timeoutHandle=-1,u3(l)),l=r.cancelPendingCommit,l!==null&&(r.cancelPendingCommit=null,l()),Hs=0,_h(),cn=r,At=l=Es(r.current,null),Lt=i,Qt=0,la=null,mi=!1,rl=Cn(r,i),Ch=!1,al=ca=Nh=io=fi=Ln=0,Xr=Cc=null,Th=!1,(i&8)!==0&&(i|=i&32);var m=r.entangledLanes;if(m!==0)for(r=r.entanglements,m&=i;0<m;){var b=31-wt(m),k=1<<b;i|=r[b],m&=~k}return Bs=i,pd(),l}function Mk(r,i){jt=null,$.H=xc,i===Yo||i===wd?(i=qb(),Qt=3):i===Op?(i=qb(),Qt=4):Qt=i===ch?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,la=i,At===null&&(Ln=1,Dd(r,Ea(i,r.current)))}function Ek(){var r=ia.current;return r===null?!0:(Lt&4194048)===Lt?Ia===null:(Lt&62914560)===Lt||(Lt&536870912)!==0?r===Ia:!1}function Ak(){var r=$.H;return $.H=xc,r===null?xc:r}function _k(){var r=$.A;return $.A=H4,r}function Wd(){Ln=4,mi||(Lt&4194048)!==Lt&&ia.current!==null||(rl=!0),(fi&134217727)===0&&(io&134217727)===0||cn===null||gi(cn,Lt,ca,!1)}function Rh(r,i,l){var m=Gt;Gt|=2;var b=Ak(),k=_k();(cn!==r||Lt!==i)&&(Gd=null,il(r,i)),i=!1;var M=Ln;e:do try{if(Qt!==0&&At!==null){var O=At,Z=la;switch(Qt){case 8:_h(),M=6;break e;case 3:case 2:case 9:case 6:ia.current===null&&(i=!0);var ue=Qt;if(Qt=0,la=null,ol(r,O,Z,ue),l&&rl){M=0;break e}break;default:ue=Qt,Qt=0,la=null,ol(r,O,Z,ue)}}V4(),M=Ln;break}catch(we){Mk(r,we)}while(!0);return i&&r.shellSuspendCounter++,_s=Qi=null,Gt=m,$.H=b,$.A=k,At===null&&(cn=null,Lt=0,pd()),M}function V4(){for(;At!==null;)Rk(At)}function G4(r,i){var l=Gt;Gt|=2;var m=Ak(),b=_k();cn!==r||Lt!==i?(Gd=null,Vd=He()+500,il(r,i)):rl=Cn(r,i);e:do try{if(Qt!==0&&At!==null){i=At;var k=la;t:switch(Qt){case 1:Qt=0,la=null,ol(r,i,k,1);break;case 2:case 9:if(Hb(k)){Qt=0,la=null,Ik(i);break}i=function(){Qt!==2&&Qt!==9||cn!==r||(Qt=7),gs(r)},k.then(i,i);break e;case 3:Qt=7;break e;case 4:Qt=5;break e;case 7:Hb(k)?(Qt=0,la=null,Ik(i)):(Qt=0,la=null,ol(r,i,k,7));break;case 5:var M=null;switch(At.tag){case 26:M=At.memoizedState;case 5:case 27:var O=At;if(M?y1(M):O.stateNode.complete){Qt=0,la=null;var Z=O.sibling;if(Z!==null)At=Z;else{var ue=O.return;ue!==null?(At=ue,Yd(ue)):At=null}break t}}Qt=0,la=null,ol(r,i,k,5);break;case 6:Qt=0,la=null,ol(r,i,k,6);break;case 8:_h(),Ln=6;break e;default:throw Error(s(462))}}K4();break}catch(we){Mk(r,we)}while(!0);return _s=Qi=null,$.H=m,$.A=b,Gt=l,At!==null?0:(cn=null,Lt=0,pd(),Ln)}function K4(){for(;At!==null&&!Xe();)Rk(At)}function Rk(r){var i=nk(r.alternate,r,Bs);r.memoizedProps=r.pendingProps,i===null?Yd(r):At=i}function Ik(r){var i=r,l=i.alternate;switch(i.tag){case 15:case 0:i=Xv(l,i,i.pendingProps,i.type,void 0,Lt);break;case 11:i=Xv(l,i,i.pendingProps,i.type.render,i.ref,Lt);break;case 5:Kp(i);default:ak(l,i),i=At=_b(i,Bs),i=nk(l,i,Bs)}r.memoizedProps=r.pendingProps,i===null?Yd(r):At=i}function ol(r,i,l,m){_s=Qi=null,Kp(i),Xo=null,cc=0;var b=i.return;try{if(O4(r,b,i,l,Lt)){Ln=1,Dd(r,Ea(l,r.current)),At=null;return}}catch(k){if(b!==null)throw At=b,k;Ln=1,Dd(r,Ea(l,r.current)),At=null;return}i.flags&32768?($t||m===1?r=!0:rl||(Lt&536870912)!==0?r=!1:(mi=r=!0,(m===2||m===9||m===3||m===6)&&(m=ia.current,m!==null&&m.tag===13&&(m.flags|=16384))),Lk(i,r)):Yd(i)}function Yd(r){var i=r;do{if((i.flags&32768)!==0){Lk(i,mi);return}r=i.return;var l=U4(i.alternate,i,Bs);if(l!==null){At=l;return}if(i=i.sibling,i!==null){At=i;return}At=i=r}while(i!==null);Ln===0&&(Ln=5)}function Lk(r,i){do{var l=P4(r.alternate,r);if(l!==null){l.flags&=32767,At=l;return}if(l=r.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!i&&(r=r.sibling,r!==null)){At=r;return}At=r=l}while(r!==null);Ln=6,At=null}function Ok(r,i,l,m,b,k,M,O,Z){r.cancelPendingCommit=null;do Xd();while(rr!==0);if((Gt&6)!==0)throw Error(s(327));if(i!==null){if(i===r.current)throw Error(s(177));if(k=i.lanes|i.childLanes,k|=vp,Nr(r,l,k,M,O,Z),r===cn&&(At=cn=null,Lt=0),sl=i,hi=r,Hs=l,Mh=k,Eh=b,jk=m,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,Q4(Ue,function(){return zk(),null})):(r.callbackNode=null,r.callbackPriority=0),m=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||m){m=$.T,$.T=null,b=X.p,X.p=2,M=Gt,Gt|=4;try{z4(r,i,l)}finally{Gt=M,X.p=b,$.T=m}}rr=1,Dk(),$k(),Uk()}}function Dk(){if(rr===1){rr=0;var r=hi,i=sl,l=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||l){l=$.T,$.T=null;var m=X.p;X.p=2;var b=Gt;Gt|=4;try{gk(i,r);var k=qh,M=wb(r.containerInfo),O=k.focusedElem,Z=k.selectionRange;if(M!==O&&O&&O.ownerDocument&&kb(O.ownerDocument.documentElement,O)){if(Z!==null&&hp(O)){var ue=Z.start,we=Z.end;if(we===void 0&&(we=ue),"selectionStart"in O)O.selectionStart=ue,O.selectionEnd=Math.min(we,O.value.length);else{var Ne=O.ownerDocument||document,fe=Ne&&Ne.defaultView||window;if(fe.getSelection){var xe=fe.getSelection(),Ve=O.textContent.length,lt=Math.min(Z.start,Ve),rn=Z.end===void 0?lt:Math.min(Z.end,Ve);!xe.extend&&lt>rn&&(M=rn,rn=lt,lt=M);var se=vb(O,lt),te=vb(O,rn);if(se&&te&&(xe.rangeCount!==1||xe.anchorNode!==se.node||xe.anchorOffset!==se.offset||xe.focusNode!==te.node||xe.focusOffset!==te.offset)){var ce=Ne.createRange();ce.setStart(se.node,se.offset),xe.removeAllRanges(),lt>rn?(xe.addRange(ce),xe.extend(te.node,te.offset)):(ce.setEnd(te.node,te.offset),xe.addRange(ce))}}}}for(Ne=[],xe=O;xe=xe.parentNode;)xe.nodeType===1&&Ne.push({element:xe,left:xe.scrollLeft,top:xe.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;O<Ne.length;O++){var je=Ne[O];je.element.scrollLeft=je.left,je.element.scrollTop=je.top}}lm=!!Fh,qh=Fh=null}finally{Gt=b,X.p=m,$.T=l}}r.current=i,rr=2}}function $k(){if(rr===2){rr=0;var r=hi,i=sl,l=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||l){l=$.T,$.T=null;var m=X.p;X.p=2;var b=Gt;Gt|=4;try{dk(r,i.alternate,i)}finally{Gt=b,X.p=m,$.T=l}}rr=3}}function Uk(){if(rr===4||rr===3){rr=0,Ge();var r=hi,i=sl,l=Hs,m=jk;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?rr=5:(rr=0,sl=hi=null,Pk(r,r.pendingLanes));var b=r.pendingLanes;if(b===0&&(pi=null),St(l),i=i.stateNode,dt&&typeof dt.onCommitFiberRoot=="function")try{dt.onCommitFiberRoot(Ke,i,void 0,(i.current.flags&128)===128)}catch{}if(m!==null){i=$.T,b=X.p,X.p=2,$.T=null;try{for(var k=r.onRecoverableError,M=0;M<m.length;M++){var O=m[M];k(O.value,{componentStack:O.stack})}}finally{$.T=i,X.p=b}}(Hs&3)!==0&&Xd(),gs(r),b=r.pendingLanes,(l&261930)!==0&&(b&42)!==0?r===Ah?Nc++:(Nc=0,Ah=r):Nc=0,Tc(0)}}function Pk(r,i){(r.pooledCacheLanes&=i)===0&&(i=r.pooledCache,i!=null&&(r.pooledCache=null,oc(i)))}function Xd(){return Dk(),$k(),Uk(),zk()}function zk(){if(rr!==5)return!1;var r=hi,i=Mh;Mh=0;var l=St(Hs),m=$.T,b=X.p;try{X.p=32>l?32:l,$.T=null,l=Eh,Eh=null;var k=hi,M=Hs;if(rr=0,sl=hi=null,Hs=0,(Gt&6)!==0)throw Error(s(331));var O=Gt;if(Gt|=4,kk(k.current),yk(k,k.current,M,l),Gt=O,Tc(0,!1),dt&&typeof dt.onPostCommitFiberRoot=="function")try{dt.onPostCommitFiberRoot(Ke,k)}catch{}return!0}finally{X.p=b,$.T=m,Pk(r,i)}}function Bk(r,i,l){i=Ea(l,i),i=lh(r.stateNode,i,2),r=li(r,i,2),r!==null&&(Bn(r,2),gs(r))}function Zt(r,i,l){if(r.tag===3)Bk(r,r,l);else for(;i!==null;){if(i.tag===3){Bk(i,r,l);break}else if(i.tag===1){var m=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(pi===null||!pi.has(m))){r=Ea(l,r),l=Hv(2),m=li(i,l,2),m!==null&&(Fv(l,m,i,r),Bn(m,2),gs(m));break}}i=i.return}}function Ih(r,i,l){var m=r.pingCache;if(m===null){m=r.pingCache=new F4;var b=new Set;m.set(i,b)}else b=m.get(i),b===void 0&&(b=new Set,m.set(i,b));b.has(l)||(Ch=!0,b.add(l),r=W4.bind(null,r,i,l),i.then(r,r))}function W4(r,i,l){var m=r.pingCache;m!==null&&m.delete(i),r.pingedLanes|=r.suspendedLanes&l,r.warmLanes&=~l,cn===r&&(Lt&l)===l&&(Ln===4||Ln===3&&(Lt&62914560)===Lt&&300>He()-qd?(Gt&2)===0&&il(r,0):Nh|=l,al===Lt&&(al=0)),gs(r)}function Hk(r,i){i===0&&(i=Mt()),r=Wi(r,i),r!==null&&(Bn(r,i),gs(r))}function Y4(r){var i=r.memoizedState,l=0;i!==null&&(l=i.retryLane),Hk(r,l)}function X4(r,i){var l=0;switch(r.tag){case 31:case 13:var m=r.stateNode,b=r.memoizedState;b!==null&&(l=b.retryLane);break;case 19:m=r.stateNode;break;case 22:m=r.stateNode._retryCache;break;default:throw Error(s(314))}m!==null&&m.delete(i),Hk(r,l)}function Q4(r,i){return ht(r,i)}var Qd=null,ll=null,Lh=!1,Zd=!1,Oh=!1,xi=0;function gs(r){r!==ll&&r.next===null&&(ll===null?Qd=ll=r:ll=ll.next=r),Zd=!0,Lh||(Lh=!0,J4())}function Tc(r,i){if(!Oh&&Zd){Oh=!0;do for(var l=!1,m=Qd;m!==null;){if(r!==0){var b=m.pendingLanes;if(b===0)var k=0;else{var M=m.suspendedLanes,O=m.pingedLanes;k=(1<<31-wt(42|r)+1)-1,k&=b&~(M&~O),k=k&201326741?k&201326741|1:k?k|2:0}k!==0&&(l=!0,Gk(m,k))}else k=Lt,k=Xt(m,m===cn?k:0,m.cancelPendingCommit!==null||m.timeoutHandle!==-1),(k&3)===0||Cn(m,k)||(l=!0,Gk(m,k));m=m.next}while(l);Oh=!1}}function Z4(){Fk()}function Fk(){Zd=Lh=!1;var r=0;xi!==0&&c3()&&(r=xi);for(var i=He(),l=null,m=Qd;m!==null;){var b=m.next,k=qk(m,i);k===0?(m.next=null,l===null?Qd=b:l.next=b,b===null&&(ll=l)):(l=m,(r!==0||(k&3)!==0)&&(Zd=!0)),m=b}rr!==0&&rr!==5||Tc(r),xi!==0&&(xi=0)}function qk(r,i){for(var l=r.suspendedLanes,m=r.pingedLanes,b=r.expirationTimes,k=r.pendingLanes&-62914561;0<k;){var M=31-wt(k),O=1<<M,Z=b[M];Z===-1?((O&l)===0||(O&m)!==0)&&(b[M]=lr(O,i)):Z<=i&&(r.expiredLanes|=O),k&=~O}if(i=cn,l=Lt,l=Xt(r,r===i?l:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),m=r.callbackNode,l===0||r===i&&(Qt===2||Qt===9)||r.cancelPendingCommit!==null)return m!==null&&m!==null&&ve(m),r.callbackNode=null,r.callbackPriority=0;if((l&3)===0||Cn(r,l)){if(i=l&-l,i===r.callbackPriority)return i;switch(m!==null&&ve(m),St(l)){case 2:case 8:l=me;break;case 32:l=Ue;break;case 268435456:l=$e;break;default:l=Ue}return m=Vk.bind(null,r),l=ht(l,m),r.callbackPriority=i,r.callbackNode=l,i}return m!==null&&m!==null&&ve(m),r.callbackPriority=2,r.callbackNode=null,2}function Vk(r,i){if(rr!==0&&rr!==5)return r.callbackNode=null,r.callbackPriority=0,null;var l=r.callbackNode;if(Xd()&&r.callbackNode!==l)return null;var m=Lt;return m=Xt(r,r===cn?m:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),m===0?null:(Nk(r,m,i),qk(r,He()),r.callbackNode!=null&&r.callbackNode===l?Vk.bind(null,r):null)}function Gk(r,i){if(Xd())return null;Nk(r,i,!0)}function J4(){d3(function(){(Gt&6)!==0?ht(W,Z4):Fk()})}function Dh(){if(xi===0){var r=Ko;r===0&&(r=Dn,Dn<<=1,(Dn&261888)===0&&(Dn=256)),xi=r}return xi}function Kk(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Pt(""+r)}function Wk(r,i){var l=i.ownerDocument.createElement("input");return l.name=i.name,l.value=i.value,r.id&&l.setAttribute("form",r.id),i.parentNode.insertBefore(l,i),r=new FormData(r),l.parentNode.removeChild(l),r}function e3(r,i,l,m,b){if(i==="submit"&&l&&l.stateNode===b){var k=Kk((b[Rn]||null).action),M=m.submitter;M&&(i=(i=M[Rn]||null)?Kk(i.formAction):M.getAttribute("formAction"),i!==null&&(k=i,M=null));var O=new Bi("action","action",null,m,b);r.push({event:O,listeners:[{instance:null,listener:function(){if(m.defaultPrevented){if(xi!==0){var Z=M?Wk(b,M):new FormData(b);nh(l,{pending:!0,data:Z,method:b.method,action:k},null,Z)}}else typeof k=="function"&&(O.preventDefault(),Z=M?Wk(b,M):new FormData(b),nh(l,{pending:!0,data:Z,method:b.method,action:k},k,Z))},currentTarget:b}]})}}for(var $h=0;$h<bp.length;$h++){var Uh=bp[$h],t3=Uh.toLowerCase(),n3=Uh[0].toUpperCase()+Uh.slice(1);Wa(t3,"on"+n3)}Wa(Cb,"onAnimationEnd"),Wa(Nb,"onAnimationIteration"),Wa(Tb,"onAnimationStart"),Wa("dblclick","onDoubleClick"),Wa("focusin","onFocus"),Wa("focusout","onBlur"),Wa(y4,"onTransitionRun"),Wa(b4,"onTransitionStart"),Wa(v4,"onTransitionCancel"),Wa(Mb,"onTransitionEnd"),ur("onMouseEnter",["mouseout","mouseover"]),ur("onMouseLeave",["mouseout","mouseover"]),ur("onPointerEnter",["pointerout","pointerover"]),ur("onPointerLeave",["pointerout","pointerover"]),Er("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Er("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Er("onBeforeInput",["compositionend","keypress","textInput","paste"]),Er("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Er("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Er("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Mc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),r3=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Mc));function Yk(r,i){i=(i&4)!==0;for(var l=0;l<r.length;l++){var m=r[l],b=m.event;m=m.listeners;e:{var k=void 0;if(i)for(var M=m.length-1;0<=M;M--){var O=m[M],Z=O.instance,ue=O.currentTarget;if(O=O.listener,Z!==k&&b.isPropagationStopped())break e;k=O,b.currentTarget=ue;try{k(b)}catch(we){fd(we)}b.currentTarget=null,k=Z}else for(M=0;M<m.length;M++){if(O=m[M],Z=O.instance,ue=O.currentTarget,O=O.listener,Z!==k&&b.isPropagationStopped())break e;k=O,b.currentTarget=ue;try{k(b)}catch(we){fd(we)}b.currentTarget=null,k=Z}}}}function _t(r,i){var l=i[cr];l===void 0&&(l=i[cr]=new Set);var m=r+"__bubble";l.has(m)||(Xk(i,r,2,!1),l.add(m))}function Ph(r,i,l){var m=0;i&&(m|=4),Xk(l,r,m,i)}var Jd="_reactListening"+Math.random().toString(36).slice(2);function zh(r){if(!r[Jd]){r[Jd]=!0,na.forEach(function(l){l!=="selectionchange"&&(r3.has(l)||Ph(l,!1,r),Ph(l,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[Jd]||(i[Jd]=!0,Ph("selectionchange",!1,i))}}function Xk(r,i,l,m){switch(C1(i)){case 2:var b=_3;break;case 8:b=R3;break;default:b=tg}l=b.bind(null,i,l,r),b=void 0,!vt||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(b=!0),m?b!==void 0?r.addEventListener(i,l,{capture:!0,passive:b}):r.addEventListener(i,l,!0):b!==void 0?r.addEventListener(i,l,{passive:b}):r.addEventListener(i,l,!1)}function Bh(r,i,l,m,b){var k=m;if((i&1)===0&&(i&2)===0&&m!==null)e:for(;;){if(m===null)return;var M=m.tag;if(M===3||M===4){var O=m.stateNode.containerInfo;if(O===b)break;if(M===4)for(M=m.return;M!==null;){var Z=M.tag;if((Z===3||Z===4)&&M.stateNode.containerInfo===b)return;M=M.return}for(;O!==null;){if(M=Hr(O),M===null)return;if(Z=M.tag,Z===5||Z===6||Z===26||Z===27){m=k=M;continue e}O=O.parentNode}}m=m.return}_e(function(){var ue=k,we=_r(l),Ne=[];e:{var fe=Eb.get(r);if(fe!==void 0){var xe=Bi,Ve=r;switch(r){case"keypress":if(zi(l)===0)break e;case"keydown":case"keyup":xe=Je;break;case"focusin":Ve="focus",xe=Ql;break;case"focusout":Ve="blur",xe=Ql;break;case"beforeblur":case"afterblur":xe=Ql;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":xe=od;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xe=sp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xe=dr;break;case Cb:case Nb:case Tb:xe=ud;break;case Mb:xe=Na;break;case"scroll":case"scrollend":xe=Do;break;case"wheel":xe=dd;break;case"copy":case"cut":case"paste":xe=lp;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xe=An;break;case"toggle":case"beforetoggle":xe=dp}var lt=(i&4)!==0,rn=!lt&&(r==="scroll"||r==="scrollend"),se=lt?fe!==null?fe+"Capture":null:fe;lt=[];for(var te=ue,ce;te!==null;){var je=te;if(ce=je.stateNode,je=je.tag,je!==5&&je!==26&&je!==27||ce===null||se===null||(je=et(te,se),je!=null&&lt.push(Ec(te,je,ce))),rn)break;te=te.return}0<lt.length&&(fe=new xe(fe,Ve,null,l,we),Ne.push({event:fe,listeners:lt}))}}if((i&7)===0){e:{if(fe=r==="mouseover"||r==="pointerover",xe=r==="mouseout"||r==="pointerout",fe&&l!==Ka&&(Ve=l.relatedTarget||l.fromElement)&&(Hr(Ve)||Ve[zr]))break e;if((xe||fe)&&(fe=we.window===we?we:(fe=we.ownerDocument)?fe.defaultView||fe.parentWindow:window,xe?(Ve=l.relatedTarget||l.toElement,xe=ue,Ve=Ve?Hr(Ve):null,Ve!==null&&(rn=c(Ve),lt=Ve.tag,Ve!==rn||lt!==5&&lt!==27&&lt!==6)&&(Ve=null)):(xe=null,Ve=ue),xe!==Ve)){if(lt=od,je="onMouseLeave",se="onMouseEnter",te="mouse",(r==="pointerout"||r==="pointerover")&&(lt=An,je="onPointerLeave",se="onPointerEnter",te="pointer"),rn=xe==null?fe:Fr(xe),ce=Ve==null?fe:Fr(Ve),fe=new lt(je,te+"leave",xe,l,we),fe.target=rn,fe.relatedTarget=ce,je=null,Hr(we)===ue&&(lt=new lt(se,te+"enter",Ve,l,we),lt.target=ce,lt.relatedTarget=rn,je=lt),rn=je,xe&&Ve)t:{for(lt=a3,se=xe,te=Ve,ce=0,je=se;je;je=lt(je))ce++;je=0;for(var rt=te;rt;rt=lt(rt))je++;for(;0<ce-je;)se=lt(se),ce--;for(;0<je-ce;)te=lt(te),je--;for(;ce--;){if(se===te||te!==null&&se===te.alternate){lt=se;break t}se=lt(se),te=lt(te)}lt=null}else lt=null;xe!==null&&Qk(Ne,fe,xe,lt,!1),Ve!==null&&rn!==null&&Qk(Ne,rn,Ve,lt,!0)}}e:{if(fe=ue?Fr(ue):window,xe=fe.nodeName&&fe.nodeName.toLowerCase(),xe==="select"||xe==="input"&&fe.type==="file")var Ft=pb;else if(mb(fe))if(hb)Ft=h4;else{Ft=f4;var We=m4}else xe=fe.nodeName,!xe||xe.toLowerCase()!=="input"||fe.type!=="checkbox"&&fe.type!=="radio"?ue&&Qe(ue.elementType)&&(Ft=pb):Ft=p4;if(Ft&&(Ft=Ft(r,ue))){fb(Ne,Ft,l,we);break e}We&&We(r,fe,ue),r==="focusout"&&ue&&fe.type==="number"&&ue.memoizedProps.value!=null&&Ga(fe,"number",fe.value)}switch(We=ue?Fr(ue):window,r){case"focusin":(mb(We)||We.contentEditable==="true")&&(Po=We,gp=ue,ac=null);break;case"focusout":ac=gp=Po=null;break;case"mousedown":xp=!0;break;case"contextmenu":case"mouseup":case"dragend":xp=!1,Sb(Ne,l,we);break;case"selectionchange":if(x4)break;case"keydown":case"keyup":Sb(Ne,l,we)}var Nt;if(mp)e:{switch(r){case"compositionstart":var Ot="onCompositionStart";break e;case"compositionend":Ot="onCompositionEnd";break e;case"compositionupdate":Ot="onCompositionUpdate";break e}Ot=void 0}else Uo?ub(r,l)&&(Ot="onCompositionEnd"):r==="keydown"&&l.keyCode===229&&(Ot="onCompositionStart");Ot&&(ob&&l.locale!=="ko"&&(Uo||Ot!=="onCompositionStart"?Ot==="onCompositionEnd"&&Uo&&(Nt=id()):(tr=we,Pi="value"in tr?tr.value:tr.textContent,Uo=!0)),We=em(ue,Ot),0<We.length&&(Ot=new Jl(Ot,r,null,l,we),Ne.push({event:Ot,listeners:We}),Nt?Ot.data=Nt:(Nt=db(l),Nt!==null&&(Ot.data=Nt)))),(Nt=o4?l4(r,l):c4(r,l))&&(Ot=em(ue,"onBeforeInput"),0<Ot.length&&(We=new Jl("onBeforeInput","beforeinput",null,l,we),Ne.push({event:We,listeners:Ot}),We.data=Nt)),e3(Ne,r,ue,l,we)}Yk(Ne,i)})}function Ec(r,i,l){return{instance:r,listener:i,currentTarget:l}}function em(r,i){for(var l=i+"Capture",m=[];r!==null;){var b=r,k=b.stateNode;if(b=b.tag,b!==5&&b!==26&&b!==27||k===null||(b=et(r,l),b!=null&&m.unshift(Ec(r,b,k)),b=et(r,i),b!=null&&m.push(Ec(r,b,k))),r.tag===3)return m;r=r.return}return[]}function a3(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function Qk(r,i,l,m,b){for(var k=i._reactName,M=[];l!==null&&l!==m;){var O=l,Z=O.alternate,ue=O.stateNode;if(O=O.tag,Z!==null&&Z===m)break;O!==5&&O!==26&&O!==27||ue===null||(Z=ue,b?(ue=et(l,k),ue!=null&&M.unshift(Ec(l,ue,Z))):b||(ue=et(l,k),ue!=null&&M.push(Ec(l,ue,Z)))),l=l.return}M.length!==0&&r.push({event:i,listeners:M})}var s3=/\r\n?/g,i3=/\u0000|\uFFFD/g;function Zk(r){return(typeof r=="string"?r:""+r).replace(s3,`
10
- `).replace(i3,"")}function Jk(r,i){return i=Zk(i),Zk(r)===i}function nn(r,i,l,m,b,k){switch(l){case"children":typeof m=="string"?i==="body"||i==="textarea"&&m===""||br(r,m):(typeof m=="number"||typeof m=="bigint")&&i!=="body"&&br(r,""+m);break;case"className":Ar(r,"class",m);break;case"tabIndex":Ar(r,"tabindex",m);break;case"dir":case"role":case"viewBox":case"width":case"height":Ar(r,l,m);break;case"style":Re(r,m,k);break;case"data":if(i!=="object"){Ar(r,"data",m);break}case"src":case"href":if(m===""&&(i!=="a"||l!=="href")){r.removeAttribute(l);break}if(m==null||typeof m=="function"||typeof m=="symbol"||typeof m=="boolean"){r.removeAttribute(l);break}m=Pt(""+m),r.setAttribute(l,m);break;case"action":case"formAction":if(typeof m=="function"){r.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof k=="function"&&(l==="formAction"?(i!=="input"&&nn(r,i,"name",b.name,b,null),nn(r,i,"formEncType",b.formEncType,b,null),nn(r,i,"formMethod",b.formMethod,b,null),nn(r,i,"formTarget",b.formTarget,b,null)):(nn(r,i,"encType",b.encType,b,null),nn(r,i,"method",b.method,b,null),nn(r,i,"target",b.target,b,null)));if(m==null||typeof m=="symbol"||typeof m=="boolean"){r.removeAttribute(l);break}m=Pt(""+m),r.setAttribute(l,m);break;case"onClick":m!=null&&(r.onclick=Wt);break;case"onScroll":m!=null&&_t("scroll",r);break;case"onScrollEnd":m!=null&&_t("scrollend",r);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(s(61));if(l=m.__html,l!=null){if(b.children!=null)throw Error(s(60));r.innerHTML=l}}break;case"multiple":r.multiple=m&&typeof m!="function"&&typeof m!="symbol";break;case"muted":r.muted=m&&typeof m!="function"&&typeof m!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(m==null||typeof m=="function"||typeof m=="boolean"||typeof m=="symbol"){r.removeAttribute("xlink:href");break}l=Pt(""+m),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":m!=null&&typeof m!="function"&&typeof m!="symbol"?r.setAttribute(l,""+m):r.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":m&&typeof m!="function"&&typeof m!="symbol"?r.setAttribute(l,""):r.removeAttribute(l);break;case"capture":case"download":m===!0?r.setAttribute(l,""):m!==!1&&m!=null&&typeof m!="function"&&typeof m!="symbol"?r.setAttribute(l,m):r.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":m!=null&&typeof m!="function"&&typeof m!="symbol"&&!isNaN(m)&&1<=m?r.setAttribute(l,m):r.removeAttribute(l);break;case"rowSpan":case"start":m==null||typeof m=="function"||typeof m=="symbol"||isNaN(m)?r.removeAttribute(l):r.setAttribute(l,m);break;case"popover":_t("beforetoggle",r),_t("toggle",r),ka(r,"popover",m);break;case"xlinkActuate":er(r,"http://www.w3.org/1999/xlink","xlink:actuate",m);break;case"xlinkArcrole":er(r,"http://www.w3.org/1999/xlink","xlink:arcrole",m);break;case"xlinkRole":er(r,"http://www.w3.org/1999/xlink","xlink:role",m);break;case"xlinkShow":er(r,"http://www.w3.org/1999/xlink","xlink:show",m);break;case"xlinkTitle":er(r,"http://www.w3.org/1999/xlink","xlink:title",m);break;case"xlinkType":er(r,"http://www.w3.org/1999/xlink","xlink:type",m);break;case"xmlBase":er(r,"http://www.w3.org/XML/1998/namespace","xml:base",m);break;case"xmlLang":er(r,"http://www.w3.org/XML/1998/namespace","xml:lang",m);break;case"xmlSpace":er(r,"http://www.w3.org/XML/1998/namespace","xml:space",m);break;case"is":ka(r,"is",m);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=mt.get(l)||l,ka(r,l,m))}}function Hh(r,i,l,m,b,k){switch(l){case"style":Re(r,m,k);break;case"dangerouslySetInnerHTML":if(m!=null){if(typeof m!="object"||!("__html"in m))throw Error(s(61));if(l=m.__html,l!=null){if(b.children!=null)throw Error(s(60));r.innerHTML=l}}break;case"children":typeof m=="string"?br(r,m):(typeof m=="number"||typeof m=="bigint")&&br(r,""+m);break;case"onScroll":m!=null&&_t("scroll",r);break;case"onScrollEnd":m!=null&&_t("scrollend",r);break;case"onClick":m!=null&&(r.onclick=Wt);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Jn.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(b=l.endsWith("Capture"),i=l.slice(2,b?l.length-7:void 0),k=r[Rn]||null,k=k!=null?k[l]:null,typeof k=="function"&&r.removeEventListener(i,k,b),typeof m=="function")){typeof k!="function"&&k!==null&&(l in r?r[l]=null:r.hasAttribute(l)&&r.removeAttribute(l)),r.addEventListener(i,m,b);break e}l in r?r[l]=m:m===!0?r.setAttribute(l,""):ka(r,l,m)}}}function hr(r,i,l){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":_t("error",r),_t("load",r);var m=!1,b=!1,k;for(k in l)if(l.hasOwnProperty(k)){var M=l[k];if(M!=null)switch(k){case"src":m=!0;break;case"srcSet":b=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:nn(r,i,k,M,l,null)}}b&&nn(r,i,"srcSet",l.srcSet,l,null),m&&nn(r,i,"src",l.src,l,null);return;case"input":_t("invalid",r);var O=k=M=b=null,Z=null,ue=null;for(m in l)if(l.hasOwnProperty(m)){var we=l[m];if(we!=null)switch(m){case"name":b=we;break;case"type":M=we;break;case"checked":Z=we;break;case"defaultChecked":ue=we;break;case"value":k=we;break;case"defaultValue":O=we;break;case"children":case"dangerouslySetInnerHTML":if(we!=null)throw Error(s(137,i));break;default:nn(r,i,m,we,l,null)}}Ts(r,k,O,Z,ue,M,b,!1);return;case"select":_t("invalid",r),m=M=k=null;for(b in l)if(l.hasOwnProperty(b)&&(O=l[b],O!=null))switch(b){case"value":k=O;break;case"defaultValue":M=O;break;case"multiple":m=O;default:nn(r,i,b,O,l,null)}i=k,l=M,r.multiple=!!m,i!=null?Ct(r,!!m,i,!1):l!=null&&Ct(r,!!m,l,!0);return;case"textarea":_t("invalid",r),k=b=m=null;for(M in l)if(l.hasOwnProperty(M)&&(O=l[M],O!=null))switch(M){case"value":m=O;break;case"defaultValue":b=O;break;case"children":k=O;break;case"dangerouslySetInnerHTML":if(O!=null)throw Error(s(91));break;default:nn(r,i,M,O,l,null)}ja(r,m,b,k);return;case"option":for(Z in l)l.hasOwnProperty(Z)&&(m=l[Z],m!=null)&&(Z==="selected"?r.selected=m&&typeof m!="function"&&typeof m!="symbol":nn(r,i,Z,m,l,null));return;case"dialog":_t("beforetoggle",r),_t("toggle",r),_t("cancel",r),_t("close",r);break;case"iframe":case"object":_t("load",r);break;case"video":case"audio":for(m=0;m<Mc.length;m++)_t(Mc[m],r);break;case"image":_t("error",r),_t("load",r);break;case"details":_t("toggle",r);break;case"embed":case"source":case"link":_t("error",r),_t("load",r);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ue in l)if(l.hasOwnProperty(ue)&&(m=l[ue],m!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:nn(r,i,ue,m,l,null)}return;default:if(Qe(i)){for(we in l)l.hasOwnProperty(we)&&(m=l[we],m!==void 0&&Hh(r,i,we,m,l,void 0));return}}for(O in l)l.hasOwnProperty(O)&&(m=l[O],m!=null&&nn(r,i,O,m,l,null))}function o3(r,i,l,m){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var b=null,k=null,M=null,O=null,Z=null,ue=null,we=null;for(xe in l){var Ne=l[xe];if(l.hasOwnProperty(xe)&&Ne!=null)switch(xe){case"checked":break;case"value":break;case"defaultValue":Z=Ne;default:m.hasOwnProperty(xe)||nn(r,i,xe,null,m,Ne)}}for(var fe in m){var xe=m[fe];if(Ne=l[fe],m.hasOwnProperty(fe)&&(xe!=null||Ne!=null))switch(fe){case"type":k=xe;break;case"name":b=xe;break;case"checked":ue=xe;break;case"defaultChecked":we=xe;break;case"value":M=xe;break;case"defaultValue":O=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(s(137,i));break;default:xe!==Ne&&nn(r,i,fe,xe,m,Ne)}}Sa(r,M,O,Z,ue,we,k,b);return;case"select":xe=M=O=fe=null;for(k in l)if(Z=l[k],l.hasOwnProperty(k)&&Z!=null)switch(k){case"value":break;case"multiple":xe=Z;default:m.hasOwnProperty(k)||nn(r,i,k,null,m,Z)}for(b in m)if(k=m[b],Z=l[b],m.hasOwnProperty(b)&&(k!=null||Z!=null))switch(b){case"value":fe=k;break;case"defaultValue":O=k;break;case"multiple":M=k;default:k!==Z&&nn(r,i,b,k,m,Z)}i=O,l=M,m=xe,fe!=null?Ct(r,!!l,fe,!1):!!m!=!!l&&(i!=null?Ct(r,!!l,i,!0):Ct(r,!!l,l?[]:"",!1));return;case"textarea":xe=fe=null;for(O in l)if(b=l[O],l.hasOwnProperty(O)&&b!=null&&!m.hasOwnProperty(O))switch(O){case"value":break;case"children":break;default:nn(r,i,O,null,m,b)}for(M in m)if(b=m[M],k=l[M],m.hasOwnProperty(M)&&(b!=null||k!=null))switch(M){case"value":fe=b;break;case"defaultValue":xe=b;break;case"children":break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(s(91));break;default:b!==k&&nn(r,i,M,b,m,k)}ds(r,fe,xe);return;case"option":for(var Ve in l)fe=l[Ve],l.hasOwnProperty(Ve)&&fe!=null&&!m.hasOwnProperty(Ve)&&(Ve==="selected"?r.selected=!1:nn(r,i,Ve,null,m,fe));for(Z in m)fe=m[Z],xe=l[Z],m.hasOwnProperty(Z)&&fe!==xe&&(fe!=null||xe!=null)&&(Z==="selected"?r.selected=fe&&typeof fe!="function"&&typeof fe!="symbol":nn(r,i,Z,fe,m,xe));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var lt in l)fe=l[lt],l.hasOwnProperty(lt)&&fe!=null&&!m.hasOwnProperty(lt)&&nn(r,i,lt,null,m,fe);for(ue in m)if(fe=m[ue],xe=l[ue],m.hasOwnProperty(ue)&&fe!==xe&&(fe!=null||xe!=null))switch(ue){case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(s(137,i));break;default:nn(r,i,ue,fe,m,xe)}return;default:if(Qe(i)){for(var rn in l)fe=l[rn],l.hasOwnProperty(rn)&&fe!==void 0&&!m.hasOwnProperty(rn)&&Hh(r,i,rn,void 0,m,fe);for(we in m)fe=m[we],xe=l[we],!m.hasOwnProperty(we)||fe===xe||fe===void 0&&xe===void 0||Hh(r,i,we,fe,m,xe);return}}for(var se in l)fe=l[se],l.hasOwnProperty(se)&&fe!=null&&!m.hasOwnProperty(se)&&nn(r,i,se,null,m,fe);for(Ne in m)fe=m[Ne],xe=l[Ne],!m.hasOwnProperty(Ne)||fe===xe||fe==null&&xe==null||nn(r,i,Ne,fe,m,xe)}function e1(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function l3(){if(typeof performance.getEntriesByType=="function"){for(var r=0,i=0,l=performance.getEntriesByType("resource"),m=0;m<l.length;m++){var b=l[m],k=b.transferSize,M=b.initiatorType,O=b.duration;if(k&&O&&e1(M)){for(M=0,O=b.responseEnd,m+=1;m<l.length;m++){var Z=l[m],ue=Z.startTime;if(ue>O)break;var we=Z.transferSize,Ne=Z.initiatorType;we&&e1(Ne)&&(Z=Z.responseEnd,M+=we*(Z<O?1:(O-ue)/(Z-ue)))}if(--m,i+=8*(k+M)/(b.duration/1e3),r++,10<r)break}}if(0<r)return i/r/1e6}return navigator.connection&&(r=navigator.connection.downlink,typeof r=="number")?r:5}var Fh=null,qh=null;function tm(r){return r.nodeType===9?r:r.ownerDocument}function t1(r){switch(r){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function n1(r,i){if(r===0)switch(i){case"svg":return 1;case"math":return 2;default:return 0}return r===1&&i==="foreignObject"?0:r}function Vh(r,i){return r==="textarea"||r==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.children=="bigint"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Gh=null;function c3(){var r=window.event;return r&&r.type==="popstate"?r===Gh?!1:(Gh=r,!0):(Gh=null,!1)}var r1=typeof setTimeout=="function"?setTimeout:void 0,u3=typeof clearTimeout=="function"?clearTimeout:void 0,a1=typeof Promise=="function"?Promise:void 0,d3=typeof queueMicrotask=="function"?queueMicrotask:typeof a1<"u"?function(r){return a1.resolve(null).then(r).catch(m3)}:r1;function m3(r){setTimeout(function(){throw r})}function yi(r){return r==="head"}function s1(r,i){var l=i,m=0;do{var b=l.nextSibling;if(r.removeChild(l),b&&b.nodeType===8)if(l=b.data,l==="/$"||l==="/&"){if(m===0){r.removeChild(b),ml(i);return}m--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")m++;else if(l==="html")Ac(r.ownerDocument.documentElement);else if(l==="head"){l=r.ownerDocument.head,Ac(l);for(var k=l.firstChild;k;){var M=k.nextSibling,O=k.nodeName;k[Br]||O==="SCRIPT"||O==="STYLE"||O==="LINK"&&k.rel.toLowerCase()==="stylesheet"||l.removeChild(k),k=M}}else l==="body"&&Ac(r.ownerDocument.body);l=b}while(l);ml(i)}function i1(r,i){var l=r;r=0;do{var m=l.nextSibling;if(l.nodeType===1?i?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(i?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),m&&m.nodeType===8)if(l=m.data,l==="/$"){if(r===0)break;r--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||r++;l=m}while(l)}function Kh(r){var i=r.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var l=i;switch(i=i.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Kh(l),is(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}r.removeChild(l)}}function f3(r,i,l,m){for(;r.nodeType===1;){var b=l;if(r.nodeName.toLowerCase()!==i.toLowerCase()){if(!m&&(r.nodeName!=="INPUT"||r.type!=="hidden"))break}else if(m){if(!r[Br])switch(i){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(k=r.getAttribute("rel"),k==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(k!==b.rel||r.getAttribute("href")!==(b.href==null||b.href===""?null:b.href)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin)||r.getAttribute("title")!==(b.title==null?null:b.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(k=r.getAttribute("src"),(k!==(b.src==null?null:b.src)||r.getAttribute("type")!==(b.type==null?null:b.type)||r.getAttribute("crossorigin")!==(b.crossOrigin==null?null:b.crossOrigin))&&k&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(i==="input"&&r.type==="hidden"){var k=b.name==null?null:""+b.name;if(b.type==="hidden"&&r.getAttribute("name")===k)return r}else return r;if(r=La(r.nextSibling),r===null)break}return null}function p3(r,i,l){if(i==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!l||(r=La(r.nextSibling),r===null))return null;return r}function o1(r,i){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!i||(r=La(r.nextSibling),r===null))return null;return r}function Wh(r){return r.data==="$?"||r.data==="$~"}function Yh(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function h3(r,i){var l=r.ownerDocument;if(r.data==="$~")r._reactRetry=i;else if(r.data!=="$?"||l.readyState!=="loading")i();else{var m=function(){i(),l.removeEventListener("DOMContentLoaded",m)};l.addEventListener("DOMContentLoaded",m),r._reactRetry=m}}function La(r){for(;r!=null;r=r.nextSibling){var i=r.nodeType;if(i===1||i===3)break;if(i===8){if(i=r.data,i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"||i==="F!"||i==="F")break;if(i==="/$"||i==="/&")return null}}return r}var Xh=null;function l1(r){r=r.nextSibling;for(var i=0;r;){if(r.nodeType===8){var l=r.data;if(l==="/$"||l==="/&"){if(i===0)return La(r.nextSibling);i--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||i++}r=r.nextSibling}return null}function c1(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var l=r.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(i===0)return r;i--}else l!=="/$"&&l!=="/&"||i++}r=r.previousSibling}return null}function u1(r,i,l){switch(i=tm(l),r){case"html":if(r=i.documentElement,!r)throw Error(s(452));return r;case"head":if(r=i.head,!r)throw Error(s(453));return r;case"body":if(r=i.body,!r)throw Error(s(454));return r;default:throw Error(s(451))}}function Ac(r){for(var i=r.attributes;i.length;)r.removeAttributeNode(i[0]);is(r)}var Oa=new Map,d1=new Set;function nm(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var Fs=X.d;X.d={f:g3,r:x3,D:y3,C:b3,L:v3,m:k3,X:S3,S:w3,M:j3};function g3(){var r=Fs.f(),i=Kd();return r||i}function x3(r){var i=fn(r);i!==null&&i.tag===5&&i.type==="form"?Mv(i):Fs.r(r)}var cl=typeof document>"u"?null:document;function m1(r,i,l){var m=cl;if(m&&typeof i=="string"&&i){var b=hn(i);b='link[rel="'+r+'"][href="'+b+'"]',typeof l=="string"&&(b+='[crossorigin="'+l+'"]'),d1.has(b)||(d1.add(b),r={rel:r,crossOrigin:l,href:i},m.querySelector(b)===null&&(i=m.createElement("link"),hr(i,"link",r),pn(i),m.head.appendChild(i)))}}function y3(r){Fs.D(r),m1("dns-prefetch",r,null)}function b3(r,i){Fs.C(r,i),m1("preconnect",r,i)}function v3(r,i,l){Fs.L(r,i,l);var m=cl;if(m&&r&&i){var b='link[rel="preload"][as="'+hn(i)+'"]';i==="image"&&l&&l.imageSrcSet?(b+='[imagesrcset="'+hn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(b+='[imagesizes="'+hn(l.imageSizes)+'"]')):b+='[href="'+hn(r)+'"]';var k=b;switch(i){case"style":k=ul(r);break;case"script":k=dl(r)}Oa.has(k)||(r=g({rel:"preload",href:i==="image"&&l&&l.imageSrcSet?void 0:r,as:i},l),Oa.set(k,r),m.querySelector(b)!==null||i==="style"&&m.querySelector(_c(k))||i==="script"&&m.querySelector(Rc(k))||(i=m.createElement("link"),hr(i,"link",r),pn(i),m.head.appendChild(i)))}}function k3(r,i){Fs.m(r,i);var l=cl;if(l&&r){var m=i&&typeof i.as=="string"?i.as:"script",b='link[rel="modulepreload"][as="'+hn(m)+'"][href="'+hn(r)+'"]',k=b;switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":k=dl(r)}if(!Oa.has(k)&&(r=g({rel:"modulepreload",href:r},i),Oa.set(k,r),l.querySelector(b)===null)){switch(m){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Rc(k)))return}m=l.createElement("link"),hr(m,"link",r),pn(m),l.head.appendChild(m)}}}function w3(r,i,l){Fs.S(r,i,l);var m=cl;if(m&&r){var b=qr(m).hoistableStyles,k=ul(r);i=i||"default";var M=b.get(k);if(!M){var O={loading:0,preload:null};if(M=m.querySelector(_c(k)))O.loading=5;else{r=g({rel:"stylesheet",href:r,"data-precedence":i},l),(l=Oa.get(k))&&Qh(r,l);var Z=M=m.createElement("link");pn(Z),hr(Z,"link",r),Z._p=new Promise(function(ue,we){Z.onload=ue,Z.onerror=we}),Z.addEventListener("load",function(){O.loading|=1}),Z.addEventListener("error",function(){O.loading|=2}),O.loading|=4,rm(M,i,m)}M={type:"stylesheet",instance:M,count:1,state:O},b.set(k,M)}}}function S3(r,i){Fs.X(r,i);var l=cl;if(l&&r){var m=qr(l).hoistableScripts,b=dl(r),k=m.get(b);k||(k=l.querySelector(Rc(b)),k||(r=g({src:r,async:!0},i),(i=Oa.get(b))&&Zh(r,i),k=l.createElement("script"),pn(k),hr(k,"link",r),l.head.appendChild(k)),k={type:"script",instance:k,count:1,state:null},m.set(b,k))}}function j3(r,i){Fs.M(r,i);var l=cl;if(l&&r){var m=qr(l).hoistableScripts,b=dl(r),k=m.get(b);k||(k=l.querySelector(Rc(b)),k||(r=g({src:r,async:!0,type:"module"},i),(i=Oa.get(b))&&Zh(r,i),k=l.createElement("script"),pn(k),hr(k,"link",r),l.head.appendChild(k)),k={type:"script",instance:k,count:1,state:null},m.set(b,k))}}function f1(r,i,l,m){var b=(b=re.current)?nm(b):null;if(!b)throw Error(s(446));switch(r){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(i=ul(l.href),l=qr(b).hoistableStyles,m=l.get(i),m||(m={type:"style",instance:null,count:0,state:null},l.set(i,m)),m):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){r=ul(l.href);var k=qr(b).hoistableStyles,M=k.get(r);if(M||(b=b.ownerDocument||b,M={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},k.set(r,M),(k=b.querySelector(_c(r)))&&!k._p&&(M.instance=k,M.state.loading=5),Oa.has(r)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Oa.set(r,l),k||C3(b,r,l,M.state))),i&&m===null)throw Error(s(528,""));return M}if(i&&m!==null)throw Error(s(529,""));return null;case"script":return i=l.async,l=l.src,typeof l=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=dl(l),l=qr(b).hoistableScripts,m=l.get(i),m||(m={type:"script",instance:null,count:0,state:null},l.set(i,m)),m):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,r))}}function ul(r){return'href="'+hn(r)+'"'}function _c(r){return'link[rel="stylesheet"]['+r+"]"}function p1(r){return g({},r,{"data-precedence":r.precedence,precedence:null})}function C3(r,i,l,m){r.querySelector('link[rel="preload"][as="style"]['+i+"]")?m.loading=1:(i=r.createElement("link"),m.preload=i,i.addEventListener("load",function(){return m.loading|=1}),i.addEventListener("error",function(){return m.loading|=2}),hr(i,"link",l),pn(i),r.head.appendChild(i))}function dl(r){return'[src="'+hn(r)+'"]'}function Rc(r){return"script[async]"+r}function h1(r,i,l){if(i.count++,i.instance===null)switch(i.type){case"style":var m=r.querySelector('style[data-href~="'+hn(l.href)+'"]');if(m)return i.instance=m,pn(m),m;var b=g({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return m=(r.ownerDocument||r).createElement("style"),pn(m),hr(m,"style",b),rm(m,l.precedence,r),i.instance=m;case"stylesheet":b=ul(l.href);var k=r.querySelector(_c(b));if(k)return i.state.loading|=4,i.instance=k,pn(k),k;m=p1(l),(b=Oa.get(b))&&Qh(m,b),k=(r.ownerDocument||r).createElement("link"),pn(k);var M=k;return M._p=new Promise(function(O,Z){M.onload=O,M.onerror=Z}),hr(k,"link",m),i.state.loading|=4,rm(k,l.precedence,r),i.instance=k;case"script":return k=dl(l.src),(b=r.querySelector(Rc(k)))?(i.instance=b,pn(b),b):(m=l,(b=Oa.get(k))&&(m=g({},l),Zh(m,b)),r=r.ownerDocument||r,b=r.createElement("script"),pn(b),hr(b,"link",m),r.head.appendChild(b),i.instance=b);case"void":return null;default:throw Error(s(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(m=i.instance,i.state.loading|=4,rm(m,l.precedence,r));return i.instance}function rm(r,i,l){for(var m=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=m.length?m[m.length-1]:null,k=b,M=0;M<m.length;M++){var O=m[M];if(O.dataset.precedence===i)k=O;else if(k!==b)break}k?k.parentNode.insertBefore(r,k.nextSibling):(i=l.nodeType===9?l.head:l,i.insertBefore(r,i.firstChild))}function Qh(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.title==null&&(r.title=i.title)}function Zh(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.integrity==null&&(r.integrity=i.integrity)}var am=null;function g1(r,i,l){if(am===null){var m=new Map,b=am=new Map;b.set(l,m)}else b=am,m=b.get(l),m||(m=new Map,b.set(l,m));if(m.has(r))return m;for(m.set(r,null),l=l.getElementsByTagName(r),b=0;b<l.length;b++){var k=l[b];if(!(k[Br]||k[Dt]||r==="link"&&k.getAttribute("rel")==="stylesheet")&&k.namespaceURI!=="http://www.w3.org/2000/svg"){var M=k.getAttribute(i)||"";M=r+M;var O=m.get(M);O?O.push(k):m.set(M,[k])}}return m}function x1(r,i,l){r=r.ownerDocument||r,r.head.insertBefore(l,i==="title"?r.querySelector("head > title"):null)}function N3(r,i,l){if(l===1||i.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;return i.rel==="stylesheet"?(r=i.disabled,typeof i.precedence=="string"&&r==null):!0;case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function y1(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function T3(r,i,l,m){if(l.type==="stylesheet"&&(typeof m.media!="string"||matchMedia(m.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var b=ul(m.href),k=i.querySelector(_c(b));if(k){i=k._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(r.count++,r=sm.bind(r),i.then(r,r)),l.state.loading|=4,l.instance=k,pn(k);return}k=i.ownerDocument||i,m=p1(m),(b=Oa.get(b))&&Qh(m,b),k=k.createElement("link"),pn(k);var M=k;M._p=new Promise(function(O,Z){M.onload=O,M.onerror=Z}),hr(k,"link",m),l.instance=k}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(l,i),(i=l.state.preload)&&(l.state.loading&3)===0&&(r.count++,l=sm.bind(r),i.addEventListener("load",l),i.addEventListener("error",l))}}var Jh=0;function M3(r,i){return r.stylesheets&&r.count===0&&om(r,r.stylesheets),0<r.count||0<r.imgCount?function(l){var m=setTimeout(function(){if(r.stylesheets&&om(r,r.stylesheets),r.unsuspend){var k=r.unsuspend;r.unsuspend=null,k()}},6e4+i);0<r.imgBytes&&Jh===0&&(Jh=62500*l3());var b=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&om(r,r.stylesheets),r.unsuspend)){var k=r.unsuspend;r.unsuspend=null,k()}},(r.imgBytes>Jh?50:800)+i);return r.unsuspend=l,function(){r.unsuspend=null,clearTimeout(m),clearTimeout(b)}}:null}function sm(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)om(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var im=null;function om(r,i){r.stylesheets=null,r.unsuspend!==null&&(r.count++,im=new Map,i.forEach(E3,r),im=null,sm.call(r))}function E3(r,i){if(!(i.state.loading&4)){var l=im.get(r);if(l)var m=l.get(null);else{l=new Map,im.set(r,l);for(var b=r.querySelectorAll("link[data-precedence],style[data-precedence]"),k=0;k<b.length;k++){var M=b[k];(M.nodeName==="LINK"||M.getAttribute("media")!=="not all")&&(l.set(M.dataset.precedence,M),m=M)}m&&l.set(null,m)}b=i.instance,M=b.getAttribute("data-precedence"),k=l.get(M)||m,k===m&&l.set(null,b),l.set(M,b),this.count++,m=sm.bind(this),b.addEventListener("load",m),b.addEventListener("error",m),k?k.parentNode.insertBefore(b,k.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(b,r.firstChild)),i.state.loading|=4}}var Ic={$$typeof:R,Provider:null,Consumer:null,_currentValue:le,_currentValue2:le,_threadCount:0};function A3(r,i,l,m,b,k,M,O,Z){this.tag=1,this.containerInfo=r,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Pr(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pr(0),this.hiddenUpdates=Pr(null),this.identifierPrefix=m,this.onUncaughtError=b,this.onCaughtError=k,this.onRecoverableError=M,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Z,this.incompleteTransitions=new Map}function b1(r,i,l,m,b,k,M,O,Z,ue,we,Ne){return r=new A3(r,i,l,M,Z,ue,we,Ne,O),i=1,k===!0&&(i|=24),k=sa(3,null,null,i),r.current=k,k.stateNode=r,i=Rp(),i.refCount++,r.pooledCache=i,i.refCount++,k.memoizedState={element:m,isDehydrated:l,cache:i},Dp(k),r}function v1(r){return r?(r=Ho,r):Ho}function k1(r,i,l,m,b,k){b=v1(b),m.context===null?m.context=b:m.pendingContext=b,m=oi(i),m.payload={element:l},k=k===void 0?null:k,k!==null&&(m.callback=k),l=li(r,m,i),l!==null&&(Qr(l,r,i),dc(l,r,i))}function w1(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var l=r.retryLane;r.retryLane=l!==0&&l<i?l:i}}function eg(r,i){w1(r,i),(r=r.alternate)&&w1(r,i)}function S1(r){if(r.tag===13||r.tag===31){var i=Wi(r,67108864);i!==null&&Qr(i,r,67108864),eg(r,67108864)}}function j1(r){if(r.tag===13||r.tag===31){var i=ua();i=ut(i);var l=Wi(r,i);l!==null&&Qr(l,r,i),eg(r,i)}}var lm=!0;function _3(r,i,l,m){var b=$.T;$.T=null;var k=X.p;try{X.p=2,tg(r,i,l,m)}finally{X.p=k,$.T=b}}function R3(r,i,l,m){var b=$.T;$.T=null;var k=X.p;try{X.p=8,tg(r,i,l,m)}finally{X.p=k,$.T=b}}function tg(r,i,l,m){if(lm){var b=ng(m);if(b===null)Bh(r,i,m,cm,l),N1(r,m);else if(L3(b,r,i,l,m))m.stopPropagation();else if(N1(r,m),i&4&&-1<I3.indexOf(r)){for(;b!==null;){var k=fn(b);if(k!==null)switch(k.tag){case 3:if(k=k.stateNode,k.current.memoizedState.isDehydrated){var M=zn(k.pendingLanes);if(M!==0){var O=k;for(O.pendingLanes|=2,O.entangledLanes|=2;M;){var Z=1<<31-wt(M);O.entanglements[1]|=Z,M&=~Z}gs(k),(Gt&6)===0&&(Vd=He()+500,Tc(0))}}break;case 31:case 13:O=Wi(k,2),O!==null&&Qr(O,k,2),Kd(),eg(k,2)}if(k=ng(m),k===null&&Bh(r,i,m,cm,l),k===b)break;b=k}b!==null&&m.stopPropagation()}else Bh(r,i,m,null,l)}}function ng(r){return r=_r(r),rg(r)}var cm=null;function rg(r){if(cm=null,r=Hr(r),r!==null){var i=c(r);if(i===null)r=null;else{var l=i.tag;if(l===13){if(r=u(i),r!==null)return r;r=null}else if(l===31){if(r=f(i),r!==null)return r;r=null}else if(l===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null)}}return cm=r,null}function C1(r){switch(r){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Pe()){case W:return 2;case me:return 8;case Ue:case pe:return 32;case $e:return 268435456;default:return 32}default:return 32}}var ag=!1,bi=null,vi=null,ki=null,Lc=new Map,Oc=new Map,wi=[],I3="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function N1(r,i){switch(r){case"focusin":case"focusout":bi=null;break;case"dragenter":case"dragleave":vi=null;break;case"mouseover":case"mouseout":ki=null;break;case"pointerover":case"pointerout":Lc.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Oc.delete(i.pointerId)}}function Dc(r,i,l,m,b,k){return r===null||r.nativeEvent!==k?(r={blockedOn:i,domEventName:l,eventSystemFlags:m,nativeEvent:k,targetContainers:[b]},i!==null&&(i=fn(i),i!==null&&S1(i)),r):(r.eventSystemFlags|=m,i=r.targetContainers,b!==null&&i.indexOf(b)===-1&&i.push(b),r)}function L3(r,i,l,m,b){switch(i){case"focusin":return bi=Dc(bi,r,i,l,m,b),!0;case"dragenter":return vi=Dc(vi,r,i,l,m,b),!0;case"mouseover":return ki=Dc(ki,r,i,l,m,b),!0;case"pointerover":var k=b.pointerId;return Lc.set(k,Dc(Lc.get(k)||null,r,i,l,m,b)),!0;case"gotpointercapture":return k=b.pointerId,Oc.set(k,Dc(Oc.get(k)||null,r,i,l,m,b)),!0}return!1}function T1(r){var i=Hr(r.target);if(i!==null){var l=c(i);if(l!==null){if(i=l.tag,i===13){if(i=u(l),i!==null){r.blockedOn=i,Nn(r.priority,function(){j1(l)});return}}else if(i===31){if(i=f(l),i!==null){r.blockedOn=i,Nn(r.priority,function(){j1(l)});return}}else if(i===3&&l.stateNode.current.memoizedState.isDehydrated){r.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}r.blockedOn=null}function um(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var l=ng(r.nativeEvent);if(l===null){l=r.nativeEvent;var m=new l.constructor(l.type,l);Ka=m,l.target.dispatchEvent(m),Ka=null}else return i=fn(l),i!==null&&S1(i),r.blockedOn=l,!1;i.shift()}return!0}function M1(r,i,l){um(r)&&l.delete(i)}function O3(){ag=!1,bi!==null&&um(bi)&&(bi=null),vi!==null&&um(vi)&&(vi=null),ki!==null&&um(ki)&&(ki=null),Lc.forEach(M1),Oc.forEach(M1)}function dm(r,i){r.blockedOn===i&&(r.blockedOn=null,ag||(ag=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,O3)))}var mm=null;function E1(r){mm!==r&&(mm=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){mm===r&&(mm=null);for(var i=0;i<r.length;i+=3){var l=r[i],m=r[i+1],b=r[i+2];if(typeof m!="function"){if(rg(m||l)===null)continue;break}var k=fn(l);k!==null&&(r.splice(i,3),i-=3,nh(k,{pending:!0,data:b,method:l.method,action:m},m,b))}}))}function ml(r){function i(Z){return dm(Z,r)}bi!==null&&dm(bi,r),vi!==null&&dm(vi,r),ki!==null&&dm(ki,r),Lc.forEach(i),Oc.forEach(i);for(var l=0;l<wi.length;l++){var m=wi[l];m.blockedOn===r&&(m.blockedOn=null)}for(;0<wi.length&&(l=wi[0],l.blockedOn===null);)T1(l),l.blockedOn===null&&wi.shift();if(l=(r.ownerDocument||r).$$reactFormReplay,l!=null)for(m=0;m<l.length;m+=3){var b=l[m],k=l[m+1],M=b[Rn]||null;if(typeof k=="function")M||E1(l);else if(M){var O=null;if(k&&k.hasAttribute("formAction")){if(b=k,M=k[Rn]||null)O=M.formAction;else if(rg(b)!==null)continue}else O=M.action;typeof O=="function"?l[m+1]=O:(l.splice(m,3),m-=3),E1(l)}}}function A1(){function r(k){k.canIntercept&&k.info==="react-transition"&&k.intercept({handler:function(){return new Promise(function(M){return b=M})},focusReset:"manual",scroll:"manual"})}function i(){b!==null&&(b(),b=null),m||setTimeout(l,20)}function l(){if(!m&&!navigation.transition){var k=navigation.currentEntry;k&&k.url!=null&&navigation.navigate(k.url,{state:k.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var m=!1,b=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",i),navigation.addEventListener("navigateerror",i),setTimeout(l,100),function(){m=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",i),navigation.removeEventListener("navigateerror",i),b!==null&&(b(),b=null)}}}function sg(r){this._internalRoot=r}fm.prototype.render=sg.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(s(409));var l=i.current,m=ua();k1(l,m,r,i,null,null)},fm.prototype.unmount=sg.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;k1(r.current,2,null,r,null,null),Kd(),i[zr]=null}};function fm(r){this._internalRoot=r}fm.prototype.unstable_scheduleHydration=function(r){if(r){var i=gn();r={blockedOn:null,target:r,priority:i};for(var l=0;l<wi.length&&i!==0&&i<wi[l].priority;l++);wi.splice(l,0,r),l===0&&T1(r)}};var _1=t.version;if(_1!=="19.2.7")throw Error(s(527,_1,"19.2.7"));X.findDOMNode=function(r){var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(s(188)):(r=Object.keys(r).join(","),Error(s(268,r)));return r=h(i),r=r!==null?x(r):null,r=r===null?null:r.stateNode,r};var D3={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var pm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!pm.isDisabled&&pm.supportsFiber)try{Ke=pm.inject(D3),dt=pm}catch{}}return Uc.createRoot=function(r,i){if(!o(r))throw Error(s(299));var l=!1,m="",b=Uv,k=Pv,M=zv;return i!=null&&(i.unstable_strictMode===!0&&(l=!0),i.identifierPrefix!==void 0&&(m=i.identifierPrefix),i.onUncaughtError!==void 0&&(b=i.onUncaughtError),i.onCaughtError!==void 0&&(k=i.onCaughtError),i.onRecoverableError!==void 0&&(M=i.onRecoverableError)),i=b1(r,1,!1,null,null,l,m,null,b,k,M,A1),r[zr]=i.current,zh(r),new sg(i)},Uc.hydrateRoot=function(r,i,l){if(!o(r))throw Error(s(299));var m=!1,b="",k=Uv,M=Pv,O=zv,Z=null;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(b=l.identifierPrefix),l.onUncaughtError!==void 0&&(k=l.onUncaughtError),l.onCaughtError!==void 0&&(M=l.onCaughtError),l.onRecoverableError!==void 0&&(O=l.onRecoverableError),l.formState!==void 0&&(Z=l.formState)),i=b1(r,1,!0,i,l??null,m,b,Z,k,M,O,A1),i.context=v1(null),l=i.current,m=ua(),m=ut(m),b=oi(m),b.callback=null,li(l,b,m),l=m,i.current.lanes=l,Bn(i,l),gs(i),r[zr]=i.current,zh(r),new fm(i)},Uc.version="19.2.7",Uc}var B1;function V3(){if(B1)return lg.exports;B1=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),lg.exports=q3(),lg.exports}var G3=V3();const Uj={appName:"PenguinHarness",nav:{chat:"对话",newChat:"新对话",agents:"智能体",skills:"技能库",models:"模型库",usage:"成本中心",traces:"轨迹观测",benchmark:"评估中心",lastConversation:"最近一次对话",collapseSidebar:"收起侧栏",expandSidebar:"展开侧栏",collapseGroup:"折叠",expandGroup:"展开",pinGroup:"置顶分组",unpinGroup:"取消置顶"},terminal:{title:"终端",newShell:"新建 Shell",killShell:"关闭此终端",createFailed:"终端创建失败",noTerminalApi:"该服务端没有终端接口:运行中的 runtime 早于该功能。热更新只替换平台与前端,终端接口属于 runtime,需更新 runtime 本身(重启无效)",detach:"在新窗口打开",status:{connecting:"连接中",ready:"已连接",exited:"已退出",error:"连接错误"},exitedWithCode:e=>`退出码 ${e}`},dock:{addTab:"添加面板",closeTab:"关闭面板",hideDock:"收起侧边栏",moveToRight:"移到右侧",moveToBottom:"移到下方",resize:"调整面板大小",rightDock:"右侧栏",bottomDock:"下侧栏",draftEmpty:"发送第一条消息后可用",killConfirmTitle:"关闭此终端?",killConfirmBody:e=>`将结束 Shell「${e}」的进程,无法恢复。`},tracePanel:{empty:"暂无轨迹",emptyHint:"该会话还没有产生 Trace 文件",loadFailed:"轨迹加载失败"},settings:{language:"语言",languageInfo:"界面语言,可跟随浏览器设置。",systemSettings:"系统设置",groupPersonal:"个人",groupServer:"服务器",generalTitle:"通用",appearanceTitle:"外观",accountTitle:"账户",importTrace:"导入 Trace",importTraceInfo:"上传从其他部署导出的 .jsonl 轨迹文件,它会成为所选 Agent 的一个会话。目的地的两个部分都在这里选择:导入接口按 Agent 划分——轨迹文件自带的 session_meta 无法指认本机的 Agent,其中的 agent_state 路径属于导出它的那台机器——而 Project 需要明确指定,因为本对话框不显示当前是哪一个,也因此可以导入到当前打开之外的 Project。导出在对话的 Trace 面板中进行。",importTraceProject:"导入到 Project",importTraceAgent:"导入到 Agent",importTracePick:"选择文件",importTraceRunning:"导入中…",importTraceDone:e=>`轨迹已导入到 ${e}`,importTraceTooLarge:"文件超过 14MB 上限。",proxyTitle:"代理选项",proxyInfo:"服务器全局设置,保存后立即生效,无需重启。回环地址始终直连。",proxyForApp:"应用程序使用代理",proxyForAgent:"Agent 环境使用代理",proxyAddress:"代理地址",proxyAddressPlaceholder:"留空 = 跟随系统代理",uploadLimitsTitle:"上传限制",attachmentMaxMb:"单个附件上限(MB)",attachmentTotalMb:"单条消息附件合计上限(MB)",attachmentMaxMbHint:(e,t)=>`取值 ${e}–${t} MB`,attachmentTotalMbHint:(e,t)=>`取值 ${e}–${t} MB,且不得低于单个附件上限`,uploadLimitsInfo:(e,t)=>`一条消息最多 ${e} 个附件;对话内嵌图片另有 ${t}MB 上限,不随此设置变化——图片会进入对话与轨迹,每次翻阅历史与恢复会话都要重新付出它的体积。`,theme:"主题",themeInfo:"应用的明暗外观。",themeLight:"浅色",themeDark:"深色",followSystem:"跟随系统",terminalTheme:"终端主题",terminalThemeInfo:"终端面板的配色,默认跟随应用主题。",followAppTheme:"跟随主题",langZh:"中文",langEn:"English",fontSize:"字号",fontSizeInfo:"界面整体字号。",fontSmall:"小",fontMedium:"中",fontLarge:"大",accent:"主题色",accentInfo:"界面强调色。",currencyInfo:"价格显示币种;存储始终为美元。",changePasswordInfo:"更改当前账号的登录密码。",accentNames:{neutral:"灰白",blue:"蓝",green:"绿",violet:"紫",rose:"红",amber:"橙"}},update:{lastUpdated:e=>`最近更新日期 ${e}`,newVersionBadge:"有新版本可用",newVersion:e=>`新版本 v${e} 可用`,updatesAvailable:"有可用更新",checkNow:"检查更新",checking:"检查中…",foundNew:e=>`发现新版本 v${e},点击该更新入口即可安装`,upToDate:"已是最新版本",checkFailed:"检查更新失败,请稍后重试",checkDisabled:"更新检查已关闭(PENGUIN_UPDATE_CHECK=off)",releaseNotes:"更新说明",updateNow:"立即更新",updating:"更新中…",updated:"更新完成,重启服务后生效",restartHint:"在终端重新运行 penguin web(或 penguin server)即可完成重启",failed:"更新失败",unsupported:"当前安装方式不支持在线更新",confirmBody:"将下载最新版本并安装到服务器上的安装目录(数据目录不受影响)。安装完成后需要重启服务才会生效。",adminOnly:"只有管理员可以在这里执行更新。",clientCheckNow:"检查更新",clientFoundNew:e=>e!==null?`发现新版本 v${e},正在后台下载…`:"发现新版本,正在后台下载…",clientDownloading:(e,t)=>`${e!==null?`v${e} `:""}下载中…${t!==null?` ${t}%`:""}`,clientRestartToInstall:e=>e!==null?`重启并安装 v${e}`:"重启并安装更新",clientDownloadReady:e=>e!==null?`新版本 v${e} 已就绪,可重启安装`:"更新已就绪,可重启安装",clientUpdateFailed:e=>`客户端更新失败:${e}`,clientInstallFailed:e=>`无法开始安装:${e}`,clientInstallConfirmTitle:"重启并安装更新",clientInstallConfirmBody:"PenguinHarness 将重启以完成更新,正在运行的任务会被打断。",clientInstallConfirmAction:"立即重启",clientUnsupportedDev:"开发运行不支持自更新",clientUnsupportedNonAppImage:"Linux 上只有 AppImage 版本支持自更新——包安装请通过包管理器更新"},notify:{taskCompleteTitle:"任务完成",taskCompleteBody:e=>`「${e}」已完成,点击查看`},common:{save:"保存",cancel:"取消",close:"关闭",create:"创建",delete:"删除",edit:"编辑",settings:"设置",confirm:"确认",loading:"加载中…",saved:"已保存",saving:"保存中…",noChangesToSave:"当前没有需要保存的修改",confirmSaveTitle:"保存修改",confirmSaveBody:"确定保存这些修改吗?修改将写入服务器上的配置文件。",none:"(无)",retry:"重试",unknownError:"请求失败,请稍后重试",requiredField:"此项必填",copied:"已复制",moreInfo:"说明",moreInfoAbout:e=>`说明:${e}`,name:"名称",username:"用户名",role:"角色",actions:"操作",created:"创建时间",cost:"成本",time:"时间"},auth:{usernameHint:"2~32 位:小写字母开头,仅小写字母、数字与下划线",password:"密码",passwordHint:"至少 8 个字符",showPassword:"显示密码",hidePassword:"隐藏密码",login:"登录",logout:"登出",admin:"管理员",defaultAdminNote:"首次使用请以内置管理员 admin 登录,初始密码在服务端首次启动时打印(形如 penguin-1234),登录后请尽快修改密码",forgotAdminNote:"忘记管理员密码时,停止服务后执行 penguin server reset-admin-password 重置为新的初始密码"},account:{changePassword:"修改密码",oldPassword:"当前密码",oldPasswordHint:"内置管理员的初始密码在服务端首次启动时打印(形如 penguin-1234)",newPassword:"新密码",confirmPassword:"确认新密码",passwordMismatch:"两次输入的新密码不一致",initialPasswordBanner:"当前账号正在使用初始密码,建议尽快修改",changeNow:"去修改"},admin:{users:"用户管理",roleAdmin:"管理员",roleUser:"用户",createUser:"新增用户",initialPassword:"初始密码",initialPasswordFlag:"初始密码",defaultProjectNote:e=>`将自动创建默认 Project:${e}`,resetPassword:"重置密码",resetPasswordTitle:e=>`重置 ${e} 的密码`,resetPasswordNote:"重置后该用户的登录会话全部失效,需用新密码重新登录",deleteUserTitle:e=>`删除用户 ${e}`,deleteUserConfirm:e=>`将删除用户 ${e} 及其名下全部 Project(含数据目录),不可恢复。`},project:{switcher:"Project",create:"新建 Project",createTitle:"新建 Project",id:"Project id",idHint:"2~64 位:小写字母开头,仅小写字母、数字与下划线;创建后不可修改",idPrefixHint:"id 固定以「用户名-」为前缀,后接小写字母、数字或下划线;创建后不可修改",displayName:"显示名",displayNameHint:"留空则使用 Project id 作为名称",settings:"Project 设置",settingsTitle:"Project 设置",members:"成员",addMember:"添加成员",removeMember:"移除",chatDefaultsTitle:"新对话默认值",chatDefaultsHint:"新建对话时预填的默认值:Agent、工作目录、审批模式、思考等级与默认模型。",chatDefaultsAgent:"Agent",chatDefaultsNotSet:"未设置",chatDefaultsApprovalNotSet:"未设置(默认全部放行)",chatDefaultsThinkingNotSet:"未设置(跟随智能体配置)",chatDefaultsModelHint:"与模型页的默认模型同步",settingsTabGeneral:"通用",settingsTabMembers:"成员",settingsTabDefaults:"默认值",settingsTabSecurity:"安全策略",projectIdLabel:"Project ID",deleteProjectDesc:"项目目录将被递归删除,不可恢复。",commandPolicyInfo:"命令文本经空白与引号归一化后逐条匹配已启用规则的正则表达式,命中即拒绝执行,不受审批模式影响。这是防事故的护栏:运行期才拼出的命令不在覆盖范围内。",commandPolicyEnable:"启用策略",commandPolicyEnableDesc:"关闭后所有规则都不再拦截。",commandPolicyRules:"规则",commandPolicyRestore:"恢复默认",commandPolicyAddRule:"添加规则",commandPolicyEditRule:"编辑",commandPolicyApplyRule:"确定",commandPolicyEmpty:"没有规则。",commandPolicyOn:"已启用",commandPolicyOff:"已停用",commandPolicyRuleName:"名称",commandPolicyRulePattern:"正则表达式",commandPolicyRuleDesc:"描述",commandPolicyInvalidPattern:"正则表达式无效",deleteProject:"删除 Project",deleteConfirm:"确认删除该 Project?项目目录将被递归删除,不可恢复。",deleteDefaultForbidden:"default_project 与 CLI 共用,不允许在 Web 端删除",deleteLastForbidden:"这是当前账号最后一个 Project,删除后将无 Project 可用;请先创建新的 Project",noCredentialTitle:"尚未配置模型 credential",noCredentialBody:"当前 Project 的默认模型尚未配置 API key,发起对话前请先前往模型页配置。",goToModels:"前往模型页",later:"稍后再说"},agent:{listTitle:"Agents",create:"创建 Agent",createTitle:"创建 Agent",id:"Agent id",idHint:"2~64 位:小写字母开头,仅小写字母、数字与下划线;创建后不可修改",nameHint:"留空则使用 Agent id 作为名称",description:"描述",createSkills:"技能",createSkillsPlaceholder:"未选择技能",createSkillsPicked:e=>`已选 ${e} 个技能`,createSkillsHint:"创建时安装到该 Agent,之后可在其「技能」标签页增删",createSkillsEmpty:"技能库暂无可安装的技能",createDirSkills:"从项目目录导入技能",createDirSkillsPick:"未选择目录",createDirSkillsHint:"选择一个项目目录,读取其 .agents/skills 与 .claude/skills 下的技能",createDirSkillsEmpty:"该目录下没有可安装的技能",createDirSkillsFound:e=>`该目录下找到 ${e} 个技能`,createDirSkillsClear:"清除已选目录",createSnapshot:"从快照初始化",createSnapshotPick:"选择快照包",createSnapshotHint:"选择导出的 Agent State 快照包(.tar.gz),新 Agent 以包内状态创建;名称与描述留空则沿用包内值",createSnapshotSkillsOff:"快照包自带技能,与技能选择互斥",createSnapshotClear:"移除已选快照包",sessionCount:e=>`${e} 个 Session`,toolCount:e=>`${e} 个工具`,vaultKeyCount:e=>`${e} 个密钥`,scheduleCount:e=>`${e} 个定时任务`,memoryCount:e=>`${e} 条记忆`,updatedAt:"最后修改",activity:e=>`近 ${e} 天 Session 活跃度`,settings:"Agent 设置",backToList:"返回 Agents",tabOverview:"概览",tabPrompt:"系统提示词",tabMemory:"记忆",tabRuntime:"运行参数",tabTools:"工具",tabSkills:"技能",tabVault:"密钥保险柜",tabSchedules:"定时任务",stateDir:"State 路径",copyStateDir:"复制 State 路径",agentsMd:"AGENTS.md",systemPrompt:"system_prompt 模板",placeholdersTitle:"可用占位符(点击插入)",insertPlaceholder:"插入到 system_prompt 光标处",placeholders:[["{{AGENTS_MD}}","注入 AGENTS.md 内容"],["{{VAULT}}","注入保险柜区块(vault.prompt,含键名清单);开关关闭时为空"],["{{SKILLS}}","注入技能区块(skills.prompt,含已安装技能元数据);开关关闭时为空"],["{{MEMORY}}","注入记忆区块:memory.prompt 加 memory.workspace_prompt(仅持久工作区);关闭记忆时为空"],["{{SCHEDULES}}","注入定时任务区块(schedules.prompt,含任务名清单);开关关闭时为空"],["{{PLATFORM}}","运行平台"],["{{OS_VERSION}}","操作系统版本"],["{{SHELL}}","命令执行使用的 Shell"],["{{DATE}}","当前日期"],["{{PROJECT_DIR}}","PenguinHarness 应用数据根目录(存放全部 Agent 数据与 Project 级数据;不是本次任务的工作目录)"],["{{AGENT_ID}}","当前 Agent id"],["{{CWD}}","Workspace 绝对路径"],["{{PROVIDER}}","模型 provider 分组"],["{{MODEL_ID}}","上游模型 id"],["{{SESSION_ID}}","当前 Session id"]],maxTurns:"max_turns(单 Task 最大轮次,-1 不限制)",maxTokens:"model.max_tokens",thinkingLevel:"model.thinking_level",thinkingLevelOptions:[["","不提交覆盖值,沿用当前生效的配置。"],["low","开启较低强度的扩展推理。"],["medium","开启中等强度的扩展推理(新建 Agent 的缺省档位)。"],["high","开启较高强度的扩展推理,响应更慢。"],["xhigh","在 high 之上再进一步的扩展推理,部分模型上效果与 high 相同。"],["max","开启最高强度的扩展推理,最慢,部分模型上效果与 xhigh 相同。"]],thinkingLevelNoneKept:"已存的历史档位:新选择不再提供关闭档(多数模型不支持关闭思考)。",timeoutMs:"model.timeoutMs",timeoutMsHint:"单次 Request 超时,毫秒",compaction:"上下文压缩(compaction)",maxContextLength:"max_context_length",maxContextLengthHint:"触发压缩的上下文阈值",maxSessionTurns:"max_session_turns",maxSessionTurnsHint:"触发压缩的轮数阈值",compactionMode:"mode(压缩方式)",compactionModeOptions:[["","不提交覆盖值,沿用当前生效的配置。"],["summarize","先让模型为旧上下文生成摘要,再从摘要续接新的上下文窗口(缺省)。"],["discard","不生成摘要,直接丢弃旧上下文,下一轮从新窗口重新开始。"]],compactionPrompt:"prompt(摘要提示词)",maxTurnsInvalid:"max_turns 必须 > 0 或为 -1",timeoutInvalid:"timeoutMs 必须 > 0 或为 -1",toolFieldInvalid:(e,t)=>`${e}: ${t} 必须是 > 0 的整数或 -1`,toolPermission:"permission",permissionReadLabel:"Read-only",permissionReadDescription:"仅读取。审批模式为 read-only 时自动放行,无需确认。",permissionReadWriteLabel:"Read & write",permissionReadWriteDescription:"可修改。审批模式为 read-only 时需人工确认。",toolTimeout:"timeoutMs",toolMaxOutput:"maxOutputLength",toolCallDescription:"call_description",callDescriptionHint:"call_description:开启(缺省)时该工具的 schema 保留可选的 description 参数——模型为每次调用写一句说明,运行期间展示给用户;关闭则装配时从 schema 滤除该参数。仅参数中定义了 description 属性的工具可切换。",mcpServers:"MCP Server",mcpDesc:"连接外部 MCP Server:其工具以 mcp__<name>__<tool> 并入本 Agent 的工具列表。此区块的改动即时保存。",mcpEmpty:"尚未配置 MCP Server",mcpAdd:"添加 MCP Server",mcpEditTitle:"编辑 MCP Server",mcpRemove:"删除",mcpName:"name",mcpNameHint:"工具名前缀:mcp__<name>__<tool>;限字母、数字、_ 和 -",mcpTransport:"transport",mcpTransportStdio:"本地进程:启动 command 后经 stdin/stdout 通信",mcpTransportHttp:"Streamable HTTP:当前规范的远程 transport",mcpTransportSse:"旧版 HTTP+SSE:仅为未迁移的服务保留",mcpTarget:"command / url",mcpCommand:"command",mcpArgs:"args",mcpArgsHint:"每行一个参数",mcpEnv:"env",mcpEnvHint:"每行一条 KEY=value;Agent vault 不注入 MCP Server 进程",mcpCwd:"cwd",mcpCwdHint:"留空则使用本次 Session 的 Workspace",mcpUrl:"url",mcpHeaders:"headers",mcpHeadersHint:"每行一条 Header-Name: value(如 Authorization 等认证头)",mcpPermission:"permission",mcpPermissionAuto:"auto",mcpPermissionAutoLabel:"Auto(readOnlyHint)",mcpPermissionAutoDescription:"每个工具按自己的 readOnlyHint 注解取值:声明了就是只读,否则为读写。",mcpPermissionReadDescription:"该 Server 的全部工具一律视为只读,无论其自身声明。审批模式为 read-only 时自动放行。",mcpPermissionReadWriteDescription:"该 Server 的全部工具一律视为读写,无论其自身声明。审批模式为 read-only 时需人工确认。",mcpPermissionHint:"只有 read-only 审批模式会读这个等级,allow-all / deny-all / always-ask 一律不看。它不限制 Server 本身能做什么——把并非只读的 Server 标为只读,只是撤掉了 read-only 模式本会索要的那次确认。",mcpConnectTimeout:"connectTimeoutMs",mcpBudgetsHint:"留空使用默认值:connectTimeoutMs 是连接与工具发现预算(默认 10000);timeoutMs / maxOutputLength 作用于该 Server 的全部工具。",mcpNameInvalid:"限字母、数字、_ 和 -,且以字母或数字开头",mcpUrlInvalid:"必须是合法的 http(s) URL",mcpLineInvalid:e=>`第 ${e} 行格式无效`,mcpNumberInvalid:"必须是 > 0 的整数",mcpDuplicateName:"同名 Server 已存在",mcpTest:"测试连接",mcpTesting:"测试中…",mcpTestOk:(e,t)=>{const n=t!==void 0?`(${(t/1e3).toFixed(1)}s)`:"";return e===0?`连接成功,但该 Server 未暴露任何工具${n}`:`连接成功,发现 ${e} 个工具${n}`},mcpTestFail:e=>`连接失败:${e}`,mcpTestAllConfirm:e=>`将逐一连接已配置的 ${e} 个 MCP Server 并做工具发现(真实连接,不保存任何改动),结果显示在各行上。`,mcpTestAllStart:"开始测试",mcpTestPending:"测试中…",mcpTestBadge:(e,t)=>`${e} 个工具${t!==void 0?` · ${(t/1e3).toFixed(1)}s`:""}`,mcpTestBadgeFail:"连接失败",mcpDeleteTitle:"删除 MCP Server",mcpDeleteConfirm:e=>`确认删除 MCP Server「${e}」?其工具自下次 Session 起不再可用。`,defaultValue:"(缺省)",deleteAgent:"删除 Agent",builtinUndeletable:"内置 Agent 不可被删除",deleteConfirm:e=>`确认删除 Agent「${e}」?其目录(含全部 Trace)将被递归删除,不可恢复。`,stateTitle:"Agent State",stateVersion:"Agent State 版本",transferDesc:"导出当前 Agent State 快照包(tar.gz);导入整目录覆盖,并以包内版本为准。",exportSnapshot:"导出快照",importSnapshot:"导入快照",importing:"导入中…",importDone:e=>`导入完成,Agent State 版本 v${e}`,importConflictTitle:"版本冲突",importConflictBody:"快照包版本不高于当前版本,导入将覆盖现有 Agent State。确认继续?",resetConfigTitle:"还原为默认配置",resetConfigAction:"还原为默认配置",resetConfigConfirmBody:"此操作会用当前默认值覆盖该 Agent 的现有配置:自定义系统提示词、工具列表、模型/压缩参数与 MCP Server 全部被替换,仅保留名称与描述。与 Skill 更新一样不可撤销,确认继续?",resetConfigDone:"配置已还原为当前默认值",kernelTitle:"内核",kernelLegacy:"早于内核版本机制",kernelOutdatedHint:"内核有更新",kernelUpdateNeeded:"内核需要更新",kernelUpToDate:"已是最新",kernelUpdateTitle:"更新内核",kernelCurrent:"当前",kernelLatest:"最新",kernelUpdateAction:"更新内核",kernelUpdateConfirmBody:"将把未自定义的设置页更新为当前内置默认值;改动过的设置页整页保持不变,并在结果中列出。名称、描述、版本号与 MCP Server 不受影响。确认继续?",kernelUpdateDone:(e,t)=>t>0?`内核已更新至 ${e},${t} 个设置页跟进新默认`:`内核已更新至 ${e},设置页均已是当前默认或保持自定义`,kernelUpdateKeptIntro:"以下设置页因自定义被整体保留:",kernelListSeparator:"、"},models:{title:"模型配置",addCustom:"添加自定义模型",addToGroup:"添加模型",editTitle:"模型配置",addTitle:"新增模型(OpenAI 协议)",addTitleVendor:"新增模型",addProtocolHint:"新增模型走 OpenAI Chat Completions 兼容协议,base URL 填其兼容端点",vendorProtocolHint:e=>`仅支持 ${e} 官方接口协议,OpenAI 兼容接口请使用自定义模型分组`,autoRouteNone:"该模型 ID 无法按当前厂商协议识别;若使用 OpenAI 兼容接口,可转为自定义模型。",useCustomGroup:"转为自定义模型",addGroup:"新增分组",addGroupTitle:"新增分组",addGroupDesc:"自建分组与 Custom 同语义。「导入模型」按端点检测或手选协议后,一键导入其全部模型;「仅新增分组」建组后逐个添加。分组由模型条目承载,保存首个模型后即出现。",groupModeCreate:"仅新增分组",groupModeImport:"导入模型",groupImportAll:"批量导入模型",groupImportNeedUrl:"请先填写有效的 base URL(http/https)",groupImportKeyHint:"留空按协议读取 OPENAI_* / ANTHROPIC_* 环境变量",groupImportListing:"正在获取模型列表…",groupImportSaving:e=>`正在导入 ${e} 个模型…`,groupImportUnsupported:"该协议不支持列出模型,请手动添加",groupImportFailed:"获取模型列表失败",groupImportEmpty:"该端点没有可导入的模型",groupImported:(e,t)=>t>0?`已导入 ${e} 个模型,跳过 ${t} 个条目`:`已导入 ${e} 个模型`,groupNameLabel:"分组名",groupNameHint:"小写字母 / 数字开头,可含 - 与 _",groupNameInvalid:"分组名只能用小写字母、数字、- 与 _(首字符为字母或数字),长度不超过 32",groupNameExists:"该分组名已被内置分组或既有条目占用",groupEmptyHint:"该分组暂无模型,点「添加模型」创建",deleteGroup:"删除分组",deleteGroupTitle:"删除分组",deleteGroupConfirm:(e,t)=>`确定删除分组「${e}」?组内 ${t} 个模型及其 API key 配置将一并移除。`,groupDeleted:e=>`已删除分组(${e} 个模型)`,searchPlaceholder:"搜索模型:id / 名称 / 厂商",noSearchResults:"没有匹配的模型",syncCatalog:"同步预置",syncCatalogHint:"用内置目录更新预置模型:新增缺失条目、以目录字段为准刷新差异;本地新增模型与 API key 保持不变",syncDone:(e,t)=>`预置模型已同步:新增 ${e}、更新 ${t}`,syncUpToDate:"预置模型已是最新",homepage:"模型主页",speedTest:"测速",speedTestTitle:"分组测速",speedTestConfirm:e=>`将对该分组的 ${e} 个模型逐个发起一次真实请求,测量首 token 延迟(TTFT)与输出速率(TPS),会消耗少量 API 额度。是否继续?`,speedTestStart:"开始测速",speedPending:"测速中…",speedFailed:"测速失败",ttftTitle:"首 token 延迟(TTFT)",tpsTitle:"输出速率(TPS)",modelCount:e=>`${e} 个模型`,modelId:"模型 ID",modelIdHint:"上游 API 使用的模型 id,如 gpt-5.5",displayName:"模型名称",displayNameHint:"留空则展示模型 ID",providerGroup:"分组",contextWindow:"上下文窗口",tokenUnit:"Token",contextWindowHint:"留空表示未知",maxTokens:"最大输出长度",maxTokensHint:"留空沿用 Agent 设置",maxTokensTitle:"按模型限制单次请求的最大输出 Token 数;留空沿用 Agent 设置,小上下文模型建议调低",maxTokensInvalid:"必须为正整数",clientTypeLocked:e=>`协议:${e}(沿用原配置,不可修改)`,protocol:"接口协议",protocolNames:{"openai-responses":"OpenAI Responses","ant-messages":"Anthropic Messages","openai-chat":"OpenAI Chat Completions"},protocolTriggerTitle:e=>`接口协议:${e}。点击可更换。`,protocolUnset:"选择协议",detectProtocol:"检测协议",detectProtocolHint:"探测 base URL,采用它实际提供的协议",detecting:"检测中…",detectedProtocol:e=>`检测到 ${e} 协议,已应用`,detectFailedBody:"无法检测接口协议,请检查 API Key 与 base URL。",detectFellBack:"未检测到协议,已按 OpenAI Chat Completions 保存",addProtocolHintDetect:"可在 base URL 输入框右端的后缀处手动选择接口协议(OpenAI Responses / Anthropic Messages / OpenAI Chat Completions),也可点“检测协议”探测端点;未选协议时保存会先自动检测",addTitleCustom:"新增模型",vision:"支持视觉",detectVision:"检测",detectingVision:"测试中…",detectVisionHint:"发送一张极小的测试图片,判断该模型是否接受图片输入(会消耗 API Key 额度)",detectVisionNeedsId:"请先填写模型 id,再进行检测。",detectVisionOk:"该模型接受图片输入,已开启视觉",detectVisionNo:"该模型不接受图片输入,视觉保持关闭",visionOffProxyHint:"使用视觉代理模型读图",fastMode:"快速模式",fastModeHint:"输出更快,按厂商的溢价档位计费;成本中心仍按条目记录的标准单价统计",fastModeUnsupported:"该模型不支持快速模式,请关闭,否则请求会失败",fastModeConfirmTitle:"开启快速模式",fastModeConfirmBody:"快速模式按厂商的溢价价目计费(MiniMax 为标准价的 1.5 倍,OpenAI 与 Anthropic 另有溢价价目表)。条目记录的按 Token 单价不会随之调整,成本中心会低估这部分用量。",fastModeConfirmPreview:"Anthropic 的快速模式目前是限量的 research preview:在你的组织获得授权之前,请求会返回 429 限流错误。",fastModeBadge:"快速",visionBadge:"视觉",freeBadge:"免费",visionModelBadge:"视觉代理",setVisionModel:"设为视觉代理模型",visionModelHint:"供不支持图片的模型经 describe_image 代读图片",priceUnitShort:"/M tok",testConnection:"测试连通性",testing:"测试中…",testOk:e=>`连通正常(${e} ms)`,testFailed:e=>`连通失败:${e}`,priceCacheRead:"缓存读取价格",priceCacheWrite:"缓存写入价格",priceOutput:"输出价格",currency:"币种",currencyUsd:"美元 $",currencyCny:"人民币 ¥",apiKey:"API key",apiKeyKeepHint:"留空保留现有 key",apiKeyEnvHint:e=>`留空则使用环境变量 ${e}`,keyConfigured:"已配置 key",clearApiKey:"清除已存 API key",baseUrl:"自定义 base URL",baseUrlHint:"留空使用厂商默认地址",baseUrlSuffixTitle:"客户端会在 base URL 后追加字段右侧的协议路径",baseUrlRequired:"必须填写 base URL",contextWindowDefaultHint:e=>`留空按 ${e} 计`,confirmDeleteTitle:"删除模型",confirmDelete:e=>`确定删除「${e}」?该模型的配置与 API key 将一并移除。`,groupApiKey:"手动设置密钥",groupApiKeyTitle:e=>`为「${e}」统一配置 API key`,groupApiKeyHint:e=>`将写入该分组下全部 ${e} 个模型;留空不改动。`,getApiKey:"前往密钥管理",getModelIds:"获取模型 id",groupKeyApplied:e=>`已为 ${e} 个模型配置 API key`,oauthKey:"自动获取密钥",oauthTitle:e=>`从「${e}」授权新建 API key`,oauthIntro:(e,t)=>`将在你的 ${e} 账户下新建一个 API key,并写入该分组下全部 ${t} 个模型,覆盖它们当前的 key。`,oauthAuthorize:"打开授权页",oauthWaiting:"等待在新标签页中完成授权…",oauthApplied:e=>`已为 ${e} 个模型配置新的 API key`,oauthManualSwitch:"授权页跳不回来?改为手动填写授权码",oauthCallbackSwitch:"改回自动跳转",oauthManualHint:"先打开授权页,再把页面上显示的一次性授权码粘贴到这里。",oauthCodeLabel:"授权码",oauthSubmitCode:"提交授权码",oauthTimedOut:"没有等到授权结果。可以改为手动填写授权码,或重新开始。",oauthRetry:"重新开始",oauthErrors:{invalid_request:"授权请求被拒绝,请重新开始。",code_rejected:"该授权已失效:可能已过期或被用过,请重新开始。",upstream_failed:"供应商没有返回可用的 key,请重新开始。",unreachable:"连不上供应商,请检查网络后重新开始。",apply_failed:"key 已创建但未能保存。请重新授权,并到供应商控制台删掉那个没用上的 key。"},providerEnvNotes:{zhipu:"缺省端点为 Z.AI 国际版(api.z.ai);智谱开放平台(bigmodel.cn)的 key 需填 base URL https://open.bigmodel.cn/api/paas/v4",moonshot:"缺省端点为国内版(api.moonshot.cn);platform.kimi.com(国际)的 key 需填 base URL https://api.moonshot.ai/v1"},confirmVisionModelTitle:"设为视觉代理模型",confirmVisionModel:e=>`确定把「${e}」设为视觉代理模型?不支持图片的模型将由它经 describe_image 代读图片。`,confirmSaveTitle:"保存模型配置",confirmSave:e=>`确定保存对「${e}」的配置修改?`,confirmDefaultTitle:"设为默认模型",confirmDefault:e=>`确定把「${e}」设为默认模型?新建的 Session 将默认使用它。`,default:"默认",setDefault:"设为默认模型",remove:"删除模型",readOnlyHint:"member 只读;模型与 credential 修改仅 owner 可执行",empty:"尚未配置任何模型",noKey:"未配置 key",readFromEnv:"读取自环境变量",showModelsWithoutKey:e=>`显示未配置 key 的模型(${e} 个)`,modelIdExists:"该模型 id 已存在",pricingAllOrNone:"三项价格需一并填写",pricingInvalid:"必须为数字",contextWindowInvalid:"必须为数字"},memory:{desc:"跨 Session 的长期记忆(存于 agent_state/memory/):agent 会在对话中自行记下值得保留的信息,你也可以直接让它记住某件事。用户记忆对本 Agent 的所有会话生效,工作区记忆按工作区隔离;记忆修改在对话中由 agent 完成。关闭开关只停止使用记忆,不删除任何文件。",enable:"启用记忆",userScope:"用户记忆",templateMissing:"提示词模板中没有 {{MEMORY}} 占位符,记忆不会进入上下文。",insertPlaceholder:"插入 {{MEMORY}} 占位符",insertPlaceholderDone:"已插入",promptSection:"记忆提示词",promptSectionHint:"注入模板 {{MEMORY}} 占位符的内容。主提示词每个会话都注入;工作区附加段仅在持久工作区的会话中追加。",promptLabel:"主提示词",workspacePromptLabel:"工作区附加段",promptPlaceholders:[["{{USER_MEMORY_INDEX}}","用户记忆索引 MEMORY.md 的内容(最多注入 200 行、总计 25000 字符)"],["{{WORKSPACE_MEMORY_INDEX}}","当前工作区记忆索引的内容(最多注入 200 行、总计 25000 字符);仅在工作区附加段生效"],["{{WORKSPACE_MEMORY_DIR}}","当前工作区记忆目录的绝对路径;仅在工作区附加段生效"]],insertToken:"插入到光标处",itemCount:e=>`${e} 条`,emptyScope:"这个工作区还没有记忆——agent 会在会话中自行记下值得保留的信息",emptyUserScope:"还没有用户记忆——在对话里说「记住……」即可让 agent 保存",add:"添加",addScopeLabel:e=>`向${e}添加`,addTitle:"添加记忆",addWhy:"记忆整理由 agent 在对话中完成:填写内容后打开新对话,由 agent 整理保存。",addContentLabel:"要记住的内容或来源",addContentPlaceholder:"粘贴要记住的内容,或文件路径 / 链接",addPromptLead:{user:"请把下面的内容整理成记忆,存入用户记忆:",workspace:"请把下面的内容整理成记忆,存入这个工作区的记忆:"},view:"查看",edit:"编辑",editTitle:"编辑记忆",editWhy:"内容修改由 agent 在对话中完成:确认引导语后打开新对话,agent 会同步更新记忆文件与 MEMORY.md 索引。",editRequirementLabel:"修改要求",editRequirementPlaceholder:"描述要怎么改,跳转后可在对话中补充",editPromptLabel:"引导语预览",editCopyPrompt:"复制 Prompt",editOpenChat:"打开新对话",delete:"删除",deleteTitle:"删除这条记忆?",deleteConfirm:e=>`将删除「${e}」并移除 MEMORY.md 中对应的索引行。此操作不可恢复。`,deleteDone:"已删除",editPromptLead:e=>`请帮我更新一条记忆:${e}`,editPromptTail:"修改要求:",exportScope:"导出",exportScopeHint:"将该组全部记忆下载为一份 JSON 文档",exportScopeLabel:e=>`导出${e}`,importScope:"导入",importScopeHint:"从导出的 JSON 文档恢复记忆到该组",importScopeLabel:e=>`导入到${e}`,importTitle:"导入记忆",importWhy:"读取从本 agent 或其他 agent 导出的一组记忆:一个 JSON 文件,含这组记忆与它的 MEMORY.md 索引。",importFile:(e,t)=>`${e} —— ${t} 条记忆`,importModeLabel:"当这一组里已有同名记忆时",importModeSkip:"保留现有的这条",importModeSkipHint:"只添加这一组还没有的记忆,不会丢失任何现有内容。",importModeOverwrite:"改用文件里的版本",importModeOverwriteHint:"文件中没有的记忆保持不变。",importModeReplace:"整组替换",importModeReplaceHint:"文件中没有的记忆将被删除。",importAction:"导入",importInvalidFile:"这个文件不是记忆导出文件。",importEmptyFile:"这个文件里没有记忆。",importConfirmTitle:"确认导入",importWillOverwrite:e=>`将覆盖 ${e.length} 条记忆:${e.join("、")}`,importWillRemove:e=>`将删除 ${e.length} 条记忆:${e.join("、")}`,importWillReplaceIndex:"这一组的 MEMORY.md 索引将被替换。",importIrreversible:"此操作不可恢复。",importDone:(e,t,n)=>`已导入:新增 ${e} 条,覆盖 ${t} 条,删除 ${n} 条`,importNothingNew:"没有可导入的内容——文件里的记忆这一组都已经有了"},vault:{desc:"本 Agent 专属的环境变量(存于 agent_state/.vault.toml):键值对注入其 shell 命令(exec_command)的子进程环境;键名会告知模型,值不进入模型上下文。子 Agent 使用各自的保险柜,不继承。保存后自下一个任务起生效(进行中的任务不受影响)。",key:"键名",value:"值",valueMasked:"值(掩码)",add:"添加",addTitle:"添加环境变量",remove:"删除",deleteTitle:"删除环境变量",deleteConfirm:e=>`确认删除环境变量「${e}」?值不可恢复。`,overwriteTitle:"覆盖已有环境变量",overwriteConfirm:e=>`「${e}」已存在,保存将覆盖原值且不可恢复。`,empty:"尚未配置任何环境变量",readOnlyHint:"member 只读;Vault 修改仅 owner 可执行",keyHint:"字母、数字与下划线,不能以数字开头",keyInvalid:"键名不合法:仅字母、数字与下划线,且不能以数字开头",valueRequired:"值不能为空",injection:{enable:"启用密钥保险柜",templateMissing:"提示词模板中没有 {{VAULT}} 占位符,保险柜小节不会进入上下文。",legacyTemplate:"模板仍是旧版硬编码的 # Vault 段落:一键迁移会将该段落原位替换为 {{VAULT}} 占位符,措辞不变,此后可在下方编辑。",insertPlaceholder:"插入 {{VAULT}} 占位符",migrate:"迁移为 {{VAULT}} 占位符",promptSection:"保险柜提示词",promptSectionHint:"注入模板 {{VAULT}} 占位符的内容;开关关闭或模板无占位符时不注入。",promptLabel:"提示词",promptPlaceholders:[["{{VAULT_KEYS}}","保险柜键名列表(每键一行「- KEY」,仅键名,值永不注入;无键时为空)"]]}},schedule:{desc:"定时任务(agent_state/schedule/*.toml):到点自动向目标 Session 发送 prompt;文件亦可手工编辑,Web 端修改后即时生效。",readOnlyHint:"member 只读;定时任务修改仅 owner 可执行",colStatus:"状态",colPeriod:"周期",colTarget:"目标",colFireTimes:"下次 / 最近触发",colQueued:"排队",statusNames:{active:"生效",disabled:"停用",expired:"已过期",done:"已完成",missed:"已错过",invalid:"无效"},queued:"排队中",once:"一次性",newSession:"新建会话",invalidFiles:"解析失败的文件(已跳过调度)",empty:"尚未配置定时任务",enable:"启用",disable:"停用",addTitle:"新建定时任务",editTitle:e=>`编辑定时任务「${e}」`,nameHint:"即文件名(不含 .toml),创建后不可改",prompt:"Prompt",enabled:"启用",startAt:"开始时间",endAt:"结束时间",period:"周期",periodPlaceholder:"30m / 12h / 7d,留空为一次性",target:"目标",targetNew:"每次新建会话",targetSession:"绑定 Session",sessionId:"Session",chooseSession:"选择要绑定的 Session",sessionSearch:"搜索标题或 Session id…",sessionNoMatch:"无匹配的 Session",sessionEmpty:"该 Agent 暂无 Session",workspace:"Workspace",model:"Model",modelDefault:"Project 默认",deleteTitle:"删除定时任务",deleteConfirm:e=>`确认删除定时任务「${e}」?`,injection:{enable:"启用定时任务",templateMissing:"提示词模板中没有 {{SCHEDULES}} 占位符,定时任务小节不会进入上下文。",insertPlaceholder:"插入 {{SCHEDULES}} 占位符",promptSection:"定时任务提示词",promptSectionHint:"注入模板 {{SCHEDULES}} 占位符的内容,教模型用文件工具管理定时任务;开关关闭或模板无占位符时不注入。",promptLabel:"提示词",promptPlaceholders:[["{{SCHEDULE_LIST}}","现有任务名列表(每任务一行「- 名称」;无任务时注入空清单说明)"]]}},skills:{pageTitle:"技能库",pageDesc:"内置 Skill 库:浏览、快捷调用,或安装到 Agent。",quickInvoke:"快捷调用",quickInvokeText:e=>`使用 ${e} 技能`,quickInvokeNeedsInstall:"先在当前 Agent 安装该技能后才能快捷调用",selectAll:"全选",selectNone:"全不选",selectedCount:e=>`已选 ${e} 个`,manageInstall:"管理安装",manageInstallTitle:e=>`管理安装:${e}`,install:"安装",installed:"已安装",uninstall:"卸载",skillCount:e=>`${e} 个技能`,usedByAgents:e=>e===0?"未被使用":`${e} 个 Agent 在用`,installedToast:(e,t)=>`已将 ${e} 安装到 ${t}`,updateOutdated:e=>`有新版本:更新 ${e} 个 Agent 的安装`,updateAction:"更新",updateConfirmTitle:e=>`更新 ${e}`,updateConfirmWarning:e=>`更新 ${e} 会把库内当前副本重装到各 Agent,覆盖其已安装的文件——对已装技能的本地改动会丢失,如有需要请先导出备份。`,updatedToast:(e,t)=>`已将 ${e} 更新到最新版(${t} 个 Agent)`,uninstalledToast:(e,t)=>`已从 ${t} 卸载 ${e}`,uninstallConfirmTitle:e=>`卸载 ${e}`,uninstallConfirmBody:(e,t)=>`确定从 ${t} 卸载 ${e} 吗?已安装的技能文件(含本地改动)将被删除。`,agentTabDesc:"该 Agent 已安装的技能(agent_state/skills/,文件即事实来源):元数据注入系统提示词,正文由模型按需读取;卸载会删除整个技能目录。",agentTabEmpty:"尚未安装任何技能",exportSkill:"打包导出",importSkill:"导入技能",importChatTitle:"推荐:让 Agent 在对话中安装",importChatWhy:"Agent 能完整阅读、审查并按需调整技能内容,比直接上传更可靠。",importSourceLabel:"技能来源",importSourceHint:"支持网页 / GitHub 仓库或目录 / 本地路径 / 其他生态的安装命令",importSourcePlaceholder:"https://…、git 仓库、/path/to/skill 或 npx skills add <name>",importSourceToken:"<来源>",importPromptLabel:"发送给 Agent 的 Prompt(预览)",importPromptLead:{webUrl:e=>`请阅读这个网页,并把其中的 Skill 安装到你的技能目录:${e}。`,repoUrl:e=>`请获取这个仓库或目录(git clone 或直接抓取),定位其中含 SKILL.md 的技能目录,并安装到你的技能目录:${e}。`,localPath:e=>`请直接读取这个本地路径下的技能文件,并安装到你的技能目录:${e}。`,command:e=>`这是一条其他生态的技能/插件安装命令,请不要直接执行:先解读它会安装什么,从对应的仓库或注册表获取相同内容,再安装到你的技能目录:${e}。`,reference:e=>`请根据这个技能/插件引用找到其来源(仓库、插件市场或文档页),并把对应的 Skill 安装到你的技能目录:${e}。`},importPromptTail:"安装前请完整阅读全部内容,确认安全、无恶意指令后再写入,并向我说明它的用途。如果你安装了 skill-porting 技能,请先阅读并按其流程处理。",importCopyPrompt:"复制 Prompt",importOpenChat:"打开新对话",importUploadTitle:"上传技能 zip 包",importUploadDesc:"zip 根目录为 SKILL.md,或仅含一个内含 SKILL.md 的顶层目录。",importUploadAction:"选择 zip 文件",importUploading:"上传中…",importDoneToast:"技能已安装",importOverwriteTitle:"覆盖已安装技能",importOverwriteBody:e=>`技能「${e}」已存在,覆盖安装将替换其全部文件(含本地改动),不可恢复。确认继续?`,importOverwriteAction:"覆盖安装",injection:{enable:"启用技能",templateMissing:"提示词模板中没有 {{SKILLS}} 占位符,技能小节不会进入上下文。",legacyTemplate:"模板仍是旧版硬编码的 # Skills 段落:一键迁移会将该段落原位替换为 {{SKILLS}} 占位符,措辞不变,此后可在下方编辑。",insertPlaceholder:"插入 {{SKILLS}} 占位符",migrate:"迁移为 {{SKILLS}} 占位符",promptSection:"技能提示词",promptSectionHint:"注入模板 {{SKILLS}} 占位符的内容;开关关闭或模板无占位符时不注入。",promptLabel:"提示词",promptPlaceholders:[["{{SKILL_METADATA}}","已安装技能的元数据行(每技能一行「- 名称 — 描述」;无技能时为空)"]]}},chat:{newSessionMenu:"新建对话",chooseAgent:"选择 Agent",chooseModel:"选择模型",thinkingLevel:"思考等级",thinkingLevelNames:{none:"无",low:"低",medium:"中",high:"高",xhigh:"极高",max:"最高"},thinkingLevelMenuName:(e,t)=>`${e} (${t})`,thinkingSwitchTitle:"切换思考等级",thinkingSwitchBody:e=>`将思考等级切换为「${e}」?会话中途切换会降低提示词缓存命中率、增加成本,先压缩上下文再切换更省。`,thinkingSwitchBusyHint:"会话正在运行,压缩要等空闲后才能开始。",thinkingSwitchCompactFirst:"压缩后切换",thinkingSwitchConfirm:"仍要切换",thinkingSwitchCompacting:"正在压缩上下文,压缩结束后切换思考等级。",thinkingSwitchApplied:e=>`上下文已压缩,思考等级已切换为「${e}」。`,thinkingSwitchCompactFailed:"压缩未成功完成,思考等级已照常切换。",workspaceUseThis:"使用此目录",workspaceUp:"上级目录",workspaceNoSubdirs:"无子目录",workspaceAuto:"临时工作区",workspaceClear:"改用临时工作区",workspaceDirInvalid:"目录不存在或无法访问,已回退",groupByWorkspace:"按工作区分组",groupByAgent:"按 Agent 分组",groupByTime:"按时间分组",timeGroups:{day:"近一天",month:"近一月",earlier:"更早"},searchSessions:"搜索会话",searchSessionsPlaceholder:"搜索会话…",searchClear:"清除搜索",searchNoMatches:"已加载的会话中无匹配",listSettings:"列表选项",groupModeSection:"分组方式",sortModeSection:"排序方式",sortManual:"手动排序",sortRecent:"最近更新",newWorkspaceEntity:"新建工作区",workspaceMenu:"工作区选项",renameWorkspace:"重命名工作区",renameWorkspaceLabel:"名称",renameWorkspaceHint:"留空则使用目录名",deleteWorkspace:"删除工作区",deleteWorkspaceConfirm:e=>`确定移除「${e}」?仅从侧边栏移除该工作区分组,不影响磁盘目录与已有会话,可随时重新添加。`,tempWorkspaces:"临时工作区",newSessionInWorkspace:"在此工作区新建对话",draftSubtitle:"最擅长 AI 开发任务的自进化 Agent",exampleFolders:{webapps:"搭建网页应用",agents:"搭建和优化智能体",schedules:"创建定时任务"},exampleFillHint:"点击填入输入框,可修改后自行发送",shortcuts:{folder:"我的快捷指令",new:"新建快捷指令",newFromComposer:"以输入框中的内容作为起点",createTitle:"新建快捷指令",editTitle:"编辑快捷指令",titleLabel:"名称",titleHint:e=>`最多 ${e} 个字符`,promptLabel:"提示词",promptHint:e=>`最多 ${e} 个字符`,promptInfo:"点击这条快捷指令时,这段文字会原样填入输入框,不会自动发送;需要的 Skill 仍在输入框里自行勾选。",titleTooLong:e=>`名称最多 ${e} 个字符`,promptTooLong:e=>`提示词最多 ${e} 个字符`,deleteTitle:"删除快捷指令",deleteConfirm:e=>`确定删除「${e}」?该快捷指令会从你的所有设备上消失。`},exampleTasks:{game:{label:"2D 企鹅雪橇越野小游戏",desc:"可爱南极企鹅滑雪橇跳石头,难度由易到难的 2D 纯前端小游戏",prompt:"做一个可爱的南极企鹅滑雪橇越野 2D 小游戏:按空格键起跳,跃过冰面上迎面而来的石头;开局要足够简单、上手无压力,滑行速度与障碍密度随时间平滑、循序渐进地上升,避免突然变难,实时计分,撞上石头即结束并可一键重新开始。2D 横版画面、可爱卡通风,纯前端实现(单个 HTML 文件即可),界面遵循 web-design 技能。完成后在浏览器里自测一次,确认开局能轻松玩过几秒,并告诉我怎么打开和怎么玩。"},gamecenter:{label:"多智能体搭建小游戏中心",desc:"并行产出 10 个玩法互不重复的纯前端小游戏,配一个统一风格的索引首页",prompt:`用多智能体并行搭建一个网页小游戏中心:10 个玩法互不重复的纯前端小游戏,外加一个索引首页。
11
-
12
- ## 分工方式
13
- - 先规划这 10 个游戏(例如贪吃蛇、2048、俄罗斯方块、打砖块、扫雷、记忆翻牌、推箱子、太空射击、跳跃平台、节奏点击),确认玩法确实互不重复,并定好统一的目录结构、配色与交互规范。
14
- - 再把 10 个游戏分派给多个子智能体并行实现,每个子智能体只负责自己的那一个游戏,严格按既定规范产出,互不改动他人的文件。
15
-
16
- ## 每个游戏
17
- - 独立的 \`games/<slug>/index.html\`,纯前端单文件、file:// 直接打开即可运行,不依赖后端与任何 CDN 资源。
18
- - 具备开始 / 重新开始、实时计分或计时、失败或通关结算,并同时支持键盘与触摸操作,页面内写明玩法说明。
19
- - 提供返回索引首页的入口。
20
-
21
- ## 索引首页
22
- - 根目录 \`index.html\`:卡片网格列出全部 10 个游戏(名称 + 一句话玩法 + 操作方式),点击进入对应游戏。
23
- - 与所有游戏共用一套设计语言,遵循 web-design 技能。
24
-
25
- ## 收尾
26
- - 统一验收:10 个游戏玩法确实不重复、风格一致,索引页的链接全部可达。
27
- - 在浏览器里逐个自测,确认都能开始、能结束、能重开,然后告诉我怎么打开。`},lol:{label:"英雄联盟音乐播放器",desc:"用 SoundCloud Widget API 播放历届 Worlds 主题曲,单文件即开即用",prompt:`用 SoundCloud Widget API(见 https://developers.soundcloud.com/docs/api/html5-widget)做一个英雄联盟 Worlds 主题曲播放器,单文件 index.html,file:// 打开即用。
28
-
29
- ## 技术约束
30
- - 使用 SC.Widget JS API(widget.load / widget.toggle / widget.setVolume / widget.seekTo),引入 https://w.soundcloud.com/player/api.js
31
- - iframe 必须可见(180px 高),visual=true color=f0b90b single_active=true
32
- - 仅包含以下 8 首已确认可播曲目(oEmbed 验证通过),不要添加未经 oEmbed 验证的曲目:
33
- - Warriors (S4) — soundcloud.com/leagueoflegends/warriors
34
- - Worlds Collide (S5) — soundcloud.com/leagueoflegends/worlds-collide
35
- - Legends Never Die (S7) — soundcloud.com/leagueoflegends/legends-never-die
36
- - Phoenix (S9) — soundcloud.com/leagueoflegends/phoenix
37
- - Burn It All Down (S11) — soundcloud.com/leagueoflegends/burn-it-all-down
38
- - GODS (S13) — soundcloud.com/leagueoflegends/gods
39
- - Heavy Is The Crown (S14) — soundcloud.com/linkinpark/heavy-is-the-crown
40
- - Sacrifice (S15) — soundcloud.com/leagueoflegends/sacrifice
41
-
42
- ## 布局
43
- - 左侧 260px 粘性侧边栏:曲目列表(S4/S5/… 标签 + emoji + 曲名 + 年份),点击高亮金色边框,SC.Widget.load() 切歌 + auto_play
44
- - 右侧主区域:Hero 标题 + 桌面时钟(80px 等宽金色 HH:MM:SS,每秒刷新,冒号闪烁)+ 心情标签
45
- - 播放器卡片:SoundCloud iframe + 自定义控制栏(⏮ ▶/⏸ ⏭ + 曲目信息 + 音量滑块,点击喇叭图标静音切换)
46
- - 心情波动区:15 根金色动画柱,切歌时重新随机生成
47
- - 键盘快捷键:空格播放暂停、← → 切歌、↑ ↓ 调音量
48
-
49
- ## 设计
50
- Penguin 视觉风格(见 web-design 技能),默认深色。手机端侧边栏变为顶部横向滚动。
51
-
52
- 完成后在浏览器打开 index.html 自测一次。`},rhythmRunner:{label:"音乐节奏跑酷小游戏",desc:"喵斯快跑式的音乐节奏跑酷:企鹅主角,音符踩着节拍飞来,判定分 Perfect / Great / Miss",prompt:"做一个喵斯快跑(Muse Dash)式的音乐节奏跑酷小游戏:主角是一只企鹅,自动向前跑;音符画成音符图标,严格踩着节拍飞来,玩家按键击打,判定显示 Perfect / Great / Miss 三档,连击计分,难度随曲子推进。纯前端单文件,file:// 直接打开即玩。"},investmentCopilot:{label:"对话式投资分析助理",desc:"用 Penguin SDK 做对话式看盘 Copilot:首页列出近期走势较好的股票,每个判断都说清市场因素",prompt:"用 Penguin SDK 做一个对话式的股市 Copilot,形态参考 perplexity.ai/finance:启动后每 5 分钟实时抓取大盘行情,首页直接列出近期走势较好的股票和板块强弱,每个判断都要说清背后的市场因素——政策、行业消息、资金流向、财报或宏观数据,而不是技术指标,只做分析不是投资建议。它的查股工具要能答「帮我查一下智谱的股票」这类问题:按公司名(中文也行)自己对应到股票代码,查不到或没上市就直说,不要编。"},rag:{label:"构建 Claude Code 文档 RAG 智能体",desc:"收集 claude-code-docs 仓库,生成可对话、带来源引用的 RAG 知识应用",prompt:"收集 https://github.com/ericbuess/claude-code-docs 的文档,构建一个 RAG 知识应用:克隆仓库并整理语料,建立检索索引;应用化身 Claude Code 配置专家,检索增强回答 Claude Code 相关问题并标注可点击的来源引用——引用要能展示命中的原文片段,并链接到真实文档;按 web-design 技能提供美观的 Web 聊天界面。完成后运行应用,用一个中文问题和一个英文问题各自测一次,确认两者都检索到了正确的英文文档、流式回答正常,并告诉我访问方式。"},agentBenchmarkBuild:{label:"构建通用决策智能体和评测基准",desc:"创建一个通用决策 Agent,并用足球、售后和投资任务检验它",prompt:`请依次使用 \`agent-initialization\` 和 \`benchmark-design\`,创建决策 Agent,并产出 Frozen Benchmark 与 Formal Baseline。
53
-
54
- Agent:
55
- - id:\`finite_choice_agent\`
56
- - 能力:面对有限选项,在公开信息不足或冲突时仍能给出稳定、可解释的选择
57
- - installed_skills:\`[]\`
58
-
59
- Benchmark:
60
- - id:\`contextual-choice-adaptation\`
61
- - capability:从公开规则、历史案例和当前事实中形成并迁移稳定的有限选择决策过程
62
- - desired_baseline_score:\`<75\`
63
- - pilot_iteration_limit:\`5\`
64
-
65
- 场景:
66
- 1. 根据历史比赛与当前信息进行足球投注决策。
67
- 2. 根据售后政策与工单事实选择处置动作。
68
- 3. 根据投资策略、历史市场与当前指标选择投资动作。`},agentOptimization:{label:"优化通用决策智能体的准确率",desc:"根据已有评测结果改进 Agent,并验证新版本是否真正提升",prompt:"请使用 `agent-optimization`,根据 Frozen Benchmark 优化决策 Agent。\n\n- test_agent_id:`finite_choice_agent`\n- benchmark_id:`contextual-choice-adaptation`\n- capability_direction:提高信息不完整、规则冲突和有限选项决策中的稳定性\n- runs:`3`\n- desired_score:`>=95`\n- candidate_round_limit:`5`"},dailyPlan:{label:"每天早 9 点的计划对话",desc:"每天 09:00 在同一个会话里聊当天计划,并回顾昨天的进展",prompt:"建一个定时任务:每天早上 9 点在这个会话里和我聊今天的计划。先回看上文说清昨天定的事做完了多少、哪些卡住,再给我一份排好序的今日候选、每条一句理由,我确认后写成清单。"},githubDigest:{label:"每天汇总 GitHub 项目状态",desc:"定时跑一遍仓库的 Issue、PR 与 CI,日报结尾给出按优先级排序的建议",prompt:"建一个定时任务:每天早上用 gh 汇总一个 GitHub 仓库的 Issue、PR 与 CI 状态,挑出停滞的、待评审的和挂掉的,结尾给出按优先级排序的建议,每条说清为什么排在这个位置。"},memoryReview:{label:"每周五晚回顾并记录 Memory",desc:"周五傍晚一起过一遍这周值得长期记住的事,确认后由你写进 Memory",prompt:"建一个定时任务:每周五傍晚在这个会话里和我过一遍这周值得长期记住的事。先看已有记忆索引避免重复,再逐条问我该记什么、要不要改已有的,我确认后你写进 Memory。"}},sessionList:"Session",defaultSessionTitle:"新对话",agent:"Agent",model:"Model",workspace:"Workspace",workspaceHint:"留空自动创建临时工作区;指定时必须是服务器上已存在的目录",workspaceHintShort:"留空自动创建临时工作区",approvalMode:"审批模式",approvalModeNames:{"allow-all":"全部放行","deny-all":"全部拒绝","read-only":"放行只读","always-ask":"总是询问"},approvalModes:{"allow-all":"全部放行(allow-all)","deny-all":"全部拒绝(deny-all)","read-only":"放行只读(read-only)","always-ask":"总是询问(always-ask)"},statusRunning:"运行中",statusCompacting:"压缩中",statusCompletedUnread:"运行完毕,未读",pendingApprovals:e=>`${e} 个待审批`,jumpToLatest:"回到最新消息",loadingEarlier:"正在加载更早的对话…",loadEarlierRetry:"更早的对话加载失败,点击重试",historyBeginning:"已是对话开头",outlineTitle:"对话索引",outlineTickLabel:(e,t)=>`第 ${e} 轮:${t}`,outlineNoText:"(图片或附件)",outlineAnswering:"回答生成中…",inputPlaceholder:"输入消息,Enter 发送,Shift+Enter 换行,可粘贴图片",inputPlaceholderShort:"输入消息…",steerPlaceholder:"给运行中的 Agent 留言,随下一轮对话送达",steerPlaceholderShort:"给运行中的 Agent 留言…",steerSend:"发送给运行中的 Agent",steerQueuedIndicator:"插话已排队,将随下一轮送达",steerQueuedItem:e=>`插话已排队,将随下一轮送达:${e}`,userSteering:"用户插话",steerModeLabel:"运行中发送方式",steerModeSteer:"插话",steerModeSteerHint:"立即插话:随下一轮对话送达运行中的 Agent",steerModeFollowUp:"排队",steerModeFollowUpHint:"排队跟进:本轮结束后自动作为新消息发送",followUpPlaceholder:"排队为下一条消息,本轮结束后自动发送",followUpPlaceholderShort:"排队为下一条消息…",followUpSend:"排队为下一条消息",followUpQueuedChip:e=>`${e} 条跟进消息已排队,本轮结束后自动发送`,followUpQueuedItem:e=>`跟进消息已排队,本轮结束后自动发送:${e}`,recallQueued:"撤回",recallQueuedTitle:"撤回到输入框,编辑后重新发送",send:"发送",stop:"停止",compact:"压缩上下文",approve:"允许",deny:"拒绝",decisionAllow:"已批准",decisionDeny:"已拒绝",decisionManual:"手动",decisionAuto:"自动",decisionPolicy:"策略",thinking:"思考",subagent:"子会话",subagentRunning:"运行中",aborted:e=>{const t=e?.errorCode==="user_abort"?"用户中断":e?.errorCode==="backoff_interrupted"?"重试等待中被中断":e?.errorCode==="compaction_interrupted"?"压缩过程中被中断":e?.errorCode??e?.reason??"",n=t?`${t}${e?.errorMessage?`:${e.errorMessage}`:""}`:"";return`[已中断]${n?`:${n}`:""}`},reconnect:(e,t,n,s,o,c)=>{const u=c??e,f=u==="timeout"?"连接超时或网络中断":u==="malformed"?"响应不完整或无法解析":u==="network"?"网络或服务暂时不可用":u==="failed"?"模型服务返回错误":"请求失败",p=t==="gaveUp"?`第 ${n} 次尝试后放弃${o?`:${o}`:""}`:t==="retried"?`已发起第 ${n} 次重试`:s!==void 0?`第 ${n} 次重试,${s} 秒后发起…`:`正在发起第 ${n} 次重试…`;return`[重试] ${f},${p}`},llmError:e=>`[错误]:模型请求错误${e?`:${e}`:""}`,reconnectRetryNow:"立即重试",reconnectGiveUp:"放弃",imageAlt:"用户上传的图片",toolImageAlt:"工具输出的图片",imagesAsPathHint:"当前模型不支持直接查看图片:发送时图片将保存到会话临时目录,以文件路径转交(模型经 describe_image 查看)",infoPanel:"Session 信息",sessionStats:"统计",sessionIdLabel:"Session id",copySessionId:"复制 Session id",processList:"会话进程",processStop:"停止",processExited:"已退出",processRemove:"移除",processRemoveHint:"移除该条目——该进程已捕获的输出也会一并丢弃",runningServices:e=>`${e} 个运行中的服务`,statTokens:"Token 累计",statTotalTokens:"总 Token",statCacheHit:e=>`缓存命中率 ${e}`,statElapsed:"用时",statInput:"输入 tokens",statCached:"已缓存",statOutput:"输出 tokens",statTps:"输出 TPS",statParenOpen:"(",statParenClose:")",noSessions:"还没有 Session",emptyStream:"发送一条消息开始对话",historyLoadFailed:"历史消息加载失败",statsLabel:"统计信息",removeImage:"移除图片",openAgents:"智能体面板",workspacePanel:"工作区",filesInMessage:e=>`${e} 个文件`,imagesInMessage:e=>`${e} 张图片`,openPreview:"点击预览",showMoreFiles:e=>`显示其余 ${e} 个文件`,showLess:"收起",memoryChangesTitle:e=>`${e} 条记忆更新`,memoryScopeWorkspace:e=>`工作区记忆(${e})`,memoryOpWrite:"写入",memoryOpEdit:"编辑",memoryViewTitle:"记忆",memoryChangedMark:"本次对话已更改",memoryContentUnavailable:"无法加载内容(文件可能已被移动或删除)",memoryRowOpen:"查看内容",memoryBack:"返回列表",memoryEmptyAll:"还没有任何记忆——在对话里说「记住……」即可让 agent 保存",openAgentMemory:"在 Agent 设置中管理",memoryShowMore:e=>`显示其余 ${e} 条`,prevGroupPage:"上一页分组",nextGroupPage:"下一页分组",groupPagePosition:(e,t)=>`第 ${e} 页,共 ${t} 页`,contextUsage:"上下文占用",contextUnknown:"上下文占用:压缩后待下次请求回报",contextComposition:"上下文构成",contextPartSystemPrompt:"系统提示词",contextPartToolDefs:"工具定义",contextPartUserMessages:"用户消息",contextPartAssistantMessages:"模型消息",contextPartToolRequests:"工具请求",contextPartToolResults:"工具结果",contextTopTools:"工具用量 Top 5",contextCompactAt:e=>`压缩阈值 ${e}`,contextTopToolsHint:"按每个工具的调用与结果所占上下文排序(工具定义计入「工具定义」一项)",contextUnknownHint:"刚压缩过,占用待下次请求回报,届时才能给出构成",contextBreakdownEmpty:"当前上下文还没有可统计的内容",contextBreakdownFailed:"读取上下文构成失败",slashHint:"输入 / 使用命令",switchAgent:"交给其他 Agent,发送时开启新会话",switchAgentTitle:"选择 Agent",agentSearchPlaceholder:"搜索 Agent:id / 名称",agentsNoMatch:"没有匹配的 Agent",handoffTargetTitle:e=>`发送后交接给 ${e}`,handoffRemove:"移除交接目标",skillsSelect:"技能",skillRemove:"移除技能",skillsSearchPlaceholder:"搜索技能",skillsNoMatch:"没有匹配的技能",skillsEmptyHint:"暂无已装技能,去技能库添加",skillsAutoMessage:e=>`使用 ${e.join("、")} 技能`,handoffFrom:e=>`由 ${e} 的对话交接而来`,handoffBack:e=>e?`回到原对话:${e}`:"回到原对话",switchModel:"切换模型,发送时开启新会话延续本对话",switchModelTitle:"切换模型",modelSwitchTargetTitle:e=>`发送后换用 ${e} 延续本对话`,modelSwitchRemove:"移除切换模型",modelSwitchBusyHint:"本轮结束后才能切换模型:新会话要从当前会话的记录接续",modelSwitchFrom:e=>e?`已切换模型(原为 ${e}),延续原会话`:"已切换模型,延续原会话",modelSwitchAutoMessage:"换用新模型继续这段对话",modelLockedHint:"输入 /model 切换模型",scheduledFrom:e=>`由定时任务「${e}」触发`,backgroundDone:(e,t)=>{const n=e==="command"?"后台命令":"后台任务";return t==="stopped"?`${n}已停止`:t==="completed"?`${n}完成`:`${n}失败`},emptyGreeting:"开始一段新对话",mcpConnectTitle:"MCP 连接",mcpServerList:e=>e.join("、"),mcpConnectResult:(e,t)=>{const n=[];return(e>0||t.length===0)&&n.push(`发现 ${e} 个工具`),t.length>0&&n.push(`不可用:${t.join("、")}`),n.join(";")},mcpToolsCount:e=>`${e} 个工具`,mcpServerFailed:"连接失败",mcpConnectAborted:"已中断,下次发送时重新连接",compactionTitle:e=>e==="discard"?"清空":"压缩",compactionFailed:(e,t)=>{if(e==="aborted")return"已中断,保留当前上下文";const n=t!==void 0?`(${t})`:"";return e==="retryable"?`失败${n},保留当前上下文,下次触发时重试`:e==="fatal"?`失败${n},保留当前上下文,需修复模型配置后重试`:`失败${n},保留当前上下文`},unknownTool:"(未知工具)",workRunning:"运行中",workDone:"运行完毕",workGroupSteps:e=>`${e} 步`,approvalWaiting:"待审批",copyCode:"复制代码",copyReply:"复制回复",forkSession:"从这里分叉对话",forkSessionConfirmBody:"将把这段对话(截至这条回复)复制为一个新对话,原对话保持不变。",forkSessionConfirmAction:"分叉",forkSessionFailed:"无法定位这条回复,请刷新后重试。",copyMessage:"复制消息",deleteSession:"删除对话",renameSession:"重命名对话",renameSessionLabel:"标题",deleteSessionConfirm:e=>`确定删除「${e}」?该对话的消息与 Trace 将被移除,且不可恢复。`,draftGroup:"草稿",draftUntitled:"(无标题草稿)",deleteDraft:"删除草稿",deleteDraftConfirm:e=>`确定删除草稿「${e}」?未发送的内容将被丢弃。`,archiveSession:"归档",unarchiveSession:"取消归档",pinSession:"置顶",unpinSession:"取消置顶",pinnedSession:"已置顶",moreActions:"更多",loadMore:"更多",expandRestSessions:e=>`展开其余 ${e} 个对话`,loadMoreSessions:"加载更多会话",folderGroups:{subagent:e=>`子智能体(${e})`,schedule:e=>`定时任务(${e})`,archived:e=>`已归档(${e})`},skillsBanner:e=>`使用技能:${e.join("、")}`,attachedFilesBanner:e=>`附加文件:${e.join("、")}`,plusMenu:"更多输入方式",uploadImage:"上传图片",uploadImageDesc:"为本条消息附加图片",uploadFile:"上传文件",uploadFileDesc:"文件存入会话临时目录,模型按路径读取",removeFile:"移除文件",attachmentTooLarge:(e,t)=>`${e} 超过 ${t}MB 上限,未添加。`,dropFilesTitle:"松开以添加附件",dropFilesDesc:"图片与文件将添加到输入框",dropFilesGoalHint:"目标模式仅支持附加图片,文件未添加。",goalMode:"目标模式",goalModeDesc:"循环运行直至目标完成",goalBudgetLabel:"Token 预算",goalBudgetUnlimited:"预算不限",goalBudgetValue:e=>`预算 ${e}`,goalBudgetPlaceholder:"例如 500k",goalBudgetHint:"支持 k/m 后缀;留空表示预算不限",goalBudgetInvalid:"无效预算:应为正数,可带 k/m 后缀(500k、2m)",goalBudgetSave:"保存预算",goalRemove:"退出目标模式",goalRoundBanner:e=>`目标 · 第 ${e} 轮`,goalRoundImages:e=>`${e} 张附图`,goalProgress:(e,t)=>`第 ${e} 轮 · tokens ${t}`,goalStatus:{active:"进行中",complete:"已完成",blocked:"受阻",budget_limited:"预算耗尽",aborted:"已中断"}},feishu:{intro:"绑定后,发给飞书机器人的消息会进入本对话,AI 的回复会以纯文本发回飞书。需要一个开通了机器人能力、订阅了接收消息事件(长连接方式)的飞书自建应用。",appId:"App ID",appSecret:"App Secret",appSecretKeepHint:"留空保持已保存的 App Secret 不变",clearSecret:"清除已存 App Secret",baseDomain:"API 域名",baseDomainHint:"飞书为 https://open.feishu.cn,Lark 为 https://open.larksuite.com",invalidDomain:"域名需为 http(s):// 地址",testMessageNoChat:"先在飞书中给机器人发一条消息,机器人才知道要发到哪个会话",setupSteps:["在飞书开发者后台创建一个企业自建应用","为应用开通机器人能力","订阅「接收消息」事件,事件订阅方式选择「长连接」","在「凭证与基础信息」页取得 App ID 与 App Secret,填入上方表单","发布应用版本并通过审核,然后在飞书中给机器人发一条消息"]},telegram:{intro:"绑定后,发给 Telegram 机器人的消息会进入本对话,AI 的回复会以纯文本发回 Telegram。用 @BotFather 创建机器人并粘贴其 Bot Token 即可,无需公网地址。",botToken:"Bot Token",botTokenKeepHint:"留空保持已保存的 Bot Token 不变",clearToken:"清除已存 Bot Token",invalidToken:"Bot Token 形如「数字:密钥」,由 @BotFather 签发",testMessageNoChat:"先在 Telegram 中给机器人发一条消息,机器人才知道要发到哪个会话",setupSteps:["在 Telegram 中打开 @BotFather,发送 /newbot 创建机器人","按提示取名后,复制 @BotFather 返回的 Bot Token,填入上方表单","在 Telegram 中找到这个机器人,给它发一条消息"]},messaging:{panelTitle:"消息软件",bindAction:"消息软件绑定…",dialogTitle:"消息软件绑定",channelLabel:"渠道",channelName:{feishu:"飞书",telegram:"Telegram"},tutorial:"前往教程",console:"前往开发者后台",enabled:"启用连接",saveBeforeEnable:"先保存凭证,再启用连接",test:"测试连接",testing:"测试中…",testOk:e=>`连接成功(${e}ms)`,testOkAs:(e,t)=>`连接成功,机器人为 ${e}(${t}ms)`,testFail:e=>`连接失败:${e}`,sendTestMessage:"发送测试消息",sendingTestMessage:"发送中…",testMessageSent:"测试消息已发送",statusLabel:"连接状态",status:{disconnected:"未连接",connecting:"连接中",connected:"已连接",error:"连接错误"},otherEnabledHint:e=>`同一会话只能启用一个渠道:先停用${e}连接`,credentialMissingHint:"先填写并保存凭证,再启用连接",disableBeforeClearHint:"先停用连接,才能清除凭证",enabledIndicator:{feishu:"飞书连接已启用",telegram:"Telegram 连接已启用"},faqSetupTitle:"如何创建机器人",faqWhatTitle:"绑定后会发生什么",faqTroubleTitle:"常见问题",troubleNoChat:"「发送测试消息」不可用?机器人要先收到过一条消息,才知道要发到哪个会话。",troubleConnError:"连接状态显示错误?检查凭证是否正确;飞书还需确认 API 域名与事件订阅方式(长连接)。",troubleOnePoller:"Telegram 提示已有其他程序在轮询?一个 Bot Token 同一时刻只能被一个程序使用——关闭正在占用它的另一个 PenguinHarness 服务端或机器人脚本,或为该会话单独建一个机器人。"},subagentPanel:{topologyLabel:"调用关系",mainSessionNote:"主会话请在对话区查看",empty:"本次任务尚未派生子智能体",nodeRunning:"运行中",nodeDone:"已完成",openAsSession:"跳转到该会话",subagentGone:"该子会话已不存在,无法恢复"},files:{title:"文件",upload:"上传",download:"下载",openInNewTab:"新页面打开",previewNotIsolatedHint:"当前访问地址无法提供独立预览源,页面将以沙箱模式打开:localStorage、Cookie 与第三方 embed 不可用。经 127.0.0.1 或 localhost 访问,或配置 PENGUIN_PREVIEW_ORIGIN 即可解除。",refresh:"刷新",root:"根目录",empty:"空目录",previewUnsupported:"该类型不支持预览,请下载查看",uploaded:"已上传",overwriteTitle:"覆盖同名文件",overwriteConfirm:e=>`当前目录已存在以下 ${e} 个同名文件,上传将覆盖:`,loadFailed:"加载失败",previewTruncated:"内容过大,预览已截断,请下载查看完整文件",details:"详情",workspacePath:"Workspace 路径",htmlRendered:"渲染视图",htmlSource:"源码",backToList:"返回列表"},usage:{title:"成本与统计",today:"今日",last7d:"近 7 天",total:"累计",tokens:"Token",requests:"Requests",from:"起始日期",to:"结束日期",colCacheRead:"cache_read",colCacheWrite:"cache_write",colOutput:"output",uncostedNote:"* 只计入配置了价格的模型成本",filterAllAgents:"全部 Agent",filterAllModels:"全部模型",rangeLabel:"日期范围",rangeHour:"最近一小时",rangeDay:"最近一天",range7d:"近 7 天",range30d:"近 30 天",range90d:"近 90 天",rangeCustom:"自定义",chartRequestsByAgent:"各 Agent 请求与成功率",chartRequestsByModel:"各模型请求与成功率",legendSuccessRate:"成功率",chartTokenTrend:"Token 变化",chartCostTrend:"成本变化",legendOther:e=>`其他 ${e} 项`,bucketTotal:"合计",legendHitRate:"缓存命中率",empty:"暂无用量记录",errors:"异常",errorsTotal:"总数",errorsUnexpected:"未预期",errorsExpected:"预期内",errorsTopCode:"最常见",errorsColCode:"来源 · 错误码",errorsColKind:"类型",errorsColMessage:"消息",errorsEmpty:"暂无异常",errorsNewer:"较新",errorsOlder:"更早",errorsPageOf:(e,t,n)=>`第 ${e} / ${t} 页 · 共 ${n} 条`},traces:{timeline:"执行时间线",laneLLM:"模型",kindThinking:"思考",kindModelReply:"模型回复",kindToolGen:"工具调用生成",legendToolExec:"工具调用执行",legendOther:"其他",toolParams:"参数 Schema",requiredParam:"必填",legendApprovalWait:"审批等待",task:e=>`第 ${e} 轮`,globalSummary:"全局统计",tasksLabel:"轮次",messages:"消息",truncatedNote:(e,t)=>`仅展示前 ${e} / ${t} 条消息`,zoom:"缩放",zoomReset:"双击复位缩放",zoomOut:"缩小",zoomIn:"放大",linkHint:"鼠标移到时间线段或消息行即可联动高亮,点击时间线段跳转到对应消息;图例可高亮同类;拖动下方滑块平移/缩放",filesTitle:"Trace 文件",toolCalls:"工具调用",taskInput:"本轮输入 tokens",taskOutput:"本轮输出 tokens",cacheHit:"命中缓存",hitRate:"命中率",compactions:"压缩次数",inProgress:"进行中",systemPrompt:"系统提示词",toolDefs:e=>`工具定义(${e})`,exportFile:"导出"},benchmark:{title:"评估中心",selectBenchmark:"在左侧选择一个 Benchmark",emptyAgent:"该 Agent 暂无 Benchmark",caseCount:e=>`${e} 题`,trendTitle:e=>`${e}随时间变化`,cases:"题目",viewCase:"查看详情",taskMaterials:"任务材料",rubric:"评分标准",agentHidden:"被测 Agent 不可见",caseFileUnavailable:"案例文件暂时无法读取",evaluations:"评估明细",noEvaluations:"暂无评估记录",summaryLabel:"评估说明",legendUnlabeled:"未标注模型",colVersion:"版本",colModel:"模型 ID",colThinkingLevel:"推理强度",colScore:"Score",colDuration:"耗时",colCase:"题目",colRun:"运行",colSession:"Session"},errors:{networkError:"网络错误,请检查连接",modelCredentialMissing:e=>`模型 ${e} 还没有可用的 API key,请先在「模型」页为它配置`,noDefaultModel:"该 Project 还没有默认模型,请先在「模型」页添加模型并设为默认",byCode:{invalid_credentials:"用户名或密码错误。",too_many_attempts:"登录失败次数过多,请稍后重试。",password_mismatch:"当前密码不正确。",invalid_password:"密码至少 8 位。",admin_required:"仅管理员可执行此操作。",desktop_single_user:"桌面应用为单用户模式,用户管理不可用。",not_found:"资源不存在,或你没有访问权限。",internal:"服务器内部错误,请稍后重试。",agent_not_found:"该 Agent 已不存在。",unknown_agent:"该 Agent 不存在于本 Project。",agent_exists:"该 Agent id 已被占用。",agent_deleting:"该 Agent 正在删除中。",project_exists:"该 Project id 已被占用。",project_not_found:"该 Project 已不存在,或你没有访问权限。",cannot_delete_last_project:"这是最后一个 Project,不能删除。",user_exists:"该用户名已被占用。",user_not_found:"该用户已不存在。",cannot_delete_admin:"内置 admin 不可删除。",member_not_found:"该用户不是本 Project 的成员。",already_member:"该用户已是本 Project 的成员。",already_owner:"该用户已是本 Project 的所有者。",memory_import_confirm_required:"本次导入会覆盖或删除已有记忆,请确认后继续。",schedule_exists:"已存在同名定时任务。",schedule_not_found:"该定时任务已不存在。",unknown_skill:"该技能不在技能库中。",skill_too_large:"该技能目录过大,超出了导入限制。",file_not_found:"该文件已不存在。",not_pending:"该插话已随本轮送达模型,无法撤回。",follow_up_started:"该跟进消息已开始发送,无法撤回。",file_too_large:"文件过大。",too_many_files:"一条消息附加的文件过多。",payload_too_large:"请求体过大。",image_too_large:"图片过大,无法随对话发送。",dir_not_absolute:"目录必须是绝对路径。",dir_not_found:"该目录不存在或不可访问。",not_a_dir:"该路径不是目录。",path_not_found:"该路径不存在。",workspace_missing:"该 Session 的 Workspace 已不存在。",workspace_not_found:"该 Workspace 不存在或不是目录。",session_not_found:"该 Session 已不存在,或你没有访问权限。",session_deleting:"该 Session 正在删除中。",approval_not_found:"该授权请求已处理或已失效。",process_not_found:"该后台进程已结束或已被移除。",process_running:"该后台进程仍在运行,请先结束再移除。",memory_file_not_found:"该记忆文件已不存在。",memory_scope_not_found:"该记忆范围已不存在。",task_in_progress:"该 Session 已有任务在运行。",compacting:"该 Session 正在压缩上下文,暂不接受新的输入。",shutting_down:"服务正在关闭,请稍后重试。",compaction_not_configured:"该 Agent 没有配置上下文压缩。",nothing_to_compact:"当前上下文还没有可压缩的内容(尚未完成一轮对话)。",already_compacted:"刚刚压缩过,之后还没有新的对话,无需重复压缩。",version_conflict:"快照版本不高于当前版本。",invalid_title:"标题无效。",invalid_proxy_url:"代理地址无效:应为 http(s):// 或 socks5:// 代理 URL,或 主机[:端口]。",invalid_attachment_limit:"上传限制无效:请填写允许范围内的整数 MB,且合计不低于单个上限。",invalid_trace:"该文件不是有效的 Trace 文件。",trace_not_found:"该 Trace 文件已不存在。",trace_session_exists:"该 Agent 已存在同名 Session,无法导入重复的 Trace。",feishu_app_in_use:"该飞书应用已绑定到其他 Session,请先解除或换一个应用。",feishu_secret_required:"需要填写 App Secret。",feishu_not_bound:"该 Session 尚未绑定飞书。",feishu_no_chat:"尚未收到飞书消息:先在飞书中给机器人发一条消息。",feishu_send_failed:"飞书消息发送失败。",telegram_bot_in_use:"该 Telegram 机器人已绑定到其他 Session,请先解除或换一个机器人。",telegram_token_required:"需要填写 Bot Token。",telegram_token_invalid:"Bot Token 格式不正确:应形如「数字:密钥」。",telegram_not_bound:"该 Session 尚未绑定 Telegram。",telegram_no_chat:"尚未收到 Telegram 消息:先在 Telegram 中给机器人发一条消息。",telegram_send_failed:"Telegram 消息发送失败。",another_channel_enabled:"该会话已启用另一渠道的连接:先停用它,再启用当前渠道。",messaging_disable_before_clear:"先停用该渠道的连接,才能清除其凭证。"}}};let d=Uj;function K3(e){d=e}const W3={appName:"PenguinHarness",nav:{chat:"Chat",newChat:"New chat",agents:"Agents",skills:"Skills",models:"Models",usage:"Cost Center",traces:"Trajectories",benchmark:"Evaluation Center",lastConversation:"Last conversation",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",collapseGroup:"Collapse",expandGroup:"Expand",pinGroup:"Pin group",unpinGroup:"Unpin group"},terminal:{title:"Terminal",newShell:"New shell",killShell:"Kill this terminal",createFailed:"Could not start a terminal",noTerminalApi:"this server has no terminal API: the running runtime predates it. A hot push replaces the platform and Web App, but the terminal endpoints are runtime-owned — the runtime itself has to be updated (restarting will not help)",detach:"Open in new window",status:{connecting:"connecting",ready:"ready",exited:"exited",error:"error"},exitedWithCode:e=>`exit code ${e}`},dock:{addTab:"Add panel",closeTab:"Close panel",hideDock:"Hide sidebar",moveToRight:"Move to the right",moveToBottom:"Move to the bottom",resize:"Resize panel",rightDock:"Right sidebar",bottomDock:"Bottom panel",draftEmpty:"Available once the conversation starts",killConfirmTitle:"Close this terminal?",killConfirmBody:e=>`This ends the shell "${e}" — it cannot be restored.`},tracePanel:{empty:"No traces yet",emptyHint:"This session has not produced a Trace file yet",loadFailed:"Failed to load traces"},settings:{language:"Language",languageInfo:"Interface language; can follow the browser.",systemSettings:"System settings",groupPersonal:"Personal",groupServer:"Server",generalTitle:"General",appearanceTitle:"Appearance",accountTitle:"Account",importTrace:"Import Trace",importTraceInfo:"Upload a .jsonl Trace exported from another install and it becomes a conversation of the chosen Agent. Both halves of the destination are picked here: the endpoint is per-Agent — a Trace file's own session_meta cannot name a local Agent, since its agent_state path belongs to the machine that exported it — and the Project is asked for because this dialog does not show which one is open, which also means a Trace can go to a Project other than the open one. Exporting happens in a conversation's Trace panel.",importTraceProject:"Import into project",importTraceAgent:"Import into agent",importTracePick:"Choose file",importTraceRunning:"Importing…",importTraceDone:e=>`Trace imported into ${e}`,importTraceTooLarge:"The file exceeds the 14MB limit.",proxyTitle:"Proxy options",proxyInfo:"Server-global, and in force the moment it is saved — nothing to restart. Loopback addresses always go direct.",proxyForApp:"Application uses the proxy",proxyForAgent:"Agent environment uses the proxy",proxyAddress:"Proxy address",proxyAddressPlaceholder:"Empty = follow system proxy",uploadLimitsTitle:"Upload limits",attachmentMaxMb:"Max attachment size (MB)",attachmentTotalMb:"Max total per message (MB)",attachmentMaxMbHint:(e,t)=>`${e}–${t} MB`,attachmentTotalMbHint:(e,t)=>`${e}–${t} MB, and not below the per-file limit`,uploadLimitsInfo:(e,t)=>`A message may carry at most ${e} attachments. Images placed inline in the conversation keep a separate ${t}MB limit that this setting does not raise — an inline image enters the conversation and the Trace, where its size is paid again on every history page and resume.`,theme:"Theme",themeInfo:"Light or dark look of the app.",themeLight:"Light",themeDark:"Dark",followSystem:"System",terminalTheme:"Terminal theme",terminalThemeInfo:"Colors of the terminal panel; follows the app theme by default.",followAppTheme:"App",langZh:"中文",langEn:"English",fontSize:"Font size",fontSizeInfo:"Overall interface font size.",fontSmall:"S",fontMedium:"M",fontLarge:"L",accent:"Accent",accentInfo:"Interface accent color.",currencyInfo:"Display currency for prices; storage is always USD.",changePasswordInfo:"Change this account's sign-in password.",accentNames:{neutral:"Neutral",blue:"Blue",green:"Green",violet:"Violet",rose:"Rose",amber:"Amber"}},update:{lastUpdated:e=>`Last updated ${e}`,newVersionBadge:"New version available",newVersion:e=>`New version v${e} available`,updatesAvailable:"Updates available",checkNow:"Check for updates",checking:"Checking…",foundNew:e=>`New version v${e} found — use the update entry to install`,upToDate:"You're on the latest version",checkFailed:"Update check failed — try again later",checkDisabled:"Update checks are disabled (PENGUIN_UPDATE_CHECK=off)",releaseNotes:"Release notes",updateNow:"Update now",updating:"Updating…",updated:"Update complete — restart the service to apply",restartHint:"Restart by re-running penguin web (or penguin server) in a terminal",failed:"Update failed",unsupported:"This install cannot be updated from the web UI",confirmBody:"Downloads the latest release and installs it into the install directory on the server (the data directory is not touched). Restart the service afterwards for the update to take effect.",adminOnly:"Only an administrator can run the update from here.",clientCheckNow:"Check for updates",clientFoundNew:e=>e!==null?`Version v${e} found — downloading in the background…`:"New version found — downloading in the background…",clientDownloading:(e,t)=>`Downloading${e!==null?` v${e}`:""}…${t!==null?` ${t}%`:""}`,clientRestartToInstall:e=>e!==null?`Restart to install v${e}`:"Restart to install the update",clientDownloadReady:e=>e!==null?`Version v${e} is ready — restart to install`:"The update is ready — restart to install",clientUpdateFailed:e=>`Client update failed: ${e}`,clientInstallFailed:e=>`Could not start the install: ${e}`,clientInstallConfirmTitle:"Restart and install the update",clientInstallConfirmBody:"PenguinHarness will restart to finish updating. Running tasks will be interrupted.",clientInstallConfirmAction:"Restart now",clientUnsupportedDev:"A dev run does not update itself",clientUnsupportedNonAppImage:"Only the AppImage build updates itself on Linux — update a package install through your package manager"},notify:{taskCompleteTitle:"Task completed",taskCompleteBody:e=>`"${e}" has finished — click to view`},common:{save:"Save",cancel:"Cancel",close:"Close",create:"Create",delete:"Delete",edit:"Edit",settings:"Settings",confirm:"Confirm",loading:"Loading…",saved:"Saved",saving:"Saving…",noChangesToSave:"No changes to save",confirmSaveTitle:"Save changes",confirmSaveBody:"Save these changes? They will be written to the configuration files on the server.",none:"(none)",retry:"Retry",unknownError:"Request failed, please try again later",requiredField:"This field is required",copied:"Copied",moreInfo:"More info",moreInfoAbout:e=>`More info: ${e}`,name:"Name",username:"Username",role:"Role",actions:"Actions",created:"Created",cost:"Cost",time:"Time"},auth:{usernameHint:"2–32 chars: starts with a lowercase letter; lowercase letters, digits and underscores only",password:"Password",passwordHint:"At least 8 characters",showPassword:"Show password",hidePassword:"Hide password",login:"Sign in",logout:"Sign out",admin:"Admin",defaultAdminNote:"First run: sign in as the built-in admin “admin” with the initial password printed in the server startup output (looks like penguin-1234), then change it soon",forgotAdminNote:"Forgot the admin password? Stop the server and run penguin server reset-admin-password to issue a fresh initial one"},account:{changePassword:"Change password",oldPassword:"Current password",oldPasswordHint:"The built-in admin's initial password is printed in the server startup output (looks like penguin-1234)",newPassword:"New password",confirmPassword:"Confirm new password",passwordMismatch:"New passwords do not match",initialPasswordBanner:"This account is using its initial password. Please change it soon.",changeNow:"Change now"},admin:{users:"Users",roleAdmin:"Admin",roleUser:"User",createUser:"Add user",initialPassword:"Initial password",initialPasswordFlag:"initial password",defaultProjectNote:e=>`A default Project will be created: ${e}`,resetPassword:"Reset password",resetPasswordTitle:e=>`Reset password for ${e}`,resetPasswordNote:"All sign-in sessions of this user will be revoked; they must sign in with the new password",deleteUserTitle:e=>`Delete user ${e}`,deleteUserConfirm:e=>`This deletes user ${e} and every Project they own (including data directories). This cannot be undone.`},project:{switcher:"Project",create:"New Project",createTitle:"New Project",id:"Project id",idHint:"2–64 chars: starts with a lowercase letter; lowercase letters, digits and underscores only. Cannot be changed later.",idPrefixHint:"The id is prefixed with your username and a hyphen; append lowercase letters, digits or underscores. Cannot be changed later.",displayName:"Display name",displayNameHint:"Leave empty to use the Project id as the name",settings:"Project settings",settingsTitle:"Project settings",members:"Members",addMember:"Add member",removeMember:"Remove",chatDefaultsTitle:"New chat defaults",chatDefaultsHint:"Prefilled defaults for every new chat: agent, working directory, approval mode, thinking level and default model.",chatDefaultsAgent:"Agent",chatDefaultsNotSet:"Not set",chatDefaultsApprovalNotSet:"Not set (defaults to allow all)",chatDefaultsThinkingNotSet:"Not set (follow the agent's config)",chatDefaultsModelHint:"Same default model as the Models page",settingsTabGeneral:"General",settingsTabMembers:"Members",settingsTabDefaults:"Defaults",settingsTabSecurity:"Security policy",projectIdLabel:"Project ID",deleteProjectDesc:"The project directory is removed recursively and cannot be recovered.",commandPolicyInfo:"The command text is normalized for whitespace and quoting, then matched against each enabled rule's regular expression; a hit is refused outright whatever the approval mode allows. It is an accident guardrail: a command assembled at run time is not covered.",commandPolicyEnable:"Enable policy",commandPolicyEnableDesc:"When off, no rule blocks anything.",commandPolicyRules:"Rules",commandPolicyRestore:"Restore defaults",commandPolicyAddRule:"Add rule",commandPolicyEditRule:"Edit",commandPolicyApplyRule:"Apply",commandPolicyEmpty:"No rules.",commandPolicyOn:"Enabled",commandPolicyOff:"Disabled",commandPolicyRuleName:"Name",commandPolicyRulePattern:"Regular expression",commandPolicyRuleDesc:"Description",commandPolicyInvalidPattern:"Invalid regular expression",deleteProject:"Delete Project",deleteConfirm:"Delete this Project? Its directory will be removed recursively and cannot be recovered.",deleteLastForbidden:"This is the last Project on this account; create another Project before deleting it",deleteDefaultForbidden:"default_project is shared with the CLI and cannot be deleted from the web",noCredentialTitle:"No model credential configured",noCredentialBody:"The default model of this Project has no API key yet. Configure it on the Models page before chatting.",goToModels:"Go to Models",later:"Later"},agent:{listTitle:"Agents",create:"Create agent",createTitle:"Create agent",id:"Agent id",idHint:"2–64 chars: starts with a lowercase letter; lowercase letters, digits and underscores only. Cannot be changed later.",nameHint:"Leave empty to use the agent id as the name",description:"Description",createSkills:"Skills",createSkillsPlaceholder:"No skills selected",createSkillsPicked:e=>`${e} skill${e===1?"":"s"} selected`,createSkillsHint:"Installed into the agent at creation; add or remove them later in its Skills tab.",createSkillsEmpty:"The skill library has nothing to install.",createDirSkills:"Import Skills from a project directory",createDirSkillsPick:"No directory selected",createDirSkillsHint:"Pick a project directory to read the Skills under its .agents/skills and .claude/skills",createDirSkillsEmpty:"This directory carries no installable Skills",createDirSkillsFound:e=>`${e} skill${e===1?"":"s"} found in this directory`,createDirSkillsClear:"Clear the selected directory",createSnapshot:"Initialize from a snapshot",createSnapshotPick:"Choose a snapshot package",createSnapshotHint:"Pick an exported Agent State snapshot package (.tar.gz) to start the new agent from its state; name and description left empty keep the package's values.",createSnapshotSkillsOff:"The snapshot package carries its own skills, so skill seeding is unavailable.",createSnapshotClear:"Remove the selected package",sessionCount:e=>`${e} session${e===1?"":"s"}`,toolCount:e=>`${e} tool${e===1?"":"s"}`,vaultKeyCount:e=>`${e} vault key${e===1?"":"s"}`,scheduleCount:e=>`${e} scheduled task${e===1?"":"s"}`,memoryCount:e=>e===1?"1 memory":`${e} memories`,updatedAt:"Last modified",activity:e=>`${e}-day session activity`,settings:"Agent settings",backToList:"Back to Agents",tabOverview:"Overview",tabPrompt:"System Prompt",tabMemory:"Memory",tabRuntime:"Runtime",tabTools:"Tools",tabSkills:"Skills",tabVault:"Vault",tabSchedules:"Schedules",stateDir:"State path",copyStateDir:"Copy State path",agentsMd:"AGENTS.md",systemPrompt:"system_prompt template",placeholdersTitle:"Available placeholders (click to insert)",insertPlaceholder:"Insert at the system_prompt cursor",placeholders:[["{{AGENTS_MD}}","Injects the AGENTS.md content"],["{{VAULT}}","Injects the vault block (vault.prompt with the key-name list); empty when its toggle is off"],["{{SKILLS}}","Injects the skills block (skills.prompt with installed-skill metadata); empty when its toggle is off"],["{{MEMORY}}","Injects the memory block: memory.prompt plus memory.workspace_prompt (persistent workspaces only); empty when memory is off"],["{{SCHEDULES}}","Injects the scheduled-tasks block (schedules.prompt with the task-name roster); empty when its toggle is off"],["{{PLATFORM}}","Runtime platform"],["{{OS_VERSION}}","Operating system version"],["{{SHELL}}","Shell used to run commands"],["{{DATE}}","Current date"],["{{PROJECT_DIR}}","PenguinHarness app data root — all agents' data and project-level data; not the task working directory"],["{{AGENT_ID}}","Current agent id"],["{{CWD}}","Absolute Workspace path"],["{{PROVIDER}}","Model provider group"],["{{MODEL_ID}}","Upstream model id"],["{{SESSION_ID}}","Current Session id"]],maxTurns:"max_turns (max turns per Task, -1 = unlimited)",maxTokens:"model.max_tokens",thinkingLevel:"model.thinking_level",thinkingLevelOptions:[["","Send no override — keep whatever is currently configured."],["low","Enables a lower tier of extended reasoning."],["medium","Enables a medium tier of extended reasoning (the default tier for a newly created agent)."],["high","Enables a higher tier of extended reasoning; slower responses."],["xhigh","Enables an extended tier of reasoning beyond high; identical to high on some models."],["max","Enables the deepest tier of extended reasoning; slowest and identical to xhigh on some models."]],thinkingLevelNoneKept:"Stored legacy tier: new selections no longer offer the off tier (many models cannot disable thinking).",timeoutMs:"model.timeoutMs",timeoutMsHint:"Per-request timeout, ms",compaction:"Context compaction",maxContextLength:"max_context_length",maxContextLengthHint:"Context threshold that triggers compaction",maxSessionTurns:"max_session_turns",maxSessionTurnsHint:"Turn threshold that triggers compaction",compactionMode:"mode (compaction strategy)",compactionModeOptions:[["","Send no override — keep whatever is currently configured."],["summarize","Summarizes the old context with the model, then continues from that summary in a fresh window (default)."],["discard","Drops the old context without summarizing; the next turn starts fresh in a new window."]],compactionPrompt:"prompt (summarization prompt)",maxTurnsInvalid:"max_turns must be > 0 or -1",timeoutInvalid:"timeoutMs must be > 0 or -1",toolFieldInvalid:(e,t)=>`${e}: ${t} must be a positive integer or -1`,toolPermission:"permission",permissionReadLabel:"Read-only",permissionReadDescription:"Only reads. Auto-approved when the approval mode is read-only.",permissionReadWriteLabel:"Read & write",permissionReadWriteDescription:"Can modify things. Needs manual confirmation when the approval mode is read-only.",toolTimeout:"timeoutMs",toolMaxOutput:"maxOutputLength",toolCallDescription:"call_description",callDescriptionHint:"call_description: when on (the default), the tool's schema keeps the optional description argument — a model-written sentence about each call, shown to the user while it runs; when off, the argument is filtered out of the schema at assembly. Only tools whose parameters declare a description property can be toggled.",mcpServers:"MCP Servers",mcpDesc:"Connect external MCP Servers: their tools join this agent's toolset as mcp__<name>__<tool>. Changes in this block save immediately.",mcpEmpty:"No MCP Servers configured yet",mcpAdd:"Add MCP Server",mcpEditTitle:"Edit MCP Server",mcpRemove:"Remove",mcpName:"name",mcpNameHint:"Tool-name prefix: mcp__<name>__<tool>; letters, digits, _ and - only",mcpTransport:"transport",mcpTransportStdio:"Local process: spawns command and talks over stdin/stdout",mcpTransportHttp:"Streamable HTTP: the current spec's remote transport",mcpTransportSse:"Legacy HTTP+SSE: kept for servers that have not migrated",mcpTarget:"command / url",mcpCommand:"command",mcpArgs:"args",mcpArgsHint:"One argument per line",mcpEnv:"env",mcpEnvHint:"One KEY=value per line; the Agent vault is not injected into MCP Server processes",mcpCwd:"cwd",mcpCwdHint:"Leave empty to use the Session's Workspace",mcpUrl:"url",mcpHeaders:"headers",mcpHeadersHint:"One Header-Name: value per line (auth headers such as Authorization)",mcpPermission:"permission",mcpPermissionAuto:"auto",mcpPermissionAutoLabel:"Auto (readOnlyHint)",mcpPermissionAutoDescription:"Each tool gets the level its own readOnlyHint annotation implies: read-only when it declares one, read & write otherwise.",mcpPermissionReadDescription:"Treat every tool of this server as read-only, whatever it declares. Auto-approved when the approval mode is read-only.",mcpPermissionReadWriteDescription:"Treat every tool of this server as read & write, whatever it declares. Needs manual confirmation when the approval mode is read-only.",mcpPermissionHint:"Only the read-only approval mode reads this level; allow-all, deny-all and always-ask ignore it. It never restricts what the server itself can do — marking a server read-only that is not one only drops the confirmation read-only mode would have asked for.",mcpConnectTimeout:"connectTimeoutMs",mcpBudgetsHint:"Leave empty for defaults: connectTimeoutMs is the connect + tool-discovery budget (default 10000); timeoutMs / maxOutputLength bound every tool of this Server.",mcpNameInvalid:"Letters, digits, _ and - only, starting with a letter or digit",mcpUrlInvalid:"Must be a valid http(s) URL",mcpLineInvalid:e=>`Line ${e} is not valid`,mcpNumberInvalid:"Must be an integer > 0",mcpDuplicateName:"A server with this name already exists",mcpTest:"Test connection",mcpTesting:"Testing…",mcpTestOk:(e,t)=>{const n=t!==void 0?` (${(t/1e3).toFixed(1)}s)`:"";return e===0?`Connected, but the server exposes no tools${n}`:`Connected — ${e} tool${e===1?"":"s"}${n}`},mcpTestFail:e=>`Connection failed: ${e}`,mcpTestAllConfirm:e=>`Connects to ${e===1?"the configured MCP server":`each of the ${e} configured MCP servers`} in turn and runs tool discovery (real connections, nothing is saved); results land on each row.`,mcpTestAllStart:"Start test",mcpTestPending:"Testing…",mcpTestBadge:(e,t)=>`${e} tool${e===1?"":"s"}${t!==void 0?` · ${(t/1e3).toFixed(1)}s`:""}`,mcpTestBadgeFail:"Connection failed",mcpDeleteTitle:"Delete MCP Server",mcpDeleteConfirm:e=>`Delete MCP Server "${e}"? Its tools stop being available from the next Session on.`,defaultValue:"(default)",deleteAgent:"Delete agent",builtinUndeletable:"Built-in agents cannot be deleted",deleteConfirm:e=>`Delete agent "${e}"? Its directory (including all Traces) will be removed recursively and cannot be recovered.`,stateTitle:"Agent State",stateVersion:"Agent State version",transferDesc:"Export the current Agent State snapshot (tar.gz); importing overwrites the whole directory and adopts the version inside the package.",exportSnapshot:"Export snapshot",importSnapshot:"Import snapshot",importing:"Importing…",importDone:e=>`Import finished, Agent State version v${e}`,importConflictTitle:"Version conflict",importConflictBody:"The snapshot's version is not newer than the current one; importing will overwrite the existing Agent State. Continue?",resetConfigTitle:"Restore default configuration",resetConfigAction:"Restore default configuration",resetConfigConfirmBody:"This overwrites the agent's existing configuration with the current defaults: the custom system prompt, tool list, model/compaction settings and MCP servers are all replaced, keeping only name and description. Like a skill update this cannot be undone. Continue?",resetConfigDone:"Configuration restored to the current defaults",kernelTitle:"Kernel",kernelLegacy:"predates kernel versioning",kernelOutdatedHint:"Kernel update available",kernelUpdateNeeded:"Kernel update needed",kernelUpToDate:"Up to date",kernelUpdateTitle:"Update kernel",kernelCurrent:"current",kernelLatest:"latest",kernelUpdateAction:"Update kernel",kernelUpdateConfirmBody:"Settings tabs you have not customized will be updated to the current built-in defaults; a tab you have edited stays unchanged in full and is listed in the result. Name, description, the State version and MCP servers are unaffected. Continue?",kernelUpdateDone:(e,t)=>t>0?`Kernel updated to ${e}; ${t} tab(s) now follow the new defaults`:`Kernel updated to ${e}; every tab was already current or kept as customized`,kernelUpdateKeptIntro:"Kept whole because customized:",kernelListSeparator:", "},models:{title:"Models",addCustom:"Add custom model",addToGroup:"Add model",editTitle:"Model settings",addTitle:"Add model (OpenAI protocol)",addTitleVendor:"Add model",addProtocolHint:"New models use the OpenAI Chat Completions protocol; set the base URL to a compatible endpoint",vendorProtocolHint:e=>`Only ${e}'s official API protocol is supported; use a custom model group for OpenAI-compatible endpoints.`,autoRouteNone:"This model ID cannot be routed with the current provider protocol. If it uses an OpenAI-compatible endpoint, move it to Custom.",useCustomGroup:"Move to Custom",addGroup:"Add group",addGroupTitle:"Add group",addGroupDesc:`User-defined groups share Custom semantics. "Import models" detects (or lets you pick) the endpoint's protocol, then imports every model it serves in one go; "Create only" adds models one by one after the group. Groups live on model entries — the group appears once its first model is saved.`,groupModeCreate:"Create only",groupModeImport:"Import models",groupImportAll:"Import all models",groupImportNeedUrl:"Fill in a valid base URL first (http/https)",groupImportKeyHint:"Leave empty to read the protocol's OPENAI_* / ANTHROPIC_* env vars",groupImportListing:"Fetching model list…",groupImportSaving:e=>`Importing ${e} models…`,groupImportUnsupported:"This protocol cannot list models — add them manually",groupImportFailed:"Fetching the model list failed",groupImportEmpty:"No models to import from this endpoint",groupImported:(e,t)=>t>0?`Imported ${e} models, skipped ${t} entries`:`Imported ${e} models`,groupNameLabel:"Group name",groupNameHint:"Starts with a lowercase letter / digit; may contain - and _",groupNameInvalid:"Group names may only use lowercase letters, digits, - and _ (starting with a letter or digit), up to 32 characters",groupNameExists:"This name is taken by a built-in group or an existing entry",groupEmptyHint:"No models in this group yet; use “Add model” to create one",deleteGroup:"Delete group",deleteGroupTitle:"Delete group",deleteGroupConfirm:(e,t)=>`Delete the group “${e}”? Its ${t} models and their API key configuration will be removed.`,groupDeleted:e=>`Group deleted (${e} models)`,searchPlaceholder:"Search models: id / name / provider",noSearchResults:"No matching models",syncCatalog:"Sync presets",syncCatalogHint:"Update preset models from the built-in catalog: add missing entries and reset differing ones to the catalog's fields; locally added models and API keys are left untouched",syncDone:(e,t)=>`Presets synced: ${e} added, ${t} updated`,syncUpToDate:"Presets are already up to date",homepage:"Model page",speedTest:"Speed test",speedTestTitle:"Speed test",speedTestConfirm:e=>`This sends one real request to each of the ${e} models in this group, one at a time, to measure time-to-first-token (TTFT) and output rate (TPS). It consumes a small amount of API quota. Continue?`,speedTestStart:"Start",speedPending:"Testing…",speedFailed:"Test failed",ttftTitle:"Time to first token (TTFT)",tpsTitle:"Output rate (TPS)",modelCount:e=>`${e} model${e===1?"":"s"}`,modelId:"Model ID",modelIdHint:"The upstream API model id, e.g. gpt-5.5",displayName:"Display name",displayNameHint:"Defaults to the model ID",providerGroup:"Group",contextWindow:"Context window",tokenUnit:"Token",contextWindowHint:"Leave empty if unknown",maxTokens:"Max output tokens",maxTokensHint:"Empty = inherit agent setting",maxTokensTitle:"Caps output tokens per request; leave empty to inherit the agent setting — lower it for small-context models",maxTokensInvalid:"Must be a positive integer",clientTypeLocked:e=>`Protocol: ${e} (kept as configured; not editable)`,protocol:"Protocol",protocolNames:{"openai-responses":"OpenAI Responses","ant-messages":"Anthropic Messages","openai-chat":"OpenAI Chat Completions"},protocolTriggerTitle:e=>`Protocol: ${e}. Click to change it.`,protocolUnset:"Select protocol",detectProtocol:"Detect",detectProtocolHint:"Probe the base URL and apply the protocol it serves",detecting:"Detecting…",detectedProtocol:e=>`Detected ${e}; applied`,detectFailedBody:"Could not detect the protocol. Please check the API key and the base URL.",detectFellBack:"Protocol not detected; saved as OpenAI Chat Completions",addProtocolHintDetect:"Pick the protocol from the base URL field's suffix (OpenAI Responses / Anthropic Messages / OpenAI Chat Completions), or press Detect to probe the endpoint — saving without one detects it first",addTitleCustom:"Add model",vision:"Vision support",detectVision:"Detect",detectingVision:"Testing…",detectVisionHint:"Send one tiny test image to see whether this model accepts images (uses your API key)",detectVisionNeedsId:"Fill in the model id first, then detect.",detectVisionOk:"This model accepts images; vision turned on",detectVisionNo:"This model does not accept images; vision left off",visionOffProxyHint:"Images are read via the vision proxy model",fastMode:"Fast mode",fastModeHint:"Faster output, billed at the provider's premium tier; the Cost center still counts it at the entry's standard prices",fastModeUnsupported:"This model does not support fast mode — turn it off, or its requests will fail",fastModeConfirmTitle:"Enable fast mode",fastModeConfirmBody:"Fast mode is billed at the provider's premium price list (MiniMax charges 1.5x standard; OpenAI and Anthropic publish separate premium rates). The entry's recorded per-token prices are not adjusted, so the Cost center will under-report this usage.",fastModeConfirmPreview:"Anthropic's fast mode is a limited research preview: until your organization is granted access, requests return a 429 rate-limit error.",fastModeBadge:"Fast",visionBadge:"Vision",freeBadge:"Free",visionModelBadge:"Proxy vision",setVisionModel:"Set as proxy vision model",visionModelHint:"Describes images via describe_image for models without vision",priceUnitShort:"/M tok",testConnection:"Test connection",testing:"Testing…",testOk:e=>`Connected (${e} ms)`,testFailed:e=>`Failed: ${e}`,priceCacheRead:"Cache read price",priceCacheWrite:"Cache write price",priceOutput:"Output price",currency:"Currency",currencyUsd:"USD $",currencyCny:"CNY ¥",apiKey:"API key",apiKeyKeepHint:"Leave empty to keep the current key",apiKeyEnvHint:e=>`Leave empty to use the ${e} env var`,keyConfigured:"Key configured",clearApiKey:"Clear stored API key",baseUrl:"Custom base URL",baseUrlHint:"Leave empty to use the provider default",baseUrlSuffixTitle:"The client appends the protocol path shown at the field's right edge to the base URL",baseUrlRequired:"A base URL is required",contextWindowDefaultHint:e=>`Defaults to ${e} if empty`,confirmDeleteTitle:"Delete model",confirmDelete:e=>`Delete "${e}"? Its configuration and API key will be removed.`,groupApiKey:"Set key",groupApiKeyTitle:e=>`Set the API key for ${e}`,groupApiKeyHint:e=>`Applies to all ${e} models in this group; leave empty to keep them unchanged.`,getApiKey:"Manage keys",getModelIds:"Get model IDs",groupKeyApplied:e=>`API key set for ${e} models`,oauthKey:"Authorize key",oauthTitle:e=>`Authorize a new ${e} API key`,oauthIntro:(e,t)=>`A new API key will be created on your ${e} account and written to all ${t} models in this group, replacing the key they use now.`,oauthAuthorize:"Open authorization page",oauthWaiting:"Waiting for the authorization to finish in the other tab…",oauthApplied:e=>`New API key set for ${e} models`,oauthManualSwitch:"Page can't redirect back? Enter the code by hand",oauthCallbackSwitch:"Go back to the automatic redirect",oauthManualHint:"Open the authorization page, then paste the one-time code it shows you here.",oauthCodeLabel:"Authorization code",oauthSubmitCode:"Submit code",oauthTimedOut:"The authorization never came back. Enter the code by hand, or start again.",oauthRetry:"Start again",oauthErrors:{invalid_request:"The authorization request was rejected. Start again.",code_rejected:"That authorization is no longer valid: it expired or was already used. Start again.",upstream_failed:"The provider returned no usable key. Start again.",unreachable:"The provider could not be reached. Check the network and start again.",apply_failed:"A key was created but could not be saved. Authorize again, then delete the unused key in the provider's console."},providerEnvNotes:{zhipu:"Defaults to the Z.AI global endpoint (api.z.ai); keys from bigmodel.cn need base URL https://open.bigmodel.cn/api/paas/v4",moonshot:"Defaults to the China endpoint (api.moonshot.cn); keys from platform.kimi.com need base URL https://api.moonshot.ai/v1"},confirmVisionModelTitle:"Set as proxy vision model",confirmVisionModel:e=>`Make "${e}" the proxy vision model? Models without vision will read images through it via describe_image.`,confirmSaveTitle:"Save model settings",confirmSave:e=>`Save the changes to "${e}"?`,confirmDefaultTitle:"Set as default model",confirmDefault:e=>`Make "${e}" the default model? New sessions will use it by default.`,default:"Default",setDefault:"Set as default model",remove:"Delete model",readOnlyHint:"Members have read-only access; only owners can change models and credentials",empty:"No models configured yet",noKey:"No key",readFromEnv:"Read from environment variable",showModelsWithoutKey:e=>`Show model${e===1?"":"s"} without a key (${e})`,modelIdExists:"This model id already exists",pricingAllOrNone:"Fill all three prices",pricingInvalid:"Must be a number",contextWindowInvalid:"Must be a number"},memory:{desc:"Long-term memory across Sessions (stored in agent_state/memory/): the agent saves what is worth keeping as it works, and you can also just ask it to remember something. User memory applies to all of this agent's sessions; workspace memory is kept per workspace. Memory edits are made by the agent in chat. Turning the switch off only stops memory from being used and deletes nothing.",enable:"Enable memory",userScope:"User memory",templateMissing:"The prompt template has no {{MEMORY}} placeholder, so memory never enters the context.",insertPlaceholder:"Insert the {{MEMORY}} placeholder",insertPlaceholderDone:"Inserted",promptSection:"Memory prompt",promptSectionHint:"What the template's {{MEMORY}} placeholder expands to. The main prompt is injected into every session; the workspace addendum only in sessions with a persistent workspace.",promptLabel:"Main prompt",workspacePromptLabel:"Workspace addendum",promptPlaceholders:[["{{USER_MEMORY_INDEX}}","Content of the user MEMORY.md index (at most 200 lines and 25,000 characters total)"],["{{WORKSPACE_MEMORY_INDEX}}","Content of the workspace MEMORY.md index (at most 200 lines and 25,000 characters total); effective only in the workspace addendum"],["{{WORKSPACE_MEMORY_DIR}}","Absolute path of the current workspace's memory directory; effective only in the workspace addendum"]],insertToken:"Insert at the cursor",itemCount:e=>e===1?"1 item":`${e} items`,emptyScope:"No memories for this Workspace yet — the agent saves what is worth keeping as it works",emptyUserScope:'No user memories yet — say "remember …" in a chat and the agent will save it',add:"Add",addScopeLabel:e=>`Add to ${e}`,addTitle:"Add memory",addWhy:"The agent organizes and saves memories in a chat: fill in the content, open a new conversation, and the agent does the rest.",addContentLabel:"Content or source to remember",addContentPlaceholder:"Paste the content to remember, or a file path / URL",addPromptLead:{user:"Please turn the following into memories in user memory:",workspace:"Please turn the following into memories in this workspace's memory:"},view:"View",edit:"Edit",editTitle:"Edit memory",editWhy:"Content edits are made by the agent in a chat: confirm the prompt to open a new conversation, and the agent updates the memory file and its MEMORY.md index together.",editRequirementLabel:"What to change",editRequirementPlaceholder:"Describe the change — you can finish it in the chat",editPromptLabel:"Prompt preview",editCopyPrompt:"Copy prompt",editOpenChat:"Open a new chat",delete:"Delete",deleteTitle:"Delete this memory?",deleteConfirm:e=>`This deletes "${e}" and removes its index line from MEMORY.md. This cannot be undone.`,deleteDone:"Deleted",editPromptLead:e=>`Please update a memory: ${e}`,editPromptTail:"What to change: ",exportScope:"Export",exportScopeHint:"Download every memory in this group as one JSON document",exportScopeLabel:e=>`Export ${e}`,importScope:"Import",importScopeHint:"Restore memories into this group from an exported JSON document",importScopeLabel:e=>`Import into ${e}`,importTitle:"Import memories",importWhy:"Reads a memory group exported from this or another agent: a JSON file holding the memories and the group's MEMORY.md index.",importFile:(e,t)=>`${e} — ${t} memories`,importModeLabel:"When this group already has a memory of the same name",importModeSkip:"Keep the one that is here",importModeSkipHint:"Adds only what this group does not have. Nothing here is lost.",importModeOverwrite:"Take the file's version",importModeOverwriteHint:"Memories the file does not carry are left alone.",importModeReplace:"Replace the whole group",importModeReplaceHint:"Every memory the file does not carry is deleted.",importAction:"Import",importInvalidFile:"This file is not a memory export.",importEmptyFile:"This file carries no memories.",importConfirmTitle:"Confirm the import",importWillOverwrite:e=>`${e.length} memories will be overwritten: ${e.join(", ")}`,importWillRemove:e=>`${e.length} memories will be deleted: ${e.join(", ")}`,importWillReplaceIndex:"The group's MEMORY.md index will be replaced.",importIrreversible:"This cannot be undone.",importDone:(e,t,n)=>`Imported: ${e} added, ${t} replaced, ${n} deleted`,importNothingNew:"Nothing to import — this group already has every memory in the file"},vault:{desc:"Environment variables owned by this agent (stored in agent_state/.vault.toml), injected into the environment of its shell commands (exec_command); key names are shared with the model, values never enter the model context. Subagents use their own vaults and do not inherit this one. Saved changes take effect from the next task (a task already running is unaffected).",key:"Name",value:"Value",valueMasked:"Value (masked)",add:"Add",addTitle:"Add variable",remove:"Remove",deleteTitle:"Delete variable",deleteConfirm:e=>`Delete variable "${e}"? Its value cannot be recovered.`,overwriteTitle:"Overwrite existing variable",overwriteConfirm:e=>`"${e}" already exists — saving will overwrite its value, which cannot be recovered.`,empty:"No variables configured yet",readOnlyHint:"Members are read-only; only the owner can edit the vault",keyHint:"Letters, digits and underscores; must not start with a digit",keyInvalid:"Invalid name: only letters, digits and underscores, not starting with a digit",valueRequired:"Value must not be empty",injection:{enable:"Enable vault",templateMissing:"The prompt template has no {{VAULT}} placeholder, so the vault section never enters the context.",legacyTemplate:"The template still carries the legacy hardcoded # Vault section: one-click migration replaces it in place with the {{VAULT}} placeholder, wording unchanged, after which it is editable below.",insertPlaceholder:"Insert the {{VAULT}} placeholder",migrate:"Migrate to the {{VAULT}} placeholder",promptSection:"Vault prompt",promptSectionHint:"What the template's {{VAULT}} placeholder expands to; nothing is injected when the toggle is off or the template lacks the placeholder.",promptLabel:"Prompt",promptPlaceholders:[["{{VAULT_KEYS}}",'Vault key-name list (one "- KEY" line per key, names only — values are never injected; empty when no keys)']]}},schedule:{desc:"Scheduled tasks (agent_state/schedule/*.toml): the prompt is sent to the target Session on schedule; files can also be edited by hand, and changes made here take effect immediately.",readOnlyHint:"Members are read-only; only the owner can modify schedules",colStatus:"Status",colPeriod:"Period",colTarget:"Target",colFireTimes:"Next / last fired",colQueued:"Queue",statusNames:{active:"Active",disabled:"Disabled",expired:"Expired",done:"Done",missed:"Missed",invalid:"Invalid"},queued:"Queued",once:"One-off",newSession:"New session",invalidFiles:"Files that failed to parse (skipped by the scheduler)",empty:"No scheduled tasks yet",enable:"Enable",disable:"Disable",addTitle:"New scheduled task",editTitle:e=>`Edit scheduled task "${e}"`,nameHint:"The file name (without .toml); cannot be changed later",prompt:"Prompt",enabled:"Enabled",startAt:"Start at",endAt:"End at",period:"Period",periodPlaceholder:"30m / 12h / 7d; leave empty for a one-off task",target:"Target",targetNew:"New session each time",targetSession:"Bound Session",sessionId:"Session",chooseSession:"Choose a Session to bind",sessionSearch:"Search title or Session id…",sessionNoMatch:"No matching Session",sessionEmpty:"This agent has no Sessions yet",workspace:"Workspace",model:"Model",modelDefault:"Project default",deleteTitle:"Delete scheduled task",deleteConfirm:e=>`Delete scheduled task "${e}"?`,injection:{enable:"Enable schedules",templateMissing:"The prompt template has no {{SCHEDULES}} placeholder, so the scheduled-tasks section never enters the context.",insertPlaceholder:"Insert the {{SCHEDULES}} placeholder",promptSection:"Schedules prompt",promptSectionHint:"What the template's {{SCHEDULES}} placeholder expands to — teaches the model to manage scheduled tasks with its file tools; nothing is injected when the toggle is off or the template lacks the placeholder.",promptLabel:"Prompt",promptPlaceholders:[["{{SCHEDULE_LIST}}",'Current task-name list (one "- name" line per task; an empty-roster note when none exist)']]}},skills:{pageTitle:"Skill library",pageDesc:"Built-in skill library: browse, quick-start a chat, or install to agents.",quickInvoke:"Quick start",quickInvokeText:e=>`use the ${e} skill`,quickInvokeNeedsInstall:"Install this skill on the current agent first to quick-start",selectAll:"Select all",selectNone:"Select none",selectedCount:e=>`${e} selected`,manageInstall:"Manage installs",manageInstallTitle:e=>`Manage installs: ${e}`,install:"Install",installed:"Installed",uninstall:"Uninstall",skillCount:e=>e===1?"1 skill":`${e} skills`,usedByAgents:e=>e===0?"not used yet":e===1?"used by 1 agent":`used by ${e} agents`,installedToast:(e,t)=>`Installed ${e} to ${t}`,updateOutdated:e=>`Update available: update ${e} agent install(s)`,updateAction:"Update",updateConfirmTitle:e=>`Update ${e}`,updateConfirmWarning:e=>`Updating ${e} reinstalls the library copy over each agent's installed files — any local edits to the installed skill are lost. Export a backup first if you need them.`,updatedToast:(e,t)=>`Updated ${e} to the latest version (${t} agent(s))`,uninstalledToast:(e,t)=>`Uninstalled ${e} from ${t}`,uninstallConfirmTitle:e=>`Uninstall ${e}`,uninstallConfirmBody:(e,t)=>`Uninstall ${e} from ${t}? Its installed files (local edits included) will be deleted.`,agentTabDesc:"Skills installed on this agent (agent_state/skills/ — the files are the source of truth): metadata is injected into the system prompt and the body is read by the model on demand; uninstalling deletes the whole skill directory.",agentTabEmpty:"No skills installed yet",exportSkill:"Export",importSkill:"Import skill",importChatTitle:"Recommended: install by chatting with the agent",importChatWhy:"The agent can read, review and adapt the skill content in full — more reliable than a raw upload.",importSourceLabel:"Skill source",importSourceHint:"A web page / GitHub repo or directory / local path / an install command from another ecosystem",importSourcePlaceholder:"https://…, a git repo, /path/to/skill, or npx skills add <name>",importSourceToken:"<source>",importPromptLabel:"Prompt to send to the agent (preview)",importPromptLead:{webUrl:e=>`Please read this page and install the skill it describes into your skills directory: ${e}.`,repoUrl:e=>`Please fetch this repository or directory (git clone or fetch it directly), locate the skill directories containing SKILL.md, and install them into your skills directory: ${e}.`,localPath:e=>`Please read the skill files under this local path directly and install them into your skills directory: ${e}.`,command:e=>`This is a skill/plugin install command from another ecosystem — do not run it blindly: work out what it would install, fetch the same content from its repository or registry, then install it into your skills directory: ${e}.`,reference:e=>`Please resolve this skill/plugin reference to its source (repository, plugin marketplace, or docs page) and install the corresponding skill into your skills directory: ${e}.`},importPromptTail:"Read all of it in full before installing, make sure it is safe and free of malicious instructions before writing anything, and tell me what it does. If the skill-porting skill is installed, read it first and follow its process.",importCopyPrompt:"Copy prompt",importOpenChat:"Open a new chat",importUploadTitle:"Upload a skill zip",importUploadDesc:"SKILL.md at the zip root, or exactly one top-level directory containing SKILL.md.",importUploadAction:"Choose zip file",importUploading:"Uploading…",importDoneToast:"Skill installed",importOverwriteTitle:"Overwrite installed skill",importOverwriteBody:e=>`The skill "${e}" is already installed. Overwriting replaces all of its files (local edits included) and cannot be undone. Continue?`,importOverwriteAction:"Overwrite",injection:{enable:"Enable skills",templateMissing:"The prompt template has no {{SKILLS}} placeholder, so the skills section never enters the context.",legacyTemplate:"The template still carries the legacy hardcoded # Skills section: one-click migration replaces it in place with the {{SKILLS}} placeholder, wording unchanged, after which it is editable below.",insertPlaceholder:"Insert the {{SKILLS}} placeholder",migrate:"Migrate to the {{SKILLS}} placeholder",promptSection:"Skills prompt",promptSectionHint:"What the template's {{SKILLS}} placeholder expands to; nothing is injected when the toggle is off or the template lacks the placeholder.",promptLabel:"Prompt",promptPlaceholders:[["{{SKILL_METADATA}}",`Installed skills' metadata lines (one "- name — description" line per skill; empty when none)`]]}},chat:{newSessionMenu:"New chat",chooseAgent:"Choose agent",chooseModel:"Choose model",thinkingLevel:"Thinking level",thinkingLevelNames:{none:"none",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},thinkingLevelMenuName:e=>e,thinkingSwitchTitle:"Switch thinking level",thinkingSwitchBody:e=>`Switch the thinking level to "${e}"? Switching mid-conversation lowers the prompt-cache hit rate and raises cost; compacting the context first is cheaper.`,thinkingSwitchBusyHint:"This conversation is still working — compaction has to wait for it.",thinkingSwitchCompactFirst:"Compact, then switch",thinkingSwitchConfirm:"Switch anyway",thinkingSwitchCompacting:"Compacting the context — the thinking level switches when it ends.",thinkingSwitchApplied:e=>`Context compacted; thinking level switched to "${e}".`,thinkingSwitchCompactFailed:"The compaction did not finish; the thinking level was switched anyway.",workspaceUseThis:"Use this dir",workspaceUp:"Parent dir",workspaceNoSubdirs:"No subdirectories",workspaceAuto:"Temporary workspace",workspaceClear:"Use a temporary workspace instead",workspaceDirInvalid:"Directory does not exist or is inaccessible; reverted",groupByWorkspace:"Group by workspace",groupByAgent:"Group by agent",groupByTime:"Group by time",timeGroups:{day:"Past day",month:"Past month",earlier:"Earlier"},searchSessions:"Search chats",searchSessionsPlaceholder:"Search chats…",searchClear:"Clear search",searchNoMatches:"No matches among loaded chats",listSettings:"List options",groupModeSection:"Group by",sortModeSection:"Sort by",sortManual:"Manual order",sortRecent:"Most recent",newWorkspaceEntity:"New workspace",workspaceMenu:"Workspace options",renameWorkspace:"Rename workspace",renameWorkspaceLabel:"Name",renameWorkspaceHint:"Leave empty to use the folder name",deleteWorkspace:"Remove workspace",deleteWorkspaceConfirm:e=>`Remove "${e}"? This only removes the workspace group from the sidebar — the directory on disk and existing chats are untouched, and it can be re-added anytime.`,tempWorkspaces:"Temporary workspaces",newSessionInWorkspace:"New chat in this workspace",draftSubtitle:"The self-evolving agent that excels at AI development tasks",exampleFolders:{webapps:"Build web apps",agents:"Build and optimize agents",schedules:"Create scheduled tasks"},exampleFillHint:"Click to fill the composer — edit it if you like, then send",shortcuts:{folder:"My shortcuts",new:"New shortcut",newFromComposer:"Starts from whatever is in the composer",createTitle:"New shortcut",editTitle:"Edit shortcut",titleLabel:"Name",titleHint:e=>`At most ${e} characters`,promptLabel:"Prompt",promptHint:e=>`At most ${e} characters`,promptInfo:"Clicking this shortcut puts the text into the composer verbatim and sends nothing; Skills stay a separate pick in the composer.",titleTooLong:e=>`The name may be at most ${e} characters`,promptTooLong:e=>`The prompt may be at most ${e} characters`,deleteTitle:"Delete shortcut",deleteConfirm:e=>`Delete "${e}"? The shortcut disappears from every device you use.`},exampleTasks:{game:{label:"2D penguin sled game",desc:"A cute Antarctic penguin sleds over rocks, easy start with a gentle difficulty ramp — a 2D pure-frontend mini game",prompt:"Build a cute Antarctic penguin sledding 2D game: press Space to jump over the rocks coming up on the ice; start easy and forgiving, with sled speed and obstacle density ramping up smoothly and gradually over time (no sudden spikes), live scoring, and hitting a rock ending the run with one-click restart. A 2D side-scroller with a cute cartoon look, pure frontend (a single HTML file is fine), styled per the web-design skill. When done, test it in a browser once, confirm the first few seconds are easy to clear, and tell me how to open it and how to play."},gamecenter:{label:"A mini-game center built by multiple agents",desc:"Ten pure-frontend games with no repeated mechanics, built in parallel behind one index page",prompt:`Build a web mini-game center with multiple agents working in parallel: 10 pure-frontend games with no two sharing the same mechanic, plus an index page.
69
-
70
- ## How to split the work
71
- - First plan the 10 games (say snake, 2048, tetris, breakout, minesweeper, memory match, sokoban, space shooter, platform jumper, rhythm tap), confirm no two mechanics repeat, and fix a shared directory layout, palette and interaction spec.
72
- - Then hand the 10 games to several subagents to implement in parallel — each subagent owns exactly one game, follows the agreed spec, and never edits another's files.
73
-
74
- ## Each game
75
- - Its own \`games/<slug>/index.html\`: pure frontend, a single file that runs straight from file://, with no backend and no CDN assets.
76
- - Start / restart, live score or timer, a lose-or-clear summary, both keyboard and touch controls, and the rules written on the page.
77
- - A way back to the index page.
78
-
79
- ## Index page
80
- - \`index.html\` at the root: a card grid listing all 10 games (name + one-line mechanic + controls), each card opening its game.
81
- - One design language shared with every game, following the web-design skill.
82
-
83
- ## Wrap-up
84
- - Review as a whole: the 10 mechanics really are distinct, the styling is consistent, and every index link resolves.
85
- - Self-test each game in a browser — it starts, it ends, it restarts — then tell me how to open it.`},lol:{label:"League of Legends music player",desc:"Worlds anthems on the SoundCloud Widget API — a single file that opens from file://",prompt:`Build a League of Legends Worlds anthem player with the SoundCloud Widget API (see https://developers.soundcloud.com/docs/api/html5-widget): a single index.html that works when opened from file://.
86
-
87
- ## Technical constraints
88
- - Use the SC.Widget JS API (widget.load / widget.toggle / widget.setVolume / widget.seekTo), loading https://w.soundcloud.com/player/api.js
89
- - The iframe must stay visible (180px tall), with visual=true color=f0b90b single_active=true
90
- - Include ONLY these 8 tracks confirmed playable (oEmbed-verified); do not add tracks that are not oEmbed-verified:
91
- - Warriors (S4) — soundcloud.com/leagueoflegends/warriors
92
- - Worlds Collide (S5) — soundcloud.com/leagueoflegends/worlds-collide
93
- - Legends Never Die (S7) — soundcloud.com/leagueoflegends/legends-never-die
94
- - Phoenix (S9) — soundcloud.com/leagueoflegends/phoenix
95
- - Burn It All Down (S11) — soundcloud.com/leagueoflegends/burn-it-all-down
96
- - GODS (S13) — soundcloud.com/leagueoflegends/gods
97
- - Heavy Is The Crown (S14) — soundcloud.com/linkinpark/heavy-is-the-crown
98
- - Sacrifice (S15) — soundcloud.com/leagueoflegends/sacrifice
99
-
100
- ## Layout
101
- - Left 260px sticky sidebar: the track list (S4/S5/… badge + emoji + title + year); clicking highlights with a gold border and switches tracks via SC.Widget.load() with auto_play
102
- - Right main area: hero title + a desktop clock (80px monospace gold HH:MM:SS, refreshed every second, blinking colons) + a mood tag
103
- - Player card: the SoundCloud iframe + a custom control bar (⏮ ▶/⏸ ⏭ + track info + a volume slider; clicking the speaker icon toggles mute)
104
- - Mood-wave section: 15 gold animated bars, re-randomized on every track switch
105
- - Keyboard shortcuts: Space play/pause, ← → previous/next, ↑ ↓ volume
106
-
107
- ## Design
108
- Penguin visual style (see the web-design skill), dark by default. On phones the sidebar becomes a horizontally scrolling top bar.
109
-
110
- When done, open index.html in a browser and self-test once.`},rhythmRunner:{label:"Rhythm runner mini game",desc:"A Muse Dash-style rhythm runner: a penguin lead, notes locked to the beat, graded Perfect / Great / Miss",prompt:"Build a Muse Dash-style rhythm runner: a penguin runs forward on its own, and notes — drawn as music-note icons — fly in locked to the beat for me to hit. Show Perfect / Great / Miss for each hit, score combos, and let the difficulty climb as the track goes on. Pure front end, one file, playable straight from file://."},investmentCopilot:{label:"Conversational investment analyst",desc:"A conversational market Copilot on the Penguin SDK: the home page lists what is trending, with the market factors behind every call",prompt:`Build a conversational stock-market Copilot on the Penguin SDK, along the lines of perplexity.ai/finance: from startup it pulls live market data every 5 minutes, and the home page lists the stocks trending strongest lately alongside how the sectors compare. Every call has to name the market factors behind it — policy, sector news, fund flows, earnings, macro data — rather than technical indicators. Analysis of public data, not investment advice. Its stock-lookup tool has to handle questions like "look up Zhipu's stock for me": resolve a company name to its ticker itself, and when there is no match or the company is not listed, say so rather than inventing a quote.`},rag:{label:"Build a Claude Code docs RAG agent",desc:"Collect the claude-code-docs repo into a conversational RAG knowledge app with source citations",prompt:"Collect the docs from https://github.com/ericbuess/claude-code-docs and build a RAG knowledge app: clone the repo and prepare the corpus, then build a retrieval index; the app acts as a Claude Code configuration expert, answering Claude Code questions with retrieval-augmented replies and clickable citations that reveal the matched original text chunk and link to the real documents; give it a beautiful web chat UI following the web-design skill. When done, run the app and self-test one Chinese question and one English question, confirming both retrieve the right English documents and stream their answers, then tell me how to access it."},agentBenchmarkBuild:{label:"Build a general-purpose decision agent and its benchmark",desc:"Create a general decision Agent and test it on football, after-sales, and investment tasks",prompt:`Use \`agent-initialization\` followed by \`benchmark-design\` to create a decision Agent and produce a frozen Benchmark with a Formal Baseline.
111
-
112
- Agent:
113
- - id: \`finite_choice_agent\`
114
- - capability: make stable, explainable finite choices when public information is incomplete or conflicting
115
- - installed_skills: \`[]\`
116
-
117
- Benchmark:
118
- - id: \`contextual-choice-adaptation\`
119
- - capability: form and transfer a stable finite-choice decision process from public rules, historical examples, and current facts
120
- - desired_baseline_score: \`<75\`
121
- - pilot_iteration_limit: \`5\`
122
-
123
- Scenarios:
124
- 1. Make football betting decisions from historical matches and current information.
125
- 2. Choose after-sales actions from policy and ticket facts.
126
- 3. Choose investment actions from a strategy, historical markets, and current indicators.`},agentOptimization:{label:"Improve the general-purpose decision agent's accuracy",desc:"Improve an Agent from existing evaluation results and verify that the new version is better",prompt:"Use `agent-optimization` to optimize a decision Agent against its frozen Benchmark.\n\n- test_agent_id: `finite_choice_agent`\n- benchmark_id: `contextual-choice-adaptation`\n- capability_direction: improve stability under incomplete information, conflicting rules, and finite choices\n- runs: `3`\n- desired_score: `>=95`\n- candidate_round_limit: `5`"},dailyPlan:{label:"A 9am daily planning check-in",desc:"09:00 every day: talk through the day's plan in this same chat, and review yesterday's progress",prompt:"Set up a scheduled task: every day at 9am, in this same conversation, plan today's work with me. Read back over the conversation first and say what yesterday's plan got done and where it stuck, then offer an ordered shortlist for today with a line of reasoning each, and write up what I confirm as a checklist."},githubDigest:{label:"Daily GitHub project digest",desc:"A daily pass over one repo's issues, PRs and CI, ending in prioritized recommendations",prompt:"Set up a scheduled task: every morning, use gh to digest one GitHub repo's issues, PRs and CI — surface what has stalled, what is waiting on review and what is failing — and end with recommendations ranked by priority, each saying why it sits where it does."},memoryReview:{label:"Friday memory review",desc:"Friday evening: go through what is worth remembering from the week and write it into Memory",prompt:"Set up a scheduled task: every Friday evening, in this same conversation, go through what is worth remembering from the week with me. Check the existing memory index first so nothing is duplicated, then take it item by item — what to record, what to revise — and write what I confirm into Memory."}},sessionList:"Sessions",defaultSessionTitle:"New chat",agent:"Agent",model:"Model",workspace:"Workspace",workspaceHint:"Leave empty for an auto-created temporary workspace; if set, it must be an existing directory on the server",workspaceHintShort:"Leave empty for a temporary workspace",approvalMode:"Approval mode",approvalModeNames:{"allow-all":"Approve everything","deny-all":"Deny everything","read-only":"Approve read-only","always-ask":"Ask every time"},approvalModes:{"allow-all":"Approve everything (allow-all)","deny-all":"Deny everything (deny-all)","read-only":"Approve read-only (read-only)","always-ask":"Ask every time (always-ask)"},statusRunning:"Running",statusCompacting:"Compacting",statusCompletedUnread:"Done, unread",pendingApprovals:e=>`${e} pending approval${e>1?"s":""}`,jumpToLatest:"Jump to latest",loadingEarlier:"Loading earlier messages…",loadEarlierRetry:"Failed to load earlier messages — click to retry",historyBeginning:"Beginning of conversation",outlineTitle:"Outline",outlineTickLabel:(e,t)=>`Turn ${e}: ${t}`,outlineNoText:"(image or attachment)",outlineAnswering:"Answering…",inputPlaceholder:"Type a message. Enter to send, Shift+Enter for newline, paste images",inputPlaceholderShort:"Type a message…",steerPlaceholder:"Message the running agent — delivered with the next turn",steerPlaceholderShort:"Message the running agent…",steerSend:"Send to the running agent",steerQueuedIndicator:"Steering queued — delivered with the next turn",steerQueuedItem:e=>`Steering queued — delivered with the next turn: ${e}`,userSteering:"User steering",steerModeLabel:"Mid-run send mode",steerModeSteer:"Steer",steerModeSteerHint:"Steer now: delivered to the running agent with the next turn",steerModeFollowUp:"Queue",steerModeFollowUpHint:"Queue a follow-up: sent automatically as a new message when this run finishes",followUpPlaceholder:"Queue as the next message — sent automatically when this run finishes",followUpPlaceholderShort:"Queue as the next message…",followUpSend:"Queue as the next message",followUpQueuedChip:e=>`${e} follow-up ${e===1?"message":"messages"} queued — sent when this run finishes`,followUpQueuedItem:e=>`Follow-up queued — sent when this run finishes: ${e}`,recallQueued:"Recall",recallQueuedTitle:"Recall to the input box to edit and resend",send:"Send",stop:"Stop",compact:"Compact context",approve:"Allow",deny:"Deny",decisionAllow:"Approved",decisionDeny:"Denied",decisionManual:"manual",decisionAuto:"auto",decisionPolicy:"policy",thinking:"Thinking",subagent:"Subagent",subagentRunning:"Running",aborted:e=>{const t=e?.errorCode==="user_abort"?"aborted by user":e?.errorCode==="backoff_interrupted"?"aborted during reconnect backoff":e?.errorCode==="compaction_interrupted"?"aborted during compaction":e?.errorCode??e?.reason??"",n=t?`${t}${e?.errorMessage?`: ${e.errorMessage}`:""}`:"";return`[Aborted]${n?`: ${n}`:""}`},reconnect:(e,t,n,s,o,c)=>{const u=c??e,f=u==="timeout"?"Connection timed out":u==="malformed"?"Response incomplete or unparseable":u==="network"?"Network or service temporarily unavailable":u==="failed"?"The model provider returned an error":"The request failed",p=t==="gaveUp"?`giving up after attempt ${n}${o?`: ${o}`:""}`:t==="retried"?`retry #${n} sent`:s!==void 0?`retry #${n} in ${s}s…`:`starting retry #${n}…`;return`[Retry] ${f}; ${p}`},llmError:e=>`[Error]: llm request error${e?`: ${e}`:""}`,reconnectRetryNow:"Retry now",reconnectGiveUp:"Give up",imageAlt:"Image uploaded by user",toolImageAlt:"Image from tool output",imagesAsPathHint:"This model cannot view images directly: on send, images are saved to the session scratchpad and passed as file paths (viewed via describe_image)",infoPanel:"Session info",sessionStats:"Stats",sessionIdLabel:"Session id",copySessionId:"Copy Session id",processList:"Processes",processStop:"Stop",processExited:"exited",processRemove:"Remove",processRemoveHint:"Remove this entry — the output captured from it is discarded too",runningServices:e=>e===1?"1 running service":`${e} running services`,statTokens:"Total Tokens",statTotalTokens:"Total Tokens",statCacheHit:e=>`cache hit rate ${e}`,statElapsed:"Elapsed",statInput:"Input tokens",statCached:"cached",statOutput:"Output tokens",statTps:"Output TPS",statParenOpen:" (",statParenClose:")",noSessions:"No Sessions yet",emptyStream:"Send a message to start the conversation",historyLoadFailed:"Failed to load history",statsLabel:"Stats",removeImage:"Remove image",openAgents:"Agents panel",workspacePanel:"Workspace",filesInMessage:e=>`${e} ${e===1?"file":"files"}`,imagesInMessage:e=>`${e} ${e===1?"image":"images"}`,openPreview:"Click to preview",showMoreFiles:e=>`Show ${e} more ${e===1?"file":"files"}`,showLess:"Show less",memoryChangesTitle:e=>`${e} memory ${e===1?"update":"updates"}`,memoryScopeWorkspace:e=>`Workspace memory (${e})`,memoryOpWrite:"Wrote",memoryOpEdit:"Edited",memoryViewTitle:"Memory",memoryChangedMark:"Changed in this conversation",memoryContentUnavailable:"Content unavailable (the file may have been moved or deleted)",memoryRowOpen:"View content",memoryBack:"Back to the list",memoryEmptyAll:"No memory yet — say “remember …” in a chat to have the agent save one",openAgentMemory:"Manage in agent settings",memoryShowMore:e=>`Show ${e} more`,prevGroupPage:"Previous groups",nextGroupPage:"Next groups",groupPagePosition:(e,t)=>`Page ${e} of ${t}`,contextUsage:"Context usage",contextUnknown:"Context usage: unknown until the next request reports it",contextComposition:"Context composition",contextPartSystemPrompt:"System prompt",contextPartToolDefs:"Tool definitions",contextPartUserMessages:"User messages",contextPartAssistantMessages:"Model messages",contextPartToolRequests:"Tool requests",contextPartToolResults:"Tool results",contextTopTools:"Top 5 tools",contextCompactAt:e=>`Compaction threshold ${e}`,contextTopToolsHint:"Ranked by the context each tool's calls and results occupy (definitions count under “Tool definitions”)",contextUnknownHint:"Just compacted — the next request reports the usage, and the composition with it",contextBreakdownEmpty:"Nothing in the current context to break down yet",contextBreakdownFailed:"Could not read the context composition",slashHint:"Type / for commands",switchAgent:"Hand off to another agent — opens a new session on send",switchAgentTitle:"Choose agent",agentSearchPlaceholder:"Search agents: id / name",agentsNoMatch:"No matching agents",handoffTargetTitle:e=>`Sending hands this conversation to ${e}`,handoffRemove:"Remove handoff target",skillsSelect:"Skills",skillRemove:"Remove skill",skillsSearchPlaceholder:"Search skills",skillsNoMatch:"No matching skills",skillsEmptyHint:"No skills installed yet — add some from the skill library",skillsAutoMessage:e=>e.length===1?`use the ${e[0]} skill`:`use the ${e.join(", ")} skills`,handoffFrom:e=>`Handed off from ${e}'s conversation`,handoffBack:e=>e?`Back to the original conversation: ${e}`:"Back to the original conversation",switchModel:"Switch model — on send, continues this conversation in a new session",switchModelTitle:"Switch model",modelSwitchTargetTitle:e=>`Sending continues this conversation on ${e}`,modelSwitchRemove:"Remove model switch",modelSwitchBusyHint:"The model switch waits for this turn to finish: the new session continues from this session's record",modelSwitchFrom:e=>e?`Switched model (was ${e}) — continued from the earlier conversation`:"Switched model — continued from the earlier conversation",modelSwitchAutoMessage:"Continue this conversation on the new model",modelLockedHint:"Type /model to switch models",scheduledFrom:e=>`Triggered by scheduled task "${e}"`,backgroundDone:(e,t)=>{const n=e==="command"?"Background command":"Background task";return t==="stopped"?`${n} stopped`:t==="completed"?`${n} finished`:`${n} failed`},emptyGreeting:"Start a new conversation",mcpConnectTitle:"MCP connect",mcpServerList:e=>e.join(", "),mcpConnectResult:(e,t)=>{const n=[];return(e>0||t.length===0)&&n.push(`${e} tool${e===1?"":"s"} discovered`),t.length>0&&n.push(`unavailable: ${t.join(", ")}`),n.join("; ")},mcpToolsCount:e=>`${e} tool${e===1?"":"s"}`,mcpServerFailed:"connection failed",mcpConnectAborted:"interrupted — reconnects on the next send",compactionTitle:e=>e==="discard"?"Clear":"Compaction",compactionFailed:(e,t)=>{if(e==="aborted")return"aborted, keeping current context";const n=t!==void 0?` (${t})`:"";return e==="retryable"?`failed${n}, keeping current context; retries at the next trigger`:e==="fatal"?`failed${n}, keeping current context; fix the model configuration to retry`:`failed${n}, keeping current context`},unknownTool:"(unknown tool)",workRunning:"Running",workDone:"Done",workGroupSteps:e=>`${e} ${e===1?"step":"steps"}`,approvalWaiting:"awaiting approval",copyCode:"Copy code",copyReply:"Copy reply",forkSession:"Fork chat from here",forkSessionConfirmBody:"This copies the conversation up to this reply into a new chat. The original chat stays unchanged.",forkSessionConfirmAction:"Fork",forkSessionFailed:"This reply could not be located. Refresh and try again.",copyMessage:"Copy message",deleteSession:"Delete chat",renameSession:"Rename chat",renameSessionLabel:"Title",deleteSessionConfirm:e=>`Delete "${e}"? Its messages and Trace will be removed permanently.`,draftGroup:"Drafts",draftUntitled:"(untitled draft)",deleteDraft:"Delete draft",deleteDraftConfirm:e=>`Delete draft "${e}"? Unsent content will be discarded.`,archiveSession:"Archive",unarchiveSession:"Unarchive",pinSession:"Pin",unpinSession:"Unpin",pinnedSession:"Pinned",moreActions:"More",loadMore:"More",expandRestSessions:e=>`Show ${e} more ${e===1?"chat":"chats"}`,loadMoreSessions:"Load more chats",folderGroups:{subagent:e=>`Subagents (${e})`,schedule:e=>`Scheduled (${e})`,archived:e=>`Archived (${e})`},skillsBanner:e=>`Using skill${e.length===1?"":"s"}: ${e.join(", ")}`,attachedFilesBanner:e=>`Attached file${e.length===1?"":"s"}: ${e.join(", ")}`,plusMenu:"More input options",uploadImage:"Upload image",uploadImageDesc:"Attach images to this message",uploadFile:"Upload file",uploadFileDesc:"Saved to the session scratchpad; the model reads them by path",removeFile:"Remove file",attachmentTooLarge:(e,t)=>`${e} exceeds the ${t}MB limit and was not attached.`,dropFilesTitle:"Drop files to attach",dropFilesDesc:"Images and files are added to the message draft",dropFilesGoalHint:"Goal mode takes images only; the files were not attached.",goalMode:"Goal mode",goalModeDesc:"Loop until the goal completes",goalBudgetLabel:"Token budget",goalBudgetUnlimited:"Budget unlimited",goalBudgetValue:e=>`Budget ${e}`,goalBudgetPlaceholder:"e.g. 500k",goalBudgetHint:"Use a k/m suffix; leave blank for no budget limit",goalBudgetInvalid:"Invalid budget: use a positive number with an optional k/m suffix (500k, 2m)",goalBudgetSave:"Save budget",goalRemove:"Exit goal mode",goalRoundBanner:e=>`Goal · round ${e}`,goalRoundImages:e=>e===1?"1 attached image":`${e} attached images`,goalProgress:(e,t)=>`round ${e} · tokens ${t}`,goalStatus:{active:"running",complete:"complete",blocked:"blocked",budget_limited:"budget exhausted",aborted:"interrupted"}},feishu:{intro:"Once bound, messages sent to the Feishu bot flow into this conversation, and the AI's replies are sent back to Feishu as plain text. You need a self-built Feishu app with the bot capability and the message-receive event subscribed in long-connection mode.",appId:"App ID",appSecret:"App Secret",appSecretKeepHint:"Leave empty to keep the saved App Secret",clearSecret:"Clear stored App Secret",baseDomain:"API domain",baseDomainHint:"https://open.feishu.cn for Feishu, https://open.larksuite.com for Lark",invalidDomain:"The domain must be an http(s) URL",testMessageNoChat:"Message the bot once in Feishu first, so it knows which chat to send to",setupSteps:["Create a self-built app in the Feishu developer console","Enable the bot capability for the app","Subscribe to the message-receive event, with the subscription mode set to long connection","Copy the App ID and App Secret from the credentials page into the form above","Publish an app version, get it approved, then message the bot once in Feishu"]},telegram:{intro:"Once bound, messages sent to the Telegram bot flow into this conversation, and the AI's replies are sent back to Telegram as plain text. Create a bot with @BotFather and paste its Bot Token — no public URL is needed.",botToken:"Bot Token",botTokenKeepHint:"Leave empty to keep the saved Bot Token",clearToken:"Clear stored Bot Token",invalidToken:"The Bot Token looks like <digits>:<secret>, as issued by @BotFather",testMessageNoChat:"Message the bot once in Telegram first, so it knows which chat to send to",setupSteps:["Open @BotFather in Telegram and send /newbot to create a bot","Name it as prompted, then copy the Bot Token @BotFather returns into the form above","Find the bot in Telegram and send it one message"]},messaging:{panelTitle:"Messaging",bindAction:"Messaging binding…",dialogTitle:"Messaging binding",channelLabel:"Channel",channelName:{feishu:"Feishu",telegram:"Telegram"},tutorial:"Open tutorial",console:"Open developer console",enabled:"Enable connection",saveBeforeEnable:"Save the credentials first, then enable the connection",test:"Test connection",testing:"Testing…",testOk:e=>`Connected (${e}ms)`,testOkAs:(e,t)=>`Connected as ${e} (${t}ms)`,testFail:e=>`Connection failed: ${e}`,sendTestMessage:"Send test message",sendingTestMessage:"Sending…",testMessageSent:"Test message sent",statusLabel:"Connection status",status:{disconnected:"Not connected",connecting:"Connecting",connected:"Connected",error:"Connection error"},otherEnabledHint:e=>`Only one channel can be enabled per conversation: turn off the ${e} connection first`,credentialMissingHint:"Enter and save the credential first, then enable the connection",disableBeforeClearHint:"Disable the connection before clearing the credential",enabledIndicator:{feishu:"Feishu connection enabled",telegram:"Telegram connection enabled"},faqSetupTitle:"Set up the bot",faqWhatTitle:"What binding does",faqTroubleTitle:"Troubleshooting",troubleNoChat:"“Send test message” disabled? The bot must have received one message first, so it knows which chat to send to.",troubleConnError:"Connection status shows an error? Check the credentials; for Feishu also confirm the API domain and the long-connection event subscription.",troubleOnePoller:"Telegram reports that another program is polling? A Bot Token serves exactly one program at a time — close the other PenguinHarness server or bot script using it, or give this conversation a bot of its own."},subagentPanel:{topologyLabel:"Call graph",mainSessionNote:"The main conversation stays in the chat area",empty:"No subagents in the current task yet",nodeRunning:"running",nodeDone:"done",openAsSession:"Jump to this session",subagentGone:"This subagent session no longer exists and could not be revived"},files:{title:"Files",upload:"Upload",download:"Download",openInNewTab:"Open in new tab",previewNotIsolatedHint:"This address has no separate preview origin, so the page opens sandboxed: localStorage, cookies and third-party embeds will not work. Reach the app over 127.0.0.1 or localhost, or set PENGUIN_PREVIEW_ORIGIN.",refresh:"Refresh",root:"Workspace root",empty:"Empty directory",previewUnsupported:"Preview not supported for this type; download instead",uploaded:"Uploaded",overwriteTitle:"Overwrite existing files",overwriteConfirm:e=>`The current directory already has ${e} file(s) with these names — uploading will overwrite:`,loadFailed:"Failed to load",previewTruncated:"File too large; preview truncated, download for the full file",details:"Details",workspacePath:"Workspace path",htmlRendered:"Rendered",htmlSource:"Source",backToList:"Back to list"},usage:{title:"Costs & usage",today:"Today",last7d:"Last 7 days",total:"Total",tokens:"Tokens",requests:"Requests",from:"From",to:"To",colCacheRead:"cache_read",colCacheWrite:"cache_write",colOutput:"output",uncostedNote:"* Only models with configured pricing count toward cost",filterAllAgents:"All agents",filterAllModels:"All models",rangeLabel:"Date range",rangeHour:"Last hour",rangeDay:"Last 24 hours",range7d:"Last 7 days",range30d:"Last 30 days",range90d:"Last 90 days",rangeCustom:"Custom",chartRequestsByAgent:"Requests & success rate by agent",chartRequestsByModel:"Requests & success rate by model",legendSuccessRate:"Success rate",chartTokenTrend:"Token trend",chartCostTrend:"Cost trend",legendOther:e=>`Other (${e})`,bucketTotal:"Total",legendHitRate:"Cache hit rate",empty:"No usage records",errors:"Errors",errorsTotal:"Total",errorsUnexpected:"Unexpected",errorsExpected:"Expected",errorsTopCode:"Most common",errorsColCode:"Source · code",errorsColKind:"Type",errorsColMessage:"Message",errorsEmpty:"No errors",errorsNewer:"Newer",errorsOlder:"Older",errorsPageOf:(e,t,n)=>`Page ${e} / ${t} · ${n} total`},traces:{timeline:"Execution timeline",laneLLM:"Model",kindThinking:"thinking",kindModelReply:"model reply",kindToolGen:"tool call gen",legendToolExec:"tool exec",legendOther:"Other",toolParams:"Parameter schema",requiredParam:"required",legendApprovalWait:"approval wait",task:e=>`Turn ${e}`,globalSummary:"Overall",tasksLabel:"Turns",messages:"Messages",truncatedNote:(e,t)=>`Showing first ${e} / ${t} messages`,zoom:"Zoom",zoomReset:"Double-click to reset zoom",zoomOut:"Zoom out",zoomIn:"Zoom in",linkHint:"Hover a timeline segment or event row to cross-highlight, click a segment to jump to its message; legend highlights its kind; drag the bar below to pan/zoom",filesTitle:"Trace files",toolCalls:"Tool calls",taskInput:"Input tokens this turn",taskOutput:"Output tokens this turn",cacheHit:"Cache hits",hitRate:"Hit rate",compactions:"compactions",inProgress:"in progress",systemPrompt:"System prompt",toolDefs:e=>`Tool definitions (${e})`,exportFile:"Export"},benchmark:{title:"Evaluation Center",selectBenchmark:"Select a Benchmark on the left",emptyAgent:"No Benchmarks for this agent",caseCount:e=>`${e} case${e===1?"":"s"}`,trendTitle:e=>`${e} over time`,cases:"Cases",viewCase:"View details",taskMaterials:"Task materials",rubric:"Scoring rubric",agentHidden:"Hidden from Target Agent",caseFileUnavailable:"Case files are unavailable",evaluations:"Evaluations",noEvaluations:"No evaluations yet",summaryLabel:"Summary",legendUnlabeled:"unlabeled model",colVersion:"Version",colModel:"Model ID",colThinkingLevel:"Thinking level",colScore:"Score",colDuration:"Duration",colCase:"Case",colRun:"Run",colSession:"Session"},errors:{networkError:"Network error, please check your connection",modelCredentialMissing:e=>`Model ${e} has no API key yet — configure it on the Models page first`,noDefaultModel:"This project has no default model yet — add one on the Models page first",byCode:{invalid_credentials:"Incorrect username or password.",too_many_attempts:"Too many failed sign-in attempts. Try again shortly.",password_mismatch:"The current password is incorrect.",invalid_password:"Password must be at least 8 characters.",admin_required:"Only an admin can perform this operation.",desktop_single_user:"The desktop app is single-user; user management is unavailable.",not_found:"This resource does not exist, or you do not have access.",internal:"The server hit an internal error. Please try again shortly.",agent_not_found:"This agent no longer exists.",unknown_agent:"That agent does not exist in this Project.",agent_exists:"This agent id is already taken.",agent_deleting:"This agent is being deleted.",project_exists:"This Project id is already taken.",project_not_found:"This Project no longer exists, or you do not have access.",cannot_delete_last_project:"This is the last Project and cannot be deleted.",user_exists:"This username is already taken.",user_not_found:"This user no longer exists.",cannot_delete_admin:"The built-in admin cannot be deleted.",member_not_found:"This user is not a member of the Project.",already_member:"This user is already a member of the Project.",already_owner:"This user is already an owner of the Project.",memory_import_confirm_required:"This import would overwrite or delete memories. Confirm it to continue.",schedule_exists:"A scheduled task with this name already exists.",schedule_not_found:"This scheduled task no longer exists.",unknown_skill:"This skill is not in the library.",skill_too_large:"This skill directory exceeds the import limits.",file_not_found:"This file no longer exists.",not_pending:"This steering message already reached the model and can no longer be recalled.",follow_up_started:"This follow-up already started and can no longer be recalled.",file_too_large:"The file is too large.",too_many_files:"Too many files attached to one message.",payload_too_large:"The request is too large.",image_too_large:"The image is too large to send inline.",dir_not_absolute:"The directory must be an absolute path.",dir_not_found:"That directory does not exist or is inaccessible.",not_a_dir:"That path is not a directory.",path_not_found:"That path does not exist.",workspace_missing:"This Session's Workspace no longer exists.",workspace_not_found:"That Workspace does not exist, or is not a directory.",session_not_found:"This Session no longer exists, or you do not have access.",session_deleting:"This Session is being deleted.",approval_not_found:"This approval request was already answered, or is no longer valid.",process_not_found:"This background process already exited, or was removed.",process_running:"This background process is still running — stop it before removing it.",memory_file_not_found:"This memory file no longer exists.",memory_scope_not_found:"This memory scope no longer exists.",task_in_progress:"This Session already has a task running.",compacting:"This Session is compacting its context and is not accepting new input.",shutting_down:"The server is shutting down. Please try again shortly.",compaction_not_configured:"This agent does not have context compaction configured.",nothing_to_compact:"There is nothing to compact in the current context yet (no completed conversation turn).",already_compacted:"The context was just compacted and nothing has been said since — no need to compact again.",version_conflict:"The snapshot's version is not newer than the current one.",invalid_title:"The title is invalid.",invalid_proxy_url:"Invalid proxy address — use an http(s):// or socks5:// proxy URL, or host[:port].",invalid_attachment_limit:"Invalid upload limit — use a whole number of MB inside the allowed range, with the total no lower than the per-file limit.",invalid_trace:"This file is not a valid Trace file.",trace_not_found:"This Trace file no longer exists.",trace_session_exists:"This agent already has a Session with that id; a duplicate Trace cannot be imported.",feishu_app_in_use:"This Feishu app is already bound to another Session — unbind it there or use a different app.",feishu_secret_required:"App Secret is required.",feishu_not_bound:"This Session has no Feishu binding yet.",feishu_no_chat:"No Feishu message received yet — message the bot once in Feishu first.",feishu_send_failed:"Sending the Feishu message failed.",telegram_bot_in_use:"This Telegram bot is already bound to another Session — unbind it there or use a different bot.",telegram_token_required:"Bot Token is required.",telegram_token_invalid:"The Bot Token is malformed: it looks like <digits>:<secret>.",telegram_not_bound:"This Session has no Telegram binding yet.",telegram_no_chat:"No Telegram message received yet — message the bot once in Telegram first.",telegram_send_failed:"Sending the Telegram message failed.",another_channel_enabled:"Another channel's connection is enabled on this conversation: disable it first.",messaging_disable_before_clear:"Disable this channel's connection before clearing its credential."}}},Pj="penguin.lang",zj=y.createContext(null);function Y3(e){return e?.toLowerCase().startsWith("zh")?"zh":"en"}function X3(){return Y3(navigator.language)}function Q3(e){return e==="system"?X3():e}function Z3(){const e=localStorage.getItem(Pj);return e==="zh"||e==="en"||e==="system"?e:"system"}function J3({children:e}){const[t,n]=y.useState(Z3),[,s]=y.useState(0),o=Q3(t);K3(o==="en"?W3:Uj),y.useEffect(()=>{if(t!=="system")return;const u=()=>s(f=>f+1);return window.addEventListener("languagechange",u),()=>window.removeEventListener("languagechange",u)},[t]);const c=y.useCallback(u=>{localStorage.setItem(Pj,u),n(u)},[]);return a.jsx(zj.Provider,{value:{lang:t,locale:o,setLang:c},children:e})}function eE({children:e}){const{locale:t}=Dr();return a.jsx("div",{className:"contents",children:e},t)}function Dr(){const e=y.useContext(zj);if(!e)throw new Error("useLocale must be used within a LocaleProvider");return e}const wx=7,Bj="penguin.theme",Hj="penguin.fontScale",Fj="penguin.accent",qj="penguin.currency",Vj="penguin.terminal.theme",tE={sm:"16px",md:"18px",lg:"20px"},Gj=y.createContext(null);function nE(){const e=localStorage.getItem(Bj);return e==="light"||e==="dark"||e==="system"?e:"system"}function rE(){const e=localStorage.getItem(Hj);return e==="sm"||e==="md"||e==="lg"?e:"md"}function aE(){const e=localStorage.getItem(Fj);return e==="neutral"||e==="blue"||e==="green"||e==="violet"||e==="rose"||e==="amber"?e:"neutral"}function sE(){const e=localStorage.getItem(Vj);return e==="light"||e==="dark"||e==="app"?e:"app"}function iE(){return localStorage.getItem(qj)==="CNY"?"CNY":"USD"}function oE(){return window.matchMedia("(prefers-color-scheme: dark)").matches}function lE({children:e}){const[t,n]=y.useState(nE),[s,o]=y.useState(oE),[c,u]=y.useState(rE),[f,p]=y.useState(aE),[h,x]=y.useState(iE),[g,v]=y.useState(sE),w=t==="system"?s:t==="dark",S=g==="app"?w:g==="dark";y.useEffect(()=>{document.documentElement.classList.toggle("dark",w)},[w]),y.useEffect(()=>{document.documentElement.style.fontSize=tE[c]},[c]),y.useEffect(()=>{f==="neutral"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=f},[f]),y.useEffect(()=>{if(t!=="system")return;const D=window.matchMedia("(prefers-color-scheme: dark)"),z=E=>o(E.matches);return o(D.matches),D.addEventListener("change",z),()=>D.removeEventListener("change",z)},[t]);const C=y.useCallback(D=>{localStorage.setItem(Bj,D),n(D)},[]),N=y.useCallback(D=>{localStorage.setItem(Hj,D),u(D)},[]),T=y.useCallback(D=>{localStorage.setItem(Fj,D),p(D)},[]),_=y.useCallback(D=>{localStorage.setItem(qj,D),x(D)},[]),R=y.useCallback(D=>{localStorage.setItem(Vj,D),v(D)},[]);return a.jsx(Gj.Provider,{value:{mode:t,dark:w,setMode:C,fontScale:c,setFontScale:N,accent:f,setAccent:T,currency:h,setCurrency:_,terminalMode:g,setTerminalMode:R,terminalDark:S},children:e})}function as(){const e=y.useContext(Gj);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}const cE=[{value:"neutral",color:"#6b7280"},{value:"blue",color:"#2563eb"},{value:"green",color:"#15803d"},{value:"violet",color:"#7c3aed"},{value:"rose",color:"#be123c"},{value:"amber",color:"#b45309"}];class xr extends Error{status;code;constructor(t,n,s){super(s),this.name="ApiError",this.status=t,this.code=n}}let Kj=null;function H1(e){Kj=e}function uE(e){return e.startsWith("/api/auth/")}async function Ee(e,t={}){return(await Wj(e,t)).data}async function Wj(e,t={}){let n=e;if(t.query){const f=new URLSearchParams;for(const[h,x]of Object.entries(t.query))x!==void 0&&f.set(h,String(x));const p=f.toString();p&&(n+=`?${p}`)}let s;try{s=await fetch(n,{method:t.method??"GET",credentials:"same-origin",...t.body!==void 0?{headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:{}})}catch{throw new xr(0,"network_error",d.errors.networkError)}if(!s.ok){let f="http_error",p=d.common.unknownError;try{const h=await s.json();h.error?.code&&(f=h.error.code),h.error?.message&&(p=h.error.message)}catch{}throw s.status===401&&!uE(e)&&Kj?.(),new xr(s.status,f,p)}const o=Date.parse(s.headers.get("date")??""),c=Number.isFinite(o)?o:null;if(s.status===204)return{data:void 0,serverNowMs:c};const u=await s.text();return u?{data:JSON.parse(u),serverNowMs:c}:{data:void 0,serverNowMs:c}}const dE=e=>Ee("/api/auth/login",{method:"POST",body:e}),mE=()=>Ee("/api/auth/logout",{method:"POST",body:{}}),qm=()=>Ee("/api/me"),fE=e=>Ee("/api/me/password",{method:"PUT",body:e}),Sx=()=>Ee("/api/me/prefs"),Nf=e=>Ee("/api/me/prefs",{method:"PUT",body:e}),pE=()=>Ee("/api/admin/users"),hE=e=>Ee("/api/admin/users",{method:"POST",body:e}),gE=(e,t)=>Ee(`/api/admin/users/${encodeURIComponent(e)}/password`,{method:"POST",body:t}),xE=e=>Ee(`/api/admin/users/${encodeURIComponent(e)}`,{method:"DELETE"}),Yj=()=>Ee("/api/admin/settings"),Xj=e=>Ee("/api/admin/settings",{method:"PUT",body:e}),yE=()=>Ee("/api/projects"),bE=e=>Ee("/api/projects",{method:"POST",body:e}),vE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:t}),kE=e=>Ee(`/api/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),mg=e=>Ee(`/api/projects/${encodeURIComponent(e)}/members`),wE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/members`,{method:"POST",body:t}),SE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:"DELETE"}),Qj=e=>Ee(`/api/projects/${encodeURIComponent(e)}/chat-defaults`),jE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/chat-defaults`,{method:"PUT",body:t}),CE=e=>Ee(`/api/projects/${encodeURIComponent(e)}/command-policy`),NE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/command-policy`,{method:"PUT",body:t}),Ml=e=>Ee(`/api/projects/${encodeURIComponent(e)}/models`),TE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models`,{method:"PUT",body:t}),ME=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models/default`,{method:"PUT",body:t}),Zj=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models/test`,{method:"POST",body:t}),Jj=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models/detect`,{method:"POST",body:t}),EE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models/list`,{method:"POST",body:t}),AE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/models/detect-vision`,{method:"POST",body:t}),_E=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/model-oauth/start`,{method:"POST",body:t}),RE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/model-oauth/${encodeURIComponent(t)}`),IE=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/model-oauth/${encodeURIComponent(t)}/code`,{method:"POST",body:{code:n}}),LE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault`),OE=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault`,{method:"PUT",body:n}),DE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault/template-placeholder`,{method:"POST",body:{}}),$E=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/template-placeholder`,{method:"POST",body:{}}),UE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/template-placeholder`,{method:"POST",body:{}}),Tf=(e,t)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/memory`,jx=(e,t,n)=>`${Tf(e,t)}/scopes/${encodeURIComponent(n)}/files`,eC=(e,t)=>Ee(Tf(e,t)),PE=(e,t)=>Ee(`${Tf(e,t)}/template-placeholder`,{method:"POST",body:{}}),tC=(e,t,n)=>Ee(jx(e,t,n)),nC=(e,t,n,s)=>Ee(`${jx(e,t,n)}/${encodeURIComponent(s)}`),zE=(e,t,n,s)=>Ee(`${jx(e,t,n)}/${encodeURIComponent(s)}`,{method:"DELETE"}),rC=(e,t,n)=>`${Tf(e,t)}/scopes/${encodeURIComponent(n)}`,BE=(e,t,n)=>Ee(`${rC(e,t,n)}/export`),HE=(e,t,n,s)=>Ee(`${rC(e,t,n)}/import`,{method:"POST",body:s}),aC=e=>Ee(`/api/projects/${encodeURIComponent(e)}/agents`),FE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents`,{method:"POST",body:t}),Ao=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config`),To=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config`,{method:"PUT",body:n}),F1=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/mcp-test`,{method:"POST",body:n}),qE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/reset`,{method:"POST"}),VE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/kernel-update`,{method:"POST"}),c0=(e,t,n)=>{const s=n?`?limit=${n.limit}&offset=${n.offset}`+(n.category?`&category=${n.category}`:"")+(n.workspaceGroup?`&workspaceGroup=${encodeURIComponent(n.workspaceGroup)}`:"")+(n.withCounts?"&counts=1":""):"";return Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/sessions${s}`)},GE=(e,t="")=>Ee(`/api/projects/${encodeURIComponent(e)}/dirs?path=${encodeURIComponent(t)}`),KE=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/dir-skills?path=${encodeURIComponent(t)}`),u0=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/sessions`,{method:"POST",body:n}),WE=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/fork`,{method:"POST",body:t}),d0=e=>Ee(`/api/sessions/${encodeURIComponent(e)}`),tf=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:t}),nf=e=>Ee(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"}),YE=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/messaging`),XE=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/messaging/feishu`,{method:"PUT",body:t}),QE=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/messaging/telegram`,{method:"PUT",body:t}),ZE=(e,t,n)=>Ee(`/api/sessions/${encodeURIComponent(e)}/messaging/${t}/state`,{method:"POST",body:{enabled:n}}),JE=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/messaging/feishu/test`,{method:"POST",body:t}),eA=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/messaging/telegram/test`,{method:"POST",body:t}),tA=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/messaging/${t}/test-message`,{method:"POST",body:{}}),sC=(e,t)=>{const n=t===void 0?"":t.kind==="tail"?`?tailLimit=${t.limit}`:`?before=${encodeURIComponent(t.cursor)}&limit=${t.limit}`;return Wj(`/api/sessions/${encodeURIComponent(e)}/messages${n}`).then(({data:s,serverNowMs:o})=>({...s,serverNowMs:o}))},su=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/tasks`,{method:"POST",body:t}),nA=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/goal`),rA=(e,t,n)=>Ee(`/api/sessions/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:n}),aA=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/abort`,{method:"POST",body:{}}),sA=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/retry-now`,{method:"POST",body:{}}),q1=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/processes`),iA=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/kill`,{method:"POST",body:{}}),oA=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}`,{method:"DELETE"}),lA=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/steer`,{method:"POST",body:t}),cA=(e,t,n,s)=>Ee(`/api/sessions/${encodeURIComponent(e)}/subagents/${encodeURIComponent(t)}/message`,{method:"POST",body:{text:n,...s?{thinkingLevel:s}:{}}}),uA=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/subagents/${encodeURIComponent(t)}/abort`,{method:"POST",body:{}}),dA=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/steer/${encodeURIComponent(t)}`,{method:"DELETE"}),mA=(e,t)=>Ee(`/api/sessions/${encodeURIComponent(e)}/follow-ups/${encodeURIComponent(t)}`,{method:"DELETE"}),fA=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/compact`,{method:"POST",body:{}}),pA=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/context`),hA=e=>Ee(`/api/sessions/${encodeURIComponent(e)}/traces`),gA=(e,t,n,s,o,c)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(n)}/${s}`,{query:{offset:o,limit:c}}),xA=(e,t,n,s)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(n)}/${s}/analysis`),yA=(e,t,n,s)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(n)}/${s}/download`,bA=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/import`,{method:"POST",body:n}),vA=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/usage/errors`,{query:{offset:String(t.offset),limit:String(t.limit),from:t.from,to:t.to,agentId:t.agentId}}),iC=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/usage`,{query:{from:t.from,to:t.to,fromTs:t.fromTs,toTs:t.toTs,groupBy:t.groupBy,granularity:t.granularity,agentId:t.agentId,provider:t.provider,modelId:t.modelId}}),kA=(e,t)=>Ee(`/api/projects/${e}/agents/${t}`,{method:"DELETE"}),wA=(e,t)=>Ee(`/api/sessions/${e}/files`,{query:{path:t}}),ji=(e,t,n=!1)=>`/api/sessions/${e}/files/content?path=${encodeURIComponent(t)}${n?"&download=1":""}`,V1=(e,t)=>`/api/sessions/${e}/files/preview-redirect?path=${encodeURIComponent(t)}`,SA=(e,t,n)=>Ee(`/api/sessions/${e}/files/content`,{method:"PUT",body:{dataBase64:n},query:{path:t}}),jA=(e,t)=>Ee(`/api/sessions/${e}/files/stat`,{method:"POST",body:{paths:t}}),CA=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules`),NA=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules`,{method:"POST",body:n}),G1=(e,t,n,s)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/${encodeURIComponent(n)}`,{method:"PUT",body:s}),TA=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/${encodeURIComponent(n)}`,{method:"DELETE"}),oC=()=>Ee("/api/skills"),Bu=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills`),K1=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills`,{method:"POST",body:{names:n}}),MA=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/archive`,{method:"POST",body:n}),EA=(e,t,n)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/${encodeURIComponent(n)}/archive`,lC=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/${encodeURIComponent(n)}`,{method:"DELETE"}),AA=(e,t)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks`),_A=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks/${encodeURIComponent(n)}/cases`),cC=(e,t,n,s,o)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks/${encodeURIComponent(n)}/cases/${encodeURIComponent(s)}${o==="rubric"?"/rubric":""}/files`,RA=(e,t,n,s,o,c)=>Ee(cC(e,t,n,s,c),{query:{path:o}}),IA=(e,t,n,s,o,c,u)=>`${cC(e,t,n,s,c)}/content?path=${encodeURIComponent(o)}`+(u?.download?"&download=1":"")+(u?.preview&&!u.download?"&preview=1":""),LA=(e,t)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/export`,OA=(e,t,n)=>Ee(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/import`,{method:"POST",body:n}),DA=()=>Ee("/api/version"),uC=(e=!1)=>Ee(`/api/version/update-check${e?"?force=1":""}`),$A=()=>Ee("/api/version/update",{method:"POST",body:{}}),UA=()=>Ee("/api/desktop/update"),PA=()=>Ee("/api/desktop/update/check",{method:"POST",body:{}}),zA=()=>Ee("/api/desktop/update/install",{method:"POST",body:{}}),BA={attachmentMaxMb:100,attachmentTotalMb:120,attachmentMaxCount:20,imageMaxMb:20,attachmentLimitMinMb:1,attachmentLimitMaxMb:200},dC=y.createContext(null);function HA({children:e}){const[t,n]=y.useState(void 0),[s,o]=y.useState(!0),[c,u]=y.useState(!1),[f,p]=y.useState("password"),[h,x]=y.useState(BA);y.useEffect(()=>(H1(()=>n(null)),()=>H1(null)),[]),y.useEffect(()=>{let S=!1;return qm().then(C=>{S||(n(C.user),o(C.previewIsolated),u(C.desktopMode),p(C.sessionVia),x(C.uploadLimits))}).catch(C=>{S||(C instanceof xr&&C.status,n(null))}),()=>{S=!0}},[]);const g=y.useCallback(async(S,C)=>{const N=await dE({userId:S,password:C});n(N.user);try{const T=await qm();n(T.user),o(T.previewIsolated),u(T.desktopMode),p(T.sessionVia),x(T.uploadLimits)}catch{}},[]),v=y.useCallback(async()=>{try{await mE()}finally{n(null)}},[]),w=y.useCallback(async()=>{const S=await qm();n(S.user),o(S.previewIsolated),u(S.desktopMode),p(S.sessionVia),x(S.uploadLimits)},[]);return a.jsx(dC.Provider,{value:{user:t,previewIsolated:s,desktopMode:c,sessionVia:f,uploadLimits:h,login:g,logout:v,refresh:w},children:e})}function mn(){const e=y.useContext(dC);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const Cx=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,mC=/^[\\/]{2}/;function FA(e,t){return t+e.replace(/\\/g,"/")}const W1="popstate";function Y1(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function qA(e={}){function t(s,o){let c=o.state?.masked,{pathname:u,search:f,hash:p}=c||s.location;return m0("",{pathname:u,search:f,hash:p},o.state&&o.state.usr||null,o.state&&o.state.key||"default",c?{pathname:s.location.pathname,search:s.location.search,hash:s.location.hash}:void 0)}function n(s,o){return typeof o=="string"?o:bu(o)}return GA(t,n,null,e)}function wn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Cs(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function VA(){return Math.random().toString(36).substring(2,10)}function X1(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function m0(e,t,n=null,s,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ul(t):t,state:n,key:t&&t.key||s||VA(),mask:o}}function bu({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Ul(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function GA(e,t,n,s={}){let{window:o=document.defaultView,v5Compat:c=!1}=s,u=o.history,f="POP",p=null,h=x();h==null&&(h=0,u.replaceState({...u.state,idx:h},""));function x(){return(u.state||{idx:null}).idx}function g(){f="POP";let N=x(),T=N==null?null:N-h;h=N,p&&p({action:f,location:C.location,delta:T})}function v(N,T){f="PUSH";let _=Y1(N)?N:m0(C.location,N,T);h=x()+1;let R=X1(_,h),D=C.createHref(_.mask||_);try{u.pushState(R,"",D)}catch(z){if(z instanceof DOMException&&z.name==="DataCloneError")throw z;o.location.assign(D)}c&&p&&p({action:f,location:C.location,delta:1})}function w(N,T){f="REPLACE";let _=Y1(N)?N:m0(C.location,N,T);h=x();let R=X1(_,h),D=C.createHref(_.mask||_);u.replaceState(R,"",D),c&&p&&p({action:f,location:C.location,delta:0})}function S(N){return KA(o,N)}let C={get action(){return f},get location(){return e(o,u)},listen(N){if(p)throw new Error("A history only accepts one active listener");return o.addEventListener(W1,g),p=N,()=>{o.removeEventListener(W1,g),p=null}},createHref(N){return t(o,N)},createURL:S,encodeLocation(N){let T=S(N);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:v,replace:w,go(N){return u.go(N)}};return C}function KA(e,t,n=!1){let s="http://localhost";e&&(s=e.location.origin!=="null"?e.location.origin:e.location.href),wn(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:bu(t);return o=o.replace(/ $/,"%20"),!n&&mC.test(o)&&(o=s+o),new URL(o,s)}function fC(e,t,n="/"){return WA(e,t,n,!1)}function WA(e,t,n,s,o){let c=Ri((typeof t=="string"?Ul(t):t).pathname||"/",n);if(c==null)return null;let u=YA(e),f=null,p=yC(c);for(let h=0;f==null&&h<u.length;++h)f=o_(u[h],p,s);return f}function YA(e){let t=pC(e);return XA(t),t}function pC(e,t=[],n=[],s="",o=!1){let c=(u,f,p=o,h)=>{let x={relativePath:h===void 0?u.path||"":h,caseSensitive:u.caseSensitive===!0,childrenIndex:f,route:u};if(x.relativePath.startsWith("/")){if(!x.relativePath.startsWith(s)&&p)return;wn(x.relativePath.startsWith(s),`Absolute route path "${x.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),x.relativePath=x.relativePath.slice(s.length)}let g=Za([s,x.relativePath]),v=n.concat(x);u.children&&u.children.length>0&&(wn(u.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${g}".`),pC(u.children,t,v,g,p)),!(u.path==null&&!u.index)&&t.push({path:g,score:s_(g,u.index),routesMeta:v.map((w,S)=>{let[C,N]=xC(w.relativePath,w.caseSensitive,S===v.length-1);return{...w,matcher:C,compiledParams:N}})})};return e.forEach((u,f)=>{if(u.path===""||!u.path?.includes("?"))c(u,f);else for(let p of hC(u.path))c(u,f,!0,p)}),t}function hC(e){let t=e.split("/");if(t.length===0)return[];let[n,...s]=t,o=n.endsWith("?"),c=n.replace(/\?$/,"");if(s.length===0)return o?[c,""]:[c];let u=hC(s.join("/")),f=[];return f.push(...u.map(p=>p===""?c:[c,p].join("/"))),o&&f.push(...u),f.map(p=>e.startsWith("/")&&p===""?"/":p)}function XA(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:i_(t.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const QA=/^:[\w-]+$/,ZA=/^:[\w-]+/,JA=3.5,e_=3,t_=2,n_=1,r_=10,a_=-2,Q1=e=>e==="*";function s_(e,t){let n=e.split("/"),s=n.length;return n.some(Q1)&&(s+=a_),t&&(s+=t_),n.filter(o=>!Q1(o)).reduce((o,c)=>o+(QA.test(c)?e_:ZA.test(c)?JA:c===""?n_:r_),s)}function i_(e,t){return e.length===t.length&&e.slice(0,-1).every((n,s)=>n===t[s])?e[e.length-1]-t[t.length-1]:0}function o_(e,t,n=!1){let{routesMeta:s}=e,o={},c="/",u=[];for(let f=0;f<s.length;++f){let p=s[f],h=f===s.length-1,x=c==="/"?t:t.slice(c.length)||"/",g={path:p.relativePath,caseSensitive:p.caseSensitive,end:h},v=p.matcher&&p.compiledParams?gC(g,x,p.matcher,p.compiledParams):vu(g,x),w=p.route;if(!v&&h&&n&&!s[s.length-1].route.index&&(v=vu({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},x)),!v)return null;Object.assign(o,v.params),u.push({params:o,pathname:Za([c,v.pathname]),pathnameBase:u_(Za([c,v.pathnameBase])),route:w}),v.pathnameBase!=="/"&&(c=Za([c,v.pathnameBase]))}return u}function vu(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,s]=xC(e.path,e.caseSensitive,e.end);return gC(e,t,n,s)}function gC(e,t,n,s){let o=t.match(n);if(!o)return null;let c=o[0],u=c.replace(/(.)\/+$/,"$1"),f=o.slice(1);return{params:s.reduce((p,{paramName:h,isOptional:x},g)=>{if(h==="*"){let w=f[g]||"";u=c.slice(0,c.length-w.length).replace(/(.)\/+$/,"$1")}const v=f[g];return x&&!v?p[h]=void 0:p[h]=(v||"").replace(/%2F/g,"/"),p},{}),pathname:c,pathnameBase:u,pattern:e}}function xC(e,t=!1,n=!0){Cs(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 s=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,u,f,p,h)=>{if(s.push({paramName:u,isOptional:f!=null}),f){let x=h.charAt(p+c.length);return x&&x!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(?=\/|$|\()/g,"(?:/$1)?");return e.endsWith("*")?(s.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),s]}function yC(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Cs(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ri(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,s=e.charAt(n);return s&&s!=="/"?null:e.slice(n)||"/"}function l_(e,t="/"){let{pathname:n,search:s="",hash:o=""}=typeof e=="string"?Ul(e):e,c;return n?(n=bC(n),n.startsWith("/")?c=Z1(n.substring(1),"/"):c=Z1(n,t)):c=t,{pathname:c,search:d_(s),hash:m_(o)}}function Z1(e,t){let n=vC(t).split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function fg(e,t,n,s){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function c_(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nx(e){let t=c_(e);return t.map((n,s)=>s===t.length-1?n.pathname:n.pathnameBase)}function Mf(e,t,n,s=!1){let o;typeof e=="string"?o=Ul(e):(o={...e},wn(!o.pathname||!o.pathname.includes("?"),fg("?","pathname","search",o)),wn(!o.pathname||!o.pathname.includes("#"),fg("#","pathname","hash",o)),wn(!o.search||!o.search.includes("#"),fg("#","search","hash",o)));let c=e===""||o.pathname==="",u=c?"/":o.pathname,f;if(u==null)f=n;else{let g=t.length-1;if(!s&&u.startsWith("..")){let v=u.split("/");for(;v[0]==="..";)v.shift(),g-=1;o.pathname=v.join("/")}f=g>=0?t[g]:"/"}let p=l_(o,f),h=u&&u!=="/"&&u.endsWith("/"),x=(c||u===".")&&n.endsWith("/");return!p.pathname.endsWith("/")&&(h||x)&&(p.pathname+="/"),p}const bC=e=>e.replace(/[\\/]{2,}/g,"/"),Za=e=>bC(e.join("/")),vC=e=>e.replace(/\/+$/,""),u_=e=>vC(e).replace(/^\/*/,"/"),d_=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,m_=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;var f_=class{status;statusText;data;error;internal;constructor(e,t,n,s=!1){this.status=e,this.statusText=t||"",this.internal=s,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function p_(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function h_(e){return Za(e.map(t=>t.route.path).filter(Boolean))||"/"}const kC=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function wC(e,t){let n=e;if(typeof n!="string"||!Cx.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,o=!1;if(kC)try{let c=new URL(window.location.href),u=mC.test(n)?new URL(FA(n,c.protocol)):new URL(n),f=Ri(u.pathname,t);u.origin===c.origin&&f!=null?n=f+u.search+u.hash:o=!0}catch{Cs(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:o,to:n}}const SC=["POST","PUT","PATCH","DELETE"];new Set(SC);const g_=["GET",...SC];new Set(g_);const x_=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function y_(e){try{return x_.includes(new URL(e).protocol)}catch{return!1}}const Pl=y.createContext(null);Pl.displayName="DataRouter";const Ef=y.createContext(null);Ef.displayName="DataRouterState";const jC=y.createContext(!1);function b_(){return y.useContext(jC)}const CC=y.createContext({isTransitioning:!1});CC.displayName="ViewTransition";const v_=y.createContext(new Map);v_.displayName="Fetchers";const k_=y.createContext(null);k_.displayName="Await";const qa=y.createContext(null);qa.displayName="Navigation";const Hu=y.createContext(null);Hu.displayName="Location";const Va=y.createContext({outlet:null,matches:[],isDataRoute:!1});Va.displayName="Route";const Tx=y.createContext(null);Tx.displayName="RouteError";const NC="REACT_ROUTER_ERROR",w_="REDIRECT",S_="ROUTE_ERROR_RESPONSE";function j_(e){if(e.startsWith(`${NC}:${w_}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function C_(e){if(e.startsWith(`${NC}:${S_}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new f_(t.status,t.statusText,t.data)}catch{}}function N_(e,{relative:t}={}){wn(_o(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:s}=y.useContext(qa),{hash:o,pathname:c,search:u}=Fu(e,{relative:t}),f=c;return n!=="/"&&(f=c==="/"?n:Za([n,c])),s.createHref({pathname:f,search:u,hash:o})}function _o(){return y.useContext(Hu)!=null}function $r(){return wn(_o(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(Hu).location}function Mx(e){wn(_o(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:t}=$r();return y.useMemo(()=>vu(e,yC(t)),[t,e])}const TC="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function yr(){let{isDataRoute:e}=y.useContext(Va);return e?H_():T_()}function T_(){wn(_o(),"useNavigate() may be used only in the context of a <Router> component.");let e=y.useContext(Pl),{basename:t,navigator:n}=y.useContext(qa),{matches:s}=y.useContext(Va),{pathname:o}=$r(),c=JSON.stringify(Nx(s)),u=y.useRef(!1);return y.useLayoutEffect(()=>{u.current=!0}),y.useCallback((f,p={})=>{if(Cs(u.current,TC),!u.current)return;if(typeof f=="number"){n.go(f);return}let h=Mf(f,JSON.parse(c),o,p.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:Za([t,h.pathname])),(p.replace?n.replace:n.push)(h,p.state,p)},[t,n,c,o,e])}const M_=y.createContext(null);function E_(e){let t=y.useContext(Va).outlet;return y.useMemo(()=>t&&y.createElement(M_.Provider,{value:e},t),[t,e])}function MC(){let{matches:e}=y.useContext(Va);return e[e.length-1]?.params??{}}function Fu(e,{relative:t}={}){let{matches:n}=y.useContext(Va),{pathname:s}=$r(),o=JSON.stringify(Nx(n));return y.useMemo(()=>Mf(e,JSON.parse(o),s,t==="path"),[e,o,s,t])}function A_(e,t){return EC(e,t)}function EC(e,t,n){wn(_o(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=y.useContext(qa),{matches:o}=y.useContext(Va),c=o[o.length-1],u=c?c.params:{};c&&c.pathname;let f=c?c.pathnameBase:"/";c&&c.route;let p=$r(),h;if(t){let S=typeof t=="string"?Ul(t):t;wn(f==="/"||S.pathname?.startsWith(f),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${f}" but pathname "${S.pathname}" was given in the \`location\` prop.`),h=S}else h=p;let x=h.pathname||"/",g=x;if(f!=="/"){let S=f.replace(/^\//,"").split("/");g="/"+x.replace(/^\//,"").split("/").slice(S.length).join("/")}let v=n&&n.state.matches.length?n.state.matches.map(S=>Object.assign(S,{route:n.manifest[S.route.id]||S.route})):fC(e,{pathname:g}),w=D_(v&&v.map(S=>Object.assign({},S,{params:Object.assign({},u,S.params),pathname:Za([f,s.encodeLocation?s.encodeLocation(S.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?f:Za([f,s.encodeLocation?s.encodeLocation(S.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n);return t&&w?y.createElement(Hu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...h},navigationType:"POP"}},w):w}function __(){let e=B_(),t=p_(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null;return y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},t),n?y.createElement("pre",{style:{padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"}},n):null,null)}const R_=y.createElement(__,null);var I_=class extends y.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static contextType=jC;static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=C_(e.digest);n&&(e=n)}let t=e!==void 0?y.createElement(Va.Provider,{value:this.props.routeContext},y.createElement(Tx.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?y.createElement(L_,{error:e},t):t}};const pg=new WeakMap;function L_({children:e,error:t}){let{basename:n}=y.useContext(qa);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=j_(t.digest);if(s){let o=pg.get(t);if(o)throw o;let c=wC(s.location,n),u=c.absoluteURL||c.to;if(y_(u))throw new Error("Invalid redirect location");if(kC&&!pg.get(t))if(c.isExternal||s.reloadDocument)window.location.href=u;else{const f=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(c.to,{replace:s.replace}));throw pg.set(t,f),f}return y.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u}`})}}return e}function O_({routeContext:e,match:t,children:n}){let s=y.useContext(Pl);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),y.createElement(Va.Provider,{value:e},n)}function D_(e,t=[],n){let s=n?.state;if(e==null){if(!s)return null;if(s.errors)e=s.matches;else if(t.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let o=e,c=s?.errors;if(c!=null){let x=o.findIndex(g=>g.route.id&&c?.[g.route.id]!==void 0);wn(x>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(c).join(",")}`),o=o.slice(0,Math.min(o.length,x+1))}let u=!1,f=-1;if(n&&s){u=s.renderFallback;for(let x=0;x<o.length;x++){let g=o[x];if((g.route.HydrateFallback||g.route.hydrateFallbackElement)&&(f=x),g.route.id){let{loaderData:v,errors:w}=s,S=g.route.loader&&!v.hasOwnProperty(g.route.id)&&(!w||w[g.route.id]===void 0);if(g.route.lazy||S){n.isStatic&&(u=!0),f>=0?o=o.slice(0,f+1):o=[o[0]];break}}}}let p=n?.onError,h=s&&p?(x,g)=>{p(x,{location:s.location,params:s.matches?.[0]?.params??{},pattern:h_(s.matches),errorInfo:g})}:void 0;return o.reduceRight((x,g,v)=>{let w,S=!1,C=null,N=null;s&&(w=c&&g.route.id?c[g.route.id]:void 0,C=g.route.errorElement||R_,u&&(f<0&&v===0?(F_("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),S=!0,N=null):f===v&&(S=!0,N=g.route.hydrateFallbackElement||null)));let T=t.concat(o.slice(0,v+1)),_=()=>{let R;return w?R=C:S?R=N:g.route.Component?R=y.createElement(g.route.Component,null):g.route.element?R=g.route.element:R=x,y.createElement(O_,{match:g,routeContext:{outlet:x,matches:T,isDataRoute:s!=null},children:R})};return s&&(g.route.ErrorBoundary||g.route.errorElement||v===0)?y.createElement(I_,{location:s.location,revalidation:s.revalidation,component:C,error:w,children:_(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:h}):_()},null)}function Ex(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $_(e){let t=y.useContext(Pl);return wn(t,Ex(e)),t}function U_(e){let t=y.useContext(Ef);return wn(t,Ex(e)),t}function P_(e){let t=y.useContext(Va);return wn(t,Ex(e)),t}function Ax(e){let t=P_(e),n=t.matches[t.matches.length-1];return wn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function z_(){return Ax("useRouteId")}function B_(){let e=y.useContext(Tx),t=U_("useRouteError"),n=Ax("useRouteError");return e!==void 0?e:t.errors?.[n]}function H_(){let{router:e}=$_("useNavigate"),t=Ax("useNavigate"),n=y.useRef(!1);return y.useLayoutEffect(()=>{n.current=!0}),y.useCallback(async(s,o={})=>{Cs(n.current,TC),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...o}))},[e,t])}const J1={};function F_(e,t,n){J1[e]||(J1[e]=!0,Cs(!1,n))}y.memo(q_);function q_({routes:e,manifest:t,future:n,state:s,isStatic:o,onError:c}){return EC(e,void 0,{manifest:t,state:s,isStatic:o,onError:c})}function ku({to:e,replace:t,state:n,relative:s}){wn(_o(),"<Navigate> may be used only in the context of a <Router> component.");let{static:o}=y.useContext(qa);Cs(!o,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:c}=y.useContext(Va),{pathname:u}=$r(),f=yr(),p=Mf(e,Nx(c),u,s==="path"),h=JSON.stringify(p);return y.useEffect(()=>{f(JSON.parse(h),{replace:t,state:n,relative:s})},[f,h,s,t,n]),null}function V_(e){return E_(e.context)}function da(e){wn(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function G_({basename:e="/",children:t=null,location:n,navigationType:s="POP",navigator:o,static:c=!1,useTransitions:u}){wn(!_o(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let f=e.replace(/^\/*/,"/"),p=y.useMemo(()=>({basename:f,navigator:o,static:c,useTransitions:u,future:{}}),[f,o,c,u]);typeof n=="string"&&(n=Ul(n));let{pathname:h="/",search:x="",hash:g="",state:v=null,key:w="default",mask:S}=n,C=y.useMemo(()=>{let N=Ri(h,f);return N==null?null:{location:{pathname:N,search:x,hash:g,state:v,key:w,mask:S},navigationType:s}},[f,h,x,g,v,w,s,S]);return Cs(C!=null,`<Router basename="${f}"> is not able to match the URL "${h}${x}${g}" because it does not start with the basename, so the <Router> won't render anything.`),C==null?null:y.createElement(qa.Provider,{value:p},y.createElement(Hu.Provider,{children:t,value:C}))}function K_({children:e,location:t}){return A_(f0(e),t)}function f0(e,t=[]){let n=[];return y.Children.forEach(e,(s,o)=>{if(!y.isValidElement(s))return;let c=[...t,o];if(s.type===y.Fragment){n.push.apply(n,f0(s.props.children,c));return}wn(s.type===da,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`);let u=s.props;wn(!u.index||!u.children,"An index route cannot have child routes.");let f={id:u.id||c.join("-"),caseSensitive:u.caseSensitive,element:u.element,Component:u.Component,index:u.index,path:u.path,middleware:u.middleware,loader:u.loader,action:u.action,hydrateFallbackElement:u.hydrateFallbackElement,HydrateFallback:u.HydrateFallback,errorElement:u.errorElement,ErrorBoundary:u.ErrorBoundary,shouldRevalidate:u.shouldRevalidate,handle:u.handle,lazy:u.lazy};u.children&&(f.children=f0(u.children,c)),n.push(f)}),n}const Vm="application/x-www-form-urlencoded";function Af(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function W_(e){return Af(e)&&e.tagName.toLowerCase()==="button"}function Y_(e){return Af(e)&&e.tagName.toLowerCase()==="form"}function X_(e){return Af(e)&&e.tagName.toLowerCase()==="input"}function Q_(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Z_(e,t){return e.button===0&&(!t||t==="_self")&&!Q_(e)}function p0(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let s=e[n];return t.concat(Array.isArray(s)?s.map(o=>[n,o]):[[n,s]])},[]))}function J_(e,t){let n=p0(e);return t&&t.forEach((s,o)=>{n.has(o)||t.getAll(o).forEach(c=>{n.append(o,c)})}),n}let gm=null;function eR(){if(gm===null)try{new FormData(document.createElement("form"),0),gm=!1}catch{gm=!0}return gm}const tR=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function hg(e){return e!=null&&!tR.has(e)?(Cs(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Vm}"`),null):e}function nR(e,t){let n,s,o,c,u;if(Y_(e)){let f=e.getAttribute("action");s=f?Ri(f,t):null,n=e.getAttribute("method")||"get",o=hg(e.getAttribute("enctype"))||Vm,c=new FormData(e)}else if(W_(e)||X_(e)&&(e.type==="submit"||e.type==="image")){let f=e.form;if(f==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=e.getAttribute("formaction")||f.getAttribute("action");if(s=p?Ri(p,t):null,n=e.getAttribute("formmethod")||f.getAttribute("method")||"get",o=hg(e.getAttribute("formenctype"))||hg(f.getAttribute("enctype"))||Vm,c=new FormData(f,e),!eR()){let{name:h,type:x,value:g}=e;if(x==="image"){let v=h?`${h}.`:"";c.append(`${v}x`,"0"),c.append(`${v}y`,"0")}else h&&c.append(h,g)}}else{if(Af(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n="get",s=null,o=Vm,u=e}return c&&o==="text/plain"&&(u=c,c=void 0),{action:s,method:n.toLowerCase(),encType:o,formData:c,body:u}}function _x(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function AC(e,t){let n=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n.pathname.endsWith("/")?n.pathname=`${n.pathname}_.${t}`:n.pathname=`${n.pathname}.${t}`,n}async function rR(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function aR(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function sR(e,t,n){return cR((await Promise.all(e.map(async s=>{let o=t.routes[s.route.id];if(o){let c=await rR(o,n);return c.links?c.links():[]}return[]}))).flat(1).filter(aR).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function ew(e,t,n,s,o,c){let u=(p,h)=>n[h]?p.route.id!==n[h].route.id:!0,f=(p,h)=>n[h].pathname!==p.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==p.params["*"];return c==="assets"?t.filter((p,h)=>u(p,h)||f(p,h)):c==="data"?t.filter((p,h)=>{let x=s.routes[p.route.id];if(!x||!x.hasLoader)return!1;if(u(p,h)||f(p,h))return!0;if(p.route.shouldRevalidate){let g=p.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof g=="boolean")return g}return!0}):[]}function iR(e,t,{includeHydrateFallback:n}={}){return oR(e.map(s=>{let o=t.routes[s.route.id];if(!o)return[];let c=[o.module];return o.clientActionModule&&(c=c.concat(o.clientActionModule)),o.clientLoaderModule&&(c=c.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(c=c.concat(o.hydrateFallbackModule)),o.imports&&(c=c.concat(o.imports)),c}).flat(1))}function oR(e){return[...new Set(e)]}function lR(e){let t={},n=Object.keys(e).sort();for(let s of n)t[s]=e[s];return t}function cR(e,t){let n=new Set;return new Set(t),e.reduce((s,o)=>{let c=JSON.stringify(lR(o));return n.has(c)||(n.add(c),s.push({key:c,link:o})),s},[])}function uR(){let e=y.useContext(Pl);return _x(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function dR(){let e=y.useContext(Ef);return _x(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}const Rx=y.createContext(void 0);Rx.displayName="FrameworkContext";function Ix(){let e=y.useContext(Rx);return _x(e,"You must render this element inside a <HydratedRouter> element"),e}function mR(e,t){let n=y.useContext(Rx),[s,o]=y.useState(!1),[c,u]=y.useState(!1),{onFocus:f,onBlur:p,onMouseEnter:h,onMouseLeave:x,onTouchStart:g}=t,v=y.useRef(null);y.useEffect(()=>{if(e==="render"&&u(!0),e==="viewport"){let C=T=>{T.forEach(_=>{u(_.isIntersecting)})},N=new IntersectionObserver(C,{threshold:.5});return v.current&&N.observe(v.current),()=>{N.disconnect()}}},[e]),y.useEffect(()=>{if(s){let C=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(C)}}},[s]);let w=()=>{o(!0)},S=()=>{o(!1),u(!1)};return n?e!=="intent"?[c,v,{}]:[c,v,{onFocus:Pc(f,w),onBlur:Pc(p,S),onMouseEnter:Pc(h,w),onMouseLeave:Pc(x,S),onTouchStart:Pc(g,w)}]:[!1,v,{}]}function Pc(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function fR({page:e,...t}){let n=b_(),{nonce:s}=Ix(),{router:o}=uR(),c=y.useMemo(()=>fC(o.routes,e,o.basename),[o.routes,e,o.basename]);return c?(t.nonce==null&&s&&(t={...t,nonce:s}),n?y.createElement(hR,{page:e,matches:c,...t}):y.createElement(gR,{page:e,matches:c,...t})):null}function pR(e){let{manifest:t,routeModules:n}=Ix(),[s,o]=y.useState([]);return y.useEffect(()=>{let c=!1;return sR(e,t,n).then(u=>{c||o(u)}),()=>{c=!0}},[e,t,n]),s}function hR({page:e,matches:t,...n}){let s=$r(),o=y.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let c=AC(e,"rsc"),u=!1,f=[];for(let p of t)typeof p.route.shouldRevalidate=="function"?u=!0:f.push(p.route.id);return u&&f.length>0&&c.searchParams.set("_routes",f.join(",")),[c.pathname+c.search]},[e,s,t]);return y.createElement(y.Fragment,null,o.map(c=>y.createElement("link",{key:c,rel:"prefetch",as:"fetch",href:c,...n})))}function gR({page:e,matches:t,...n}){let s=$r(),{manifest:o,routeModules:c}=Ix(),{loaderData:u,matches:f}=dR(),p=y.useMemo(()=>ew(e,t,f,o,s,"data"),[e,t,f,o,s]),h=y.useMemo(()=>ew(e,t,f,o,s,"assets"),[e,t,f,o,s]),x=y.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let w=new Set,S=!1;if(t.forEach(N=>{let T=o.routes[N.route.id];!T||!T.hasLoader||(!p.some(_=>_.route.id===N.route.id)&&N.route.id in u&&c[N.route.id]?.shouldRevalidate||T.hasClientLoader?S=!0:w.add(N.route.id))}),w.size===0)return[];let C=AC(e,"data");return S&&w.size>0&&C.searchParams.set("_routes",t.filter(N=>w.has(N.route.id)).map(N=>N.route.id).join(",")),[C.pathname+C.search]},[u,s,o,p,t,e,c]),g=y.useMemo(()=>iR(h,o),[h,o]),v=pR(h);return y.createElement(y.Fragment,null,x.map(w=>y.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...n})),g.map(w=>y.createElement("link",{key:w,rel:"modulepreload",href:w,...n})),v.map(({key:w,link:S})=>y.createElement("link",{key:w,nonce:n.nonce,...S,crossOrigin:S.crossOrigin??n.crossOrigin})))}function xR(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}const yR=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{yR&&(window.__reactRouterVersion="8.3.0")}catch{}function bR({basename:e,children:t,useTransitions:n,window:s}){let o=y.useRef(null);o.current==null&&(o.current=qA({window:s,v5Compat:!0}));let c=o.current,[u,f]=y.useState({action:c.action,location:c.location}),p=y.useCallback(h=>{n===!1?f(h):y.startTransition(()=>f(h))},[n]);return y.useLayoutEffect(()=>c.listen(p),[c,p]),y.createElement(G_,{basename:e,children:t,location:u.location,navigationType:u.action,navigator:c,useTransitions:n})}const _C=y.forwardRef(function({onClick:t,discover:n="render",prefetch:s="none",relative:o,reloadDocument:c,replace:u,mask:f,state:p,target:h,to:x,preventScrollReset:g,viewTransition:v,defaultShouldRevalidate:w,...S},C){let{basename:N,navigator:T,useTransitions:_}=y.useContext(qa),R=typeof x=="string"&&Cx.test(x),D=wC(x,N);x=D.to;let z=N_(x,{relative:o}),E=$r(),L=null;if(f){let H=Mf(f,[],E.mask?E.mask.pathname:"/",!0);N!=="/"&&(H.pathname=H.pathname==="/"?N:Za([N,H.pathname])),L=T.createHref(H)}let[F,V,P]=mR(s,S),B=wR(x,{replace:u,mask:f,state:p,target:h,preventScrollReset:g,relative:o,viewTransition:v,defaultShouldRevalidate:w,useTransitions:_});function Y(H){t&&t(H),H.defaultPrevented||B(H)}let q=!(D.isExternal||c),K=y.createElement("a",{...S,...P,href:(q?L:void 0)||D.absoluteURL||z,onClick:q?Y:t,ref:xR(C,V),target:h,"data-discover":!R&&n==="render"?"true":void 0});return F&&!R?y.createElement(y.Fragment,null,K,y.createElement(fR,{page:z})):K});_C.displayName="Link";const Lx=y.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:s="",end:o=!1,style:c,to:u,viewTransition:f,children:p,...h},x){let g=Fu(u,{relative:h.relative}),v=$r(),w=y.useContext(Ef),{navigator:S,basename:C}=y.useContext(qa),N=w!=null&&TR(g)&&f===!0,T=S.encodeLocation?S.encodeLocation(g).pathname:g.pathname,_=v.pathname,R=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;n||(_=_.toLowerCase(),R=R?R.toLowerCase():null,T=T.toLowerCase()),R&&C&&(R=Ri(R,C)||R);const D=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let z=_===T||!o&&_.startsWith(T)&&_.charAt(D)==="/",E=R!=null&&(R===T||!o&&R.startsWith(T)&&R.charAt(D)==="/"),L={isActive:z,isPending:E,isTransitioning:N},F=z?t:void 0,V;typeof s=="function"?V=s(L):V=[s,z?"active":null,E?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let P=typeof c=="function"?c(L):c;return y.createElement(_C,{...h,"aria-current":F,className:V,ref:x,style:P,to:u,viewTransition:f},typeof p=="function"?p(L):p)});Lx.displayName="NavLink";const vR=y.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:s,replace:o,state:c,method:u="get",action:f,onSubmit:p,relative:h,preventScrollReset:x,viewTransition:g,defaultShouldRevalidate:v,...w},S)=>{let{useTransitions:C}=y.useContext(qa),N=CR(),T=NR(f,{relative:h}),_=u.toLowerCase()==="get"?"get":"post",R=typeof f=="string"&&Cx.test(f),D=z=>{if(p&&p(z),z.defaultPrevented)return;z.preventDefault();let E=z.nativeEvent.submitter,L=E?.getAttribute("formmethod")||u,F=()=>N(E||z.currentTarget,{fetcherKey:t,method:L,navigate:n,replace:o,state:c,relative:h,preventScrollReset:x,viewTransition:g,defaultShouldRevalidate:v});C&&n!==!1?y.startTransition(()=>F()):F()};return y.createElement("form",{ref:S,method:_,action:T,onSubmit:s?p:D,...w,"data-discover":!R&&e==="render"?"true":void 0})});vR.displayName="Form";function kR(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function RC(e){let t=y.useContext(Pl);return wn(t,kR(e)),t}function wR(e,{target:t,replace:n,mask:s,state:o,preventScrollReset:c,relative:u,viewTransition:f,defaultShouldRevalidate:p,useTransitions:h}={}){let x=yr(),g=$r(),v=Fu(e,{relative:u});return y.useCallback(w=>{if(Z_(w,t)){w.preventDefault();let S=n!==void 0?n:bu(g)===bu(v),C=()=>x(e,{replace:S,mask:s,state:o,preventScrollReset:c,relative:u,viewTransition:f,defaultShouldRevalidate:p});h?y.startTransition(()=>C()):C()}},[g,x,v,n,s,o,t,e,c,u,f,p,h])}function Ox(e){Cs(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=y.useRef(p0(e)),n=y.useRef(!1),s=$r(),o=y.useMemo(()=>J_(s.search,n.current?null:t.current),[s.search]),c=yr();return[o,y.useCallback((u,f)=>{const p=p0(typeof u=="function"?u(new URLSearchParams(o)):u);n.current=!0,c("?"+p,f)},[c,o])]}let SR=0,jR=()=>`__${String(++SR)}__`;function CR(){let{router:e}=RC("useSubmit"),{basename:t}=y.useContext(qa),n=z_(),s=e.fetch,o=e.navigate;return y.useCallback(async(c,u={})=>{let{action:f,method:p,encType:h,formData:x,body:g}=nR(c,t);u.navigate===!1?await s(u.fetcherKey||jR(),n,u.action||f,{defaultShouldRevalidate:u.defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:x,body:g,formMethod:u.method||p,formEncType:u.encType||h,flushSync:u.flushSync}):await o(u.action||f,{defaultShouldRevalidate:u.defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:x,body:g,formMethod:u.method||p,formEncType:u.encType||h,replace:u.replace,state:u.state,fromRouteId:n,flushSync:u.flushSync,viewTransition:u.viewTransition})},[s,o,t,n])}function NR(e,{relative:t}={}){let{basename:n}=y.useContext(qa),s=y.useContext(Va);wn(s,"useFormAction must be used inside a RouteContext");let[o]=s.matches.slice(-1),c={...Fu(e||".",{relative:t})},u=$r();if(e==null){c.search=u.search;let f=new URLSearchParams(c.search),p=f.getAll("index");if(p.some(h=>h==="")){f.delete("index"),p.filter(x=>x).forEach(x=>f.append("index",x));let h=f.toString();c.search=h?`?${h}`:""}}return(!e||e===".")&&o.route.index&&(c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(c.pathname=c.pathname==="/"?n:Za([n,c.pathname])),bu(c)}function TR(e,{relative:t}={}){let n=y.useContext(CC);wn(n!=null,"`useViewTransitionState` must be used within `react-router/dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=RC("useViewTransitionState"),o=Fu(e,{relative:t});if(!n.isTransitioning)return!1;let c=Ri(n.currentLocation.pathname,s)||n.currentLocation.pathname,u=Ri(n.nextLocation.pathname,s)||n.nextLocation.pathname;return vu(o.pathname,u)!=null||vu(o.pathname,c)!=null}const tw=e=>{let t;const n=new Set,s=(h,x)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const v=t;t=x??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(w=>w(t,v))}},o=()=>t,f={setState:s,getState:o,getInitialState:()=>p,subscribe:h=>(n.add(h),()=>n.delete(h))},p=t=e(s,o,f);return f},zl=(e=>e?tw(e):tw),MR=e=>e;function Bl(e,t=MR){const n=hm.useSyncExternalStore(e.subscribe,hm.useCallback(()=>t(e.getState()),[e,t]),hm.useCallback(()=>t(e.getInitialState()),[e,t]));return hm.useDebugValue(n),n}const nw="penguin.lastProjectId",rw=e=>`penguin.lastAgentId.${e}`,IC=y.createContext(null);function wu(e){return e.name??e.projectId}function _n(e){return e.name??e.agentId}function ER(){return zl((e,t)=>({projects:[],projectsLoading:!0,currentProjectId:null,agents:[],agentsLoading:!0,currentAgentId:null,reloadProjects:async()=>{e({projectsLoading:!0});try{const n=await yE(),s=t().currentProjectId??localStorage.getItem(nw),o=n.projects.find(c=>c.projectId===s);e({projects:n.projects,currentProjectId:(o??n.projects[0])?.projectId??null})}finally{e({projectsLoading:!1})}},setCurrentProjectId:n=>{n!==t().currentProjectId&&(localStorage.setItem(nw,n),e({currentProjectId:n,currentAgentId:null,agents:[],agentsLoading:!0}),Nf({lastProjectId:n}).catch(()=>{}))},reloadAgents:async()=>{const n=t().currentProjectId;if(n){e({agentsLoading:!0});try{const s=await aC(n),o=t().currentAgentId??localStorage.getItem(rw(n)),c=s.agents.find(f=>f.agentId===o),u=s.agents.find(f=>f.agentId==="default_agent")??s.agents[0]??null;e({agents:s.agents,currentAgentId:(c??u)?.agentId??null})}finally{e({agentsLoading:!1})}}},setCurrentAgentId:n=>{const s=t().currentProjectId;s&&localStorage.setItem(rw(s),n),e({currentAgentId:n})}}))}function AR({children:e}){const[t]=y.useState(ER),n=Bl(t);y.useEffect(()=>{t.getState().reloadProjects()},[t]);const{currentProjectId:s}=n;y.useEffect(()=>{t.setState({agents:[]}),t.getState().reloadAgents()},[t,s]);const o=y.useMemo(()=>{const c=n.projects.find(f=>f.projectId===n.currentProjectId)??null,u=n.agents.find(f=>f.agentId===n.currentAgentId)??null;return{projects:n.projects,projectsLoading:n.projectsLoading,currentProject:c,setCurrentProjectId:n.setCurrentProjectId,reloadProjects:n.reloadProjects,agents:n.agents,agentsLoading:n.agentsLoading,currentAgent:u,setCurrentAgentId:n.setCurrentAgentId,reloadAgents:n.reloadAgents}},[n]);return a.jsx(IC.Provider,{value:o,children:e})}function en(){const e=y.useContext(IC);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e}function LC(e,t){const n=new EventSource(e);n.onmessage=o=>{try{t.onOmniMessage(JSON.parse(o.data),o.lastEventId||null)}catch{}},n.addEventListener("server_event",o=>{try{t.onServerEvent(JSON.parse(o.data),o.lastEventId||null)}catch{}}),t.onOpen&&(n.onopen=t.onOpen);const{onError:s}=t;return s&&(n.onerror=()=>s(n.readyState===EventSource.CLOSED)),{close:()=>n.close()}}function _R(e,t){return LC(`/api/sessions/${encodeURIComponent(e)}/stream`,t)}function RR(e){return LC("/api/events",e)}const Dx="\0temp-workspaces",IR=/[/\\]workspaces[/\\]tmp-[0-9a-f]{8}$/;function OC(e){const t=e.trim();return t===""||IR.test(t)}function vo(e){return OC(e)?Dx:e.trim()}function LR(e){return e===Dx?"temp":e}function $x(e){const t=e.trim().split(/[/\\]+/).filter(Boolean);return t[t.length-1]??"/"}const bs=10,_f=10;function DC(e,t=_f){return Math.max(1,Math.ceil(e/t))}function $C(e,t,n=_f){return Math.min(Math.max(e,0),DC(t,n)-1)}function OR(e,t=_f){return Math.floor(Math.max(e,0)/t)}function aw(e,t,n=_f){const s=$C(t,e.length,n)*n;return e.slice(s,s+n)}function DR({shown:e,loaded:t,total:n,fullyLoaded:s}){return Math.max((s?t:Math.max(n,t))-e,0)}function sw(e,t){return e.length>t?{items:e.slice(0,t),hasMore:!0}:{items:e,hasMore:!1}}function ha(e){return e.archived?"archived":e.source==="subagent"||e.source==="schedule"?e.source:"active"}function $R(e,t){const n=t.trim().toLowerCase();return n===""?!0:(e.title??"").toLowerCase().includes(n)}const rf=["subagent","schedule","archived"];function gg(e){const t={active:[],subagent:[],schedule:[],archived:[]};for(const n of e)t[ha(n)].push(n);return t}const UC=["active",...rf];function UR(e){const t=new Map;for(const[n,s]of e)for(const[o,c]of Object.entries(s)){const u=vo(o);let f=t.get(u);f||(f={totals:{active:0,subagent:0,schedule:0,archived:0},agents:{active:[],subagent:[],schedule:[],archived:[]}},t.set(u,f));for(const p of UC){const h=c[p];h>0&&(f.totals[p]+=h,f.agents[p].includes(n)||f.agents[p].push(n))}}return t}function PC(e){let t=null;for(const n of e){const s=ha(n);s!=="active"&&s!=="schedule"||(!t||n.createdAt>t.createdAt||n.createdAt===t.createdAt&&n.sessionId>t.sessionId)&&(t=n)}return t}function PR(e){const t=new Map;for(const o of e){const c=vo(o.workspace);let u=t.get(c);if(!u){const f=c===Dx;u={key:c,label:f?"":$x(o.workspace),fullPath:f?null:o.workspace.trim(),temp:f,sessions:[]},t.set(c,u)}u.sessions.push(o)}const n=(o,c)=>o<c?1:o>c?-1:0,s=[...t.values()];for(const o of s)o.sessions.sort((c,u)=>n(c.createdAt,u.createdAt));return s.sort((o,c)=>o.temp!==c.temp?o.temp?1:-1:n(o.sessions[0]?.createdAt??"",c.sessions[0]?.createdAt??"")),s}const zR=["day","month","earlier"],zC=1440*60*1e3,BR=30*zC,HR=e=>`\0time-${e}`,zc="\0time-folders";function FR(e,t){const n=Date.parse(e);if(!Number.isFinite(n))return"earlier";const s=t-n;return s<zC?"day":s<BR?"month":"earlier"}function qR(e,t){const n=new Map;for(const o of e){const c=FR(o.lastActiveAt,t),u=n.get(c);u?u.push(o):n.set(c,[o])}const s=[];for(const o of zR){const c=n.get(o);c!==void 0&&(c.sort((u,f)=>u.lastActiveAt<f.lastActiveAt?1:u.lastActiveAt>f.lastActiveAt?-1:0),s.push({key:HR(o),bucket:o,sessions:c}))}return s}function VR(e){const t={active:0,subagent:0,schedule:0,archived:0};for(const n of e.values())for(const s of UC){const o=n[s];o>0&&(t[s]+=o)}return t}function GR(e,t,n){if(n.size===0)return[...e];const s=[],o=[];for(const c of e)(n.has(t(c))?s:o).push(c);return[...s,...o]}const BC=y.createContext(null),po=(e,t,n="")=>`${e}\0${t}\0${n}`,KR=["active",...rf];function WR(e){const t=e.split("\0");if(t.length!==3)return null;const[n,s,o]=t;return KR.includes(s)?{agentId:n,category:s,scope:o}:null}const h0=e=>e===void 0||e===""?"":LR(e),YR=500;function XR(){let e=0;return zl((t,n)=>{const s=(o,c,u)=>{const{agentId:f,workspace:p}=o,h=n().countsByAgent,x=h.get(f);if(x){const w=new Map(h);w.set(f,{...x,[c]:Math.max(0,x[c]+u)}),t({countsByAgent:w})}const g=n().workspaceCountsByAgent,v=g.get(f);if(v){const w=v[p]??{active:0,subagent:0,schedule:0,archived:0},S=new Map(g);S.set(f,{...v,[p]:{...w,[c]:Math.max(0,w[c]+u)}}),t({workspaceCountsByAgent:S})}};return{projectId:null,agentIds:[],sessions:[],deletedSessionIds:new Set,pageState:new Map,countsByAgent:new Map,workspaceCountsByAgent:new Map,loading:!0,reload:async()=>{const{projectId:o,agentIds:c}=n();if(!o||c.length===0)return;const u=++e;t({loading:!0});try{const f=await Promise.all(c.map(async w=>{const S=[{category:"active",scope:""}];for(const C of n().pageState.keys()){const N=WR(C);N===null||N.agentId!==w||N.category==="active"&&N.scope===""||S.push({category:N.category,scope:N.scope})}try{const C=await Promise.all(S.map(async({category:N,scope:T})=>{const _=await c0(o,w,{offset:0,limit:bs+1,category:N,...T===""?{}:{workspaceGroup:T},...N==="active"&&T===""?{withCounts:!0}:{}});return{category:N,scope:T,counts:_.counts,workspaceCounts:_.workspaceCounts,...sw(_.sessions,bs)}}));return{agentId:w,pages:C}}catch{return{agentId:w,pages:[]}}}));if(u!==e)return;const p=[],h=new Set,x=new Map,g=new Map,v=new Map;for(const w of f)for(const S of w.pages){x.set(po(w.agentId,S.category,S.scope),{hasMore:S.hasMore,fetched:S.items.length}),S.counts&&g.set(w.agentId,S.counts),S.workspaceCounts&&v.set(w.agentId,S.workspaceCounts);for(const C of S.items)h.has(C.sessionId)||(h.add(C.sessionId),p.push(C))}t({sessions:p,pageState:x,countsByAgent:g,workspaceCountsByAgent:v})}finally{u===e&&t({loading:!1})}},loadMoreFor:async(o,c,u)=>{const{projectId:f}=n();if(!f)return;const p=h0(u),h=[...new Set(o)].filter(R=>{const D=n().pageState.get(po(R,c,p));return D===void 0?p!==""||(n().countsByAgent.get(R)?.[c]??0)>0:D.hasMore});if(h.length===0)return;const x=e,g=(R,D)=>n().sessions.filter(z=>z.agentId===R&&ha(z)===c&&vo(z.workspace)===D).length,v=await Promise.all(h.map(async R=>{const z=n().pageState.get(po(R,c,p))?.fetched??(u===void 0||u===""?0:g(R,u));try{const E=(await c0(f,R,{offset:z,limit:bs+1,category:c,...p===""?{}:{workspaceGroup:p}})).sessions;return{agentId:R,offset:z,...sw(E,bs)}}catch{return null}}));if(x!==e)return;const w=v.filter(R=>R!==null),S=n().sessions,C=new Set(S.map(R=>R.sessionId)),N=w.flatMap(R=>R.items.filter(D=>!C.has(D.sessionId))),T=n().pageState,_=new Map(T);for(const R of w){const D=po(R.agentId,c,p);_.set(D,{hasMore:R.hasMore,fetched:(T.get(D)?.fetched??R.offset)+R.items.length})}t({...N.length>0?{sessions:[...S,...N]}:{},pageState:_})},add:o=>{e+=1,!n().sessions.some(u=>u.sessionId===o.sessionId)&&n().pageState.get(po(o.agentId,ha(o)))?.hasMore===!1&&s(o,ha(o),1),t({sessions:[o,...n().sessions.filter(u=>u.sessionId!==o.sessionId)]})},remove:o=>{e+=1;const c=n().sessions.find(f=>f.sessionId===o);c&&s(c,ha(c),-1);const u=new Set(n().deletedSessionIds);for(u.add(o);u.size>YR;){const f=u.values().next();if(f.done)break;u.delete(f.value)}t({deletedSessionIds:u,sessions:n().sessions.filter(f=>f.sessionId!==o)})},replace:o=>{const c=n().sessions.find(u=>u.sessionId===o.sessionId);c&&ha(c)!==ha(o)&&(s(o,ha(c),-1),s(o,ha(o),1)),t({sessions:n().sessions.map(u=>u.sessionId===o.sessionId?o:u)})},setStatus:(o,c,u)=>{const f=n().sessions,p=f.find(v=>v.sessionId===o);if(!p)return;const h=u?.lastActiveAt??p.lastActiveAt,x=c==="running"||c==="compacting",g=p.hasTrace||u?.hasTrace===!0||x;p.status===c&&p.lastActiveAt===h&&p.hasTrace===g||t({sessions:f.map(v=>v.sessionId===o?{...v,status:c,lastActiveAt:h,hasTrace:g}:v)})},setTitle:(o,c)=>{const u=n().sessions,f=u.find(p=>p.sessionId===o);!f||f.title===c||t({sessions:u.map(p=>p.sessionId===o?{...p,title:c}:p)})}}})}function QR(e,t,n){if(t.type==="web_updated"){n();return}if(t.type==="session_state"){e.getState().setStatus(t.sessionId,t.state,{lastActiveAt:t.lastActiveAt,hasTrace:t.hasTrace});return}if(t.type==="session_title"){e.getState().setTitle(t.sessionId,t.title);return}if(t.type==="resync_required"){e.getState().reload();return}t.type==="schedule_fired"&&t.projectId===e.getState().projectId&&e.getState().reload()}function ZR({children:e}){const{currentProject:t,agents:n}=en(),s=t?.projectId??null,o=n.map(w=>w.agentId).join(","),[c]=y.useState(XR),u=Bl(c);y.useEffect(()=>{c.setState({projectId:s,agentIds:o===""?[]:o.split(","),sessions:[],pageState:new Map,countsByAgent:new Map,workspaceCountsByAgent:new Map}),c.getState().reload()},[c,s,o]),y.useEffect(()=>{const w=RR({onOmniMessage:()=>{},onServerEvent:S=>QR(c,S,()=>window.location.reload())});return()=>w.close()},[c]);const{pageState:f,countsByAgent:p}=u,h=y.useCallback((w,S,C)=>f.has(po(w,S,h0(C))),[f]),x=y.useCallback((w,S,C)=>{const N=h0(C),T=f.get(po(w,S,N));return T!==void 0?T.hasMore:(p.get(w)?.[S]??0)>0},[f,p]),g=y.useCallback(w=>c.getState().deletedSessionIds.has(w),[c]),v=y.useMemo(()=>{const w=new Map;for(const S of u.sessions){const C=w.get(S.agentId);C?C.push(S):w.set(S.agentId,[S])}for(const S of w.values())S.sort((C,N)=>N.createdAt.localeCompare(C.createdAt)||N.sessionId.localeCompare(C.sessionId));return{sessions:u.sessions,byAgent:w,countsByAgent:u.countsByAgent,workspaceCountsByAgent:u.workspaceCountsByAgent,isLoadedFor:h,hasMoreFor:x,loading:u.loading,reload:u.reload,loadMoreFor:u.loadMoreFor,add:u.add,remove:u.remove,isDeleted:g,replace:u.replace,setStatus:u.setStatus,setTitle:u.setTitle}},[u,h,x,g]);return a.jsx(BC.Provider,{value:v,children:e})}function Ii(){const e=y.useContext(BC);if(!e)throw new Error("useSessions must be used within a SessionsProvider");return e}function HC(e){return e.desktopMode&&e.sessionVia==="desktop"}const JR={check:{action:"check",busy:!1},checking:{action:"none",busy:!0},downloading:{action:"none",busy:!0},install:{action:"install",busy:!1},unsupported:{action:"none",busy:!1},unknown:{action:"none",busy:!1}};function oo(e,t,n={}){return{labelKind:e,...JR[e],version:null,percent:null,appVersion:t?.appVersion??null,unsupportedReason:null,...n}}function FC(e,t=!1){if(e===null)return oo("unknown",e);switch(e.state){case"unsupported":return oo("unsupported",e,{unsupportedReason:e.reason??null});case"checking":return oo("checking",e);case"downloading":return oo("downloading",e,{version:e.version??null,percent:e.percent??null});case"downloaded":return oo("install",e,{version:e.version??null});default:return oo(t?"checking":"check",e)}}const eI=6e4;function tI(e,t,n){const s=n>=eI;if(t===null)return s?{kind:"failed",message:null}:null;if(t.state==="checking")return null;if(!(t.seq!==void 0&&e!==null?t.seq!==e:n>=4e3))return s?{kind:"failed",message:null}:null;switch(t.state){case"up-to-date":return{kind:"up-to-date"};case"downloading":return{kind:"found",version:t.version??null};case"downloaded":return{kind:"ready",version:t.version??null};case"unsupported":return{kind:"unsupported",reason:t.reason??null};case"error":return{kind:"failed",message:t.message??null};default:return s?{kind:"failed",message:null}:null}}function Ae(e,t){return e instanceof xr?e.code==="model_credential_missing"?t?.modelId?d.errors.modelCredentialMissing(t.modelId):e.message:e.code==="no_default_model"?d.errors.noDefaultModel:d.errors.byCode[e.code]??e.message:d.common.unknownError}var ss=$j();const nI={success:2500,info:4e3,error:6e3},uu=zl(()=>({items:[]}));let rI=1;const aI=160;function qC(e){const t=uu.getState().items.find(n=>n.id===e);!t||t.leaving||(uu.setState(n=>({items:n.items.map(s=>s.id===e?{...s,leaving:!0}:s)})),setTimeout(()=>{uu.setState(n=>({items:n.items.filter(s=>s.id!==e)}))},aI))}function Ux(e,t){if(!t)return;const n=rI++;uu.setState(s=>({items:[...s.items,{id:n,kind:e,text:t}]})),setTimeout(()=>qC(n),nI[e])}const yt=e=>Ux("success",e),Be=e=>Ux("error",e),wr=e=>Ux("info",e),sI={success:"border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-200",error:"border-red-200 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200",info:"border-sky-200 bg-sky-50 text-sky-800 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-200"};function iI(){const e=Bl(uu,t=>t.items);return e.length===0?null:ss.createPortal(a.jsx("div",{className:"pointer-events-none fixed inset-x-0 top-3 z-[100] flex flex-col items-center gap-2 px-4",children:e.map(t=>a.jsx("button",{type:"button",onClick:()=>qC(t.id),className:`pointer-events-auto max-w-lg break-words rounded-md border px-3 py-2 text-left text-sm shadow-lg ${t.leaving?"anim-toast-out":"anim-toast-in"} ${sI[t.kind]}`,children:t.text},t.id))}),document.body)}const oI=1500,lI=8e3;let Sl=null,Bc=null,Ai=null;const g0=new Set;function x0(){for(const e of g0)e()}function cI(){if(Ai===null)return;const e=tI(Ai.atClickSeq,Sl,Date.now()-Ai.armedAt);if(e!==null)switch(Ai=null,e.kind){case"up-to-date":yt(d.update.upToDate);break;case"found":yt(d.update.clientFoundNew(e.version));break;case"ready":yt(d.update.clientDownloadReady(e.version));break;case"unsupported":wr(e.reason==="linux-not-appimage"?d.update.clientUnsupportedNonAppImage:d.update.clientUnsupportedDev);break;default:Be(e.message!==null?d.update.clientUpdateFailed(e.message):d.update.checkFailed)}}function af(){return Bc||(Bc=(async()=>{try{Sl=(await UA()).status}catch{}finally{Bc=null,cI(),x0()}})(),Bc)}function uI(){af()}async function dI(){if(Ai===null){Ai={atClickSeq:Sl?.seq??null,armedAt:Date.now()},x0();try{await PA(),af()}catch(e){Ai=null,x0(),Be(Ae(e))}}}async function mI(){try{await zA()}catch(e){Be(d.update.clientInstallFailed(Ae(e)))}}function VC(e,t){const[,n]=y.useReducer(u=>u+1,0);y.useEffect(()=>(g0.add(n),()=>{g0.delete(n)}),[]);const s=Ai!==null,o=s||Sl?.state==="checking"||Sl?.state==="downloading",c=e&&(t||s);return y.useEffect(()=>{if(!c)return;af();const u=setInterval(()=>{af()},o?oI:lI);return()=>clearInterval(u)},[c,o]),{status:Sl,checkPending:s}}let xg=null,yg=null,Gm=null,jl=null;const y0=new Set;function b0(){for(const e of y0)e()}function fI(e){return e.disabled===!0?{kind:"disabled"}:e.error!==void 0?{kind:"failed"}:e.updateAvailable&&e.latestVersion!==null?{kind:"found",latestVersion:e.latestVersion}:{kind:"up-to-date"}}function Px(e){const[t,n]=y.useState(xg),[s,o]=y.useState(Gm);return y.useEffect(()=>{const c=()=>{n(xg),o(Gm)};return y0.add(c),()=>{y0.delete(c)}},[]),y.useEffect(()=>{if(!e)return;let c=!1;return yg??=DA().then(u=>(xg=u,b0(),u)),yg.then(u=>{c||n(u)}).catch(()=>{yg=null}),jl??=uC().then(u=>(Gm=u,b0(),u)),jl.then(u=>{c||o(u)}).catch(()=>{jl=null}),()=>{c=!0}},[e]),{version:t,update:s}}async function iw(){const e=uC(!0).then(t=>(Gm=t,t));jl=e;try{return await e}catch(t){throw jl===e&&(jl=null),t}finally{b0()}}function GC(e){return e?.updateAvailable===!0?e.latestVersion??null:null}function pI(e){if(e.releaseRowOffered){const t=GC(e.update);if(t!==null)return{kind:"release",version:t}}if(e.clientRowOffered){const t=FC(e.clientStatus);if(t.action==="install")return{kind:"client",version:t.version}}return null}function hI(e){return e.some(t=>t.kernelOutdated)}function gI(e,t){return e!==null&&t?{kind:"mixed"}:e!==null?e:t?{kind:"kernel"}:{kind:"none"}}function zx(e=!1){const{desktopMode:t,sessionVia:n}=mn(),{agents:s}=en(),o=HC({desktopMode:t,sessionVia:n}),{update:c}=Px(e),{status:u}=VC(!1,!1);y.useEffect(()=>{e&&o&&uI()},[e,o]);const f=pI({releaseRowOffered:!t,clientRowOffered:o,update:c,clientStatus:u}),p=hI(s),h=p?d.agent.kernelOutdatedHint:null,x=f===null?null:ow(f);return{software:f,softwareNote:x,kernel:p,kernelNote:h,any:f!==null||p,note:ow(gI(f,p))}}function ow(e){switch(e.kind){case"none":return null;case"release":return d.update.newVersion(e.version);case"client":return d.update.clientRestartToInstall(e.version);case"kernel":return d.agent.kernelOutdatedHint;default:return d.update.updatesAvailable}}function xI(e){return e==="running"||e==="compacting"}const yI=1e4;function bI(e=yI){const t=new Map;return{observe(n,s=Date.now()){const o=[],c=new Set;for(const u of n){if(c.has(u.sessionId))continue;c.add(u.sessionId);const f=xI(u.status),p=t.get(u.sessionId);if(p===void 0){t.set(u.sessionId,{active:f,lastFiredAt:null});continue}p.active&&!f&&(p.lastFiredAt===null||s-p.lastFiredAt>=e)&&(o.push(u.sessionId),p.lastFiredAt=s),p.active=f}for(const u of[...t.keys()])c.has(u)||t.delete(u);return o}}}function vI(){const{sessionVia:e}=mn(),{sessions:t}=Ii(),{setCurrentAgentId:n}=en(),s=yr(),o=y.useRef(bI()),c=y.useRef(s);c.current=s;const u=y.useRef(n);u.current=n;const f=e==="desktop";y.useEffect(()=>{if(!f)return;const p=o.current.observe(t.map(h=>({sessionId:h.sessionId,status:h.status})));if(p.length!==0&&!(!document.hidden&&document.hasFocus())&&!(typeof Notification>"u"||Notification.permission!=="granted"))for(const h of p){const x=t.find(w=>w.sessionId===h),g=x?.title??d.chat.defaultSessionTitle,v=x?.agentId??null;try{const w=new Notification(d.notify.taskCompleteTitle,{body:d.notify.taskCompleteBody(g),tag:`penguin-task-${h}`,icon:"/penguin-logo.svg"});w.onclick=()=>{w.close(),window.focus(),v!==null&&u.current(v),c.current(`/chat/${h}`)}}catch{}}},[f,t])}function Zn({open:e,size:t=14,className:n=""}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:`block shrink-0 transition-transform duration-200 ${e?"rotate-90":""} ${n}`,children:a.jsx("path",{d:"M9 5l7 7-7 7"})})}const Ye={inlineGlyph:13,rowLead:14,iconButton:15,groupHeaderGlyph:15,groupHeaderAction:16,navRow:16,chevron:14,chevronDense:12,caretDense:10},Ro={tight:"gap-1",row:"gap-1.5",menu:"gap-2"};function Oe({d:e,size:t=Ye.inlineGlyph,className:n="",filled:s=!1}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:s?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",className:`block shrink-0 ${n}`,"aria-hidden":!0,children:a.jsx("path",{d:e})})}function vn({d:e,size:t=Ye.navRow}){return a.jsx(Oe,{d:e,size:t})}const El="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z",kI="m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",Bx="M12 3v3m-6 4a6 6 0 0 1 12 0v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5zm3 3h.01M15 13h.01",wI="M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0M12 6v6l4 2",SI="M8 2v4M16 2v4M3 10h18M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z",jI="m21 16-4 4-4-4M17 20V4M3 8l4-4 4 4M7 4v16",xm={workspace:El,agent:Bx,time:SI},lw={recent:wI,manual:jI},KC="penguin.sidebarGroupMode";function bg(){const e=localStorage.getItem(KC);return e==="agent"||e==="time"?e:"workspace"}function CI(e){return e==="agent"?"agent":e==="time"?"chat":"workspace"}function NI(e){localStorage.setItem(KC,e)}const WC="flex w-full items-center gap-1 rounded px-1.5 py-1 text-left text-[11px] font-medium text-gray-400 transition-colors duration-150 hover:bg-gray-200/50 dark:text-gray-500 dark:hover:bg-gray-800/50";function Km({label:e,ariaLabel:t,pending:n=!1,onClick:s,className:o}){return a.jsxs("button",{type:"button","aria-label":t??d.chat.loadMore,disabled:n,onClick:s,className:`${WC}${o?` ${o}`:""} disabled:opacity-60`,children:[a.jsx("span",{className:"w-3","aria-hidden":!0}),n?d.common.loading:e]})}const TI="M15 18 9 12l6-6",MI="m9 18 6-6-6-6";function EI({page:e,pageCount:t,onChange:n}){const s=c=>{const u=e+c;u>=0&&u<t&&n(u)},o="flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-400 transition-colors duration-150 hover:bg-gray-200/50 hover:text-gray-700 disabled:pointer-events-none disabled:opacity-40 dark:text-gray-500 dark:hover:bg-gray-800/50 dark:hover:text-gray-300";return a.jsxs("div",{className:"mt-1 flex items-center justify-center gap-1.5 px-1.5 py-0.5",children:[a.jsx("button",{type:"button",title:d.chat.prevGroupPage,"aria-label":d.chat.prevGroupPage,disabled:e<=0,onClick:()=>s(-1),className:o,children:a.jsx(vn,{d:TI,size:12})}),a.jsxs("span",{"aria-live":"polite","aria-label":d.chat.groupPagePosition(e+1,t),className:"min-w-[2.5rem] text-center text-[11px] font-medium tabular-nums text-gray-400 dark:text-gray-500",children:[e+1,"/",t]}),a.jsx("button",{type:"button",title:d.chat.nextGroupPage,"aria-label":d.chat.nextGroupPage,disabled:e>=t-1,onClick:()=>s(1),className:o,children:a.jsx(vn,{d:MI,size:12})})]})}function AI({label:e,open:t,onToggle:n,more:s=!1,moreLabel:o,pending:c=!1,onMore:u,children:f}){return a.jsxs("div",{className:"mt-1",children:[a.jsxs("button",{type:"button",onClick:n,className:WC,children:[a.jsx(Zn,{open:t,size:12}),e]}),t&&f,t&&s&&a.jsx(Km,{label:o??d.chat.loadMore,...o!==void 0?{ariaLabel:o}:{},pending:c,onClick:()=>u?.()})]})}function ym({open:e,onToggle:t,icon:n,label:s,uppercase:o=!1,count:c,title:u,actions:f,draggable:p=!1,onDragStart:h,onDragEnd:x,onDragOver:g,onDragLeave:v,onDrop:w}){return a.jsxs("div",{className:`group/header flex items-center gap-0.5 px-1 pb-0.5${p?" cursor-grab":""}`,...p?{draggable:!0,onDragStart:h,onDragEnd:x,onDragOver:g,onDragLeave:v,onDrop:w}:{},children:[a.jsxs("button",{type:"button",onClick:t,"aria-expanded":e,"aria-label":e?d.nav.collapseGroup:d.nav.expandGroup,...u!==void 0?{title:u}:{},className:"flex min-w-0 flex-1 items-center gap-1 self-stretch rounded px-1 py-0.5 text-left transition-colors duration-150 hover:bg-gray-200/50 dark:hover:bg-gray-800/50",children:[n,a.jsx("span",{className:`min-w-0 truncate text-xs font-semibold ${o?"uppercase tracking-wide ":""}text-gray-500 dark:text-gray-400`,children:s}),c!==void 0&&a.jsx("span",{className:"shrink-0 text-[11px] text-gray-400 dark:text-gray-500",children:c}),a.jsx(Zn,{open:e,size:12,className:"text-gray-400"}),a.jsx("span",{className:"min-w-0 flex-1"})]}),f]})}function ns({size:e=12,className:t=""}){return a.jsx("svg",{width:e,height:e,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:a.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function qu({size:e=13,className:t=""}){return a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:a.jsx("path",{d:"M5 12l4 4L19 6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function _I({size:e=14,strokeWidth:t=1.7,className:n=""}){return a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${n}`,children:a.jsx("path",{d:"M12 5v14M5 12h14",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round"})})}function Hx({size:e=13,className:t=""}){return a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:a.jsx("path",{d:"M12 4v11m0 0l-5-5m5 5l5-5M4 20h16",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function YC({size:e=13,className:t=""}){return a.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:a.jsx("path",{d:"M12 15V4m0 0L7 9m5-5l5 5M4 20h16",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function Hl({size:e=14,className:t=""}){return a.jsx("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`block shrink-0 ${t}`,children:a.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})}function Rf({onClose:e,className:t="",...n}){return a.jsx("button",{type:"button","aria-label":d.common.close,onClick:e,className:`rounded-md p-1.5 text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300 ${t}`,...n,children:a.jsx(Hl,{})})}const RI="M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 11v5m0-8h.01",XC="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",II="M22 2 11 13M22 2l-7 20-4-9-9-4z",If="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-2zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z",vs={agents:Bx,skills:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2zM22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",models:"M7 7h10v10H7zM4 10h3m10 0h3M4 14h3m10 0h3M10 4v3m4-3v3m-4 10v3m4-3v3",usage:"M4 20V10m6 10V4m6 16v-7m4 7H2",traces:"M4 6h16M4 12h10M4 18h13",benchmark:"M7 4h10v5a5 5 0 0 1-10 0V4zM7 5H4v1a3 3 0 0 0 3 3m10-4h3v1a3 3 0 0 1-3 3M12 14v4m-4 0h8",terminal:"M3 5h18v14H3zM7 9l3 3-3 3M13 15h4"};function QC({open:e,side:t="left",title:n,onClose:s,children:o,widthClass:c}){return y.useEffect(()=>{if(!e)return;const u=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,s]),e?a.jsxs("div",{className:"fixed inset-0 z-50",children:[a.jsx("div",{className:"anim-fade absolute inset-0 bg-black/45",onMouseDown:s}),a.jsxs("div",{className:`absolute inset-y-0 flex w-[80vw] flex-col bg-white shadow-xl dark:bg-gray-900 ${c??"max-w-xs"} ${t==="left"?"anim-drawer-left left-0 border-r border-gray-200 dark:border-gray-800":"anim-drawer-right right-0 border-l border-gray-200 dark:border-gray-800"}`,children:[a.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800",children:[a.jsx("span",{className:"text-base font-semibold",children:n??""}),a.jsx(Rf,{onClose:s})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pb-[env(safe-area-inset-bottom)]",children:o})]})]}):null}const LI={chrome:"h-2.5 w-2.5 border-2 border-gray-50 dark:border-gray-900",inline:"h-1.5 w-1.5"};function Mo({size:e="chrome",position:t="-right-0.5 -top-0.5"}){return a.jsx("span",{"aria-hidden":!0,className:`pointer-events-none absolute rounded-full bg-red-400 ${LI[e]} ${t}`})}function OI({onClick:e,children:t}){return a.jsx("button",{type:"button",onClick:e,className:"inline-flex shrink-0 items-center whitespace-nowrap rounded-full bg-red-100 px-2 py-0.5 text-[11px] font-semibold text-red-800 transition-colors duration-150 hover:bg-red-200 dark:bg-red-950 dark:text-red-300 dark:hover:bg-red-900",children:t})}function ko(e){const t=e.toFixed(1);return t.endsWith(".0")?t.slice(0,-2):t}function It(e){const t=Math.abs(e);return t<1e3?`${e}`:t<1e6?`${ko(e/1e3)}k`:`${ko(e/1e6)}M`}function Pn(e,t){if(e<1e3)return`${Math.round(e)}ms`;const n=e/1e3;if(n<60&&!(t?.compact&&n>=10))return`${ko(n)}s`;const s=Math.round(n);return s<60?`${s}s`:`${Math.floor(s/60)}m${s%60}s`}function ZC(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`}function v0(e,t){return t>0?e/(t/1e3):null}function sf(e){return e==null||!Number.isFinite(e)?"—":`${Math.abs(e)<1e3?ko(e):It(e)} tok/s`}function JC(e,t){const n=e+t;return n>0?e/n:null}function Lf(e){return e==null||!Number.isFinite(e)?"—":`${Math.round(e*100)}%`}function rs(e,t="USD",n){if(e==null)return"—";const s=t==="CNY"?"¥":"$",o=t==="CNY"?e*7:e;if(o===0)return`${s}0`;const c=Math.abs(o);if(n?.compact&&c<1)return`${s}${Number(o.toPrecision(2))}`;const u=c>=100?0:c>=1?2:4;return`${s}${o.toFixed(u)}`}function Su(e){return Number.isInteger(e)?`${e}`:e.toFixed(2).replace(/0+$/,"").replace(/\.$/,"")}function cw(e){return Number(e.toFixed(1))<1024}function ju(e){if(e<1024)return`${e}B`;const t=e/1024;if(cw(t))return`${ko(t)}KB`;const n=t/1024;return cw(n)?`${ko(n)}MB`:`${ko(n/1024)}GB`}function yo(e){return e<10?`0${e}`:`${e}`}function Jr(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.getFullYear()}-${yo(t.getMonth()+1)}-${yo(t.getDate())} ${yo(t.getHours())}:${yo(t.getMinutes())}`}const DI=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k0(e,t){const n=/^\d{4}-(\d{2})-(\d{2})(?:$|T)/.exec(e);if(!n)return e;const s=Number(n[1]),o=Number(n[2]);return s<1||s>12||o<1||o>31?e:t==="en"?`${DI[s-1]} ${o}`:`${s} 月 ${o} 日`}function eN(e,t){const n=new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleString(t==="en"?"en-US":"zh-CN",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function of(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function $I(e,t){const n=new Date(e);if(Number.isNaN(n.getTime()))return e;const s=Math.round((of(new Date)-of(n))/864e5);return s<0?Jr(e):s===0?t==="en"?"today":"今天":s===1?t==="en"?"yesterday":"昨天":t==="en"?`${s} days ago`:`${s} 天前`}function Al(e,t){const n=new Date(e);if(Number.isNaN(n.getTime()))return e;const s=Math.round((of(new Date)-of(n))/864e5);return s<0?e:s===0?t==="en"?"updated today":"今天更新":s===1?t==="en"?"updated yesterday":"昨天更新":t==="en"?`updated ${s} days ago`:`${s} 天前更新`}function UI(e,t){const n=new Date(e);if(Number.isNaN(n.getTime()))return"";const s=Date.now()-n.getTime();if(s<0)return k0(e,t);const o=Math.floor(s/6e4);if(o<1)return t==="en"?"now":"刚刚";if(o<60)return t==="en"?`${o}m`:`${o} 分钟前`;const c=Math.floor(o/60);if(c<24)return t==="en"?`${c}h`:`${c} 小时前`;const u=Math.floor(c/24);return u<7?t==="en"?`${u}d`:`${u} 天前`:k0(e,t)}function PI(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:`${yo(t.getHours())}:${yo(t.getMinutes())}:${yo(t.getSeconds())}`}const Fx=e=>`penguin.sessionSeen.${e}`,uw=500,Cl={seededAt:0,seen:new Map};function tN(e){try{return localStorage}catch{return null}}function zI(e){if(e===null)return Cl;try{const t=JSON.parse(e);if(typeof t!="object"||t===null)return Cl;const n=t,s=typeof n.seededAt=="number"&&Number.isFinite(n.seededAt)?n.seededAt:0,o=new Map;if(typeof n.seen=="object"&&n.seen!==null)for(const[c,u]of Object.entries(n.seen))typeof u=="number"&&Number.isFinite(u)&&o.set(c,u);return{seededAt:s,seen:o}}catch{return Cl}}function BI(e){let t=[...e.seen];return t.length>uw&&(t.sort((n,s)=>s[1]-n[1]),t=t.slice(0,uw)),JSON.stringify({seededAt:e.seededAt,seen:Object.fromEntries(t)})}function HI(e,t,n,s=Date.now()){const o=Date.parse(n),c=Number.isNaN(o)?s:Math.max(s,o);return e.seen.get(t)===c?e:{seededAt:e.seededAt,seen:new Map(e.seen).set(t,c)}}function FI(e,t){if(!e.seen.has(t))return e;const n=new Map(e.seen);return n.delete(t),{seededAt:e.seededAt,seen:n}}function qI(e,t,n){const s=Date.parse(n);return Number.isNaN(s)?!1:s>(e.seen.get(t)??e.seededAt)}const qx=zl(()=>({cache:new Map}));function Vx(e,t){const{cache:n}=qx.getState(),s=n.get(e);if(s)return s;const o=tN();let c=Cl;if(o)try{c=zI(o.getItem(e))}catch{c=Cl}return n.set(e,c),c}function nN(e,t,n){const s=tN();if(s)try{s.setItem(e,BI(t))}catch{}qx.setState(o=>({cache:new Map(o.cache).set(e,t)}))}function VI(e){return Bl(qx,()=>e?Vx(Fx(e)):Cl)}function Gx(e,t,n,s){if(e===null)return;const o=Fx(e),c=Vx(o),u=c.seededAt===0?{seededAt:Date.now(),seen:c.seen}:c,f=HI(u,t,n);f!==c&&nN(o,f)}function GI(e,t,n){if(e===null)return;const s=Fx(e),o=Vx(s),c=FI(o,t);c!==o&&nN(s,c)}function rN(e,t,n){return e==="running"?"running":e==="compacting"?"compacting":t&&n?"completedUnread":null}function KI(e,t,n){const s=e.sessionId!==n&&qI(t,e.sessionId,e.lastActiveAt);return rN(e.status,e.hasTrace,s)}const WI=["agents","skills","models","usage","benchmark"],aN="penguin.sidebarNavGroupCollapsed";function YI(e){try{return(e??localStorage).getItem(aN)==="collapsed"}catch{return!1}}function XI(e,t){try{(t??localStorage).setItem(aN,e?"collapsed":"expanded")}catch{}}const sN=e=>`penguin.pinnedSessions.${e}`;function dw(e,t){if(e===null)return new Set;try{const n=t??localStorage,s=JSON.parse(n.getItem(sN(e))??"[]");return new Set(Array.isArray(s)?s.filter(o=>typeof o=="string"):[])}catch{return new Set}}function mw(e,t,n){if(e!==null)try{(n??localStorage).setItem(sN(e),JSON.stringify([...t]))}catch{}}function QI(e,t){const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function ZI(e,t){if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n}const iN=e=>`penguin.sidebarWorkspaces.${e}`;function w0(e){let t=e.trim();for(;t.length>1&&(t.endsWith("/")||t.endsWith("\\"))&&!/^[A-Za-z]:[/\\]$/.test(t);)t=t.slice(0,-1);return t}function JI(e){if(typeof e=="string"){const t=w0(e);return t===""?null:{path:t}}if(typeof e=="object"&&e!==null&&typeof e.path=="string"){const t=w0(e.path);if(t==="")return null;const n=e.alias,s=typeof n=="string"?n.trim():"";return s===""?{path:t}:{path:t,alias:s}}return null}function fw(e,t){if(e===null)return[];try{const n=t??localStorage,s=JSON.parse(n.getItem(iN(e))??"[]");if(!Array.isArray(s))return[];const o=[];for(const c of s){const u=JI(c);u!==null&&!o.some(f=>f.path===u.path)&&o.push(u)}return o}catch{return[]}}function e6(e,t,n){if(e!==null)try{(n??localStorage).setItem(iN(e),JSON.stringify(t))}catch{}}function t6(e,t){const n=w0(t);return n===""||OC(n)||e.some(s=>s.path===n)?e:[{path:n},...e]}function n6(e,t,n){const s=n.trim(),o=e.find(c=>c.path===t);return!o||(o.alias??"")===s?e:e.map(c=>c.path===t?s===""?{path:c.path}:{path:c.path,alias:s}:c)}function r6(e,t){return e.some(n=>n.path===t)?e.filter(n=>n.path!==t):e}function a6(e,t){const n=new Map(t.filter(u=>u.alias!==void 0).map(u=>[u.path,u.alias])),s=new Set(e.map(u=>u.key)),o=[];for(const{path:u,alias:f}of t){const p=vo(u);s.has(p)||p!==u||(s.add(p),o.push({key:p,label:f??$x(u),fullPath:u,temp:!1,sessions:[]}))}const c=e.map(u=>{const f=n.get(u.key);return f===void 0?u:{...u,label:f}});return o.length===0?c:[...c,...o]}const oN="penguin.sidebarSortMode";function s6(e){try{return(e??localStorage).getItem(oN)==="manual"?"manual":"recent"}catch{return"recent"}}function i6(e,t){try{(t??localStorage).setItem(oN,e)}catch{}}const lN=(e,t)=>`penguin.sessionOrder.${e}.${t}`;function Kx(e,t){try{const n=t??localStorage,s=JSON.parse(n.getItem(e)??"[]");return Array.isArray(s)?s.filter(o=>typeof o=="string"):[]}catch{return[]}}function Wx(e,t,n){try{(n??localStorage).setItem(e,JSON.stringify(t))}catch{}}function vg(e,t,n){return e===null?[]:Kx(lN(e,t),n)}function pw(e,t,n,s){e!==null&&Wx(lN(e,t),n,s)}function hw(e,t,n){if(n.length===0)return[...e];const s=new Map(n.map((u,f)=>[u,f])),o=[],c=[];for(const u of e)(s.has(t(u))?c:o).push(u);return c.sort((u,f)=>(s.get(t(u))??0)-(s.get(t(f))??0)),[...o,...c]}function cN(e,t,n,s){if(s.length===0)return GR(e,t,n);const o=e.filter(u=>n.has(t(u))),c=e.filter(u=>!n.has(t(u)));return[...hw(o,t,s),...hw(c,t,s)]}function o6(e,t,n){const s=n.recencyOf,o=s?[...e].sort((c,u)=>s(u).localeCompare(s(c))||t(u).localeCompare(t(c))):e;return cN(o,t,n.pinned,n.sortMode==="manual"?n.order:[])}function Yx(e,t,n,s){if(t===n||!e.includes(t))return e;const o=e.filter(u=>u!==t),c=o.indexOf(n);return c<0?e:(o.splice(s?c+1:c,0,t),o.every((u,f)=>u===e[f])?e:o)}function l6(e,t){const n=new Set(t);return[...t,...e.filter(s=>!n.has(s))]}function c6(e,t){return e.includes(t)?e.filter(n=>n!==t):e}const u6=["workspace","agent"];function Xx(e){return u6.includes(e)}const uN=(e,t)=>`penguin.groupOrder.${e}.${t}`;function kg(e,t,n){return e===null||!Xx(t)?[]:Kx(uN(e,t),n)}function d6(e,t,n,s){e===null||!Xx(t)||Wx(uN(e,t),n,s)}function gw(e,t,n){return cN(e,t,n.pinned,n.order)}function m6(e,t,n,s,o){const c=new Set(e),u=[...t.filter(p=>!c.has(p)),...e],f=Yx(u,n,s,o);return f===u?e:f}const Cu=[];function dN(){const e=Symbol("esc-layer");return Cu.push(e),e}function mN(e){const t=Cu.lastIndexOf(e);t!==-1&&Cu.splice(t,1)}function fN(e){return Cu[Cu.length-1]===e}function Yt({open:e,title:t,onClose:n,children:s,footer:o,widthClass:c,headerless:u,bare:f}){const p=y.useRef(n);return p.current=n,y.useEffect(()=>{if(!e)return;const h=dN(),x=g=>{g.key==="Escape"&&fN(h)&&p.current()};return window.addEventListener("keydown",x),()=>{window.removeEventListener("keydown",x),mN(h)}},[e]),e?ss.createPortal(a.jsx("div",{className:"anim-fade fixed inset-0 z-50 flex items-end justify-center bg-black/45 p-0 sm:items-center sm:p-4",onMouseDown:h=>{h.target===h.currentTarget&&n()},children:a.jsxs("div",{...u?{role:"dialog","aria-label":t}:{},className:`anim-pop w-full ${c??"sm:max-w-md"} rounded-t-lg border border-gray-200 bg-white pb-[env(safe-area-inset-bottom)] shadow-xl sm:rounded-lg sm:pb-0 dark:border-gray-800 dark:bg-gray-900`,children:[!u&&a.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800",children:[a.jsx("h2",{className:"text-base font-semibold",children:t}),a.jsx(Rf,{onClose:n})]}),f?s:a.jsx("div",{className:"max-h-[70vh] overflow-y-auto px-4 py-4",children:s}),o&&a.jsx("div",{className:"flex justify-end gap-2 border-t border-gray-200 px-4 py-3 dark:border-gray-800",children:o})]})}),document.body):null}const bm=4,Hc=8;function Qn({button:e,open:t,setOpen:n,children:s,menuClass:o,menuStyle:c,className:u,portal:f,anchorRect:p,returnFocus:h,onEscape:x,focusOnOpen:g}){const v=y.useRef(null),w=y.useRef(null),[S,C]=y.useState(null),N=y.useCallback(()=>h?.()??v.current?.querySelector("button")??null,[h]),T=y.useCallback(()=>w.current?[...w.current.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')]:[],[]),_=y.useRef(g);_.current=g,y.useEffect(()=>{!t||_.current===!1||T()[0]?.focus()},[t,T]);const R=F=>{if(F.key!=="ArrowDown"&&F.key!=="ArrowUp"||F.defaultPrevented)return;const P=document.activeElement?.tagName;if(P==="INPUT"||P==="TEXTAREA"||P==="SELECT")return;const B=T();if(B.length===0)return;F.preventDefault();const Y=B.indexOf(document.activeElement),q=F.key==="ArrowDown"?1:-1,K=Y<0?q===1?0:B.length-1:(Y+q+B.length)%B.length;B[K]?.focus()},D=y.useRef(n);D.current=n;const z=y.useRef(x);z.current=x,y.useEffect(()=>{if(!t)return;const F=B=>{const Y=B.target;v.current?.contains(Y)||w.current?.contains(Y)||D.current(!1)},V=dN(),P=B=>{if(B.key!=="Escape"||!fN(V))return;N()?.focus();const Y=z.current;Y?Y():D.current(!1)};return window.addEventListener("mousedown",F),window.addEventListener("keydown",P),()=>{mN(V),window.removeEventListener("mousedown",F),window.removeEventListener("keydown",P)}},[t]);const E=y.useCallback(()=>{if(!t||!f||!v.current){C(null);return}const F=p??v.current.getBoundingClientRect(),V=w.current,P=V?.offsetWidth??0,B=V?.offsetHeight??0,Y=f.align==="right"?F.right-P:F.left,q=Math.max(Hc,Math.min(Y,window.innerWidth-P-Hc)),K=window.innerHeight-F.bottom-bm-Hc,H=F.top-bm-Hc,$=f.direction==="up",le=($?B<=H:B<=K)?$:H>K;C({left:q,maxHeight:Math.max(0,le?H:K),...le?{bottom:window.innerHeight-F.top+bm}:{top:F.bottom+bm}})},[t,f?.direction,f?.align,s,p?.top,p?.left,p?.bottom,p?.right]);y.useLayoutEffect(E,[E]),y.useEffect(()=>{if(!t||!f)return;const F=P=>{w.current?.contains(P.target)||(p?D.current(!1):E())},V=()=>{p?D.current(!1):E()};return window.addEventListener("scroll",F,!0),window.addEventListener("resize",V),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",V)}},[t,f,E,p]);const L=`anim-pop ${f?"z-[60]":"z-40"} overflow-y-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900 ${f?"":"max-h-[70vh]"} ${o??"left-0 top-full mt-1 w-64 max-w-[calc(100vw-2rem)] origin-top-left"}`;return a.jsxs("div",{className:`relative ${u??""}`,ref:v,children:[e,t&&(f?ss.createPortal(a.jsx("div",{ref:w,onKeyDown:R,style:{position:"fixed",...S?{left:S.left,maxHeight:S.maxHeight,...S.top!==void 0?{top:S.top}:{},...S.bottom!==void 0?{bottom:S.bottom}:{}}:{left:0,top:0,visibility:"hidden"},maxWidth:`calc(100vw - ${Hc*2}px)`,...c},className:L,children:s}),document.body):a.jsx("div",{ref:w,onKeyDown:R,...c!==void 0?{style:c}:{},className:`absolute ${L}`,children:s}))]})}function pN(e,t){return{top:t,bottom:t,left:e,right:e}}function f6(e){return e.button===2&&!(e.clientX===0&&e.clientY===0)}function p6(e,t){return f6(e)?pN(e.clientX,e.clientY):t}function h6(e){return e.shiftKey&&e.key==="F10"}const g6=500,xw=10,x6=350;function hN(e){return e==="touch"||e==="pen"}function y6(e,t){return Math.abs(t.x-e.x)>xw||Math.abs(t.y-e.y)>xw}function b6(e,t){return t-e<x6}const v6={pointer:"",held:!1,settleFrom:0},xs={open:null,close:!1,swallow:!1};function k6(e,t){switch(t.kind){case"pointerdown":return{...xs,state:{...e,pointer:t.pointerType,held:!1}};case"hold":return{...xs,state:{...e,held:!0,settleFrom:t.at},open:"held"};case"nativemenu":return e.held?{...xs,state:e}:hN(e.pointer)?{...xs,state:{...e,held:!0,settleFrom:t.at},open:"event"}:{...xs,state:e,open:"event"};case"pointerup":return{...xs,state:{...e,pointer:"",settleFrom:e.held?t.at:e.settleFrom}};case"dismiss":return e.held&&b6(e.settleFrom,t.at)?{...xs,state:e}:{...xs,state:{...e,held:!1},close:!0};case"click":return e.held?{...xs,state:{...e,held:!1},swallow:!0}:{...xs,state:e}}}function w6(){const e=y.useRef(null),[t,n]=y.useState(null),s=y.useRef(null),o=y.useRef(null),c=y.useRef(v6),u=y.useCallback(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null),o.current=null},[]);y.useEffect(()=>u,[u]);const f=y.useCallback(()=>{const v=e.current?.getBoundingClientRect();return v?{top:v.top,bottom:v.bottom,left:v.left,right:v.right}:{top:0,bottom:0,left:0,right:0}},[]),p=y.useCallback((v,w)=>{const S=k6(c.current,v);if(c.current=S.state,S.open==="held"){const C=o.current;C&&n(pN(C.x,C.y))}else S.open==="event"&&w&&n(w);return S.close&&n(null),S},[]),h=v=>{const w=v.currentTarget;return w instanceof Node&&w.contains(v.target)},x={onContextMenu:v=>{h(v)&&(v.preventDefault(),p({kind:"nativemenu",at:Date.now()},p6(v,f())),c.current.held&&u())},onKeyDown:v=>{h(v)&&h6(v)&&(v.preventDefault(),n(f()))},onPointerDown:v=>{if(!h(v)||(p({kind:"pointerdown",pointerType:v.pointerType}),!hN(v.pointerType)))return;const w=v.clientX,S=v.clientY;o.current={x:w,y:S},s.current=setTimeout(()=>{s.current=null,p({kind:"hold",at:Date.now()})},g6)},onPointerMove:v=>{const w=o.current;w!==null&&y6(w,{x:v.clientX,y:v.clientY})&&u()},onPointerUp:()=>{u(),p({kind:"pointerup",at:Date.now()})},onPointerCancel:()=>{u(),p({kind:"pointerup",at:Date.now()})}},g=y.useCallback(()=>{c.current={...c.current,held:!1},n(null)},[]);return{rowRef:y.useCallback(v=>{e.current=v},[]),rowProps:x,open:t!==null,setOpen:v=>{v||p({kind:"dismiss",at:Date.now()})},anchor:t,returnFocus:()=>e.current?.querySelector("button")??null,consumeLongPressClick:()=>p({kind:"click"}).swallow,openAt:n,close:g}}const Qx="M12 17v5M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1z",Zx="M4 20h4L18.5 9.5a2.1 2.1 0 0 0-3-3L5 17v3zM14 7l3 3",S6="M3 8h18M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8M4 8l1.5-3h13L20 8M9.5 13.5 12 16l2.5-2.5",j6="M3 8h18M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8M4 8l1.5-3h13L20 8M12 17v-5m-2.5 2L12 11l2.5 3",Jx="M4 6h16M9 6V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V6M6 6v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6M10 10.5v6M14 10.5v6",C6="M4.5 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM12 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4zM19.5 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4z",ey="flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800",gN="flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs text-red-600 transition-colors duration-150 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40",ty=e=>a.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:a.jsx(vn,{d:e,size:13})}),N6=["archive"];function T6(e){return e?["pin","rename","messaging","archive","delete"]:["rename","messaging","archive","delete"]}function xN(e,t){switch(e){case"pin":return{label:t.pinned?d.chat.unpinSession:d.chat.pinSession,icon:Qx,danger:!1};case"rename":return{label:d.chat.renameSession,icon:Zx,danger:!1};case"messaging":return{label:d.messaging.bindAction,icon:XC,danger:!1};case"archive":return{label:t.archived?d.chat.unarchiveSession:d.chat.archiveSession,icon:t.archived?j6:S6,danger:!1};case"delete":return{label:d.chat.deleteSession,icon:Jx,danger:!0}}}function M6({actions:e,state:t,onRun:n}){return a.jsx(a.Fragment,{children:e.map(s=>{const o=xN(s,t);return a.jsxs("button",{type:"button",className:o.danger?gN:ey,onClick:()=>n(s),children:[o.danger?a.jsx("span",{className:"shrink-0",children:a.jsx(vn,{d:o.icon,size:13})}):ty(o.icon),o.label]},s)})})}const yw="pointer-events-none flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-400 opacity-0 transition-all duration-150 focus:pointer-events-auto focus:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100";function E6({actions:e,state:t,onRun:n,onMore:s}){const o=c=>{const u=c.currentTarget.getBoundingClientRect();s({top:u.top,bottom:u.bottom,left:u.left,right:u.right})};return a.jsxs(a.Fragment,{children:[e.map(c=>{const u=xN(c,t);return a.jsx("button",{type:"button",title:u.label,"aria-label":u.label,onClick:()=>n(c),className:`${yw} ${u.danger?"hover:text-red-600 dark:hover:text-red-400":"hover:text-gray-700 dark:text-gray-500 dark:hover:text-gray-200"}`,children:a.jsx(vn,{d:u.icon,size:14})},c)}),a.jsx("button",{type:"button",title:d.chat.moreActions,"aria-label":d.chat.moreActions,"aria-haspopup":"menu",onClick:o,className:`${yw} hover:text-gray-700 dark:text-gray-500 dark:hover:text-gray-200`,children:a.jsx(Oe,{d:C6,size:14,filled:!0})})]})}function A6(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function _6(e){return A6(e)%360}function yN(e){const t=_6(e);return{bg:`hsl(${t} 55% 50% / 0.14)`,fg:`hsl(${t} 55% 28%)`,fgDark:`hsl(${t} 55% 73%)`}}const bw=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}):void 0;function vw(e){if(e){if(!bw)return Array.from(e)[0];for(const t of bw.segment(e))return t.segment}}function bN(e,t){const n=vw(e.trim())??vw((t??"").trim());return n?n.toUpperCase():"?"}function Ha({id:e,name:t,size:n=18,className:s}){const o=yN(e);return a.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",className:s,style:{"--tile-fg":o.fg,"--tile-fg-dark":o.fgDark},"aria-hidden":!0,role:"img",children:[a.jsx("rect",{x:"0",y:"0",width:"24",height:"24",rx:"5",fill:o.bg}),a.jsx("text",{x:"12",y:"12",textAnchor:"middle",dominantBaseline:"central",fontSize:"13",fontWeight:"700",className:"[fill:var(--tile-fg)] dark:[fill:var(--tile-fg-dark)]",children:bN(t??"",e)})]})}const R6=1,I6=60,L6=350,O6=4e3;function D6(e,t){const n=e-t;return n>R6?n:0}function $6(e){if(e<=0)return 0;const t=e/I6*1e3;return Math.round(Math.min(O6,Math.max(L6,t)))}function Of({text:e,className:t="",scrollReveal:n=!1}){const s=y.useRef(null),[o,c]=y.useState(0);y.useLayoutEffect(()=>{const p=s.current;if(!p)return;const h=()=>c(D6(p.scrollWidth,p.clientWidth));if(h(),typeof ResizeObserver>"u")return;const x=new ResizeObserver(h);return x.observe(p),()=>x.disconnect()},[e,t]);const u=o>0,f=n&&u;return a.jsx("span",{ref:s,className:`truncate ${t}${f?" title-scroll":""}`,...f?{style:{"--title-scroll-shift":`-${o}px`,"--title-scroll-ms":`${$6(o)}ms`}}:{},...u?{title:e}:{},children:n?a.jsx("span",{className:"title-scroll-text",children:e}):e})}const Fc={emerald:"text-emerald-600 dark:text-emerald-400",amber:"text-amber-600 dark:text-amber-400",red:"text-red-600 dark:text-red-400",gray:"text-gray-400 dark:text-gray-500"},sn={busy:Fc.emerald,attention:Fc.amber,success:Fc.emerald,danger:Fc.red,muted:Fc.gray},vm={emerald:"bg-emerald-50 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300",amber:"bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",red:"bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300",gray:"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300"},bo={attention:vm.amber,success:vm.emerald,danger:vm.red,muted:vm.gray},Fl={busy:"bg-emerald-500",attention:"bg-amber-500",success:"bg-emerald-500"},Df={attention:"border-amber-300 bg-amber-50 text-amber-800 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-300"},U6={gray:bo.muted,brand:"bg-gray-200/80 text-gray-700 dark:bg-gray-700/60 dark:text-gray-200",green:bo.success,yellow:"bg-yellow-50 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-300",amber:bo.attention,red:bo.danger};function On({tone:e="gray",children:t}){return a.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-semibold ${U6[e]}`,children:t})}function P6(e){switch(e){case"completed":return"green";case"aborted":return"amber";default:return"red"}}const z6={running:"M6 3h12M6 21h12M8 3v3.5L12 10l4-3.5V3M8 21v-3.5L12 14l4 3.5V21",compacting:"M4 12h16M8 7l4 3 4-3M8 17l4-3 4 3"},B6={running:`hourglass-turn ${sn.attention}`,compacting:`compact-squeeze ${sn.attention}`};function S0(e){return e==="running"?d.chat.statusRunning:e==="compacting"?d.chat.statusCompacting:d.chat.statusCompletedUnread}function vN({activity:e,size:t=12}){const n=S0(e);return e==="completedUnread"?a.jsx("span",{role:"img","aria-label":n,title:n,style:{width:t,height:t},className:"flex shrink-0 items-center justify-center",children:a.jsx("span",{className:`block h-1.5 w-1.5 rounded-full ${Fl.success}`})}):a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",role:"status","aria-label":n,className:`block shrink-0 ${B6[e]}`,children:[a.jsx("title",{children:n}),a.jsx("path",{d:z6[e]})]})}const H6={primary:"bg-[var(--accent-bg)] text-[var(--accent-fg)] border border-[var(--accent-bg)] transition-opacity hover:opacity-90 disabled:opacity-50",secondary:"bg-white text-gray-800 border border-gray-300 hover:bg-gray-50 dark:bg-gray-900 dark:text-gray-200 dark:border-gray-700 dark:hover:bg-gray-800",danger:"bg-white text-red-600 border border-gray-300 hover:border-red-300 hover:bg-red-50 dark:bg-gray-900 dark:text-red-400 dark:border-gray-700 dark:hover:bg-red-950",ghost:"bg-transparent text-gray-600 border border-transparent hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100"},F6={sm:"px-2.5 py-1 text-xs rounded-md",md:"px-3 py-1.5 text-sm rounded-md",icon:"p-1.5 rounded-md"};function ge({variant:e="secondary",size:t="md",className:n,...s}){return a.jsx("button",{type:"button",className:`inline-flex items-center justify-center gap-1 font-medium transition-colors duration-150 disabled:cursor-not-allowed disabled:opacity-60 ${H6[e]} ${F6[t]} ${n??""}`,...s})}function q6({tone:e}){const t=e==="danger"?"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3zM12 9v4m0 4h.01":"M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z";return a.jsx("span",{"aria-hidden":!0,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full ${e==="danger"?"bg-red-100 text-red-600 dark:bg-red-950/60 dark:text-red-400":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300"}`,children:a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:t})})})}function ln({open:e,title:t,onClose:n,onConfirm:s,confirmLabel:o,confirmDisabled:c=!1,secondaryLabel:u,onSecondary:f,tone:p="danger",busy:h=!1,children:x}){return a.jsxs(Yt,{open:e,title:t,onClose:n,headerless:!0,widthClass:"sm:max-w-sm",children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(q6,{tone:p}),a.jsx("div",{className:"min-w-0 flex-1 pt-1.5",children:x})]}),a.jsxs("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[a.jsx(ge,{size:"sm",onClick:n,disabled:h,children:d.common.cancel}),u!==void 0&&f!==void 0&&a.jsx(ge,{size:"sm",onClick:f,disabled:h,children:u}),a.jsx(ge,{size:"sm",variant:p,disabled:h||c,onClick:s,children:o??d.common.confirm})]})]})}function ql(){const[e,t]=y.useState(null),n=a.jsx(ln,{open:e!==null,title:d.common.confirmSaveTitle,tone:"primary",confirmLabel:d.common.save,onClose:()=>t(null),onConfirm:()=>{e?.(),t(null)},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.common.confirmSaveBody})});return{requestSave:s=>t(()=>s),element:n}}const kw=4,ww=16;function $f({open:e,onClose:t,estimatedHeight:n,panelWidth:s}){const o=y.useRef(null),c=y.useRef(null),[u,f]=y.useState(null),p=y.useRef(t);return p.current=t,y.useLayoutEffect(()=>{if(!e||!o.current)return;const h=o.current.getBoundingClientRect(),x=window.innerHeight-h.bottom,g=h.top,v=Math.min(n,window.innerHeight*.7),w=x<v&&g>x,S=s??h.width,C=Math.max(ww,Math.min(h.left,window.innerWidth-S-ww));f({topPx:w?void 0:h.bottom+kw,bottomPx:w?window.innerHeight-h.top+kw:void 0,left:C,triggerWidth:h.width})},[e,n,s]),y.useEffect(()=>{if(!e)return;const h=w=>{const S=w.target;o.current?.contains(S)||c.current?.contains(S)||p.current()},x=w=>{w.key==="Escape"&&(w.stopPropagation(),p.current())},g=w=>{c.current?.contains(w.target)||p.current()},v=()=>p.current();return window.addEventListener("mousedown",h),window.addEventListener("keydown",x,!0),window.addEventListener("scroll",g,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",x,!0),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",v)}},[e]),{triggerRef:o,panelRef:c,position:u}}const V6="M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9.6 9.3a2.5 2.5 0 0 1 4.9.8c0 1.7-2.5 2.5-2.5 2.5M12 16.8h.01",G6=288;function ba({children:e,label:t,size:n=Ye.inlineGlyph,className:s=""}){const[o,c]=y.useState(!1),u=y.useId(),{triggerRef:f,panelRef:p,position:h}=$f({open:o,onClose:()=>c(!1),estimatedHeight:160,panelWidth:G6}),x=t!==void 0?d.common.moreInfoAbout(t):d.common.moreInfo;return a.jsxs(a.Fragment,{children:[a.jsx("button",{ref:f,type:"button","aria-label":x,title:x,"aria-expanded":o,"aria-controls":u,"aria-describedby":o?u:void 0,onClick:()=>c(g=>!g),className:`inline-flex shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 ${s}`,children:a.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"block shrink-0",children:a.jsx("path",{d:V6})})}),o&&h&&ss.createPortal(a.jsx("div",{ref:p,id:u,role:"tooltip",style:{position:"fixed",top:h.topPx,bottom:h.bottomPx,left:h.left},className:"anim-pop z-[60] max-h-[70vh] w-72 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-md border border-gray-200 bg-white px-3 py-2 text-xs leading-relaxed text-gray-600 shadow-lg dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300",children:e}),document.body)]})}const Uf="rounded-md border border-gray-300 bg-white text-gray-900 transition-[border-color,box-shadow] duration-200 hover:border-gray-400 focus:border-gray-500 focus:outline-none focus:ring-2 focus:ring-gray-400/30 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100 dark:hover:border-gray-600 dark:focus:border-gray-400 dark:focus:ring-gray-500/30",ny="w-full px-3 py-1.5 text-left transition-colors duration-150";function kN({label:e}){return e===void 0?a.jsx("span",{className:"ml-0.5 text-red-500 dark:text-red-400","aria-hidden":!0,children:"*"}):a.jsxs("span",{className:"ml-0.5 text-red-500 dark:text-red-400",children:[a.jsx("span",{"aria-hidden":!0,children:"*"}),a.jsx("span",{className:"sr-only",children:e})]})}function Yn({children:e,required:t,htmlFor:n,block:s=!0}){const o=`text-xs font-semibold text-gray-600 dark:text-gray-400${s?" mb-1 block":""}`,c=a.jsxs(a.Fragment,{children:[e,t&&a.jsx(kN,{})]});return n!==void 0?a.jsx("label",{htmlFor:n,className:o,children:c}):a.jsx("span",{className:o,children:c})}function wo({children:e}){return a.jsx("span",{className:"mt-1 block text-xs text-gray-500 dark:text-gray-500",children:e})}function ga({id:e,children:t}){return a.jsx("span",{id:e,role:"alert",className:"mt-1 block text-xs text-red-600 dark:text-red-400",children:t})}function Vu({label:e,hint:t,error:n,errorId:s,required:o,info:c,infoLabel:u,controlId:f,children:p}){if(!e&&!t&&!n&&!c)return a.jsx(a.Fragment,{children:p});const h=n?a.jsx(ga,{id:s,children:n}):t?a.jsx(wo,{children:t}):null,x=e!=null&&e!=="";return c!=null&&f!==void 0?a.jsxs("div",{className:"block",children:[a.jsxs("span",{className:"mb-1 flex items-center gap-1",children:[x&&a.jsx(Yn,{required:o,htmlFor:f,block:!1,children:e}),a.jsx(ba,{...u!==void 0?{label:u}:{},children:c})]}),p,h]}):a.jsxs("label",{className:"block",children:[x&&a.jsx(Yn,{required:o,children:e}),p,h]})}const wN=`w-full ${Uf} placeholder:text-gray-400 disabled:cursor-not-allowed disabled:opacity-60 dark:placeholder:text-gray-500`,Pf={base:"px-3 py-2 text-base",sm:"px-2 py-1 text-xs"},zf="!border-red-400 !bg-red-50 hover:!border-red-500 focus:!border-red-500 focus:!ring-red-400/30 dark:!border-red-800 dark:!bg-red-950/40 dark:hover:!border-red-700 dark:focus:!border-red-600";function ry(e,t){return e!==void 0&&e!=="off"?{autoComplete:e}:{autoComplete:t?"new-password":"off","data-1p-ignore":"","data-lpignore":"true","data-bwignore":"","data-form-type":"other"}}const Gu=ry(void 0,!1);function at({label:e,hint:t,info:n,infoLabel:s,error:o,invalid:c,required:u,size:f="base",className:p,autoComplete:h,id:x,...g}){const v=!!o||!!c,w=y.useId(),S=y.useId(),C=x??S;return a.jsx(Vu,{label:e,hint:t,error:o,errorId:w,required:u,info:n,infoLabel:s,controlId:C,children:a.jsx("input",{id:n!==void 0?C:x,className:`${wN} ${Pf[f]} ${v?zf:""} ${p??""}`,"aria-invalid":v?!0:void 0,"aria-required":u||void 0,"aria-describedby":o?w:void 0,...ry(h,g.type==="password"),...g})})}const ir=y.forwardRef(function({label:t,hint:n,info:s,infoLabel:o,error:c,invalid:u,required:f,mono:p,size:h="base",className:x,autoComplete:g,id:v,...w},S){const C=!!c||!!u,N=y.useId(),T=y.useId(),_=v??T;return a.jsx(Vu,{label:t,hint:n,error:c,errorId:N,required:f,info:s,infoLabel:o,controlId:_,children:a.jsx("textarea",{ref:S,id:s!==void 0?_:v,className:`${wN} px-3 py-2 ${h==="sm"?"text-xs leading-relaxed":"text-base"} ${p?"font-mono":""} ${C?zf:""} ${x??""}`,"aria-invalid":C?!0:void 0,"aria-required":f||void 0,"aria-describedby":c?N:void 0,...ry(g,!1),...w})})});function on({className:e}){return a.jsx("div",{className:`animate-pulse rounded bg-gray-200 dark:bg-gray-800 ${e??"h-4 w-full"}`})}function Sr({rows:e=3}){return a.jsx("div",{className:"space-y-2 p-2",children:Array.from({length:e},(t,n)=>a.jsx(on,{className:"h-8 w-full"},n))})}function SN({className:e,children:t}){return a.jsx("div",{className:`rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900 ${e??"p-4"}`,children:t??a.jsxs(a.Fragment,{children:[a.jsx(on,{className:"h-3 w-20"}),a.jsx(on,{className:"mt-2.5 h-6 w-28"}),a.jsx(on,{className:"mt-2.5 h-3 w-24"})]})})}function Li(e){y.useEffect(()=>{document.title=e?`${e} · ${d.appName}`:d.appName},[e])}var K6=["partial_text","partial_thinking","partial_tool_call","partial_tool_call_output"];function Nu(e){return K6.includes(e.type??"")}function ay(e){return e.type==="event_msg"}function jN(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sy(e,t){return`[${e}]
127
- ${t}
128
- [/${e}]`}function Vl(e,t,n=""){const s=jN(e);return[new RegExp(`\\[${s}\\]${t}\\[/${s}\\]`,n),new RegExp(`<${s}>${t}</${s}>`,n)]}function Ku(e,t){return e[0].exec(t)??e[1].exec(t)}function Sw(e,t){const n=jN(t);return e.replace(new RegExp(`\\[${n}\\][\\s\\S]*?\\[/${n}\\]`,"g"),"").replace(new RegExp(`\\[/?${n}\\]`,"g"),"").replace(new RegExp(`<${n}>[\\s\\S]*?</${n}>`,"g"),"").replace(new RegExp(`</?${n}>`,"g"),"")}var va={summary:"summary",userSteering:"user_steering",useSkills:"use_skills",handoffFrom:"handoff_from",scheduledTask:"scheduled_task",backgroundTaskDone:"background_task_done",modelSwitchFrom:"model_switch_from"},W6="[attached image: ",Y6="[attached file: ",X6=/^\[attached image: (.+)\]$/,Q6=/^\[attached file: (.+)\]$/;function Z6(e){return X6.exec(e)?.[1]??null}function J6(e){return Q6.exec(e)?.[1]??null}var eL=Vl(va.summary,"([\\s\\S]*?)","g");function tL(e){for(const t of eL)for(const n of e.matchAll(t)){const s=Sw(n[1],va.summary).trim();if(s!=="")return s}return Sw(e,va.summary).trim()}function jw(e,t){if(e.length===0)return t;const n=sy(va.useSkills,`skills: ${e.join(", ")}`);return t?`${n}
129
-
130
- ${t}`:n}var nL=Vl(va.useSkills,"\\nskills: ([^\\n]+)\\n");function CN(e){const t=Ku(nL,e);if(!t||t.index!==0)return null;const n=t[1].split(",").map(s=>s.trim()).filter(s=>s.length>0);return n.length===0?null:{skills:n,rest:e.slice(t[0].length).replace(/^\n+/,"")}}function NN(e){const t=/^([\w-]+) \((.*)\)$/.exec(e);return t?{id:t[1],label:t[2]}:{id:e}}function Bf(e,t){const n=new RegExp(`^(${t.join("|")}): (.+)$`),s=[];for(const o of e.split(`
131
- `)){const c=n.exec(o);c&&s.push([c[1],c[2]])}return s}function rL(e){const t=e.agentName&&e.agentName!==e.agentId?` (${e.agentName})`:"",n=[`agent: ${e.agentId}${t}`];if(e.sessionId){const s=e.sessionTitle?` (${e.sessionTitle})`:"";n.push(`session: ${e.sessionId}${s}`)}return e.workspace&&n.push(`workspace: ${e.workspace}`),sy(va.handoffFrom,["The user handed this conversation to you from another one; its origin is listed below and the user's message, if any, follows. When the request refers to an agent, session, or files without naming them, it means this origin.",...n].join(`
132
- `))}var aL=Vl(va.handoffFrom,"\\n([\\s\\S]*)\\n","");function TN(e){const t=e.trim(),n=Ku(aL,t);if(!n||n.index!==0||n[0].length!==t.length)return null;const s={agentId:""};for(const[o,c]of Bf(n[1],["agent","session","workspace"])){if(o==="workspace"){s.workspace=c;continue}const{id:u,label:f}=NN(c);o==="agent"?(s.agentId=u,f!==void 0&&(s.agentName=f)):(s.sessionId=u,f!==void 0&&(s.sessionTitle=f))}return s.agentId?s:null}var sL=Vl(va.scheduledTask,"\\n([\\s\\S]*?)\\n");function MN(e){const t=Ku(sL,e);if(!t||t.index!==0)return null;const n={name:"",firedAt:""};for(const[s,o]of Bf(t[1],["schedule","fired_at"]))s==="schedule"?n.name=o:n.firedAt=o;return n.name?{origin:n,rest:e.slice(t[0].length).replace(/^\n+/,"")}:null}function iL(e){const t=e.sessionTitle?` (${e.sessionTitle})`:"",n=[`session: ${e.sessionId}${t}`];return e.tracePath&&n.push(`trace: ${e.tracePath}`),e.workspace&&n.push(`workspace: ${e.workspace}`),e.prevModelId&&n.push(`previous_model: ${e.prevModelId}`),e.prevProvider&&n.push(`previous_provider: ${e.prevProvider}`),sy(va.modelSwitchFrom,["The user switched models: this conversation continues an earlier conversation, now on a different model. Its origin is listed below and the user's message, if any, follows. The earlier history is NOT in your context — when you need it, read the trace file at the path below (JSONL, one message envelope per line: user/assistant text, tool calls and results).",...n].join(`
133
- `))}var oL=Vl(va.modelSwitchFrom,"\\n([\\s\\S]*)\\n");function EN(e){const t=e.trim(),n=Ku(oL,t);if(!n||n.index!==0||n[0].length!==t.length)return null;const s={sessionId:""},o=["session","trace","workspace","previous_model","previous_provider"];for(const[c,u]of Bf(n[1],o))if(c==="session"){const{id:f,label:p}=NN(u);s.sessionId=f,p!==void 0&&(s.sessionTitle=p)}else c==="trace"?s.tracePath=u:c==="workspace"?s.workspace=u:c==="previous_model"?s.prevModelId=u:s.prevProvider=u;return s.sessionId?s:null}var lL=Vl(va.backgroundTaskDone,"\\n([\\s\\S]*?)\\n");function _l(e){const t=Ku(lL,e);if(!t||t.index!==0)return null;const n={kind:"command",id:"",status:"completed",detail:""};for(const[s,o]of Bf(t[1],["kind","id","status","detail","delivery"]))s==="kind"&&(o==="command"||o==="subagent")?n.kind=o:s==="id"?n.id=o:s==="status"&&(o==="completed"||o==="failed"||o==="stopped")?n.status=o:s==="detail"?n.detail=o:s==="delivery"&&o==="steering"&&(n.delivery=o);return n.id?{done:n,rest:e.slice(t[0].length).replace(/^\n+/,"")}:null}var cL=new RegExp(`^\\[${va.userSteering}\\]\\n([\\s\\S]*?)\\n\\[/${va.userSteering}\\]\\s*$`);function uL(e){const t=cL.exec(e);return t?t[1]:null}function AN(e){const t=/^\[goal\]\nround: (\d+)\n[\s\S]*?\n\[\/goal\](?:\n|$)/.exec(e);if(!t)return null;const n=Number(t[1]);return!Number.isInteger(n)||n<=0?null:{round:n,rest:e.slice(t[0].length).replace(/^\n+/,"")}}function Cw(e,t){return t?(e.cacheRead*t.cacheRead+e.cacheWrite*t.cacheWrite+e.output*t.output)/1e6:null}function dL(){return{contextNow:0,contextStale:!1,contextAtLastStats:0,sessionTotal:0,subagentTotal:0,taskTokens:0,taskCacheRead:0,taskCacheWrite:0,taskOutput:0,taskMainOutput:0,taskLlmMs:0,pendingCompactionTokens:0,pendingCompactionCacheRead:0,pendingCompactionCacheWrite:0,pendingCompactionOutput:0,hasUsage:!1,sessionElapsedMs:0,compactionActive:!1}}function Nw(e,t){e.subagentTotal=t.subagentTokens,e.sessionElapsedMs=t.elapsedMs,e.sessionTotal=t.sessionTokens,e.contextNow=t.contextTokens,e.contextAtLastStats=t.contextTokens}function _N(e,t){e.taskCacheRead+=t.request.cache_read,e.taskCacheWrite+=t.request.cache_write,e.taskOutput+=t.request.output}function mL(e,t){if(e.sessionTotal=t.session.total,e.compactionActive){e.pendingCompactionTokens+=t.request.total,e.pendingCompactionCacheRead+=t.request.cache_read,e.pendingCompactionCacheWrite+=t.request.cache_write,e.pendingCompactionOutput+=t.request.output;return}e.taskTokens+=t.request.total,_N(e,t),e.contextNow=t.request.total,e.contextStale=!1,e.taskMainOutput+=t.request.output,e.hasUsage=!0}function fL(e){e.pendingCompactionTokens!==0&&(e.taskTokens+=e.pendingCompactionTokens,e.taskCacheRead+=e.pendingCompactionCacheRead,e.taskCacheWrite+=e.pendingCompactionCacheWrite,e.taskOutput+=e.pendingCompactionOutput,e.hasUsage=!0,iy(e))}function iy(e){e.pendingCompactionTokens=0,e.pendingCompactionCacheRead=0,e.pendingCompactionCacheWrite=0,e.pendingCompactionOutput=0}function pL(e,t){t>0&&(e.taskLlmMs+=t)}function hL(e,t){e.taskTokens+=t.request.total,_N(e,t),e.subagentTotal+=t.request.total,e.hasUsage=!0}function gL(e){e.compactionActive=!0}function xL(e,t){e.compactionActive=!1,t==="completed"&&(e.contextStale=!0)}function yL(e){e.taskTokens=0,e.taskCacheRead=0,e.taskCacheWrite=0,e.taskOutput=0,e.taskMainOutput=0,e.taskLlmMs=0,iy(e),e.hasUsage=!1,e.compactionActive=!1}function bL(e,t){if(e.sessionElapsedMs+=t,iy(e),!e.hasUsage)return e.taskTokens=0,null;const n={context:e.contextNow,contextDelta:e.contextNow-e.contextAtLastStats,tokens:e.sessionTotal+e.subagentTotal,tokensDelta:e.taskTokens,elapsedMs:e.sessionElapsedMs,elapsedDeltaMs:t,tokensByBucket:{cacheRead:e.taskCacheRead,cacheWrite:e.taskCacheWrite,output:e.taskOutput},outputTps:v0(e.taskMainOutput,e.taskLlmMs)};return e.contextAtLastStats=e.contextNow,e.taskTokens=0,e.taskCacheRead=0,e.taskCacheWrite=0,e.taskOutput=0,e.taskMainOutput=0,e.taskLlmMs=0,e.hasUsage=!1,e.compactionActive=!1,n}function vL(e,t,n,s){const o=t&&n!=null?Math.max(0,s-n):0;return e.sessionElapsedMs+o}function kL(e,t){const n=e.tokensByBucket;return`[${t.stats}] ${t.input} ${It(n.cacheRead+n.cacheWrite)}${t.parenOpen}${t.cached} ${It(n.cacheRead)}${t.parenClose} · ${t.output} ${It(n.output)} · ${sf(e.outputTps)}`}function Qa(e){return`${e.scope} ${e.scopeKey??""} ${e.file}`}function Tw(e){return e.split(/[\\/]/).filter(t=>t.length>0)}function wL(e,t){const n=[...Tw(t),"memory"],s=Tw(e);if(s.length<=n.length+1)return null;for(let u=0;u<n.length;u++)if(s[u]!==n[u])return null;const o=s[n.length],c=s.slice(n.length+1).join("/");return c==="MEMORY.md"||c===".workspace"?null:o==="user"?{scope:"user",file:c}:{scope:"workspace",scopeKey:o,file:c}}function SL(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],o=t[n];if(s.scope!==o.scope||s.scopeKey!==o.scopeKey||s.file!==o.file||s.op!==o.op||s.atMs!==o.atMs)return!1}return!0}function RN(e){const t=new Map;for(const n of e){const s=Qa(n),o=t.get(s);if(o===void 0){const c={scope:n.scope,file:n.file,op:n.op};n.scopeKey!==void 0&&(c.scopeKey=n.scopeKey),n.atMs!==void 0&&(c.atMs=n.atMs),t.set(s,c)}else n.op==="write"&&(o.op="write"),n.atMs!==void 0&&(o.atMs=n.atMs)}return[...t.values()]}function jL(e){const t=[];for(const n of e)for(const s of n){const o={scope:s.scope,file:s.file,op:s.op};s.scopeKey!==void 0&&(o.scopeKey=s.scopeKey),s.atMs!==void 0&&(o.atMs=s.atMs),t.push(o)}return RN(t)}function CL(e){return e==="retryable"||e==="failed"||e==="timeout"||e==="malformed"}function IN(e,t){return{items:[],nested:e,meta:null,agentState:null,stats:dL(),openText:null,openThinking:null,pendingText:null,pendingThinking:null,openSteering:null,toolCards:new Map,subagents:new Map,localDecisions:t,pendingDecisions:new Map,pendingDecisionTs:new Map,lastTsMs:0,openRequestBeginMs:null,openApprovalWaitMs:0,taskOpen:!1,taskStartLocalMs:0,taskFirstTsMs:0,taskLastTsMs:0,taskLastReqEndMs:null,turnToolOutputs:!1,reopenTaskAtSteering:!1,nextItemId:1}}function bl(e=new Set){return IN(!1,e)}function gr(e){return e.nextItemId++}function Tu(e,t,n=Date.now()){if(t.origin&&t.origin.length>0){zL(e,t,n);return}if(NL(t)||(e.openSteering=null),t.type==="model_msg"){if(e.stats.compactionActive){if(pa(e,t.timestamp),Nu(t.payload)){const o=t.payload;o.type==="partial_text"&&o.text&&Aw(e,o.text);return}wg(e,t.timestamp);const s=t.payload;s.type==="text"&&s.role==="assistant"&&s.text&&Aw(e,s.text);return}if(Nu(t.payload)){pa(e,t.timestamp),LL(e,t.payload,Ua(t.timestamp));return}OL(e,t.payload,t.timestamp,n,t.tracePosition),wg(e,t.timestamp);return}if(ay(t)){pa(e,t.timestamp),DL(e,t.payload,Ua(t.timestamp),n),wg(e,t.timestamp);return}if(t.type==="session_meta"&&(e.agentState=t.payload.agent_state),t.type==="session_meta"&&e.nested){const s=t.payload,o={agentId:TL(s.agent_state),provider:s.provider,modelId:s.model_id};s.source!==void 0&&(o.source=s.source),e.meta=o}}function NL(e){return e.type==="model_msg"&&e.payload.type==="image_url"}function TL(e){const t=e.split(/[\\/]/).filter(n=>n.length>0);return t.length>=2?t[t.length-2]:null}function ML(e,t){const n=t.join("/");for(const s of e)if(s.startsWith(`${n} `)||s.startsWith(`${n}/`))return!0;return!1}function Ua(e){const t=Date.parse(e);return Number.isFinite(t)?t:void 0}function wg(e,t){const n=Date.parse(t);Number.isFinite(n)&&(e.lastTsMs=n)}function Mw(e,t,n=Date.now(),s=null){for(const o of t)Tu(e,o,n);if(e.taskOpen){const o=e.taskLastTsMs-e.taskFirstTsMs,c=s===null?0:s-e.taskFirstTsMs;e.taskStartLocalMs=n-Math.max(0,o,c)}}function EL(e){Hf(e)}function j0(e){Hf(e)}function AL(e,t){e.localDecisions.add(t)}function Rl(e,t){return`${e?.join("/")??""} ${t}`}function _L(e,t,n){let s=e;for(const o of t??[])if(s=s.subagents.get(o),!s)return null;return s.toolCards.get(n)??null}function pa(e,t){if(!e.taskOpen||e.stats.compactionActive)return;const n=Date.parse(t);!Number.isFinite(n)||n<=e.taskLastTsMs||(e.taskLastTsMs=n)}function km(e,t,n){Hf(e);const s=M0(e);s&&(s.gaveUp=!0),e.openRequestBeginMs=null,e.openApprovalWaitMs=0,e.turnToolOutputs=!1,e.reopenTaskAtSteering=!1,e.taskOpen=!0,e.taskStartLocalMs=n;const o=Date.parse(t);e.taskFirstTsMs=Number.isFinite(o)?o:n,e.taskLastTsMs=e.taskFirstTsMs,e.taskLastReqEndMs=null,yL(e.stats)}function Hf(e){if(!e.taskOpen)return;e.taskOpen=!1,LN(e);const t=e.taskLastReqEndMs??e.taskLastTsMs,n=Math.max(0,t-e.taskFirstTsMs),s=bL(e.stats,n);if(e.nested)return;const o=RL(e),c=IL(e);if(s===null&&o.text==="")return;const u={kind:"task_stats",id:gr(e),stats:s,assistantText:o.text,forkable:o.completed,...o.atMs!==void 0?{atMs:o.atMs}:{},...o.tracePosition!==void 0?{forkPosition:o.tracePosition}:{},...c.length>0?{memoryChanges:c}:{}};let f=e.items.length;for(;f>0&&e.items[f-1].kind==="compaction";)f--;e.items.splice(f,0,u)}function RL(e){const t=[];let n,s,o=!1;for(let c=e.items.length-1;c>=0;c--){const u=e.items[c];if(u.kind==="task_stats")break;u.kind==="assistant_text"&&u.text.trim()&&(t.push(u.text),n===void 0&&(n=u.atMs,s=u.tracePosition,o=u.stopReason==="completed"))}return{text:t.reverse().join(`
134
-
135
- `),...n!==void 0?{atMs:n}:{},...s!==void 0?{tracePosition:s}:{},completed:o}}function IL(e){if(e.agentState===null)return[];const t=[];for(let n=e.items.length-1;n>=0;n--){const s=e.items[n];if(s.kind==="task_stats")break;if(s.kind!=="tool_call"||!s.outputComplete||s.outputStopReason!=="completed"||s.name!=="write_file"&&s.name!=="edit_file")continue;let o;try{o=JSON.parse(s.argumentsText)}catch{continue}const c=o.file_path;if(typeof c!="string")continue;const u=wL(c,e.agentState);if(u===null)continue;const f={...u,op:s.name==="write_file"?"write":"edit"};s.callStartedAtMs!==void 0&&(f.atMs=s.callStartedAtMs),t.push(f)}return RN(t.reverse())}function LL(e,t,n){switch(t.type){case"partial_text":{if(t.event_type==="start"){e.pendingText=null;const o={kind:"assistant_text",id:gr(e),text:t.text??"",streaming:!0,...n!==void 0?{atMs:n}:{}};e.openText=o,e.items.push(o);return}const s=e.openText;if(!s)return;t.text&&(s.text+=t.text),t.event_type==="stop"&&(s.streaming=!1,t.stop_reason!==void 0&&(s.stopReason=t.stop_reason),e.pendingText=s,e.openText=null);return}case"partial_thinking":{if(t.event_type==="start"){e.pendingThinking=null;const o={kind:"thinking",id:gr(e),thinking:t.thinking??"",streaming:!0};n!==void 0&&(o.startedAtMs=n),e.openThinking=o,e.items.push(o);return}const s=e.openThinking;if(!s)return;t.thinking&&(s.thinking+=t.thinking),t.event_type==="stop"&&(s.streaming=!1,t.stop_reason!==void 0&&(s.stopReason=t.stop_reason),C0(s,n),e.pendingThinking=s,e.openThinking=null);return}case"partial_tool_call":{const s=e.toolCards.get(t.tool_call_id);if(s?.callComplete)return;if(t.event_type==="start"){if(s){s.name=t.name||s.name,s.argumentsText=t.arguments??"",s.callStreaming=!0,n!==void 0&&s.argStartedAtMs===void 0&&(s.argStartedAtMs=n);return}const o=T0(e,{toolCallId:t.tool_call_id,name:t.name,argumentsText:t.arguments??"",callStreaming:!0});n!==void 0&&(o.argStartedAtMs=n);return}if(!s)return;t.name&&!s.name&&(s.name=t.name),t.arguments&&(s.argumentsText+=t.arguments),t.event_type==="stop"&&(s.callStreaming=!1,t.stop_reason!==void 0&&(s.callStopReason=t.stop_reason),n!==void 0&&(s.callStartedAtMs=n));return}case"partial_tool_call_output":{const s=e.toolCards.get(t.tool_call_id);if(!s||s.outputComplete)return;if(t.event_type==="start"){s.outputStreaming=!0,t.output&&(s.output+=t.output),t.images&&t.images.length>0&&(s.images=t.images);return}if(!s.outputStreaming)return;t.output&&(s.output+=t.output),t.images&&t.images.length>0&&(s.images=t.images),t.event_type==="stop"&&(s.outputStreaming=!1,t.stop_reason!==void 0&&(s.outputStopReason=t.stop_reason),ON(s,n));return}}}function OL(e,t,n,s,o){switch(t.type){case"text":{if(t.role==="user"){if(t.text.startsWith("[context_summary]")||t.text.startsWith("<context_summary>")){pa(e,n);return}const p=uL(t.text);if(p!==null){e.reopenTaskAtSteering&&!e.taskOpen&&km(e,n,s),pa(e,n);const g=Ua(n),v={kind:"user_steering",id:gr(e),text:p,...g!==void 0?{atMs:g}:{}};e.items.push(v),e.openSteering=v;return}const h=_l(t.text);if(h!==null&&(h.done.delivery==="steering"||e.turnToolOutputs)){e.reopenTaskAtSteering&&!e.taskOpen&&km(e,n,s),pa(e,n);const g=Ua(n);e.items.push({kind:"background_notice",id:gr(e),text:t.text,...g!==void 0?{atMs:g}:{}});return}km(e,n,s);const x=Ua(n);e.items.push({kind:"user_text",id:gr(e),text:t.text,...x!==void 0?{atMs:x}:{}});return}pa(e,n);const c=e.pendingText??e.openText;if(c){if(!t.text.trim()){du(e,c),c===e.openText&&(e.openText=null),e.pendingText=null;return}c.text=t.text,c.streaming=!1;const p=Ua(n);p!==void 0&&(c.atMs=p),o!==void 0&&(c.tracePosition=o),t.stop_reason!==void 0&&(c.stopReason=t.stop_reason),c===e.openText&&(e.openText=null),e.pendingText=null;return}if(!t.text.trim())return;const u=Ua(n),f={kind:"assistant_text",id:gr(e),text:t.text,streaming:!1,...u!==void 0?{atMs:u}:{},...o!==void 0?{tracePosition:o}:{}};t.stop_reason!==void 0&&(f.stopReason=t.stop_reason),e.items.push(f);return}case"image_url":{if(e.openSteering){pa(e,n),e.openSteering.images=[...e.openSteering.images??[],t.image_url];return}km(e,n,s);const c=Ua(n);e.items.push({kind:"user_image",id:gr(e),imageUrl:t.image_url,...c!==void 0?{atMs:c}:{}});return}case"thinking":{pa(e,n);const c=Ua(n),u=e.pendingThinking??e.openThinking;if(u){if(!t.thinking.trim()){du(e,u),u===e.openThinking&&(e.openThinking=null),e.pendingThinking=null;return}u.thinking=t.thinking,u.streaming=!1,t.stop_reason!==void 0&&(u.stopReason=t.stop_reason),C0(u,c),u===e.openThinking&&(e.openThinking=null),e.pendingThinking=null;return}if(!t.thinking.trim())return;const f={kind:"thinking",id:gr(e),thinking:t.thinking,streaming:!1};t.stop_reason!==void 0&&(f.stopReason=t.stop_reason),e.lastTsMs>0&&(f.startedAtMs=e.lastTsMs),C0(f,c),e.items.push(f);return}case"tool_call":{pa(e,n);const c=Ua(n),u=e.toolCards.get(t.tool_call_id),f=u?.callComplete?void 0:u;if(f){f.name=t.name,f.argumentsText=t.arguments,f.callStreaming=!1,f.callComplete=!0,t.stop_reason!==void 0&&(f.callStopReason=t.stop_reason),c!==void 0&&(f.callStartedAtMs=c),N0(e,f),Ew(f);return}u&&!u.outputComplete&&(u.outputComplete=!0,u.outputStreaming=!1,u.outputStopReason??="aborted");const p=T0(e,{toolCallId:t.tool_call_id,name:t.name,argumentsText:t.arguments,callStreaming:!1});p.callComplete=!0,t.stop_reason!==void 0&&(p.callStopReason=t.stop_reason),c!==void 0&&(p.callStartedAtMs=c),N0(e,p),e.lastTsMs>0&&(p.argStartedAtMs=e.lastTsMs),Ew(p);return}case"tool_call_output":{pa(e,n);let c=e.toolCards.get(t.tool_call_id);c||(c=T0(e,{toolCallId:t.tool_call_id,name:"",argumentsText:"",callStreaming:!1})),c.output=t.output,t.images&&t.images.length>0&&(c.images=t.images),c.outputStreaming=!1,c.outputComplete=!0,t.stop_reason!==void 0&&(c.outputStopReason=t.stop_reason),ON(c,Ua(n)),e.turnToolOutputs=!0;return}case"inline_data":case"inline_thinking":pa(e,n);return}}function LN(e){for(const t of e.toolCards.values())t.callComplete&&!t.outputComplete&&(t.outputComplete=!0,t.outputStreaming=!1,t.outputStopReason??="aborted")}function Ew(e){!e.callStopReason||e.callStopReason==="completed"||e.outputComplete||(e.outputComplete=!0,e.outputStreaming=!1,e.outputStopReason??=e.callStopReason)}function C0(e,t){t===void 0||e.startedAtMs===void 0||(e.durationMs=Math.max(0,t-e.startedAtMs))}function ON(e,t){if(t===void 0)return;const n=e.approvalAtMs??e.callStartedAtMs;if(n===void 0)return;const s=e.argStartedAtMs!==void 0&&e.callStartedAtMs!==void 0?Math.max(0,e.callStartedAtMs-e.argStartedAtMs):0;e.durationMs=s+Math.max(0,t-n)}function N0(e,t){if(t.approvalWaitCounted)return;const{callStartedAtMs:n,approvalAtMs:s}=t;if(n===void 0||s===void 0)return;t.approvalWaitCounted=!0;const o=s-n;o>0&&(e.openApprovalWaitMs+=o)}function T0(e,t){const n={kind:"tool_call",id:gr(e),toolCallId:t.toolCallId,name:t.name,argumentsText:t.argumentsText,callStreaming:t.callStreaming,callComplete:!1,output:"",outputStreaming:!1,outputComplete:!1},s=e.pendingDecisions.get(t.toolCallId);if(s!==void 0){n.decision=s,n.decisionSource=e.localDecisions.has(t.toolCallId)?"manual":"remote",e.pendingDecisions.delete(t.toolCallId);const o=e.pendingDecisionTs.get(t.toolCallId);o!==void 0&&(n.approvalAtMs=o,e.pendingDecisionTs.delete(t.toolCallId))}return e.toolCards.set(t.toolCallId,n),e.items.push(n),n}function DL(e,t,n,s){switch(t.type){case"approval_decision":{const o=e.toolCards.get(t.tool_call_id);o?(o.decision=t.decision,o.decisionSource=e.localDecisions.has(t.tool_call_id)?"manual":"remote",n!==void 0&&o.approvalAtMs===void 0&&(o.approvalAtMs=n),N0(e,o)):(e.pendingDecisions.set(t.tool_call_id,t.decision),n!==void 0&&e.pendingDecisionTs.set(t.tool_call_id,n));return}case"abort":{LN(e);const o=M0(e);o&&(o.gaveUp=!0);const c={kind:"abort",id:gr(e)};typeof t.error_code=="string"&&(c.errorCode=t.error_code),typeof t.error_message=="string"&&(c.errorMessage=t.error_message),t.reason!=null&&(c.reason=t.reason),e.items.push(c);return}case"token_usage":mL(e.stats,t);return;case"mcp_connect_begin":{e.items.push({kind:"mcp_connect",id:gr(e),servers:t.servers,running:!0,...n!==void 0?{beginTsMs:n}:{}});return}case"mcp_connect_end":{const o=$L(e);if(!o)return;o.running=!1,n!==void 0&&o.beginTsMs!==void 0&&(o.durationMs=Math.max(0,n-o.beginTsMs)),t.status==="aborted"&&(o.aborted=!0),o.toolCount=t.results.reduce((u,f)=>u+(f.tools??0),0),o.results=t.results.map(u=>{const f=u.error_message??u.error;return{server:u.server,status:u.status,durationMs:u.duration_ms,...u.tools!==void 0?{tools:u.tools}:{},...f!==void 0?{error:f.slice(0,500)}:{}}});const c=t.results.filter(u=>u.status==="fatal"||u.status==="failed");c.length>0&&(o.failed=c.map(u=>u.server));return}case"tool_list_ready":{const o=UL(e);if(!o)return;const c=t.tools.filter(u=>u.name.startsWith("mcp__"));c.length>0&&(o.tools=c.map(u=>({name:u.name,...u.description!==void 0?{description:u.description}:{}})));return}case"compaction_begin":{PL(e)&&(Hf(e),e.reopenTaskAtSteering=!0),gL(e.stats),e.items.push({kind:"compaction",id:gr(e),reason:t.reason,mode:t.mode,running:!0,...n!==void 0?{beginTsMs:n}:{}});return}case"compaction_end":{xL(e.stats,t.status);const o=DN(e);if(o)o.running=!1,o.status=t.status,t.error_message!==void 0&&(o.errorMessage=t.error_message),n!==void 0&&o.beginTsMs!==void 0&&(o.durationMs=Math.max(0,n-o.beginTsMs)),t.status!=="completed"&&delete o.summaryText;else{const c={kind:"compaction",id:gr(e),reason:t.reason,mode:t.mode,running:!1,status:t.status,...t.error_message!==void 0?{errorMessage:t.error_message}:{}};e.items.push(c)}return}case"request_begin":{const o=M0(e);o&&(o.retrying=!0),e.stats.compactionActive||(e.openRequestBeginMs=n??null,e.openApprovalWaitMs=0,e.turnToolOutputs=!1);return}case"request_end":{if(e.stats.compactionActive)return;if(e.openRequestBeginMs!==null&&n!==void 0&&pL(e.stats,n-e.openRequestBeginMs-e.openApprovalWaitMs),e.openRequestBeginMs=null,e.openApprovalWaitMs=0,n!==void 0&&(e.taskLastReqEndMs=n),fL(e.stats),t.status==="fatal"){const o={kind:"llm_error",id:gr(e)};typeof t.error_code=="string"&&(o.errorCode=t.error_code),typeof t.error_message=="string"&&t.error_message&&(o.errorMessage=t.error_message),e.items.push(o);return}if(CL(t.status)){const o={kind:"reconnect",id:gr(e),status:t.status,attempt:t.attempt??1,retrying:!1};typeof t.error_code=="string"&&(o.errorCode=t.error_code),typeof t.error_message=="string"&&t.error_message&&(o.errorMessage=t.error_message),typeof t.retry_in_ms=="number"&&t.retry_in_ms>0?(o.plannedDelayMs=t.retry_in_ms,o.arrivedAtMs=s??Date.now()):t.status==="retryable"&&(o.gaveUp=!0),e.items.push(o)}return}}}function $L(e){for(let t=e.items.length-1;t>=0;t-=1){const n=e.items[t];if(n.kind==="mcp_connect"&&n.running)return n}return null}function UL(e){for(let t=e.items.length-1;t>=0;t-=1){const n=e.items[t];if(n.kind==="mcp_connect")return n}return null}function DN(e){for(let t=e.items.length-1;t>=0;t--){const n=e.items[t];if(n.kind==="compaction"&&n.running)return n}return null}function Aw(e,t){if(!t)return;const n=DN(e);n&&(n.summaryText=(n.summaryText??"")+t)}function PL(e){return!e.taskOpen||e.turnToolOutputs?!1:e.items[e.items.length-1]?.kind==="assistant_text"}function M0(e){for(let t=e.items.length-1;t>=0;t--){const n=e.items[t];if(n.kind==="reconnect")return!n.retrying&&!n.gaveUp?n:null}return null}function zL(e,t,n){const s=t.origin[0];ay(t)&&t.payload.type==="token_usage"&&hL(e.stats,t.payload),pa(e,t.timestamp);let o=e.subagents.get(s);o||(o=IN(!0,e.localDecisions),o.firstSeenLocalMs=n,e.subagents.set(s,o),BL(e,s,o)),o.lastActivityLocalMs=n;const c=Ua(t.timestamp);c!==void 0&&(o.firstTsMs===void 0&&(o.firstTsMs=c),(o.lastActivityTsMs===void 0||c>o.lastActivityTsMs)&&(o.lastActivityTsMs=c));const u=t.origin.slice(1),f={...t};u.length>0?f.origin=u:delete f.origin,Tu(o,f,n)}function BL(e,t,n){for(let s=e.items.length-1;s>=0;s--){const o=e.items[s];if(o.kind==="tool_call"&&o.name==="run_subagent"&&!o.subagent&&!o.outputComplete&&o.decision==="allow"){o.subagent=n,o.subagentSessionId=t;return}}e.items.push({kind:"subagent",id:gr(e),sessionId:t,model:n})}function $N(e){const{tracePosition:t,...n}=e;return JSON.stringify(n)}function HL(e,t=100){const n=new Set;for(let s=Math.max(0,e.length-t);s<e.length;s++)n.add($N(e[s]));return n}function FL(e,t){return e.has($N(t))}function UN(e,t){if(t.origin&&t.origin.length>0){const s=e.subagents.get(t.origin[0]);if(!s)return;const o=t.origin.slice(1),c={...t};o.length>0?c.origin=o:delete c.origin,UN(s,c);return}if(t.type!=="model_msg"||Nu(t.payload))return;const n=t.payload;switch(n.type){case"text":{if(n.role!=="assistant")return;const s=e.pendingText??e.openText;s&&(du(e,s),s===e.openText&&(e.openText=null),e.pendingText=null);return}case"thinking":{const s=e.pendingThinking??e.openThinking;s&&(du(e,s),s===e.openThinking&&(e.openThinking=null),e.pendingThinking=null);return}case"tool_call":{const s=e.toolCards.get(n.tool_call_id);s&&!s.callComplete&&(du(e,s),e.toolCards.delete(n.tool_call_id));return}case"tool_call_output":{const s=e.toolCards.get(n.tool_call_id);s&&!s.outputComplete&&(s.output="",s.outputStreaming=!1);return}default:return}}function du(e,t){const n=e.items.indexOf(t);n>=0&&e.items.splice(n,1)}const Xn={input:"M12 15V5m0 0L8 9m4-4l4 4M4 19h16",output:"M12 3v10m0 0l-4-4m4 4l4-4M4 19h16",cacheHit:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-5a4 4 0 1 0 0-8 4 4 0 0 0 0 8zm0-3a1 1 0 1 0 0-2 1 1 0 0 0 0 2z",tokens:"M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3zm0 0v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",toolCalls:"M14.7 6.3a4 4 0 0 0-5 5L4 17v3h3l5.7-5.7a4 4 0 0 0 5-5l-2.5 2.5-2-2 2.5-2.5z",tps:"M5 18a8 8 0 1 1 14 0M12 12l4-3",elapsed:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-14v5l3 2",services:"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5zm0 11a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3zM7 6.5h.01M7 17.5h.01",cost:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-15v12m2.6-9.3c-.5-.8-1.5-1.2-2.6-1.2-1.5 0-2.7.8-2.7 2 0 2.7 5.4 1.3 5.4 4 0 1.2-1.2 2-2.7 2-1.2 0-2.2-.5-2.7-1.4",copy:"M9 9h9v9a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2V9zM7 15H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v1",check:"M5 13l4 4L19 7"},qL=1500;function VL(e){navigator.clipboard?.writeText(e)}function lf(){const[e,t]=y.useState(!1),n=y.useRef(null);return y.useEffect(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]),{copied:e,flash:o=>{VL(o),t(!0),n.current!==null&&clearTimeout(n.current),n.current=setTimeout(()=>{n.current=null,t(!1)},qL)}}}function cf({copied:e,size:t}){return a.jsx(Oe,{d:e?Xn.check:Xn.copy,size:t})}function uf({copied:e}){return a.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:e?d.common.copied:""})}const GL="rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",PN="shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-300";function Wu({text:e,label:t,className:n=GL}){const{copied:s,flash:o}=lf();return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",title:s?d.common.copied:t,"aria-label":t,onClick:()=>o(typeof e=="function"?e():e),className:n,children:a.jsx(cf,{copied:s})}),a.jsx(uf,{copied:s})]})}function Fa({title:e,description:t,action:n}){return a.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center",children:[a.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:e}),t&&a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:t}),n&&a.jsx("div",{className:"mt-2",children:n})]})}function Ff({children:e}){return a.jsx("div",{className:"flex min-h-24 items-center justify-center rounded-md border border-dashed border-gray-300 px-4 text-center text-xs text-gray-400 dark:border-gray-700 dark:text-gray-500",children:e})}const zN=/[/\\]scratchpad[/\\]([^/\\]+)[/\\]([^/\\]+)$/;function KL(e){if(/^https?:\/\//i.test(e))return e;const t=zN.exec(e);return t?`/api/sessions/${encodeURIComponent(t[1])}/scratchpad/${encodeURIComponent(t[2])}`:null}function df(e){if(!e.includes(W6)&&!e.includes(Y6))return{text:e,images:[],files:[]};const t=[],n=[],s=[];for(const o of e.split(`
136
- `)){const c=o.trim(),u=Z6(c),f=u!==null?KL(u):null;if(f){n.push(f);continue}const p=J6(c);if(p!==null&&zN.test(p)){s.push(p);continue}t.push(o)}return{text:t.join(`
137
- `).replace(/\n+$/,""),images:n,files:s}}function WL(e){const t=e.split(/[/\\]/);return t[t.length-1]||e}function YL(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const XL=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QL=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZL={};function _w(e,t){return(ZL.jsx?QL:XL).test(e)}const JL=/[ \t\n\f\r]/g;function e8(e){return typeof e=="object"?e.type==="text"?Rw(e.value):!1:Rw(e)}function Rw(e){return e.replace(JL,"")===""}class Yu{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Yu.prototype.normal={};Yu.prototype.property={};Yu.prototype.space=void 0;function BN(e,t){const n={},s={};for(const o of e)Object.assign(n,o.property),Object.assign(s,o.normal);return new Yu(n,s,t)}function E0(e){return e.toLowerCase()}class ea{constructor(t,n){this.attribute=n,this.property=t}}ea.prototype.attribute="";ea.prototype.booleanish=!1;ea.prototype.boolean=!1;ea.prototype.commaOrSpaceSeparated=!1;ea.prototype.commaSeparated=!1;ea.prototype.defined=!1;ea.prototype.mustUseProperty=!1;ea.prototype.number=!1;ea.prototype.overloadedBoolean=!1;ea.prototype.property="";ea.prototype.spaceSeparated=!1;ea.prototype.space=void 0;let t8=0;const xt=Io(),Kn=Io(),A0=Io(),Le=Io(),un=Io(),So=Io(),ma=Io();function Io(){return 2**++t8}const _0=Object.freeze(Object.defineProperty({__proto__:null,boolean:xt,booleanish:Kn,commaOrSpaceSeparated:ma,commaSeparated:So,number:Le,overloadedBoolean:A0,spaceSeparated:un},Symbol.toStringTag,{value:"Module"})),Sg=Object.keys(_0);class oy extends ea{constructor(t,n,s,o){let c=-1;if(super(t,n),Iw(this,"space",o),typeof s=="number")for(;++c<Sg.length;){const u=Sg[c];Iw(this,Sg[c],(s&_0[u])===_0[u])}}}oy.prototype.defined=!0;function Iw(e,t,n){n&&(e[t]=n)}function Gl(e){const t={},n={};for(const[s,o]of Object.entries(e.properties)){const c=new oy(s,e.transform(e.attributes||{},s),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(c.mustUseProperty=!0),t[s]=c,n[E0(s)]=s,n[E0(c.attribute)]=s}return new Yu(t,n,e.space)}const HN=Gl({properties:{ariaActiveDescendant:null,ariaAtomic:Kn,ariaAutoComplete:null,ariaBusy:Kn,ariaChecked:Kn,ariaColCount:Le,ariaColIndex:Le,ariaColSpan:Le,ariaControls:un,ariaCurrent:null,ariaDescribedBy:un,ariaDetails:null,ariaDisabled:Kn,ariaDropEffect:un,ariaErrorMessage:null,ariaExpanded:Kn,ariaFlowTo:un,ariaGrabbed:Kn,ariaHasPopup:null,ariaHidden:Kn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:un,ariaLevel:Le,ariaLive:null,ariaModal:Kn,ariaMultiLine:Kn,ariaMultiSelectable:Kn,ariaOrientation:null,ariaOwns:un,ariaPlaceholder:null,ariaPosInSet:Le,ariaPressed:Kn,ariaReadOnly:Kn,ariaRelevant:null,ariaRequired:Kn,ariaRoleDescription:un,ariaRowCount:Le,ariaRowIndex:Le,ariaRowSpan:Le,ariaSelected:Kn,ariaSetSize:Le,ariaSort:null,ariaValueMax:Le,ariaValueMin:Le,ariaValueNow:Le,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function FN(e,t){return t in e?e[t]:t}function qN(e,t){return FN(e,t.toLowerCase())}const n8=Gl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:So,acceptCharset:un,accessKey:un,action:null,allow:null,allowFullScreen:xt,allowPaymentRequest:xt,allowUserMedia:xt,alpha:xt,alt:null,as:null,async:xt,autoCapitalize:null,autoComplete:un,autoFocus:xt,autoPlay:xt,blocking:un,capture:null,charSet:null,checked:xt,cite:null,className:un,closedBy:null,colorSpace:null,cols:Le,colSpan:Le,command:null,commandFor:null,content:null,contentEditable:Kn,controls:xt,controlsList:un,coords:Le|So,crossOrigin:null,data:null,dateTime:null,decoding:null,default:xt,defer:xt,dir:null,dirName:null,disabled:xt,download:A0,draggable:Kn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:xt,formTarget:null,headers:un,height:Le,hidden:A0,high:Le,href:null,hrefLang:null,htmlFor:un,httpEquiv:un,id:null,imageSizes:null,imageSrcSet:null,inert:xt,inputMode:null,integrity:null,is:null,isMap:xt,itemId:null,itemProp:un,itemRef:un,itemScope:xt,itemType:un,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:xt,low:Le,manifest:null,max:null,maxLength:Le,media:null,method:null,min:null,minLength:Le,multiple:xt,muted:xt,name:null,nonce:null,noModule:xt,noValidate:xt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:xt,optimum:Le,pattern:null,ping:un,placeholder:null,playsInline:xt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:xt,referrerPolicy:null,rel:un,required:xt,reversed:xt,rows:Le,rowSpan:Le,sandbox:un,scope:null,scoped:xt,seamless:xt,selected:xt,shadowRootClonable:xt,shadowRootCustomElementRegistry:xt,shadowRootDelegatesFocus:xt,shadowRootMode:null,shadowRootSerializable:xt,shape:null,size:Le,sizes:null,slot:null,span:Le,spellCheck:Kn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Le,step:null,style:null,tabIndex:Le,target:null,title:null,translate:null,type:null,typeMustMatch:xt,useMap:null,value:Kn,width:Le,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:un,axis:null,background:null,bgColor:null,border:Le,borderColor:null,bottomMargin:Le,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:xt,declare:xt,event:null,face:null,frame:null,frameBorder:null,hSpace:Le,leftMargin:Le,link:null,longDesc:null,lowSrc:null,marginHeight:Le,marginWidth:Le,noResize:xt,noHref:xt,noShade:xt,noWrap:xt,object:null,profile:null,prompt:null,rev:null,rightMargin:Le,rules:null,scheme:null,scrolling:Kn,standby:null,summary:null,text:null,topMargin:Le,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Le,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:xt,disablePictureInPicture:xt,disableRemotePlayback:xt,exportParts:So,part:un,prefix:null,property:null,results:Le,security:null,unselectable:null},space:"html",transform:qN}),r8=Gl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ma,accentHeight:Le,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Le,amplitude:Le,arabicForm:null,ascent:Le,attributeName:null,attributeType:null,azimuth:Le,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Le,by:null,calcMode:null,capHeight:Le,className:un,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Le,diffuseConstant:Le,direction:null,display:null,dur:null,divisor:Le,dominantBaseline:null,download:xt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Le,enableBackground:null,end:null,event:null,exponent:Le,externalResourcesRequired:null,fill:null,fillOpacity:Le,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:So,g2:So,glyphName:So,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Le,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Le,horizOriginX:Le,horizOriginY:Le,id:null,ideographic:Le,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Le,k:Le,k1:Le,k2:Le,k3:Le,k4:Le,kernelMatrix:ma,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Le,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Le,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Le,overlineThickness:Le,paintOrder:null,panose1:null,path:null,pathLength:Le,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:un,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Le,pointsAtY:Le,pointsAtZ:Le,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ma,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ma,rev:ma,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ma,requiredFeatures:ma,requiredFonts:ma,requiredFormats:ma,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Le,specularExponent:Le,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Le,strikethroughThickness:Le,string:null,stroke:null,strokeDashArray:ma,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Le,strokeOpacity:Le,strokeWidth:null,style:null,surfaceScale:Le,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ma,tabIndex:Le,tableValues:null,target:null,targetX:Le,targetY:Le,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ma,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Le,underlineThickness:Le,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Le,values:null,vAlphabetic:Le,vMathematical:Le,vectorEffect:null,vHanging:Le,vIdeographic:Le,version:null,vertAdvY:Le,vertOriginX:Le,vertOriginY:Le,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Le,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:FN}),VN=Gl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),GN=Gl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:qN}),KN=Gl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),a8={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},s8=/[A-Z]/g,Lw=/-[a-z]/g,i8=/^data[-\w.:]+$/i;function o8(e,t){const n=E0(t);let s=t,o=ea;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&i8.test(t)){if(t.charAt(4)==="-"){const c=t.slice(5).replace(Lw,c8);s="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=t.slice(4);if(!Lw.test(c)){let u=c.replace(s8,l8);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}o=oy}return new o(s,t)}function l8(e){return"-"+e.toLowerCase()}function c8(e){return e.charAt(1).toUpperCase()}const u8=BN([HN,n8,VN,GN,KN],"html"),ly=BN([HN,r8,VN,GN,KN],"svg");function d8(e){return e.join(" ").trim()}var fl={},jg,Ow;function m8(){if(Ow)return jg;Ow=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,f=/^\s+|\s+$/g,p=`
138
- `,h="/",x="*",g="",v="comment",w="declaration";function S(N,T){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];T=T||{};var _=1,R=1;function D(K){var H=K.match(t);H&&(_+=H.length);var $=K.lastIndexOf(p);R=~$?K.length-$:R+K.length}function z(){var K={line:_,column:R};return function(H){return H.position=new E(K),V(),H}}function E(K){this.start=K,this.end={line:_,column:R},this.source=T.source}E.prototype.content=N;function L(K){var H=new Error(T.source+":"+_+":"+R+": "+K);if(H.reason=K,H.filename=T.source,H.line=_,H.column=R,H.source=N,!T.silent)throw H}function F(K){var H=K.exec(N);if(H){var $=H[0];return D($),N=N.slice($.length),H}}function V(){F(n)}function P(K){var H;for(K=K||[];H=B();)H!==!1&&K.push(H);return K}function B(){var K=z();if(!(h!=N.charAt(0)||x!=N.charAt(1))){for(var H=2;g!=N.charAt(H)&&(x!=N.charAt(H)||h!=N.charAt(H+1));)++H;if(H+=2,g===N.charAt(H-1))return L("End of comment missing");var $=N.slice(2,H-2);return R+=2,D($),N=N.slice(H),R+=2,K({type:v,comment:$})}}function Y(){var K=z(),H=F(s);if(H){if(B(),!F(o))return L("property missing ':'");var $=F(c),X=K({type:w,property:C(H[0].replace(e,g)),value:$?C($[0].replace(e,g)):g});return F(u),X}}function q(){var K=[];P(K);for(var H;H=Y();)H!==!1&&(K.push(H),P(K));return K}return V(),q()}function C(N){return N?N.replace(f,g):g}return jg=S,jg}var Dw;function f8(){if(Dw)return fl;Dw=1;var e=fl&&fl.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(fl,"__esModule",{value:!0}),fl.default=n;const t=e(m8());function n(s,o){let c=null;if(!s||typeof s!="string")return c;const u=(0,t.default)(s),f=typeof o=="function";return u.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:x}=p;f?o(h,x,p):x&&(c=c||{},c[h]=x)}),c}return fl}var qc={},$w;function p8(){if($w)return qc;$w=1,Object.defineProperty(qc,"__esModule",{value:!0}),qc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,c=function(h){return!h||n.test(h)||e.test(h)},u=function(h,x){return x.toUpperCase()},f=function(h,x){return"".concat(x,"-")},p=function(h,x){return x===void 0&&(x={}),c(h)?h:(h=h.toLowerCase(),x.reactCompat?h=h.replace(o,f):h=h.replace(s,f),h.replace(t,u))};return qc.camelCase=p,qc}var Vc,Uw;function h8(){if(Uw)return Vc;Uw=1;var e=Vc&&Vc.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(f8()),n=p8();function s(o,c){var u={};return!o||typeof o!="string"||(0,t.default)(o,function(f,p){f&&p&&(u[(0,n.camelCase)(f,c)]=p)}),u}return s.default=s,Vc=s,Vc}var g8=h8();const x8=vx(g8),WN=YN("end"),cy=YN("start");function YN(e){return t;function t(n){const s=n&&n.position&&n.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function y8(e){const t=cy(e),n=WN(e);if(t&&n)return{start:t,end:n}}function mu(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Pw(e.position):"start"in e||"end"in e?Pw(e):"line"in e||"column"in e?R0(e):""}function R0(e){return zw(e&&e.line)+":"+zw(e&&e.column)}function Pw(e){return R0(e&&e.start)+"-"+R0(e&&e.end)}function zw(e){return e&&typeof e=="number"?e:1}class jr extends Error{constructor(t,n,s){super(),typeof n=="string"&&(s=n,n=void 0);let o="",c={},u=!1;if(n&&("line"in n&&"column"in n?c={place:n}:"start"in n&&"end"in n?c={place:n}:"type"in n?c={ancestors:[n],place:n.position}:c={...n}),typeof t=="string"?o=t:!c.cause&&t&&(u=!0,o=t.message,c.cause=t),!c.ruleId&&!c.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?c.ruleId=s:(c.source=s.slice(0,p),c.ruleId=s.slice(p+1))}if(!c.place&&c.ancestors&&c.ancestors){const p=c.ancestors[c.ancestors.length-1];p&&(c.place=p.position)}const f=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=mu(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=u&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}jr.prototype.file="";jr.prototype.name="";jr.prototype.reason="";jr.prototype.message="";jr.prototype.stack="";jr.prototype.column=void 0;jr.prototype.line=void 0;jr.prototype.ancestors=void 0;jr.prototype.cause=void 0;jr.prototype.fatal=void 0;jr.prototype.place=void 0;jr.prototype.ruleId=void 0;jr.prototype.source=void 0;const uy={}.hasOwnProperty,b8=new Map,v8=/[A-Z]/g,k8=new Set(["table","tbody","thead","tfoot","tr"]),w8=new Set(["td","th"]),XN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function S8(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=_8(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=A8(n,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ly:u8,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},c=QN(o,e,void 0);return c&&typeof c!="string"?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}function QN(e,t,n){if(t.type==="element")return j8(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return C8(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return T8(e,t,n);if(t.type==="mdxjsEsm")return N8(e,t);if(t.type==="root")return M8(e,t,n);if(t.type==="text")return E8(e,t)}function j8(e,t,n){const s=e.schema;let o=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(o=ly,e.schema=o),e.ancestors.push(t);const c=JN(e,t.tagName,!1),u=R8(e,t);let f=my(e,t);return k8.has(t.tagName)&&(f=f.filter(function(p){return typeof p=="string"?!e8(p):!0})),ZN(e,u,c,t),dy(u,f),e.ancestors.pop(),e.schema=s,e.create(t,c,u,n)}function C8(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}Mu(e,t.position)}function N8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Mu(e,t.position)}function T8(e,t,n){const s=e.schema;let o=s;t.name==="svg"&&s.space==="html"&&(o=ly,e.schema=o),e.ancestors.push(t);const c=t.name===null?e.Fragment:JN(e,t.name,!0),u=I8(e,t),f=my(e,t);return ZN(e,u,c,t),dy(u,f),e.ancestors.pop(),e.schema=s,e.create(t,c,u,n)}function M8(e,t,n){const s={};return dy(s,my(e,t)),e.create(t,e.Fragment,s,n)}function E8(e,t){return t.value}function ZN(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function dy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function A8(e,t,n){return s;function s(o,c,u,f){const h=Array.isArray(u.children)?n:t;return f?h(c,u,f):h(c,u)}}function _8(e,t){return n;function n(s,o,c,u){const f=Array.isArray(c.children),p=cy(s);return t(o,c,u,f,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function R8(e,t){const n={};let s,o;for(o in t.properties)if(o!=="children"&&uy.call(t.properties,o)){const c=L8(e,o,t.properties[o]);if(c){const[u,f]=c;e.tableCellAlignToStyle&&u==="align"&&typeof f=="string"&&w8.has(t.tagName)?s=f:n[u]=f}}if(s){const c=n.style||(n.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return n}function I8(e,t){const n={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const c=s.data.estree.body[0];c.type;const u=c.expression;u.type;const f=u.properties[0];f.type,Object.assign(n,e.evaluater.evaluateExpression(f.argument))}else Mu(e,t.position);else{const o=s.name;let c;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,c=e.evaluater.evaluateExpression(f.expression)}else Mu(e,t.position);else c=s.value===null?!0:s.value;n[o]=c}return n}function my(e,t){const n=[];let s=-1;const o=e.passKeys?new Map:b8;for(;++s<t.children.length;){const c=t.children[s];let u;if(e.passKeys){const p=c.type==="element"?c.tagName:c.type==="mdxJsxFlowElement"||c.type==="mdxJsxTextElement"?c.name:void 0;if(p){const h=o.get(p)||0;u=p+"-"+h,o.set(p,h+1)}}const f=QN(e,c,u);f!==void 0&&n.push(f)}return n}function L8(e,t,n){const s=o8(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?YL(n):d8(n)),s.property==="style"){let o=typeof n=="object"?n:O8(e,String(n));return e.stylePropertyNameCase==="css"&&(o=D8(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&s.space?a8[s.property]||s.property:s.attribute,n]}}function O8(e,t){try{return x8(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,o=new jr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=XN+"#cannot-parse-style-attribute",o}}function JN(e,t,n){let s;if(!n)s={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let c=-1,u;for(;++c<o.length;){const f=_w(o[c])?{type:"Identifier",name:o[c]}:{type:"Literal",value:o[c]};u=u?{type:"MemberExpression",object:u,property:f,computed:!!(c&&f.type==="Literal"),optional:!1}:f}s=u}else s=_w(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const o=s.value;return uy.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(s);Mu(e)}function Mu(e,t){const n=new jr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=XN+"#cannot-handle-mdx-estrees-without-createevaluater",n}function D8(e){const t={};let n;for(n in e)uy.call(e,n)&&(t[$8(n)]=e[n]);return t}function $8(e){let t=e.replace(v8,U8);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function U8(e){return"-"+e.toLowerCase()}const Cg={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},P8={};function fy(e,t){const n=P8,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,o=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return e5(e,s,o)}function e5(e,t,n){if(z8(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Bw(e.children,t,n)}return Array.isArray(e)?Bw(e,t,n):""}function Bw(e,t,n){const s=[];let o=-1;for(;++o<e.length;)s[o]=e5(e[o],t,n);return s.join("")}function z8(e){return!!(e&&typeof e=="object")}const Hw=document.createElement("i");function py(e){const t="&"+e+";";Hw.innerHTML=t;const n=Hw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function xa(e,t,n,s){const o=e.length;let c=0,u;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,n=n>0?n:0,s.length<1e4)u=Array.from(s),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);c<s.length;)u=s.slice(c,c+1e4),u.unshift(t,0),e.splice(...u),c+=1e4,t+=1e4}function Pa(e,t){return e.length>0?(xa(e,e.length,0,t),e):t}const Fw={}.hasOwnProperty;function t5(e){const t={};let n=-1;for(;++n<e.length;)B8(t,e[n]);return t}function B8(e,t){let n;for(n in t){const o=(Fw.call(e,n)?e[n]:void 0)||(e[n]={}),c=t[n];let u;if(c)for(u in c){Fw.call(o,u)||(o[u]=[]);const f=c[u];H8(o[u],Array.isArray(f)?f:f?[f]:[])}}}function H8(e,t){let n=-1;const s=[];for(;++n<t.length;)(t[n].add==="after"?e:s).push(t[n]);xa(e,0,0,s)}function n5(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ja(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Or=Oi(/[A-Za-z]/),kr=Oi(/[\dA-Za-z]/),F8=Oi(/[#-'*+\--9=?A-Z^-~]/);function mf(e){return e!==null&&(e<32||e===127)}const I0=Oi(/\d/),q8=Oi(/[\dA-Fa-f]/),V8=Oi(/[!-/:-@[-`{-~]/);function ot(e){return e!==null&&e<-2}function dn(e){return e!==null&&(e<0||e===32)}function Rt(e){return e===-2||e===-1||e===32}const qf=Oi(new RegExp("\\p{P}|\\p{S}","u")),Eo=Oi(/\s/);function Oi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Kl(e){const t=[];let n=-1,s=0,o=0;for(;++n<e.length;){const c=e.charCodeAt(n);let u="";if(c===37&&kr(e.charCodeAt(n+1))&&kr(e.charCodeAt(n+2)))o=2;else if(c<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(c))||(u=String.fromCharCode(c));else if(c>55295&&c<57344){const f=e.charCodeAt(n+1);c<56320&&f>56319&&f<57344?(u=String.fromCharCode(c,f),o=1):u="�"}else u=String.fromCharCode(c);u&&(t.push(e.slice(s,n),encodeURIComponent(u)),s=n+o+1,u=""),o&&(n+=o,o=0)}return t.join("")+e.slice(s)}function Ut(e,t,n,s){const o=s?s-1:Number.POSITIVE_INFINITY;let c=0;return u;function u(p){return Rt(p)?(e.enter(n),f(p)):t(p)}function f(p){return Rt(p)&&c++<o?(e.consume(p),f):(e.exit(n),t(p))}}const G8={tokenize:K8};function K8(e){const t=e.attempt(this.parser.constructs.contentInitial,s,o);let n;return t;function s(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ut(e,t,"linePrefix")}function o(f){return e.enter("paragraph"),c(f)}function c(f){const p=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=p),n=p,u(f)}function u(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return ot(f)?(e.consume(f),e.exit("chunkText"),c):(e.consume(f),u)}}const W8={tokenize:Y8},qw={tokenize:X8};function Y8(e){const t=this,n=[];let s=0,o,c,u;return f;function f(R){if(s<n.length){const D=n[s];return t.containerState=D[1],e.attempt(D[0].continuation,p,h)(R)}return h(R)}function p(R){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&_();const D=t.events.length;let z=D,E;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){E=t.events[z][1].end;break}T(s);let L=D;for(;L<t.events.length;)t.events[L][1].end={...E},L++;return xa(t.events,z+1,0,t.events.slice(D)),t.events.length=L,h(R)}return f(R)}function h(R){if(s===n.length){if(!o)return v(R);if(o.currentConstruct&&o.currentConstruct.concrete)return S(R);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(qw,x,g)(R)}function x(R){return o&&_(),T(s),v(R)}function g(R){return t.parser.lazy[t.now().line]=s!==n.length,u=t.now().offset,S(R)}function v(R){return t.containerState={},e.attempt(qw,w,S)(R)}function w(R){return s++,n.push([t.currentConstruct,t.containerState]),v(R)}function S(R){if(R===null){o&&_(),T(0),e.consume(R);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:c}),C(R)}function C(R){if(R===null){N(e.exit("chunkFlow"),!0),T(0),e.consume(R);return}return ot(R)?(e.consume(R),N(e.exit("chunkFlow")),s=0,t.interrupt=void 0,f):(e.consume(R),C)}function N(R,D){const z=t.sliceStream(R);if(D&&z.push(null),R.previous=c,c&&(c.next=R),c=R,o.defineSkip(R.start),o.write(z),t.parser.lazy[R.start.line]){let E=o.events.length;for(;E--;)if(o.events[E][1].start.offset<u&&(!o.events[E][1].end||o.events[E][1].end.offset>u))return;const L=t.events.length;let F=L,V,P;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if(V){P=t.events[F][1].end;break}V=!0}for(T(s),E=L;E<t.events.length;)t.events[E][1].end={...P},E++;xa(t.events,F+1,0,t.events.slice(L)),t.events.length=E}}function T(R){let D=n.length;for(;D-- >R;){const z=n[D];t.containerState=z[1],z[0].exit.call(t,e)}n.length=R}function _(){o.write([null]),c=void 0,o=void 0,t.containerState._closeFlow=void 0}}function X8(e,t,n){return Ut(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Il(e){if(e===null||dn(e)||Eo(e))return 1;if(qf(e))return 2}function Vf(e,t,n){const s=[];let o=-1;for(;++o<e.length;){const c=e[o].resolveAll;c&&!s.includes(c)&&(t=c(t,n),s.push(c))}return t}const L0={name:"attention",resolveAll:Q8,tokenize:Z8};function Q8(e,t){let n=-1,s,o,c,u,f,p,h,x;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(s=n;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[s][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;p=e[s][1].end.offset-e[s][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const g={...e[s][1].end},v={...e[n][1].start};Vw(g,-p),Vw(v,p),u={type:p>1?"strongSequence":"emphasisSequence",start:g,end:{...e[s][1].end}},f={type:p>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:v},c={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},o={type:p>1?"strong":"emphasis",start:{...u.start},end:{...f.end}},e[s][1].end={...u.start},e[n][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=Pa(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=Pa(h,[["enter",o,t],["enter",u,t],["exit",u,t],["enter",c,t]]),h=Pa(h,Vf(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),h=Pa(h,[["exit",c,t],["enter",f,t],["exit",f,t],["exit",o,t]]),e[n][1].end.offset-e[n][1].start.offset?(x=2,h=Pa(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):x=0,xa(e,s-1,n-s+3,h),n=s+h.length-x-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Z8(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,o=Il(s);let c;return u;function u(p){return c=p,e.enter("attentionSequence"),f(p)}function f(p){if(p===c)return e.consume(p),f;const h=e.exit("attentionSequence"),x=Il(p),g=!x||x===2&&o||n.includes(p),v=!o||o===2&&x||n.includes(s);return h._open=!!(c===42?g:g&&(o||!v)),h._close=!!(c===42?v:v&&(x||!g)),t(p)}}function Vw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const J8={name:"autolink",tokenize:eO};function eO(e,t,n){let s=0;return o;function o(w){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),c}function c(w){return Or(w)?(e.consume(w),u):w===64?n(w):h(w)}function u(w){return w===43||w===45||w===46||kr(w)?(s=1,f(w)):h(w)}function f(w){return w===58?(e.consume(w),s=0,p):(w===43||w===45||w===46||kr(w))&&s++<32?(e.consume(w),f):(s=0,h(w))}function p(w){return w===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.exit("autolink"),t):w===null||w===32||w===60||mf(w)?n(w):(e.consume(w),p)}function h(w){return w===64?(e.consume(w),x):F8(w)?(e.consume(w),h):n(w)}function x(w){return kr(w)?g(w):n(w)}function g(w){return w===46?(e.consume(w),s=0,x):w===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.exit("autolink"),t):v(w)}function v(w){if((w===45||kr(w))&&s++<63){const S=w===45?v:g;return e.consume(w),S}return n(w)}}const Xu={partial:!0,tokenize:tO};function tO(e,t,n){return s;function s(c){return Rt(c)?Ut(e,o,"linePrefix")(c):o(c)}function o(c){return c===null||ot(c)?t(c):n(c)}}const r5={continuation:{tokenize:rO},exit:aO,name:"blockQuote",tokenize:nO};function nO(e,t,n){const s=this;return o;function o(u){if(u===62){const f=s.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),c}return n(u)}function c(u){return Rt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function rO(e,t,n){const s=this;return o;function o(u){return Rt(u)?Ut(e,c,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):c(u)}function c(u){return e.attempt(r5,t,n)(u)}}function aO(e){e.exit("blockQuote")}const a5={name:"characterEscape",tokenize:sO};function sO(e,t,n){return s;function s(c){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(c),e.exit("escapeMarker"),o}function o(c){return V8(c)?(e.enter("characterEscapeValue"),e.consume(c),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(c)}}const s5={name:"characterReference",tokenize:iO};function iO(e,t,n){const s=this;let o=0,c,u;return f;function f(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),p}function p(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),c=31,u=kr,x(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),c=6,u=q8,x):(e.enter("characterReferenceValue"),c=7,u=I0,x(g))}function x(g){if(g===59&&o){const v=e.exit("characterReferenceValue");return u===kr&&!py(s.sliceSerialize(v))?n(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(g)&&o++<c?(e.consume(g),x):n(g)}}const Gw={partial:!0,tokenize:lO},Kw={concrete:!0,name:"codeFenced",tokenize:oO};function oO(e,t,n){const s=this,o={partial:!0,tokenize:z};let c=0,u=0,f;return p;function p(E){return h(E)}function h(E){const L=s.events[s.events.length-1];return c=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,f=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(E)}function x(E){return E===f?(u++,e.consume(E),x):u<3?n(E):(e.exit("codeFencedFenceSequence"),Rt(E)?Ut(e,g,"whitespace")(E):g(E))}function g(E){return E===null||ot(E)?(e.exit("codeFencedFence"),s.interrupt?t(E):e.check(Gw,C,D)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),v(E))}function v(E){return E===null||ot(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(E)):Rt(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ut(e,w,"whitespace")(E)):E===96&&E===f?n(E):(e.consume(E),v)}function w(E){return E===null||ot(E)?g(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),S(E))}function S(E){return E===null||ot(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(E)):E===96&&E===f?n(E):(e.consume(E),S)}function C(E){return e.attempt(o,D,N)(E)}function N(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),T}function T(E){return c>0&&Rt(E)?Ut(e,_,"linePrefix",c+1)(E):_(E)}function _(E){return E===null||ot(E)?e.check(Gw,C,D)(E):(e.enter("codeFlowValue"),R(E))}function R(E){return E===null||ot(E)?(e.exit("codeFlowValue"),_(E)):(e.consume(E),R)}function D(E){return e.exit("codeFenced"),t(E)}function z(E,L,F){let V=0;return P;function P(H){return E.enter("lineEnding"),E.consume(H),E.exit("lineEnding"),B}function B(H){return E.enter("codeFencedFence"),Rt(H)?Ut(E,Y,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):Y(H)}function Y(H){return H===f?(E.enter("codeFencedFenceSequence"),q(H)):F(H)}function q(H){return H===f?(V++,E.consume(H),q):V>=u?(E.exit("codeFencedFenceSequence"),Rt(H)?Ut(E,K,"whitespace")(H):K(H)):F(H)}function K(H){return H===null||ot(H)?(E.exit("codeFencedFence"),L(H)):F(H)}}}function lO(e,t,n){const s=this;return o;function o(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c)}function c(u){return s.parser.lazy[s.now().line]?n(u):t(u)}}const Ng={name:"codeIndented",tokenize:uO},cO={partial:!0,tokenize:dO};function uO(e,t,n){const s=this;return o;function o(h){return e.enter("codeIndented"),Ut(e,c,"linePrefix",5)(h)}function c(h){const x=s.events[s.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?u(h):n(h)}function u(h){return h===null?p(h):ot(h)?e.attempt(cO,u,p)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||ot(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),f)}function p(h){return e.exit("codeIndented"),t(h)}}function dO(e,t,n){const s=this;return o;function o(u){return s.parser.lazy[s.now().line]?n(u):ot(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):Ut(e,c,"linePrefix",5)(u)}function c(u){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(u):ot(u)?o(u):n(u)}}const mO={name:"codeText",previous:pO,resolve:fO,tokenize:hO};function fO(e){let t=e.length-4,n=3,s,o;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=n;++s<t;)if(e[s][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(s=n-1,t++;++s<=t;)o===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(o=s):(s===t||e[s][1].type==="lineEnding")&&(e[o][1].type="codeTextData",s!==o+2&&(e[o][1].end=e[s-1][1].end,e.splice(o+2,s-o-2),t-=s-o-2,s=o+2),o=void 0);return e}function pO(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function hO(e,t,n){let s=0,o,c;return u;function u(g){return e.enter("codeText"),e.enter("codeTextSequence"),f(g)}function f(g){return g===96?(e.consume(g),s++,f):(e.exit("codeTextSequence"),p(g))}function p(g){return g===null?n(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),p):g===96?(c=e.enter("codeTextSequence"),o=0,x(g)):ot(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),p):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||ot(g)?(e.exit("codeTextData"),p(g)):(e.consume(g),h)}function x(g){return g===96?(e.consume(g),o++,x):o===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(c.type="codeTextData",h(g))}}class gO{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const s=n??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,n,s){const o=n||0;this.setCursor(Math.trunc(t));const c=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return s&&Gc(this.left,s),c.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Gc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Gc(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Gc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Gc(this.left,n.reverse())}}}function Gc(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function i5(e){const t={};let n=-1,s,o,c,u,f,p,h;const x=new gO(e);for(;++n<x.length;){for(;n in t;)n=t[n];if(s=x.get(n),n&&s[1].type==="chunkFlow"&&x.get(n-1)[1].type==="listItemPrefix"&&(p=s[1]._tokenizer.events,c=0,c<p.length&&p[c][1].type==="lineEndingBlank"&&(c+=2),c<p.length&&p[c][1].type==="content"))for(;++c<p.length&&p[c][1].type!=="content";)p[c][1].type==="chunkText"&&(p[c][1]._isInFirstContentOfListItem=!0,c++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,xO(x,n)),n=t[n],h=!0);else if(s[1]._container){for(c=n,o=void 0;c--;)if(u=x.get(c),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(o&&(x.get(o)[1].type="lineEndingBlank"),u[1].type="lineEnding",o=c);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;o&&(s[1].end={...x.get(o)[1].start},f=x.slice(o,n),f.unshift(s),x.splice(o,n-o+1,f))}}return xa(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!h}function xO(e,t){const n=e.get(t)[1],s=e.get(t)[2];let o=t-1;const c=[];let u=n._tokenizer;u||(u=s.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const f=u.events,p=[],h={};let x,g,v=-1,w=n,S=0,C=0;const N=[C];for(;w;){for(;e.get(++o)[1]!==w;);c.push(o),w._tokenizer||(x=s.sliceStream(w),w.next||x.push(null),g&&u.defineSkip(w.start),w._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(x),w._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),g=w,w=w.next}for(w=n;++v<f.length;)f[v][0]==="exit"&&f[v-1][0]==="enter"&&f[v][1].type===f[v-1][1].type&&f[v][1].start.line!==f[v][1].end.line&&(C=v+1,N.push(C),w._tokenizer=void 0,w.previous=void 0,w=w.next);for(u.events=[],w?(w._tokenizer=void 0,w.previous=void 0):N.pop(),v=N.length;v--;){const T=f.slice(N[v],N[v+1]),_=c.pop();p.push([_,_+T.length-1]),e.splice(_,2,T)}for(p.reverse(),v=-1;++v<p.length;)h[S+p[v][0]]=S+p[v][1],S+=p[v][1]-p[v][0]-1;return h}const yO={resolve:vO,tokenize:kO},bO={partial:!0,tokenize:wO};function vO(e){return i5(e),e}function kO(e,t){let n;return s;function s(f){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(f)}function o(f){return f===null?c(f):ot(f)?e.check(bO,u,c)(f):(e.consume(f),o)}function c(f){return e.exit("chunkContent"),e.exit("content"),t(f)}function u(f){return e.consume(f),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}function wO(e,t,n){const s=this;return o;function o(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Ut(e,c,"linePrefix")}function c(u){if(u===null||ot(u))return n(u);const f=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(u):e.interrupt(s.parser.constructs.flow,n,t)(u)}}function o5(e,t,n,s,o,c,u,f,p){const h=p||Number.POSITIVE_INFINITY;let x=0;return g;function g(T){return T===60?(e.enter(s),e.enter(o),e.enter(c),e.consume(T),e.exit(c),v):T===null||T===32||T===41||mf(T)?n(T):(e.enter(s),e.enter(u),e.enter(f),e.enter("chunkString",{contentType:"string"}),C(T))}function v(T){return T===62?(e.enter(c),e.consume(T),e.exit(c),e.exit(o),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===62?(e.exit("chunkString"),e.exit(f),v(T)):T===null||T===60||ot(T)?n(T):(e.consume(T),T===92?S:w)}function S(T){return T===60||T===62||T===92?(e.consume(T),w):w(T)}function C(T){return!x&&(T===null||T===41||dn(T))?(e.exit("chunkString"),e.exit(f),e.exit(u),e.exit(s),t(T)):x<h&&T===40?(e.consume(T),x++,C):T===41?(e.consume(T),x--,C):T===null||T===32||T===40||mf(T)?n(T):(e.consume(T),T===92?N:C)}function N(T){return T===40||T===41||T===92?(e.consume(T),C):C(T)}}function l5(e,t,n,s,o,c){const u=this;let f=0,p;return h;function h(w){return e.enter(s),e.enter(o),e.consume(w),e.exit(o),e.enter(c),x}function x(w){return f>999||w===null||w===91||w===93&&!p||w===94&&!f&&"_hiddenFootnoteSupport"in u.parser.constructs?n(w):w===93?(e.exit(c),e.enter(o),e.consume(w),e.exit(o),e.exit(s),t):ot(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),g(w))}function g(w){return w===null||w===91||w===93||ot(w)||f++>999?(e.exit("chunkString"),x(w)):(e.consume(w),p||(p=!Rt(w)),w===92?v:g)}function v(w){return w===91||w===92||w===93?(e.consume(w),f++,g):g(w)}}function c5(e,t,n,s,o,c){let u;return f;function f(v){return v===34||v===39||v===40?(e.enter(s),e.enter(o),e.consume(v),e.exit(o),u=v===40?41:v,p):n(v)}function p(v){return v===u?(e.enter(o),e.consume(v),e.exit(o),e.exit(s),t):(e.enter(c),h(v))}function h(v){return v===u?(e.exit(c),p(u)):v===null?n(v):ot(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),Ut(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(v))}function x(v){return v===u||v===null||ot(v)?(e.exit("chunkString"),h(v)):(e.consume(v),v===92?g:x)}function g(v){return v===u||v===92?(e.consume(v),x):x(v)}}function fu(e,t){let n;return s;function s(o){return ot(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,s):Rt(o)?Ut(e,s,n?"linePrefix":"lineSuffix")(o):t(o)}}const SO={name:"definition",tokenize:CO},jO={partial:!0,tokenize:NO};function CO(e,t,n){const s=this;let o;return c;function c(w){return e.enter("definition"),u(w)}function u(w){return l5.call(s,e,f,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(w)}function f(w){return o=Ja(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),p):n(w)}function p(w){return dn(w)?fu(e,h)(w):h(w)}function h(w){return o5(e,x,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(w)}function x(w){return e.attempt(jO,g,g)(w)}function g(w){return Rt(w)?Ut(e,v,"whitespace")(w):v(w)}function v(w){return w===null||ot(w)?(e.exit("definition"),s.parser.defined.push(o),t(w)):n(w)}}function NO(e,t,n){return s;function s(f){return dn(f)?fu(e,o)(f):n(f)}function o(f){return c5(e,c,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function c(f){return Rt(f)?Ut(e,u,"whitespace")(f):u(f)}function u(f){return f===null||ot(f)?t(f):n(f)}}const TO={name:"hardBreakEscape",tokenize:MO};function MO(e,t,n){return s;function s(c){return e.enter("hardBreakEscape"),e.consume(c),o}function o(c){return ot(c)?(e.exit("hardBreakEscape"),t(c)):n(c)}}const EO={name:"headingAtx",resolve:AO,tokenize:_O};function AO(e,t){let n=e.length-2,s=3,o,c;return e[s][1].type==="whitespace"&&(s+=2),n-2>s&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(s===n-1||n-4>s&&e[n-2][1].type==="whitespace")&&(n-=s+1===n?2:4),n>s&&(o={type:"atxHeadingText",start:e[s][1].start,end:e[n][1].end},c={type:"chunkText",start:e[s][1].start,end:e[n][1].end,contentType:"text"},xa(e,s,n-s+1,[["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t]])),e}function _O(e,t,n){let s=0;return o;function o(x){return e.enter("atxHeading"),c(x)}function c(x){return e.enter("atxHeadingSequence"),u(x)}function u(x){return x===35&&s++<6?(e.consume(x),u):x===null||dn(x)?(e.exit("atxHeadingSequence"),f(x)):n(x)}function f(x){return x===35?(e.enter("atxHeadingSequence"),p(x)):x===null||ot(x)?(e.exit("atxHeading"),t(x)):Rt(x)?Ut(e,f,"whitespace")(x):(e.enter("atxHeadingText"),h(x))}function p(x){return x===35?(e.consume(x),p):(e.exit("atxHeadingSequence"),f(x))}function h(x){return x===null||x===35||dn(x)?(e.exit("atxHeadingText"),f(x)):(e.consume(x),h)}}const RO=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Ww=["pre","script","style","textarea"],IO={concrete:!0,name:"htmlFlow",resolveTo:DO,tokenize:$O},LO={partial:!0,tokenize:PO},OO={partial:!0,tokenize:UO};function DO(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function $O(e,t,n){const s=this;let o,c,u,f,p;return h;function h(j){return x(j)}function x(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),g}function g(j){return j===33?(e.consume(j),v):j===47?(e.consume(j),c=!0,C):j===63?(e.consume(j),o=3,s.interrupt?t:I):Or(j)?(e.consume(j),u=String.fromCharCode(j),N):n(j)}function v(j){return j===45?(e.consume(j),o=2,w):j===91?(e.consume(j),o=5,f=0,S):Or(j)?(e.consume(j),o=4,s.interrupt?t:I):n(j)}function w(j){return j===45?(e.consume(j),s.interrupt?t:I):n(j)}function S(j){const U="CDATA[";return j===U.charCodeAt(f++)?(e.consume(j),f===U.length?s.interrupt?t:Y:S):n(j)}function C(j){return Or(j)?(e.consume(j),u=String.fromCharCode(j),N):n(j)}function N(j){if(j===null||j===47||j===62||dn(j)){const U=j===47,ee=u.toLowerCase();return!U&&!c&&Ww.includes(ee)?(o=1,s.interrupt?t(j):Y(j)):RO.includes(u.toLowerCase())?(o=6,U?(e.consume(j),T):s.interrupt?t(j):Y(j)):(o=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(j):c?_(j):R(j))}return j===45||kr(j)?(e.consume(j),u+=String.fromCharCode(j),N):n(j)}function T(j){return j===62?(e.consume(j),s.interrupt?t:Y):n(j)}function _(j){return Rt(j)?(e.consume(j),_):P(j)}function R(j){return j===47?(e.consume(j),P):j===58||j===95||Or(j)?(e.consume(j),D):Rt(j)?(e.consume(j),R):P(j)}function D(j){return j===45||j===46||j===58||j===95||kr(j)?(e.consume(j),D):z(j)}function z(j){return j===61?(e.consume(j),E):Rt(j)?(e.consume(j),z):R(j)}function E(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),p=j,L):Rt(j)?(e.consume(j),E):F(j)}function L(j){return j===p?(e.consume(j),p=null,V):j===null||ot(j)?n(j):(e.consume(j),L)}function F(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||dn(j)?z(j):(e.consume(j),F)}function V(j){return j===47||j===62||Rt(j)?R(j):n(j)}function P(j){return j===62?(e.consume(j),B):n(j)}function B(j){return j===null||ot(j)?Y(j):Rt(j)?(e.consume(j),B):n(j)}function Y(j){return j===45&&o===2?(e.consume(j),$):j===60&&o===1?(e.consume(j),X):j===62&&o===4?(e.consume(j),A):j===63&&o===3?(e.consume(j),I):j===93&&o===5?(e.consume(j),ie):ot(j)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(LO,Q,q)(j)):j===null||ot(j)?(e.exit("htmlFlowData"),q(j)):(e.consume(j),Y)}function q(j){return e.check(OO,K,Q)(j)}function K(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),H}function H(j){return j===null||ot(j)?q(j):(e.enter("htmlFlowData"),Y(j))}function $(j){return j===45?(e.consume(j),I):Y(j)}function X(j){return j===47?(e.consume(j),u="",le):Y(j)}function le(j){if(j===62){const U=u.toLowerCase();return Ww.includes(U)?(e.consume(j),A):Y(j)}return Or(j)&&u.length<8?(e.consume(j),u+=String.fromCharCode(j),le):Y(j)}function ie(j){return j===93?(e.consume(j),I):Y(j)}function I(j){return j===62?(e.consume(j),A):j===45&&o===2?(e.consume(j),I):Y(j)}function A(j){return j===null||ot(j)?(e.exit("htmlFlowData"),Q(j)):(e.consume(j),A)}function Q(j){return e.exit("htmlFlow"),t(j)}}function UO(e,t,n){const s=this;return o;function o(u){return ot(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):n(u)}function c(u){return s.parser.lazy[s.now().line]?n(u):t(u)}}function PO(e,t,n){return s;function s(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Xu,t,n)}}const zO={name:"htmlText",tokenize:BO};function BO(e,t,n){const s=this;let o,c,u;return f;function f(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),p}function p(I){return I===33?(e.consume(I),h):I===47?(e.consume(I),z):I===63?(e.consume(I),R):Or(I)?(e.consume(I),F):n(I)}function h(I){return I===45?(e.consume(I),x):I===91?(e.consume(I),c=0,S):Or(I)?(e.consume(I),_):n(I)}function x(I){return I===45?(e.consume(I),w):n(I)}function g(I){return I===null?n(I):I===45?(e.consume(I),v):ot(I)?(u=g,X(I)):(e.consume(I),g)}function v(I){return I===45?(e.consume(I),w):g(I)}function w(I){return I===62?$(I):I===45?v(I):g(I)}function S(I){const A="CDATA[";return I===A.charCodeAt(c++)?(e.consume(I),c===A.length?C:S):n(I)}function C(I){return I===null?n(I):I===93?(e.consume(I),N):ot(I)?(u=C,X(I)):(e.consume(I),C)}function N(I){return I===93?(e.consume(I),T):C(I)}function T(I){return I===62?$(I):I===93?(e.consume(I),T):C(I)}function _(I){return I===null||I===62?$(I):ot(I)?(u=_,X(I)):(e.consume(I),_)}function R(I){return I===null?n(I):I===63?(e.consume(I),D):ot(I)?(u=R,X(I)):(e.consume(I),R)}function D(I){return I===62?$(I):R(I)}function z(I){return Or(I)?(e.consume(I),E):n(I)}function E(I){return I===45||kr(I)?(e.consume(I),E):L(I)}function L(I){return ot(I)?(u=L,X(I)):Rt(I)?(e.consume(I),L):$(I)}function F(I){return I===45||kr(I)?(e.consume(I),F):I===47||I===62||dn(I)?V(I):n(I)}function V(I){return I===47?(e.consume(I),$):I===58||I===95||Or(I)?(e.consume(I),P):ot(I)?(u=V,X(I)):Rt(I)?(e.consume(I),V):$(I)}function P(I){return I===45||I===46||I===58||I===95||kr(I)?(e.consume(I),P):B(I)}function B(I){return I===61?(e.consume(I),Y):ot(I)?(u=B,X(I)):Rt(I)?(e.consume(I),B):V(I)}function Y(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),o=I,q):ot(I)?(u=Y,X(I)):Rt(I)?(e.consume(I),Y):(e.consume(I),K)}function q(I){return I===o?(e.consume(I),o=void 0,H):I===null?n(I):ot(I)?(u=q,X(I)):(e.consume(I),q)}function K(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||dn(I)?V(I):(e.consume(I),K)}function H(I){return I===47||I===62||dn(I)?V(I):n(I)}function $(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function X(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),le}function le(I){return Rt(I)?Ut(e,ie,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):ie(I)}function ie(I){return e.enter("htmlTextData"),u(I)}}const hy={name:"labelEnd",resolveAll:VO,resolveTo:GO,tokenize:KO},HO={tokenize:WO},FO={tokenize:YO},qO={tokenize:XO};function VO(e){let t=-1;const n=[];for(;++t<e.length;){const s=e[t][1];if(n.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const o=s.type==="labelImage"?4:2;s.type="data",t+=o}}return e.length!==n.length&&xa(e,0,e.length,n),e}function GO(e,t){let n=e.length,s=0,o,c,u,f;for(;n--;)if(o=e[n][1],c){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[n][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(c=n,o.type!=="labelLink")){s=2;break}}else o.type==="labelEnd"&&(u=n);const p={type:e[c][1].type==="labelLink"?"link":"image",start:{...e[c][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[c][1].start},end:{...e[u][1].end}},x={type:"labelText",start:{...e[c+s+2][1].end},end:{...e[u-2][1].start}};return f=[["enter",p,t],["enter",h,t]],f=Pa(f,e.slice(c+1,c+s+3)),f=Pa(f,[["enter",x,t]]),f=Pa(f,Vf(t.parser.constructs.insideSpan.null,e.slice(c+s+4,u-3),t)),f=Pa(f,[["exit",x,t],e[u-2],e[u-1],["exit",h,t]]),f=Pa(f,e.slice(u+1)),f=Pa(f,[["exit",p,t]]),xa(e,c,e.length,f),e}function KO(e,t,n){const s=this;let o=s.events.length,c,u;for(;o--;)if((s.events[o][1].type==="labelImage"||s.events[o][1].type==="labelLink")&&!s.events[o][1]._balanced){c=s.events[o][1];break}return f;function f(v){return c?c._inactive?g(v):(u=s.parser.defined.includes(Ja(s.sliceSerialize({start:c.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(v),e.exit("labelMarker"),e.exit("labelEnd"),p):n(v)}function p(v){return v===40?e.attempt(HO,x,u?x:g)(v):v===91?e.attempt(FO,x,u?h:g)(v):u?x(v):g(v)}function h(v){return e.attempt(qO,x,g)(v)}function x(v){return t(v)}function g(v){return c._balanced=!0,n(v)}}function WO(e,t,n){return s;function s(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return dn(g)?fu(e,c)(g):c(g)}function c(g){return g===41?x(g):o5(e,u,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function u(g){return dn(g)?fu(e,p)(g):x(g)}function f(g){return n(g)}function p(g){return g===34||g===39||g===40?c5(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):x(g)}function h(g){return dn(g)?fu(e,x)(g):x(g)}function x(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):n(g)}}function YO(e,t,n){const s=this;return o;function o(f){return l5.call(s,e,c,u,"reference","referenceMarker","referenceString")(f)}function c(f){return s.parser.defined.includes(Ja(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(f):n(f)}function u(f){return n(f)}}function XO(e,t,n){return s;function s(c){return e.enter("reference"),e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),o}function o(c){return c===93?(e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),e.exit("reference"),t):n(c)}}const QO={name:"labelStartImage",resolveAll:hy.resolveAll,tokenize:ZO};function ZO(e,t,n){const s=this;return o;function o(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),c}function c(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),u):n(f)}function u(f){return f===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(f):t(f)}}const JO={name:"labelStartLink",resolveAll:hy.resolveAll,tokenize:eD};function eD(e,t,n){const s=this;return o;function o(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),c}function c(u){return u===94&&"_hiddenFootnoteSupport"in s.parser.constructs?n(u):t(u)}}const Tg={name:"lineEnding",tokenize:tD};function tD(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ut(e,t,"linePrefix")}}const Wm={name:"thematicBreak",tokenize:nD};function nD(e,t,n){let s=0,o;return c;function c(h){return e.enter("thematicBreak"),u(h)}function u(h){return o=h,f(h)}function f(h){return h===o?(e.enter("thematicBreakSequence"),p(h)):s>=3&&(h===null||ot(h))?(e.exit("thematicBreak"),t(h)):n(h)}function p(h){return h===o?(e.consume(h),s++,p):(e.exit("thematicBreakSequence"),Rt(h)?Ut(e,f,"whitespace")(h):f(h))}}const Zr={continuation:{tokenize:iD},exit:lD,name:"list",tokenize:sD},rD={partial:!0,tokenize:cD},aD={partial:!0,tokenize:oD};function sD(e,t,n){const s=this,o=s.events[s.events.length-1];let c=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,u=0;return f;function f(w){const S=s.containerState.type||(w===42||w===43||w===45?"listUnordered":"listOrdered");if(S==="listUnordered"?!s.containerState.marker||w===s.containerState.marker:I0(w)){if(s.containerState.type||(s.containerState.type=S,e.enter(S,{_container:!0})),S==="listUnordered")return e.enter("listItemPrefix"),w===42||w===45?e.check(Wm,n,h)(w):h(w);if(!s.interrupt||w===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(w)}return n(w)}function p(w){return I0(w)&&++u<10?(e.consume(w),p):(!s.interrupt||u<2)&&(s.containerState.marker?w===s.containerState.marker:w===41||w===46)?(e.exit("listItemValue"),h(w)):n(w)}function h(w){return e.enter("listItemMarker"),e.consume(w),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||w,e.check(Xu,s.interrupt?n:x,e.attempt(rD,v,g))}function x(w){return s.containerState.initialBlankLine=!0,c++,v(w)}function g(w){return Rt(w)?(e.enter("listItemPrefixWhitespace"),e.consume(w),e.exit("listItemPrefixWhitespace"),v):n(w)}function v(w){return s.containerState.size=c+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(w)}}function iD(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Xu,o,c);function o(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Ut(e,t,"listItemIndent",s.containerState.size+1)(f)}function c(f){return s.containerState.furtherBlankLines||!Rt(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,u(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(aD,t,u)(f))}function u(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,Ut(e,e.attempt(Zr,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function oD(e,t,n){const s=this;return Ut(e,o,"listItemIndent",s.containerState.size+1);function o(c){const u=s.events[s.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===s.containerState.size?t(c):n(c)}}function lD(e){e.exit(this.containerState.type)}function cD(e,t,n){const s=this;return Ut(e,o,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(c){const u=s.events[s.events.length-1];return!Rt(c)&&u&&u[1].type==="listItemPrefixWhitespace"?t(c):n(c)}}const Yw={name:"setextUnderline",resolveTo:uD,tokenize:dD};function uD(e,t){let n=e.length,s,o,c;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){s=n;break}e[n][1].type==="paragraph"&&(o=n)}else e[n][1].type==="content"&&e.splice(n,1),!c&&e[n][1].type==="definition"&&(c=n);const u={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",c?(e.splice(o,0,["enter",u,t]),e.splice(c+1,0,["exit",e[s][1],t]),e[s][1].end={...e[c][1].end}):e[s][1]=u,e.push(["exit",u,t]),e}function dD(e,t,n){const s=this;let o;return c;function c(h){let x=s.events.length,g;for(;x--;)if(s.events[x][1].type!=="lineEnding"&&s.events[x][1].type!=="linePrefix"&&s.events[x][1].type!=="content"){g=s.events[x][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||g)?(e.enter("setextHeadingLine"),o=h,u(h)):n(h)}function u(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===o?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),Rt(h)?Ut(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||ot(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const mD={tokenize:fD};function fD(e){const t=this,n=e.attempt(Xu,s,e.attempt(this.parser.constructs.flowInitial,o,Ut(e,e.attempt(this.parser.constructs.flow,o,e.attempt(yO,o)),"linePrefix")));return n;function s(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function o(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const pD={resolveAll:d5()},hD=u5("string"),gD=u5("text");function u5(e){return{resolveAll:d5(e==="text"?xD:void 0),tokenize:t};function t(n){const s=this,o=this.parser.constructs[e],c=n.attempt(o,u,f);return u;function u(x){return h(x)?c(x):f(x)}function f(x){if(x===null){n.consume(x);return}return n.enter("data"),n.consume(x),p}function p(x){return h(x)?(n.exit("data"),c(x)):(n.consume(x),p)}function h(x){if(x===null)return!0;const g=o[x];let v=-1;if(g)for(;++v<g.length;){const w=g[v];if(!w.previous||w.previous.call(s,s.previous))return!0}return!1}}}function d5(e){return t;function t(n,s){let o=-1,c;for(;++o<=n.length;)c===void 0?n[o]&&n[o][1].type==="data"&&(c=o,o++):(!n[o]||n[o][1].type!=="data")&&(o!==c+2&&(n[c][1].end=n[o-1][1].end,n.splice(c+2,o-c-2),o=c+2),c=void 0);return e?e(n,s):n}}function xD(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const s=e[n-1][1],o=t.sliceStream(s);let c=o.length,u=-1,f=0,p;for(;c--;){const h=o[c];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)f++,u--;if(u)break;u=-1}else if(h===-2)p=!0,f++;else if(h!==-1){c++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(f=0),f){const h={type:n===e.length||p||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:c?u:s.start._bufferIndex+u,_index:s.start._index+c,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const yD={42:Zr,43:Zr,45:Zr,48:Zr,49:Zr,50:Zr,51:Zr,52:Zr,53:Zr,54:Zr,55:Zr,56:Zr,57:Zr,62:r5},bD={91:SO},vD={[-2]:Ng,[-1]:Ng,32:Ng},kD={35:EO,42:Wm,45:[Yw,Wm],60:IO,61:Yw,95:Wm,96:Kw,126:Kw},wD={38:s5,92:a5},SD={[-5]:Tg,[-4]:Tg,[-3]:Tg,33:QO,38:s5,42:L0,60:[J8,zO],91:JO,92:[TO,a5],93:hy,95:L0,96:mO},jD={null:[L0,pD]},CD={null:[42,95]},ND={null:[]},TD=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:CD,contentInitial:bD,disable:ND,document:yD,flow:kD,flowInitial:vD,insideSpan:jD,string:wD,text:SD},Symbol.toStringTag,{value:"Module"}));function MD(e,t,n){let s={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},c=[];let u=[],f=[];const p={attempt:L(z),check:L(E),consume:_,enter:R,exit:D,interrupt:L(E,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:S,parser:e,previous:null,sliceSerialize:v,sliceStream:w,write:g};let x=t.tokenize.call(h,p);return t.resolveAll&&c.push(t),h;function g(B){return u=Pa(u,B),N(),u[u.length-1]!==null?[]:(F(t,0),h.events=Vf(c,h.events,h),h.events)}function v(B,Y){return AD(w(B),Y)}function w(B){return ED(u,B)}function S(){const{_bufferIndex:B,_index:Y,line:q,column:K,offset:H}=s;return{_bufferIndex:B,_index:Y,line:q,column:K,offset:H}}function C(B){o[B.line]=B.column,P()}function N(){let B;for(;s._index<u.length;){const Y=u[s._index];if(typeof Y=="string")for(B=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===B&&s._bufferIndex<Y.length;)T(Y.charCodeAt(s._bufferIndex));else T(Y)}}function T(B){x=x(B)}function _(B){ot(B)?(s.line++,s.column=1,s.offset+=B===-3?2:1,P()):B!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===u[s._index].length&&(s._bufferIndex=-1,s._index++)),h.previous=B}function R(B,Y){const q=Y||{};return q.type=B,q.start=S(),h.events.push(["enter",q,h]),f.push(q),q}function D(B){const Y=f.pop();return Y.end=S(),h.events.push(["exit",Y,h]),Y}function z(B,Y){F(B,Y.from)}function E(B,Y){Y.restore()}function L(B,Y){return q;function q(K,H,$){let X,le,ie,I;return Array.isArray(K)?Q(K):"tokenize"in K?Q([K]):A(K);function A(re){return ke;function ke(be){const ye=be!==null&&re[be],Se=be!==null&&re.null,Me=[...Array.isArray(ye)?ye:ye?[ye]:[],...Array.isArray(Se)?Se:Se?[Se]:[]];return Q(Me)(be)}}function Q(re){return X=re,le=0,re.length===0?$:j(re[le])}function j(re){return ke;function ke(be){return I=V(),ie=re,re.partial||(h.currentConstruct=re),re.name&&h.parser.constructs.disable.null.includes(re.name)?ee():re.tokenize.call(Y?Object.assign(Object.create(h),Y):h,p,U,ee)(be)}}function U(re){return B(ie,I),H}function ee(re){return I.restore(),++le<X.length?j(X[le]):$}}}function F(B,Y){B.resolveAll&&!c.includes(B)&&c.push(B),B.resolve&&xa(h.events,Y,h.events.length-Y,B.resolve(h.events.slice(Y),h)),B.resolveTo&&(h.events=B.resolveTo(h.events,h))}function V(){const B=S(),Y=h.previous,q=h.currentConstruct,K=h.events.length,H=Array.from(f);return{from:K,restore:$};function $(){s=B,h.previous=Y,h.currentConstruct=q,h.events.length=K,f=H,P()}}function P(){s.line in o&&s.column<2&&(s.column=o[s.line],s.offset+=o[s.line]-1)}}function ED(e,t){const n=t.start._index,s=t.start._bufferIndex,o=t.end._index,c=t.end._bufferIndex;let u;if(n===o)u=[e[n].slice(s,c)];else{if(u=e.slice(n,o),s>-1){const f=u[0];typeof f=="string"?u[0]=f.slice(s):u.shift()}c>0&&u.push(e[o].slice(0,c))}return u}function AD(e,t){let n=-1;const s=[];let o;for(;++n<e.length;){const c=e[n];let u;if(typeof c=="string")u=c;else switch(c){case-5:{u="\r";break}case-4:{u=`
139
- `;break}case-3:{u=`\r
140
- `;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&o)continue;u=" ";break}default:u=String.fromCharCode(c)}o=c===-2,s.push(u)}return s.join("")}function _D(e){const s={constructs:t5([TD,...(e||{}).extensions||[]]),content:o(G8),defined:[],document:o(W8),flow:o(mD),lazy:{},string:o(hD),text:o(gD)};return s;function o(c){return u;function u(f){return MD(s,c,f)}}}function RD(e){for(;!i5(e););return e}const Xw=/[\0\t\n\r]/g;function ID(){let e=1,t="",n=!0,s;return o;function o(c,u,f){const p=[];let h,x,g,v,w;for(c=t+(typeof c=="string"?c.toString():new TextDecoder(u||void 0).decode(c)),g=0,t="",n&&(c.charCodeAt(0)===65279&&g++,n=void 0);g<c.length;){if(Xw.lastIndex=g,h=Xw.exec(c),v=h&&h.index!==void 0?h.index:c.length,w=c.charCodeAt(v),!h){t=c.slice(g);break}if(w===10&&g===v&&s)p.push(-3),s=void 0;else switch(s&&(p.push(-5),s=void 0),g<v&&(p.push(c.slice(g,v)),e+=v-g),w){case 0:{p.push(65533),e++;break}case 9:{for(x=Math.ceil(e/4)*4,p.push(-2);e++<x;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:s=!0,e=1}g=v+1}return f&&(s&&p.push(-5),t&&p.push(t),p.push(null)),p}}const LD=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function OD(e){return e.replace(LD,DD)}function DD(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),c=o===120||o===88;return n5(n.slice(c?2:1),c?16:10)}return py(n)||e}const m5={}.hasOwnProperty;function $D(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),UD(n)(RD(_D(n).document().write(ID()(e,t,!0))))}function UD(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(J),autolinkProtocol:V,autolinkEmail:V,atxHeading:c(bt),blockQuote:c(Se),characterEscape:V,characterReference:V,codeFenced:c(Me),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:c(Me,u),codeText:c(ze,u),codeTextData:V,data:V,codeFlowValue:V,definition:c(De),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:c(ct),hardBreakEscape:c(he),hardBreakTrailing:c(he),htmlFlow:c(ne,u),htmlFlowData:V,htmlText:c(ne,u),htmlTextData:V,image:c(oe),label:u,link:c(J),listItem:c(ve),listItemValue:v,listOrdered:c(ht,g),listUnordered:c(ht),paragraph:c(Xe),reference:j,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:c(bt),strong:c(Ge),thematicBreak:c(Pe)},exit:{atxHeading:p(),atxHeadingSequence:z,autolink:p(),autolinkEmail:ye,autolinkProtocol:be,blockQuote:p(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:re,characterReference:ke,codeFenced:p(N),codeFencedFence:C,codeFencedFenceInfo:w,codeFencedFenceMeta:S,codeFlowValue:P,codeIndented:p(T),codeText:p(H),codeTextData:P,data:P,definition:p(),definitionDestinationString:D,definitionLabelString:_,definitionTitleString:R,emphasis:p(),hardBreakEscape:p(Y),hardBreakTrailing:p(Y),htmlFlow:p(q),htmlFlowData:P,htmlText:p(K),htmlTextData:P,image:p(X),label:ie,labelText:le,lineEnding:B,link:p($),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:U,resourceDestinationString:I,resourceTitleString:A,resource:Q,setextHeading:p(F),setextHeadingLineSequence:L,setextHeadingText:E,strong:p(),thematicBreak:p()}};f5(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(W){let me={type:"root",children:[]};const Ue={stack:[me],tokenStack:[],config:t,enter:f,exit:h,buffer:u,resume:x,data:n},pe=[];let $e=-1;for(;++$e<W.length;)if(W[$e][1].type==="listOrdered"||W[$e][1].type==="listUnordered")if(W[$e][0]==="enter")pe.push($e);else{const nt=pe.pop();$e=o(W,nt,$e)}for($e=-1;++$e<W.length;){const nt=t[W[$e][0]];m5.call(nt,W[$e][1].type)&&nt[W[$e][1].type].call(Object.assign({sliceSerialize:W[$e][2].sliceSerialize},Ue),W[$e][1])}if(Ue.tokenStack.length>0){const nt=Ue.tokenStack[Ue.tokenStack.length-1];(nt[1]||Qw).call(Ue,void 0,nt[0])}for(me.position={start:Ci(W.length>0?W[0][1].start:{line:1,column:1,offset:0}),end:Ci(W.length>0?W[W.length-2][1].end:{line:1,column:1,offset:0})},$e=-1;++$e<t.transforms.length;)me=t.transforms[$e](me)||me;return me}function o(W,me,Ue){let pe=me-1,$e=-1,nt=!1,gt,Ke,dt,pt;for(;++pe<=Ue;){const wt=W[pe];switch(wt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{wt[0]==="enter"?$e++:$e--,pt=void 0;break}case"lineEndingBlank":{wt[0]==="enter"&&(gt&&!pt&&!$e&&!dt&&(dt=pe),pt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:pt=void 0}if(!$e&&wt[0]==="enter"&&wt[1].type==="listItemPrefix"||$e===-1&&wt[0]==="exit"&&(wt[1].type==="listUnordered"||wt[1].type==="listOrdered")){if(gt){let st=pe;for(Ke=void 0;st--;){const Bt=W[st];if(Bt[1].type==="lineEnding"||Bt[1].type==="lineEndingBlank"){if(Bt[0]==="exit")continue;Ke&&(W[Ke][1].type="lineEndingBlank",nt=!0),Bt[1].type="lineEnding",Ke=st}else if(!(Bt[1].type==="linePrefix"||Bt[1].type==="blockQuotePrefix"||Bt[1].type==="blockQuotePrefixWhitespace"||Bt[1].type==="blockQuoteMarker"||Bt[1].type==="listItemIndent"))break}dt&&(!Ke||dt<Ke)&&(gt._spread=!0),gt.end=Object.assign({},Ke?W[Ke][1].start:wt[1].end),W.splice(Ke||pe,0,["exit",gt,wt[2]]),pe++,Ue++}if(wt[1].type==="listItemPrefix"){const st={type:"listItem",_spread:!1,start:Object.assign({},wt[1].start),end:void 0};gt=st,W.splice(pe,0,["enter",st,wt[2]]),pe++,Ue++,dt=void 0,pt=!0}}}return W[me][1]._spread=nt,Ue}function c(W,me){return Ue;function Ue(pe){f.call(this,W(pe),pe),me&&me.call(this,pe)}}function u(){this.stack.push({type:"fragment",children:[]})}function f(W,me,Ue){this.stack[this.stack.length-1].children.push(W),this.stack.push(W),this.tokenStack.push([me,Ue||void 0]),W.position={start:Ci(me.start),end:void 0}}function p(W){return me;function me(Ue){W&&W.call(this,Ue),h.call(this,Ue)}}function h(W,me){const Ue=this.stack.pop(),pe=this.tokenStack.pop();if(pe)pe[0].type!==W.type&&(me?me.call(this,W,pe[0]):(pe[1]||Qw).call(this,W,pe[0]));else throw new Error("Cannot close `"+W.type+"` ("+mu({start:W.start,end:W.end})+"): it’s not open");Ue.position.end=Ci(W.end)}function x(){return fy(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function v(W){if(this.data.expectingFirstListItemValue){const me=this.stack[this.stack.length-2];me.start=Number.parseInt(this.sliceSerialize(W),10),this.data.expectingFirstListItemValue=void 0}}function w(){const W=this.resume(),me=this.stack[this.stack.length-1];me.lang=W}function S(){const W=this.resume(),me=this.stack[this.stack.length-1];me.meta=W}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const W=this.resume(),me=this.stack[this.stack.length-1];me.value=W.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function T(){const W=this.resume(),me=this.stack[this.stack.length-1];me.value=W.replace(/(\r?\n|\r)$/g,"")}function _(W){const me=this.resume(),Ue=this.stack[this.stack.length-1];Ue.label=me,Ue.identifier=Ja(this.sliceSerialize(W)).toLowerCase()}function R(){const W=this.resume(),me=this.stack[this.stack.length-1];me.title=W}function D(){const W=this.resume(),me=this.stack[this.stack.length-1];me.url=W}function z(W){const me=this.stack[this.stack.length-1];if(!me.depth){const Ue=this.sliceSerialize(W).length;me.depth=Ue}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function L(W){const me=this.stack[this.stack.length-1];me.depth=this.sliceSerialize(W).codePointAt(0)===61?1:2}function F(){this.data.setextHeadingSlurpLineEnding=void 0}function V(W){const Ue=this.stack[this.stack.length-1].children;let pe=Ue[Ue.length-1];(!pe||pe.type!=="text")&&(pe=He(),pe.position={start:Ci(W.start),end:void 0},Ue.push(pe)),this.stack.push(pe)}function P(W){const me=this.stack.pop();me.value+=this.sliceSerialize(W),me.position.end=Ci(W.end)}function B(W){const me=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ue=me.children[me.children.length-1];Ue.position.end=Ci(W.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(me.type)&&(V.call(this,W),P.call(this,W))}function Y(){this.data.atHardBreak=!0}function q(){const W=this.resume(),me=this.stack[this.stack.length-1];me.value=W}function K(){const W=this.resume(),me=this.stack[this.stack.length-1];me.value=W}function H(){const W=this.resume(),me=this.stack[this.stack.length-1];me.value=W}function $(){const W=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";W.type+="Reference",W.referenceType=me,delete W.url,delete W.title}else delete W.identifier,delete W.label;this.data.referenceType=void 0}function X(){const W=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";W.type+="Reference",W.referenceType=me,delete W.url,delete W.title}else delete W.identifier,delete W.label;this.data.referenceType=void 0}function le(W){const me=this.sliceSerialize(W),Ue=this.stack[this.stack.length-2];Ue.label=OD(me),Ue.identifier=Ja(me).toLowerCase()}function ie(){const W=this.stack[this.stack.length-1],me=this.resume(),Ue=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ue.type==="link"){const pe=W.children;Ue.children=pe}else Ue.alt=me}function I(){const W=this.resume(),me=this.stack[this.stack.length-1];me.url=W}function A(){const W=this.resume(),me=this.stack[this.stack.length-1];me.title=W}function Q(){this.data.inReference=void 0}function j(){this.data.referenceType="collapsed"}function U(W){const me=this.resume(),Ue=this.stack[this.stack.length-1];Ue.label=me,Ue.identifier=Ja(this.sliceSerialize(W)).toLowerCase(),this.data.referenceType="full"}function ee(W){this.data.characterReferenceType=W.type}function re(W){const me=this.sliceSerialize(W),Ue=this.data.characterReferenceType;let pe;Ue?(pe=n5(me,Ue==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):pe=py(me);const $e=this.stack[this.stack.length-1];$e.value+=pe}function ke(W){const me=this.stack.pop();me.position.end=Ci(W.end)}function be(W){P.call(this,W);const me=this.stack[this.stack.length-1];me.url=this.sliceSerialize(W)}function ye(W){P.call(this,W);const me=this.stack[this.stack.length-1];me.url="mailto:"+this.sliceSerialize(W)}function Se(){return{type:"blockquote",children:[]}}function Me(){return{type:"code",lang:null,meta:null,value:""}}function ze(){return{type:"inlineCode",value:""}}function De(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ct(){return{type:"emphasis",children:[]}}function bt(){return{type:"heading",depth:0,children:[]}}function he(){return{type:"break"}}function ne(){return{type:"html",value:""}}function oe(){return{type:"image",title:null,url:"",alt:null}}function J(){return{type:"link",title:null,url:"",children:[]}}function ht(W){return{type:"list",ordered:W.type==="listOrdered",start:null,spread:W._spread,children:[]}}function ve(W){return{type:"listItem",spread:W._spread,checked:null,children:[]}}function Xe(){return{type:"paragraph",children:[]}}function Ge(){return{type:"strong",children:[]}}function He(){return{type:"text",value:""}}function Pe(){return{type:"thematicBreak"}}}function Ci(e){return{line:e.line,column:e.column,offset:e.offset}}function f5(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?f5(e,s):PD(e,s)}}function PD(e,t){let n;for(n in t)if(m5.call(t,n))switch(n){case"canContainEols":{const s=t[n];s&&e[n].push(...s);break}case"transforms":{const s=t[n];s&&e[n].push(...s);break}case"enter":case"exit":{const s=t[n];s&&Object.assign(e[n],s);break}}}function Qw(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+mu({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+mu({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+mu({start:t.start,end:t.end})+") is still open")}function zD(e){const t=this;t.parser=n;function n(s){return $D(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function BD(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function HD(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
141
- `}]}function FD(e,t){const n=t.value?t.value+`
142
- `:"",s={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(s.className=["language-"+o[0]]);let c={type:"element",tagName:"code",properties:s,children:[{type:"text",value:n}]};return t.meta&&(c.data={meta:t.meta}),e.patch(t,c),c=e.applyData(t,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(t,c),c}function qD(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function VD(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GD(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),o=Kl(s.toLowerCase()),c=e.footnoteOrder.indexOf(s);let u,f=e.footnoteCounts.get(s);f===void 0?(f=0,e.footnoteOrder.push(s),u=e.footnoteOrder.length):u=c+1,f+=1,e.footnoteCounts.set(s,f);const p={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,p);const h={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,h),e.applyData(t,h)}function KD(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function WD(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function p5(e,t){const n=t.referenceType;let s="]";if(n==="collapsed"?s+="[]":n==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const o=e.all(t),c=o[0];c&&c.type==="text"?c.value="["+c.value:o.unshift({type:"text",value:"["});const u=o[o.length-1];return u&&u.type==="text"?u.value+=s:o.push({type:"text",value:s}),o}function YD(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return p5(e,t);const o={src:Kl(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(o.title=s.title);const c={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,c),e.applyData(t,c)}function XD(e,t){const n={src:Kl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,s),e.applyData(t,s)}function QD(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const s={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,s),e.applyData(t,s)}function ZD(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return p5(e,t);const o={href:Kl(s.url||"")};s.title!==null&&s.title!==void 0&&(o.title=s.title);const c={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,c),e.applyData(t,c)}function JD(e,t){const n={href:Kl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const s={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function e$(e,t,n){const s=e.all(t),o=n?t$(n):h5(t),c={},u=[];if(typeof t.checked=="boolean"){const x=s[0];let g;x&&x.type==="element"&&x.tagName==="p"?g=x:(g={type:"element",tagName:"p",properties:{},children:[]},s.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let f=-1;for(;++f<s.length;){const x=s[f];(o||f!==0||x.type!=="element"||x.tagName!=="p")&&u.push({type:"text",value:`
143
- `}),x.type==="element"&&x.tagName==="p"&&!o?u.push(...x.children):u.push(x)}const p=s[s.length-1];p&&(o||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
144
- `});const h={type:"element",tagName:"li",properties:c,children:u};return e.patch(t,h),e.applyData(t,h)}function t$(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let s=-1;for(;!t&&++s<n.length;)t=h5(n[s])}return t}function h5(e){const t=e.spread;return t??e.children.length>1}function n$(e,t){const n={},s=e.all(t);let o=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++o<s.length;){const u=s[o];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const c={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(s,!0)};return e.patch(t,c),e.applyData(t,c)}function r$(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function a$(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function s$(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function i$(e,t){const n=e.all(t),s=n.shift(),o=[];if(s){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(t.children[0],u),o.push(u)}if(n.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},f=cy(t.children[1]),p=WN(t.children[t.children.length-1]);f&&p&&(u.position={start:f,end:p}),o.push(u)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,c),e.applyData(t,c)}function o$(e,t,n){const s=n?n.children:void 0,c=(s?s.indexOf(t):1)===0?"th":"td",u=n&&n.type==="table"?n.align:void 0,f=u?u.length:t.children.length;let p=-1;const h=[];for(;++p<f;){const g=t.children[p],v={},w=u?u[p]:void 0;w&&(v.align=w);let S={type:"element",tagName:c,properties:v,children:[]};g&&(S.children=e.all(g),e.patch(g,S),S=e.applyData(g,S)),h.push(S)}const x={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,x),e.applyData(t,x)}function l$(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Zw=9,Jw=32;function c$(e){const t=String(e),n=/\r?\n|\r/g;let s=n.exec(t),o=0;const c=[];for(;s;)c.push(eS(t.slice(o,s.index),o>0,!0),s[0]),o=s.index+s[0].length,s=n.exec(t);return c.push(eS(t.slice(o),o>0,!1)),c.join("")}function eS(e,t,n){let s=0,o=e.length;if(t){let c=e.codePointAt(s);for(;c===Zw||c===Jw;)s++,c=e.codePointAt(s)}if(n){let c=e.codePointAt(o-1);for(;c===Zw||c===Jw;)o--,c=e.codePointAt(o-1)}return o>s?e.slice(s,o):""}function u$(e,t){const n={type:"text",value:c$(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function d$(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const m$={blockquote:BD,break:HD,code:FD,delete:qD,emphasis:VD,footnoteReference:GD,heading:KD,html:WD,imageReference:YD,image:XD,inlineCode:QD,linkReference:ZD,link:JD,listItem:e$,list:n$,paragraph:r$,root:a$,strong:s$,table:i$,tableCell:l$,tableRow:o$,text:u$,thematicBreak:d$,toml:wm,yaml:wm,definition:wm,footnoteDefinition:wm};function wm(){}const g5=-1,Gf=0,pu=1,ff=2,gy=3,xy=4,yy=5,by=6,x5=7,y5=8,f$=typeof self=="object"?self:globalThis,tS=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new f$[e](t)},p$=(e,t)=>{const n=(o,c)=>(e.set(c,o),o),s=o=>{if(e.has(o))return e.get(o);const[c,u]=t[o];switch(c){case Gf:case g5:return n(u,o);case pu:{const f=n([],o);for(const p of u)f.push(s(p));return f}case ff:{const f=n({},o);for(const[p,h]of u)f[s(p)]=s(h);return f}case gy:return n(new Date(u),o);case xy:{const{source:f,flags:p}=u;return n(new RegExp(f,p),o)}case yy:{const f=n(new Map,o);for(const[p,h]of u)f.set(s(p),s(h));return f}case by:{const f=n(new Set,o);for(const p of u)f.add(s(p));return f}case x5:{const{name:f,message:p}=u;return n(tS(f,p),o)}case y5:return n(BigInt(u),o);case"BigInt":return n(Object(BigInt(u)),o);case"ArrayBuffer":return n(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:f}=new Uint8Array(u);return n(new DataView(f),u)}}return n(tS(c,u),o)};return s},nS=e=>p$(new Map,e)(0),mo="",{toString:h$}={},{keys:g$}=Object,Kc=e=>{const t=typeof e;if(t!=="object"||!e)return[Gf,t];const n=h$.call(e).slice(8,-1);switch(n){case"Array":return[pu,mo];case"Object":return[ff,mo];case"Date":return[gy,mo];case"RegExp":return[xy,mo];case"Map":return[yy,mo];case"Set":return[by,mo];case"DataView":return[pu,n]}return n.includes("Array")?[pu,n]:n.includes("Error")?[x5,n]:[ff,n]},Sm=([e,t])=>e===Gf&&(t==="function"||t==="symbol"),x$=(e,t,n,s)=>{const o=(u,f)=>{const p=s.push(u)-1;return n.set(f,p),p},c=u=>{if(n.has(u))return n.get(u);let[f,p]=Kc(u);switch(f){case Gf:{let x=u;switch(p){case"bigint":f=y5,x=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);x=null;break;case"undefined":return o([g5],u)}return o([f,x],u)}case pu:{if(p){let v=u;return p==="DataView"?v=new Uint8Array(u.buffer):p==="ArrayBuffer"&&(v=new Uint8Array(u)),o([p,[...v]],u)}const x=[],g=o([f,x],u);for(const v of u)x.push(c(v));return g}case ff:{if(p)switch(p){case"BigInt":return o([p,u.toString()],u);case"Boolean":case"Number":case"String":return o([p,u.valueOf()],u)}if(t&&"toJSON"in u)return c(u.toJSON());const x=[],g=o([f,x],u);for(const v of g$(u))(e||!Sm(Kc(u[v])))&&x.push([c(v),c(u[v])]);return g}case gy:return o([f,isNaN(u.getTime())?mo:u.toISOString()],u);case xy:{const{source:x,flags:g}=u;return o([f,{source:x,flags:g}],u)}case yy:{const x=[],g=o([f,x],u);for(const[v,w]of u)(e||!(Sm(Kc(v))||Sm(Kc(w))))&&x.push([c(v),c(w)]);return g}case by:{const x=[],g=o([f,x],u);for(const v of u)(e||!Sm(Kc(v)))&&x.push(c(v));return g}}const{message:h}=u;return o([f,{name:p,message:h}],u)};return c},rS=(e,{json:t,lossy:n}={})=>{const s=[];return x$(!(t||n),!!t,new Map,s)(e),s},pf=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?nS(rS(e,t)):structuredClone(e):(e,t)=>nS(rS(e,t));function y$(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function b$(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function v$(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||y$,s=e.options.footnoteBackLabel||b$,o=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let p=-1;for(;++p<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[p]);if(!h)continue;const x=e.all(h),g=String(h.identifier).toUpperCase(),v=Kl(g.toLowerCase());let w=0;const S=[],C=e.footnoteCounts.get(g);for(;C!==void 0&&++w<=C;){S.length>0&&S.push({type:"text",value:" "});let _=typeof n=="string"?n:n(p,w);typeof _=="string"&&(_={type:"text",value:_}),S.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+v+(w>1?"-"+w:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,w),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const N=x[x.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const _=N.children[N.children.length-1];_&&_.type==="text"?_.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...S)}else x.push(...S);const T={type:"element",tagName:"li",properties:{id:t+"fn-"+v},children:e.wrap(x,!0)};e.patch(h,T),f.push(T)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...pf(u),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
145
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:`
146
- `}]}}const Kf=(function(e){if(e==null)return j$;if(typeof e=="function")return Wf(e);if(typeof e=="object")return Array.isArray(e)?k$(e):w$(e);if(typeof e=="string")return S$(e);throw new Error("Expected function, string, or object as test")});function k$(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Kf(e[n]);return Wf(s);function s(...o){let c=-1;for(;++c<t.length;)if(t[c].apply(this,o))return!0;return!1}}function w$(e){const t=e;return Wf(n);function n(s){const o=s;let c;for(c in e)if(o[c]!==t[c])return!1;return!0}}function S$(e){return Wf(t);function t(n){return n&&n.type===e}}function Wf(e){return t;function t(n,s,o){return!!(C$(n)&&e.call(this,n,typeof s=="number"?s:void 0,o||void 0))}}function j$(){return!0}function C$(e){return e!==null&&typeof e=="object"&&"type"in e}const b5=[],N$=!0,O0=!1,T$="skip";function v5(e,t,n,s){let o;typeof t=="function"&&typeof n!="function"?(s=n,n=t):o=t;const c=Kf(o),u=s?-1:1;f(e,void 0,[])();function f(p,h,x){const g=p&&typeof p=="object"?p:{};if(typeof g.type=="string"){const w=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(p.type+(w?"<"+w+">":""))+")"})}return v;function v(){let w=b5,S,C,N;if((!t||c(p,h,x[x.length-1]||void 0))&&(w=M$(n(p,x)),w[0]===O0))return w;if("children"in p&&p.children){const T=p;if(T.children&&w[0]!==T$)for(C=(s?T.children.length:-1)+u,N=x.concat(T);C>-1&&C<T.children.length;){const _=T.children[C];if(S=f(_,C,N)(),S[0]===O0)return S;C=typeof S[1]=="number"?S[1]:C+u}}return w}}}function M$(e){return Array.isArray(e)?e:typeof e=="number"?[N$,e]:e==null?b5:[e]}function vy(e,t,n,s){let o,c,u;typeof t=="function"&&typeof n!="function"?(c=void 0,u=t,o=n):(c=t,u=n,o=s),v5(e,c,f,o);function f(p,h){const x=h[h.length-1],g=x?x.children.indexOf(p):void 0;return u(p,g,x)}}const D0={}.hasOwnProperty,E$={};function A$(e,t){const n=t||E$,s=new Map,o=new Map,c=new Map,u={...m$,...n.handlers},f={all:h,applyData:R$,definitionById:s,footnoteById:o,footnoteCounts:c,footnoteOrder:[],handlers:u,one:p,options:n,patch:_$,wrap:L$};return vy(e,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const g=x.type==="definition"?s:o,v=String(x.identifier).toUpperCase();g.has(v)||g.set(v,x)}}),f;function p(x,g){const v=x.type,w=f.handlers[v];if(D0.call(f.handlers,v)&&w)return w(f,x,g);if(f.options.passThrough&&f.options.passThrough.includes(v)){if("children"in x){const{children:C,...N}=x,T=pf(N);return T.children=f.all(x),T}return pf(x)}return(f.options.unknownHandler||I$)(f,x,g)}function h(x){const g=[];if("children"in x){const v=x.children;let w=-1;for(;++w<v.length;){const S=f.one(v[w],x);if(S){if(w&&v[w-1].type==="break"&&(!Array.isArray(S)&&S.type==="text"&&(S.value=aS(S.value)),!Array.isArray(S)&&S.type==="element")){const C=S.children[0];C&&C.type==="text"&&(C.value=aS(C.value))}Array.isArray(S)?g.push(...S):g.push(S)}}}return g}}function _$(e,t){e.position&&(t.position=y8(e))}function R$(e,t){let n=t;if(e&&e.data){const s=e.data.hName,o=e.data.hChildren,c=e.data.hProperties;if(typeof s=="string")if(n.type==="element")n.tagName=s;else{const u="children"in n?n.children:[n];n={type:"element",tagName:s,properties:{},children:u}}n.type==="element"&&c&&Object.assign(n.properties,pf(c)),"children"in n&&n.children&&o!==null&&o!==void 0&&(n.children=o)}return n}function I$(e,t){const n=t.data||{},s="value"in t&&!(D0.call(n,"hProperties")||D0.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function L$(e,t){const n=[];let s=-1;for(t&&n.push({type:"text",value:`
147
- `});++s<e.length;)s&&n.push({type:"text",value:`
148
- `}),n.push(e[s]);return t&&e.length>0&&n.push({type:"text",value:`
149
- `}),n}function aS(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function sS(e,t){const n=A$(e,t),s=n.one(e,void 0),o=v$(n),c=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return o&&c.children.push({type:"text",value:`
150
- `},o),c}function O$(e,t){return e&&"run"in e?async function(n,s){const o=sS(n,{file:s,...t});await e.run(o,s)}:function(n,s){return sS(n,{file:s,...e||t})}}function iS(e){if(e)throw e}var Mg,oS;function D$(){if(oS)return Mg;oS=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,o=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},c=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var x=e.call(h,"constructor"),g=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!x&&!g)return!1;var v;for(v in h);return typeof v>"u"||e.call(h,v)},u=function(h,x){n&&x.name==="__proto__"?n(h,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):h[x.name]=x.newValue},f=function(h,x){if(x==="__proto__")if(e.call(h,x)){if(s)return s(h,x).value}else return;return h[x]};return Mg=function p(){var h,x,g,v,w,S,C=arguments[0],N=1,T=arguments.length,_=!1;for(typeof C=="boolean"&&(_=C,C=arguments[1]||{},N=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});N<T;++N)if(h=arguments[N],h!=null)for(x in h)g=f(C,x),v=f(h,x),C!==v&&(_&&v&&(c(v)||(w=o(v)))?(w?(w=!1,S=g&&o(g)?g:[]):S=g&&c(g)?g:{},u(C,{name:x,newValue:p(_,S,v)})):typeof v<"u"&&u(C,{name:x,newValue:v}));return C},Mg}var $$=D$();const Eg=vx($$);function $0(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function U$(){const e=[],t={run:n,use:s};return t;function n(...o){let c=-1;const u=o.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);f(null,...o);function f(p,...h){const x=e[++c];let g=-1;if(p){u(p);return}for(;++g<o.length;)(h[g]===null||h[g]===void 0)&&(h[g]=o[g]);o=h,x?P$(x,f)(...h):u(null,...h)}}function s(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function P$(e,t){let n;return s;function s(...u){const f=e.length>u.length;let p;f&&u.push(o);try{p=e.apply(this,u)}catch(h){const x=h;if(f&&n)throw x;return o(x)}f||(p&&p.then&&typeof p.then=="function"?p.then(c,o):p instanceof Error?o(p):c(p))}function o(u,...f){n||(n=!0,t(u,...f))}function c(u){o(null,u)}}const ys={basename:z$,dirname:B$,extname:H$,join:F$,sep:"/"};function z$(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Qu(e);let n=0,s=-1,o=e.length,c;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){n=o+1;break}}else s<0&&(c=!0,s=o+1);return s<0?"":e.slice(n,s)}if(t===e)return"";let u=-1,f=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(c){n=o+1;break}}else u<0&&(c=!0,u=o+1),f>-1&&(e.codePointAt(o)===t.codePointAt(f--)?f<0&&(s=o):(f=-1,s=u));return n===s?s=u:s<0&&(s=e.length),e.slice(n,s)}function B$(e){if(Qu(e),e.length===0)return".";let t=-1,n=e.length,s;for(;--n;)if(e.codePointAt(n)===47){if(s){t=n;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function H$(e){Qu(e);let t=e.length,n=-1,s=0,o=-1,c=0,u;for(;t--;){const f=e.codePointAt(t);if(f===47){if(u){s=t+1;break}continue}n<0&&(u=!0,n=t+1),f===46?o<0?o=t:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||n<0||c===0||c===1&&o===n-1&&o===s+1?"":e.slice(o,n)}function F$(...e){let t=-1,n;for(;++t<e.length;)Qu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":q$(n)}function q$(e){Qu(e);const t=e.codePointAt(0)===47;let n=V$(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function V$(e,t){let n="",s=0,o=-1,c=0,u=-1,f,p;for(;++u<=e.length;){if(u<e.length)f=e.codePointAt(u);else{if(f===47)break;f=47}if(f===47){if(!(o===u-1||c===1))if(o!==u-1&&c===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(p=n.lastIndexOf("/"),p!==n.length-1){p<0?(n="",s=0):(n=n.slice(0,p),s=n.length-1-n.lastIndexOf("/")),o=u,c=0;continue}}else if(n.length>0){n="",s=0,o=u,c=0;continue}}t&&(n=n.length>0?n+"/..":"..",s=2)}else n.length>0?n+="/"+e.slice(o+1,u):n=e.slice(o+1,u),s=u-o-1;o=u,c=0}else f===46&&c>-1?c++:c=-1}return n}function Qu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const G$={cwd:K$};function K$(){return"/"}function U0(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function W$(e){if(typeof e=="string")e=new URL(e);else if(!U0(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Y$(e)}function Y$(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const s=t.codePointAt(n+2);if(s===70||s===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}const Ag=["history","path","basename","stem","extname","dirname"];class k5{constructor(t){let n;t?U0(t)?n={path:t}:typeof t=="string"||X$(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":G$.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<Ag.length;){const c=Ag[s];c in n&&n[c]!==void 0&&n[c]!==null&&(this[c]=c==="history"?[...n[c]]:n[c])}let o;for(o in n)Ag.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?ys.basename(this.path):void 0}set basename(t){Rg(t,"basename"),_g(t,"basename"),this.path=ys.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ys.dirname(this.path):void 0}set dirname(t){lS(this.basename,"dirname"),this.path=ys.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ys.extname(this.path):void 0}set extname(t){if(_g(t,"extname"),lS(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ys.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){U0(t)&&(t=W$(t)),Rg(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ys.basename(this.path,this.extname):void 0}set stem(t){Rg(t,"stem"),_g(t,"stem"),this.path=ys.join(this.dirname||"",t+(this.extname||""))}fail(t,n,s){const o=this.message(t,n,s);throw o.fatal=!0,o}info(t,n,s){const o=this.message(t,n,s);return o.fatal=void 0,o}message(t,n,s){const o=new jr(t,n,s);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function _g(e,t){if(e&&e.includes(ys.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ys.sep+"`")}function Rg(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function lS(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function X$(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Q$=(function(e){const s=this.constructor.prototype,o=s[e],c=function(){return o.apply(c,arguments)};return Object.setPrototypeOf(c,s),c}),Z$={}.hasOwnProperty;class ky extends Q${constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=U$()}copy(){const t=new ky;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(Eg(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Og("data",this.frozen),this.namespace[t]=n,this):Z$.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Og("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const o=n.call(t,...s);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=jm(t),s=this.parser||this.Parser;return Ig("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),Ig("process",this.parser||this.Parser),Lg("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(c,u){const f=jm(t),p=s.parse(f);s.run(p,f,function(x,g,v){if(x||!g||!v)return h(x);const w=g,S=s.stringify(w,v);t7(S)?v.value=S:v.result=S,h(x,v)});function h(x,g){x||!g?u(x):c?c(g):n(void 0,g)}}}processSync(t){let n=!1,s;return this.freeze(),Ig("processSync",this.parser||this.Parser),Lg("processSync",this.compiler||this.Compiler),this.process(t,o),uS("processSync","process",n),s;function o(c,u){n=!0,iS(c),s=u}}run(t,n,s){cS(t),this.freeze();const o=this.transformers;return!s&&typeof n=="function"&&(s=n,n=void 0),s?c(void 0,s):new Promise(c);function c(u,f){const p=jm(n);o.run(t,p,h);function h(x,g,v){const w=g||t;x?f(x):u?u(w):s(void 0,w,v)}}}runSync(t,n){let s=!1,o;return this.run(t,n,c),uS("runSync","run",s),o;function c(u,f){iS(u),o=f,s=!0}}stringify(t,n){this.freeze();const s=jm(n),o=this.compiler||this.Compiler;return Lg("stringify",o),cS(t),o(t,s)}use(t,...n){const s=this.attachers,o=this.namespace;if(Og("use",this.frozen),t!=null)if(typeof t=="function")p(t,n);else if(typeof t=="object")Array.isArray(t)?f(t):u(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function c(h){if(typeof h=="function")p(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[x,...g]=h;p(x,g)}else u(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function u(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");f(h.plugins),h.settings&&(o.settings=Eg(!0,o.settings,h.settings))}function f(h){let x=-1;if(h!=null)if(Array.isArray(h))for(;++x<h.length;){const g=h[x];c(g)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function p(h,x){let g=-1,v=-1;for(;++g<s.length;)if(s[g][0]===h){v=g;break}if(v===-1)s.push([h,...x]);else if(x.length>0){let[w,...S]=x;const C=s[v][1];$0(C)&&$0(w)&&(w=Eg(!0,C,w)),s[v]=[h,w,...S]}}}}const J$=new ky().freeze();function Ig(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Lg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Og(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function cS(e){if(!$0(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function uS(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function jm(e){return e7(e)?e:new k5(e)}function e7(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function t7(e){return typeof e=="string"||n7(e)}function n7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const r7="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",dS=[],mS={allowDangerousHtml:!0},a7=/^(https?|ircs?|mailto|xmpp)$/i,s7=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Zu(e){const t=i7(e),n=o7(e);return l7(t.runSync(t.parse(n),n),e)}function i7(e){const t=e.rehypePlugins||dS,n=e.remarkPlugins||dS,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...mS}:mS;return J$().use(zD).use(n).use(O$,s).use(t)}function o7(e){const t=e.children||"",n=new k5;return typeof t=="string"&&(n.value=t),n}function l7(e,t){const n=t.allowedElements,s=t.allowElement,o=t.components,c=t.disallowedElements,u=t.skipHtml,f=t.unwrapDisallowed,p=t.urlTransform||c7;for(const x of s7)Object.hasOwn(t,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+r7+x.id,void 0);return vy(e,h),S8(e,{Fragment:a.Fragment,components:o,ignoreInvalidStyle:!0,jsx:a.jsx,jsxs:a.jsxs,passKeys:!0,passNode:!0});function h(x,g,v){if(x.type==="raw"&&v&&typeof g=="number")return u?v.children.splice(g,1):v.children[g]={type:"text",value:x.value},g;if(x.type==="element"){let w;for(w in Cg)if(Object.hasOwn(Cg,w)&&Object.hasOwn(x.properties,w)){const S=x.properties[w],C=Cg[w];(C===null||C.includes(x.tagName))&&(x.properties[w]=p(String(S||""),w,x))}}if(x.type==="element"){let w=n?!n.includes(x.tagName):c?c.includes(x.tagName):!1;if(!w&&s&&typeof g=="number"&&(w=!s(x,g,v)),w&&v&&typeof g=="number")return f&&x.children?v.children.splice(g,1,...x.children):v.children.splice(g,1),g}}}function c7(e){const t=e.indexOf(":"),n=e.indexOf("?"),s=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||s!==-1&&t>s||a7.test(e.slice(0,t))?e:""}function fS(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let s=0,o=n.indexOf(t);for(;o!==-1;)s++,o=n.indexOf(t,o+t.length);return s}function u7(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function d7(e,t,n){const o=Kf((n||{}).ignore||[]),c=m7(t);let u=-1;for(;++u<c.length;)v5(e,"text",f);function f(h,x){let g=-1,v;for(;++g<x.length;){const w=x[g],S=v?v.children:void 0;if(o(w,S?S.indexOf(w):void 0,v))return;v=w}if(v)return p(h,x)}function p(h,x){const g=x[x.length-1],v=c[u][0],w=c[u][1];let S=0;const N=g.children.indexOf(h);let T=!1,_=[];v.lastIndex=0;let R=v.exec(h.value);for(;R;){const D=R.index,z={index:R.index,input:R.input,stack:[...x,h]};let E=w(...R,z);if(typeof E=="string"&&(E=E.length>0?{type:"text",value:E}:void 0),E===!1?v.lastIndex=D+1:(S!==D&&_.push({type:"text",value:h.value.slice(S,D)}),Array.isArray(E)?_.push(...E):E&&_.push(E),S=D+R[0].length,T=!0),!v.global)break;R=v.exec(h.value)}return T?(S<h.value.length&&_.push({type:"text",value:h.value.slice(S)}),g.children.splice(N,1,..._)):_=[h],N+_.length}}function m7(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let s=-1;for(;++s<n.length;){const o=n[s];t.push([f7(o[0]),p7(o[1])])}return t}function f7(e){return typeof e=="string"?new RegExp(u7(e),"g"):e}function p7(e){return typeof e=="function"?e:function(){return e}}const Dg="phrasing",$g=["autolink","link","image","label"];function h7(){return{transforms:[w7],enter:{literalAutolink:x7,literalAutolinkEmail:Ug,literalAutolinkHttp:Ug,literalAutolinkWww:Ug},exit:{literalAutolink:k7,literalAutolinkEmail:v7,literalAutolinkHttp:y7,literalAutolinkWww:b7}}}function g7(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Dg,notInConstruct:$g},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Dg,notInConstruct:$g},{character:":",before:"[ps]",after:"\\/",inConstruct:Dg,notInConstruct:$g}]}}function x7(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Ug(e){this.config.enter.autolinkProtocol.call(this,e)}function y7(e){this.config.exit.autolinkProtocol.call(this,e)}function b7(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function v7(e){this.config.exit.autolinkEmail.call(this,e)}function k7(e){this.exit(e)}function w7(e){d7(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,S7],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),j7]],{ignore:["link","linkReference"]})}function S7(e,t,n,s,o){let c="";if(!w5(o)||(/^w/i.test(t)&&(n=t+n,t="",c="http://"),!C7(n)))return!1;const u=N7(n+s);if(!u[0])return!1;const f={type:"link",title:null,url:c+t+u[0],children:[{type:"text",value:t+u[0]}]};return u[1]?[f,{type:"text",value:u[1]}]:f}function j7(e,t,n,s){return!w5(s,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function C7(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function N7(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],s=n.indexOf(")");const o=fS(e,"(");let c=fS(e,")");for(;s!==-1&&o>c;)e+=n.slice(0,s+1),n=n.slice(s+1),s=n.indexOf(")"),c++;return[e,n]}function w5(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Eo(n)||qf(n))&&(!t||n!==47)}S5.peek=O7;function T7(){this.buffer()}function M7(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function E7(){this.buffer()}function A7(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function _7(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ja(this.sliceSerialize(e)).toLowerCase(),n.label=t}function R7(e){this.exit(e)}function I7(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ja(this.sliceSerialize(e)).toLowerCase(),n.label=t}function L7(e){this.exit(e)}function O7(){return"["}function S5(e,t,n,s){const o=n.createTracker(s);let c=o.move("[^");const u=n.enter("footnoteReference"),f=n.enter("reference");return c+=o.move(n.safe(n.associationId(e),{after:"]",before:c})),f(),u(),c+=o.move("]"),c}function D7(){return{enter:{gfmFootnoteCallString:T7,gfmFootnoteCall:M7,gfmFootnoteDefinitionLabelString:E7,gfmFootnoteDefinition:A7},exit:{gfmFootnoteCallString:_7,gfmFootnoteCall:R7,gfmFootnoteDefinitionLabelString:I7,gfmFootnoteDefinition:L7}}}function $7(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:S5},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,o,c,u){const f=c.createTracker(u);let p=f.move("[^");const h=c.enter("footnoteDefinition"),x=c.enter("label");return p+=f.move(c.safe(c.associationId(s),{before:p,after:"]"})),x(),p+=f.move("]:"),s.children&&s.children.length>0&&(f.shift(4),p+=f.move((t?`
151
- `:" ")+c.indentLines(c.containerFlow(s,f.current()),t?j5:U7))),h(),p}}function U7(e,t,n){return t===0?e:j5(e,t,n)}function j5(e,t,n){return(n?"":" ")+e}const P7=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];C5.peek=q7;function z7(){return{canContainEols:["delete"],enter:{strikethrough:H7},exit:{strikethrough:F7}}}function B7(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:P7}],handlers:{delete:C5}}}function H7(e){this.enter({type:"delete",children:[]},e)}function F7(e){this.exit(e)}function C5(e,t,n,s){const o=n.createTracker(s),c=n.enter("strikethrough");let u=o.move("~~");return u+=n.containerPhrasing(e,{...o.current(),before:u,after:"~"}),u+=o.move("~~"),c(),u}function q7(){return"~"}function V7(e){return e.length}function G7(e,t){const n=t||{},s=(n.align||[]).concat(),o=n.stringLength||V7,c=[],u=[],f=[],p=[];let h=0,x=-1;for(;++x<e.length;){const C=[],N=[];let T=-1;for(e[x].length>h&&(h=e[x].length);++T<e[x].length;){const _=K7(e[x][T]);if(n.alignDelimiters!==!1){const R=o(_);N[T]=R,(p[T]===void 0||R>p[T])&&(p[T]=R)}C.push(_)}u[x]=C,f[x]=N}let g=-1;if(typeof s=="object"&&"length"in s)for(;++g<h;)c[g]=pS(s[g]);else{const C=pS(s);for(;++g<h;)c[g]=C}g=-1;const v=[],w=[];for(;++g<h;){const C=c[g];let N="",T="";C===99?(N=":",T=":"):C===108?N=":":C===114&&(T=":");let _=n.alignDelimiters===!1?1:Math.max(1,p[g]-N.length-T.length);const R=N+"-".repeat(_)+T;n.alignDelimiters!==!1&&(_=N.length+_+T.length,_>p[g]&&(p[g]=_),w[g]=_),v[g]=R}u.splice(1,0,v),f.splice(1,0,w),x=-1;const S=[];for(;++x<u.length;){const C=u[x],N=f[x];g=-1;const T=[];for(;++g<h;){const _=C[g]||"";let R="",D="";if(n.alignDelimiters!==!1){const z=p[g]-(N[g]||0),E=c[g];E===114?R=" ".repeat(z):E===99?z%2?(R=" ".repeat(z/2+.5),D=" ".repeat(z/2-.5)):(R=" ".repeat(z/2),D=R):D=" ".repeat(z)}n.delimiterStart!==!1&&!g&&T.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&_==="")&&(n.delimiterStart!==!1||g)&&T.push(" "),n.alignDelimiters!==!1&&T.push(R),T.push(_),n.alignDelimiters!==!1&&T.push(D),n.padding!==!1&&T.push(" "),(n.delimiterEnd!==!1||g!==h-1)&&T.push("|")}S.push(n.delimiterEnd===!1?T.join("").replace(/ +$/,""):T.join(""))}return S.join(`
152
- `)}function K7(e){return e==null?"":String(e)}function pS(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function W7(e,t,n,s){const o=n.enter("blockquote"),c=n.createTracker(s);c.move("> "),c.shift(2);const u=n.indentLines(n.containerFlow(e,c.current()),Y7);return o(),u}function Y7(e,t,n){return">"+(n?"":" ")+e}function X7(e,t){return hS(e,t.inConstruct,!0)&&!hS(e,t.notInConstruct,!1)}function hS(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let s=-1;for(;++s<t.length;)if(e.includes(t[s]))return!0;return!1}function gS(e,t,n,s){let o=-1;for(;++o<n.unsafe.length;)if(n.unsafe[o].character===`
153
- `&&X7(n.stack,n.unsafe[o]))return/[ \t]/.test(s.before)?"":" ";return`\\
154
- `}function Q7(e,t){const n=String(e);let s=n.indexOf(t),o=s,c=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;s!==-1;)s===o?++c>u&&(u=c):c=1,o=s+t.length,s=n.indexOf(t,o);return u}function Z7(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function J7(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function e9(e,t,n,s){const o=J7(n),c=e.value||"",u=o==="`"?"GraveAccent":"Tilde";if(Z7(e,n)){const g=n.enter("codeIndented"),v=n.indentLines(c,t9);return g(),v}const f=n.createTracker(s),p=o.repeat(Math.max(Q7(c,o)+1,3)),h=n.enter("codeFenced");let x=f.move(p);if(e.lang){const g=n.enter(`codeFencedLang${u}`);x+=f.move(n.safe(e.lang,{before:x,after:" ",encode:["`"],...f.current()})),g()}if(e.lang&&e.meta){const g=n.enter(`codeFencedMeta${u}`);x+=f.move(" "),x+=f.move(n.safe(e.meta,{before:x,after:`
155
- `,encode:["`"],...f.current()})),g()}return x+=f.move(`
156
- `),c&&(x+=f.move(c+`
157
- `)),x+=f.move(p),h(),x}function t9(e,t,n){return(n?"":" ")+e}function wy(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function n9(e,t,n,s){const o=wy(n),c=o==='"'?"Quote":"Apostrophe",u=n.enter("definition");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("[");return h+=p.move(n.safe(n.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":`
158
- `,...p.current()}))),f(),e.title&&(f=n.enter(`title${c}`),h+=p.move(" "+o),h+=p.move(n.safe(e.title,{before:h,after:o,...p.current()})),h+=p.move(o),f()),u(),h}function r9(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Eu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function hf(e,t,n){const s=Il(e),o=Il(t);return s===void 0?o===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}N5.peek=a9;function N5(e,t,n,s){const o=r9(n),c=n.enter("emphasis"),u=n.createTracker(s),f=u.move(o);let p=u.move(n.containerPhrasing(e,{after:o,before:f,...u.current()}));const h=p.charCodeAt(0),x=hf(s.before.charCodeAt(s.before.length-1),h,o);x.inside&&(p=Eu(h)+p.slice(1));const g=p.charCodeAt(p.length-1),v=hf(s.after.charCodeAt(0),g,o);v.inside&&(p=p.slice(0,-1)+Eu(g));const w=u.move(o);return c(),n.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},f+p+w}function a9(e,t,n){return n.options.emphasis||"*"}function s9(e,t){let n=!1;return vy(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,O0}),!!((!e.depth||e.depth<3)&&fy(e)&&(t.options.setext||n))}function i9(e,t,n,s){const o=Math.max(Math.min(6,e.depth||1),1),c=n.createTracker(s);if(s9(e,n)){const x=n.enter("headingSetext"),g=n.enter("phrasing"),v=n.containerPhrasing(e,{...c.current(),before:`
159
- `,after:`
160
- `});return g(),x(),v+`
161
- `+(o===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
162
- `))+1))}const u="#".repeat(o),f=n.enter("headingAtx"),p=n.enter("phrasing");c.move(u+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
163
- `,...c.current()});return/^[\t ]/.test(h)&&(h=Eu(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,n.options.closeAtx&&(h+=" "+u),p(),f(),h}T5.peek=o9;function T5(e){return e.value||""}function o9(){return"<"}M5.peek=l9;function M5(e,t,n,s){const o=wy(n),c=o==='"'?"Quote":"Apostrophe",u=n.enter("image");let f=n.enter("label");const p=n.createTracker(s);let h=p.move("![");return h+=p.move(n.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(n.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=n.enter("destinationRaw"),h+=p.move(n.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=n.enter(`title${c}`),h+=p.move(" "+o),h+=p.move(n.safe(e.title,{before:h,after:o,...p.current()})),h+=p.move(o),f()),h+=p.move(")"),u(),h}function l9(){return"!"}E5.peek=c9;function E5(e,t,n,s){const o=e.referenceType,c=n.enter("imageReference");let u=n.enter("label");const f=n.createTracker(s);let p=f.move("![");const h=n.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),u();const x=n.stack;n.stack=[],u=n.enter("reference");const g=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return u(),n.stack=x,c(),o==="full"||!h||h!==g?p+=f.move(g+"]"):o==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function c9(){return"!"}A5.peek=u9;function A5(e,t,n){let s=e.value||"",o="`",c=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(s);)o+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++c<n.unsafe.length;){const u=n.unsafe[c],f=n.compilePattern(u);let p;if(u.atBreak)for(;p=f.exec(s);){let h=p.index;s.charCodeAt(h)===10&&s.charCodeAt(h-1)===13&&h--,s=s.slice(0,h)+" "+s.slice(p.index+1)}}return o+s+o}function u9(){return"`"}function _5(e,t){const n=fy(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}R5.peek=d9;function R5(e,t,n,s){const o=wy(n),c=o==='"'?"Quote":"Apostrophe",u=n.createTracker(s);let f,p;if(_5(e,n)){const x=n.stack;n.stack=[],f=n.enter("autolink");let g=u.move("<");return g+=u.move(n.containerPhrasing(e,{before:g,after:">",...u.current()})),g+=u.move(">"),f(),n.stack=x,g}f=n.enter("link"),p=n.enter("label");let h=u.move("[");return h+=u.move(n.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=n.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(n.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(p=n.enter("destinationRaw"),h+=u.move(n.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),p(),e.title&&(p=n.enter(`title${c}`),h+=u.move(" "+o),h+=u.move(n.safe(e.title,{before:h,after:o,...u.current()})),h+=u.move(o),p()),h+=u.move(")"),f(),h}function d9(e,t,n){return _5(e,n)?"<":"["}I5.peek=m9;function I5(e,t,n,s){const o=e.referenceType,c=n.enter("linkReference");let u=n.enter("label");const f=n.createTracker(s);let p=f.move("[");const h=n.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),u();const x=n.stack;n.stack=[],u=n.enter("reference");const g=n.safe(n.associationId(e),{before:p,after:"]",...f.current()});return u(),n.stack=x,c(),o==="full"||!h||h!==g?p+=f.move(g+"]"):o==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function m9(){return"["}function Sy(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function f9(e){const t=Sy(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function p9(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function L5(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function h9(e,t,n,s){const o=n.enter("list"),c=n.bulletCurrent;let u=e.ordered?p9(n):Sy(n);const f=e.ordered?u==="."?")":".":f9(n);let p=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&x&&(!x.children||!x.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(p=!0),L5(n)===u&&x){let g=-1;for(;++g<e.children.length;){const v=e.children[g];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(u=f),n.bulletCurrent=u;const h=n.containerFlow(e,s);return n.bulletLastUsed=u,n.bulletCurrent=c,o(),h}function g9(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function x9(e,t,n,s){const o=g9(n);let c=n.bulletCurrent||Sy(n);t&&t.type==="list"&&t.ordered&&(c=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+c);let u=c.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const f=n.createTracker(s);f.move(c+" ".repeat(u-c.length)),f.shift(u);const p=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,f.current()),x);return p(),h;function x(g,v,w){return v?(w?"":" ".repeat(u))+g:(w?c:c+" ".repeat(u-c.length))+g}}function y9(e,t,n,s){const o=n.enter("paragraph"),c=n.enter("phrasing"),u=n.containerPhrasing(e,s);return c(),o(),u}const b9=Kf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function v9(e,t,n,s){return(e.children.some(function(u){return b9(u)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function k9(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}O5.peek=w9;function O5(e,t,n,s){const o=k9(n),c=n.enter("strong"),u=n.createTracker(s),f=u.move(o+o);let p=u.move(n.containerPhrasing(e,{after:o,before:f,...u.current()}));const h=p.charCodeAt(0),x=hf(s.before.charCodeAt(s.before.length-1),h,o);x.inside&&(p=Eu(h)+p.slice(1));const g=p.charCodeAt(p.length-1),v=hf(s.after.charCodeAt(0),g,o);v.inside&&(p=p.slice(0,-1)+Eu(g));const w=u.move(o+o);return c(),n.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},f+p+w}function w9(e,t,n){return n.options.strong||"*"}function S9(e,t,n,s){return n.safe(e.value,s)}function j9(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function C9(e,t,n){const s=(L5(n)+(n.options.ruleSpaces?" ":"")).repeat(j9(n));return n.options.ruleSpaces?s.slice(0,-1):s}const D5={blockquote:W7,break:gS,code:e9,definition:n9,emphasis:N5,hardBreak:gS,heading:i9,html:T5,image:M5,imageReference:E5,inlineCode:A5,link:R5,linkReference:I5,list:h9,listItem:x9,paragraph:y9,root:v9,strong:O5,text:S9,thematicBreak:C9};function N9(){return{enter:{table:T9,tableData:xS,tableHeader:xS,tableRow:E9},exit:{codeText:A9,table:M9,tableData:Pg,tableHeader:Pg,tableRow:Pg}}}function T9(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function M9(e){this.exit(e),this.data.inTable=void 0}function E9(e){this.enter({type:"tableRow",children:[]},e)}function Pg(e){this.exit(e)}function xS(e){this.enter({type:"tableCell",children:[]},e)}function A9(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,_9));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function _9(e,t){return t==="|"?t:e}function R9(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,o=t.stringLength,c=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
164
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:u,tableCell:p,tableRow:f}};function u(w,S,C,N){return h(x(w,C,N),w.align)}function f(w,S,C,N){const T=g(w,C,N),_=h([T]);return _.slice(0,_.indexOf(`
165
- `))}function p(w,S,C,N){const T=C.enter("tableCell"),_=C.enter("phrasing"),R=C.containerPhrasing(w,{...N,before:c,after:c});return _(),T(),R}function h(w,S){return G7(w,{align:S,alignDelimiters:s,padding:n,stringLength:o})}function x(w,S,C){const N=w.children;let T=-1;const _=[],R=S.enter("table");for(;++T<N.length;)_[T]=g(N[T],S,C);return R(),_}function g(w,S,C){const N=w.children;let T=-1;const _=[],R=S.enter("tableRow");for(;++T<N.length;)_[T]=p(N[T],w,S,C);return R(),_}function v(w,S,C){let N=D5.inlineCode(w,S,C);return C.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function I9(){return{exit:{taskListCheckValueChecked:yS,taskListCheckValueUnchecked:yS,paragraph:O9}}}function L9(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:D9}}}function yS(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function O9(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const s=n.children[0];if(s&&s.type==="text"){const o=t.children;let c=-1,u;for(;++c<o.length;){const f=o[c];if(f.type==="paragraph"){u=f;break}}u===n&&(s.value=s.value.slice(1),s.value.length===0?n.children.shift():n.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,n.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function D9(e,t,n,s){const o=e.children[0],c=typeof e.checked=="boolean"&&o&&o.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",f=n.createTracker(s);c&&f.move(u);let p=D5.listItem(e,t,n,{...s,...f.current()});return c&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),p;function h(x){return x+u}}function $9(){return[h7(),D7(),z7(),N9(),I9()]}function U9(e){return{extensions:[g7(),$7(e),B7(),R9(e),L9()]}}const P9={tokenize:V9,partial:!0},$5={tokenize:G9,partial:!0},U5={tokenize:K9,partial:!0},P5={tokenize:W9,partial:!0},z9={tokenize:Y9,partial:!0},z5={name:"wwwAutolink",tokenize:F9,previous:H5},B5={name:"protocolAutolink",tokenize:q9,previous:F5},Zs={name:"emailAutolink",tokenize:H9,previous:q5},Ns={};function B9(){return{text:Ns}}let lo=48;for(;lo<123;)Ns[lo]=Zs,lo++,lo===58?lo=65:lo===91&&(lo=97);Ns[43]=Zs;Ns[45]=Zs;Ns[46]=Zs;Ns[95]=Zs;Ns[72]=[Zs,B5];Ns[104]=[Zs,B5];Ns[87]=[Zs,z5];Ns[119]=[Zs,z5];function H9(e,t,n){const s=this;let o,c;return u;function u(g){return!P0(g)||!q5.call(s,s.previous)||jy(s.events)?n(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return P0(g)?(e.consume(g),f):g===64?(e.consume(g),p):n(g)}function p(g){return g===46?e.check(z9,x,h)(g):g===45||g===95||kr(g)?(c=!0,e.consume(g),p):x(g)}function h(g){return e.consume(g),o=!0,p}function x(g){return c&&o&&Or(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):n(g)}}function F9(e,t,n){const s=this;return o;function o(u){return u!==87&&u!==119||!H5.call(s,s.previous)||jy(s.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(P9,e.attempt($5,e.attempt(U5,c),n),n)(u))}function c(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function q9(e,t,n){const s=this;let o="",c=!1;return u;function u(g){return(g===72||g===104)&&F5.call(s,s.previous)&&!jy(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):n(g)}function f(g){if(Or(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(g),p}return n(g)}function p(g){return g===47?(e.consume(g),c?h:(c=!0,p)):n(g)}function h(g){return g===null||mf(g)||dn(g)||Eo(g)||qf(g)?n(g):e.attempt($5,e.attempt(U5,x),n)(g)}function x(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function V9(e,t,n){let s=0;return o;function o(u){return(u===87||u===119)&&s<3?(s++,e.consume(u),o):u===46&&s===3?(e.consume(u),c):n(u)}function c(u){return u===null?n(u):t(u)}}function G9(e,t,n){let s,o,c;return u;function u(h){return h===46||h===95?e.check(P5,p,f)(h):h===null||dn(h)||Eo(h)||h!==45&&qf(h)?p(h):(c=!0,e.consume(h),u)}function f(h){return h===95?s=!0:(o=s,s=void 0),e.consume(h),u}function p(h){return o||s||!c?n(h):t(h)}}function K9(e,t){let n=0,s=0;return o;function o(u){return u===40?(n++,e.consume(u),o):u===41&&s<n?c(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(P5,t,c)(u):u===null||dn(u)||Eo(u)?t(u):(e.consume(u),o)}function c(u){return u===41&&s++,e.consume(u),o}}function W9(e,t,n){return s;function s(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),s):f===38?(e.consume(f),c):f===93?(e.consume(f),o):f===60||f===null||dn(f)||Eo(f)?t(f):n(f)}function o(f){return f===null||f===40||f===91||dn(f)||Eo(f)?t(f):s(f)}function c(f){return Or(f)?u(f):n(f)}function u(f){return f===59?(e.consume(f),s):Or(f)?(e.consume(f),u):n(f)}}function Y9(e,t,n){return s;function s(c){return e.consume(c),o}function o(c){return kr(c)?n(c):t(c)}}function H5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||dn(e)}function F5(e){return!Or(e)}function q5(e){return!(e===47||P0(e))}function P0(e){return e===43||e===45||e===46||e===95||kr(e)}function jy(e){let t=e.length,n=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){n=!0;break}if(s._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const X9={tokenize:aU,partial:!0};function Q9(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:tU,continuation:{tokenize:nU},exit:rU}},text:{91:{name:"gfmFootnoteCall",tokenize:eU},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Z9,resolveTo:J9}}}}function Z9(e,t,n){const s=this;let o=s.events.length;const c=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let u;for(;o--;){const p=s.events[o][1];if(p.type==="labelImage"){u=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!u||!u._balanced)return n(p);const h=Ja(s.sliceSerialize({start:u.end,end:s.now()}));return h.codePointAt(0)!==94||!c.includes(h.slice(1))?n(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function J9(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const c={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},c.start),end:Object.assign({},c.end)},f=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",c,t],["enter",u,t],["exit",u,t],["exit",c,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...f),e}function eU(e,t,n){const s=this,o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c=0,u;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),p}function p(g){return g!==94?n(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(c>999||g===93&&!u||g===null||g===91||dn(g))return n(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(Ja(s.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(g)}return dn(g)||(u=!0),c++,e.consume(g),g===92?x:h}function x(g){return g===91||g===92||g===93?(e.consume(g),c++,h):h(g)}}function tU(e,t,n){const s=this,o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c,u=0,f;return p;function p(S){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(S){return S===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):n(S)}function x(S){if(u>999||S===93&&!f||S===null||S===91||dn(S))return n(S);if(S===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return c=Ja(s.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return dn(S)||(f=!0),u++,e.consume(S),S===92?g:x}function g(S){return S===91||S===92||S===93?(e.consume(S),u++,x):x(S)}function v(S){return S===58?(e.enter("definitionMarker"),e.consume(S),e.exit("definitionMarker"),o.includes(c)||o.push(c),Ut(e,w,"gfmFootnoteDefinitionWhitespace")):n(S)}function w(S){return t(S)}}function nU(e,t,n){return e.check(Xu,t,e.attempt(X9,t,n))}function rU(e){e.exit("gfmFootnoteDefinition")}function aU(e,t,n){const s=this;return Ut(e,o,"gfmFootnoteDefinitionIndent",5);function o(c){const u=s.events[s.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(c):n(c)}}function sU(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:c,resolveAll:o};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function o(u,f){let p=-1;for(;++p<u.length;)if(u[p][0]==="enter"&&u[p][1].type==="strikethroughSequenceTemporary"&&u[p][1]._close){let h=p;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[p][1].end.offset-u[p][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[p][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[p][1].end)},g={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[p][1].start)},v=[["enter",x,f],["enter",u[h][1],f],["exit",u[h][1],f],["enter",g,f]],w=f.parser.constructs.insideSpan.null;w&&xa(v,v.length,0,Vf(w,u.slice(h+1,p),f)),xa(v,v.length,0,[["exit",g,f],["enter",u[p][1],f],["exit",u[p][1],f],["exit",x,f]]),xa(u,h-1,p-h+3,v),p=h+v.length-2;break}}for(p=-1;++p<u.length;)u[p][1].type==="strikethroughSequenceTemporary"&&(u[p][1].type="data");return u}function c(u,f,p){const h=this.previous,x=this.events;let g=0;return v;function v(S){return h===126&&x[x.length-1][1].type!=="characterEscape"?p(S):(u.enter("strikethroughSequenceTemporary"),w(S))}function w(S){const C=Il(h);if(S===126)return g>1?p(S):(u.consume(S),g++,w);if(g<2&&!n)return p(S);const N=u.exit("strikethroughSequenceTemporary"),T=Il(S);return N._open=!T||T===2&&!!C,N._close=!C||C===2&&!!T,f(S)}}}class iU{constructor(){this.map=[]}add(t,n,s){oU(this,t,n,s)}consume(t){if(this.map.sort(function(c,u){return c[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let o=s.pop();for(;o;){for(const c of o)t.push(c);o=s.pop()}this.map.length=0}}function oU(e,t,n,s){let o=0;if(!(n===0&&s.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...s);return}o+=1}e.map.push([t,n,s])}}function lU(e,t){let n=!1;const s=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const c=s.length-1;s[c]=s[c]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return s}function cU(){return{flow:{null:{name:"table",tokenize:uU,resolveAll:dU}}}}function uU(e,t,n){const s=this;let o=0,c=0,u;return f;function f(P){let B=s.events.length-1;for(;B>-1;){const K=s.events[B][1].type;if(K==="lineEnding"||K==="linePrefix")B--;else break}const Y=B>-1?s.events[B][1].type:null,q=Y==="tableHead"||Y==="tableRow"?E:p;return q===E&&s.parser.lazy[s.now().line]?n(P):q(P)}function p(P){return e.enter("tableHead"),e.enter("tableRow"),h(P)}function h(P){return P===124||(u=!0,c+=1),x(P)}function x(P){return P===null?n(P):ot(P)?c>1?(c=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),w):n(P):Rt(P)?Ut(e,x,"whitespace")(P):(c+=1,u&&(u=!1,o+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),u=!0,x):(e.enter("data"),g(P)))}function g(P){return P===null||P===124||dn(P)?(e.exit("data"),x(P)):(e.consume(P),P===92?v:g)}function v(P){return P===92||P===124?(e.consume(P),g):g(P)}function w(P){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(P):(e.enter("tableDelimiterRow"),u=!1,Rt(P)?Ut(e,S,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):S(P))}function S(P){return P===45||P===58?N(P):P===124?(u=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),C):z(P)}function C(P){return Rt(P)?Ut(e,N,"whitespace")(P):N(P)}function N(P){return P===58?(c+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),T):P===45?(c+=1,T(P)):P===null||ot(P)?D(P):z(P)}function T(P){return P===45?(e.enter("tableDelimiterFiller"),_(P)):z(P)}function _(P){return P===45?(e.consume(P),_):P===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),R):(e.exit("tableDelimiterFiller"),R(P))}function R(P){return Rt(P)?Ut(e,D,"whitespace")(P):D(P)}function D(P){return P===124?S(P):P===null||ot(P)?!u||o!==c?z(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):z(P)}function z(P){return n(P)}function E(P){return e.enter("tableRow"),L(P)}function L(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),L):P===null||ot(P)?(e.exit("tableRow"),t(P)):Rt(P)?Ut(e,L,"whitespace")(P):(e.enter("data"),F(P))}function F(P){return P===null||P===124||dn(P)?(e.exit("data"),L(P)):(e.consume(P),P===92?V:F)}function V(P){return P===92||P===124?(e.consume(P),F):F(P)}}function dU(e,t){let n=-1,s=!0,o=0,c=[0,0,0,0],u=[0,0,0,0],f=!1,p=0,h,x,g;const v=new iU;for(;++n<e.length;){const w=e[n],S=w[1];w[0]==="enter"?S.type==="tableHead"?(f=!1,p!==0&&(bS(v,t,p,h,x),x=void 0,p=0),h={type:"table",start:Object.assign({},S.start),end:Object.assign({},S.end)},v.add(n,0,[["enter",h,t]])):S.type==="tableRow"||S.type==="tableDelimiterRow"?(s=!0,g=void 0,c=[0,0,0,0],u=[0,n+1,0,0],f&&(f=!1,x={type:"tableBody",start:Object.assign({},S.start),end:Object.assign({},S.end)},v.add(n,0,[["enter",x,t]])),o=S.type==="tableDelimiterRow"?2:x?3:1):o&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")?(s=!1,u[2]===0&&(c[1]!==0&&(u[0]=u[1],g=Cm(v,t,c,o,void 0,g),c=[0,0,0,0]),u[2]=n)):S.type==="tableCellDivider"&&(s?s=!1:(c[1]!==0&&(u[0]=u[1],g=Cm(v,t,c,o,void 0,g)),c=u,u=[c[1],n,0,0])):S.type==="tableHead"?(f=!0,p=n):S.type==="tableRow"||S.type==="tableDelimiterRow"?(p=n,c[1]!==0?(u[0]=u[1],g=Cm(v,t,c,o,n,g)):u[1]!==0&&(g=Cm(v,t,u,o,n,g)),o=0):o&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")&&(u[3]=n)}for(p!==0&&bS(v,t,p,h,x),v.consume(t.events),n=-1;++n<t.events.length;){const w=t.events[n];w[0]==="enter"&&w[1].type==="table"&&(w[1]._align=lU(t.events,n))}return e}function Cm(e,t,n,s,o,c){const u=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",f="tableContent";n[0]!==0&&(c.end=Object.assign({},hl(t.events,n[0])),e.add(n[0],0,[["exit",c,t]]));const p=hl(t.events,n[1]);if(c={type:u,start:Object.assign({},p),end:Object.assign({},p)},e.add(n[1],0,[["enter",c,t]]),n[2]!==0){const h=hl(t.events,n[2]),x=hl(t.events,n[3]),g={type:f,start:Object.assign({},h),end:Object.assign({},x)};if(e.add(n[2],0,[["enter",g,t]]),s!==2){const v=t.events[n[2]],w=t.events[n[3]];if(v[1].end=Object.assign({},w[1].end),v[1].type="chunkText",v[1].contentType="text",n[3]>n[2]+1){const S=n[2]+1,C=n[3]-n[2]-1;e.add(S,C,[])}}e.add(n[3]+1,0,[["exit",g,t]])}return o!==void 0&&(c.end=Object.assign({},hl(t.events,o)),e.add(o,0,[["exit",c,t]]),c=void 0),c}function bS(e,t,n,s,o){const c=[],u=hl(t.events,n);o&&(o.end=Object.assign({},u),c.push(["exit",o,t])),s.end=Object.assign({},u),c.push(["exit",s,t]),e.add(n+1,0,c)}function hl(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const mU={name:"tasklistCheck",tokenize:pU};function fU(){return{text:{91:mU}}}function pU(e,t,n){const s=this;return o;function o(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),c)}function c(p){return dn(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),u):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),u):n(p)}function u(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):n(p)}function f(p){return ot(p)?t(p):Rt(p)?e.check({tokenize:hU},t,n)(p):n(p)}}function hU(e,t,n){return Ut(e,s,"whitespace");function s(o){return o===null?n(o):t(o)}}function gU(e){return t5([B9(),Q9(),sU(e),cU(),fU()])}const xU={};function yU(e){const t=this,n=e||xU,s=t.data(),o=s.micromarkExtensions||(s.micromarkExtensions=[]),c=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),u=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);o.push(gU(n)),c.push($9()),u.push(U9(n))}const bU=/[^\x00-\x7F]+$/;function vU(e){if(e.children.length!==1)return!1;const t=e.children[0];if(!t||t.type!=="text")return!1;const{value:n}=t;return e.url===n||e.url===`http://${n}`}function kU(e){if(!vU(e))return null;const t=e.children[0],n=bU.exec(t.value);if(!n)return null;const s=t.value.slice(0,n.index);return!s.includes("://")&&!s.startsWith("www.")?null:(t.value=s,e.url=e.url.startsWith("http://")&&!s.startsWith("http")?`http://${s}`:s,{type:"text",value:n[0]})}function V5(e){for(let t=0;t<e.children.length;t+=1){const n=e.children[t];if(n.type==="link"){const o=kU(n);o&&e.children.splice(t+1,0,o)}const s=n.children;Array.isArray(s)&&V5(n)}}function wU(){return e=>V5(e)}const Ju=[yU,wU],SU="modulepreload",jU=function(e){return"/"+e},vS={},an=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let p=function(h){return Promise.all(h.map(x=>Promise.resolve(x).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),f=u?.nonce||u?.getAttribute("nonce");o=p(n.map(h=>{if(h=jU(h),h in vS)return;vS[h]=!0;const x=h.endsWith(".css"),g=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const v=document.createElement("link");if(v.rel=x?"stylesheet":SU,x||(v.as="script"),v.crossOrigin="",v.href=h,f&&v.setAttribute("nonce",f),document.head.appendChild(v),x)return new Promise((w,S)=>{v.addEventListener("load",w),v.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function c(u){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=u,window.dispatchEvent(f),!f.defaultPrevented)throw u}return o.then(u=>{for(const f of u||[])f.status==="rejected"&&c(f.reason);return t().catch(c)})};function Cy({language:e,code:t,highlight:n=!0}){const[s,o]=y.useState();return y.useEffect(()=>{if(!n){o(void 0);return}let c=!0;return an(()=>import("./highlighter-B3HctNDB.js"),[]).then(u=>u.highlightToHtml(t,e)).then(u=>{c&&o(u)}).catch(()=>{c&&o(void 0)}),()=>{c=!1}},[t,e,n]),a.jsxs("div",{className:"code-block my-2 overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800",children:[a.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 bg-gray-50 px-3 py-1 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("span",{className:"font-mono text-xs lowercase text-gray-500 dark:text-gray-400",children:e||"text"}),a.jsx(Wu,{text:t,label:d.chat.copyCode})]}),a.jsx("div",{className:"overflow-x-auto bg-white text-[13px] leading-relaxed dark:bg-gray-950",children:s?a.jsx("div",{dangerouslySetInnerHTML:{__html:s}}):a.jsx("pre",{className:"m-0 px-3 py-2.5 font-mono text-gray-800 dark:text-gray-200",children:a.jsx("code",{children:t})})})]})}function CU(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="string").join(""):""}function G5({children:e,streaming:t}){if(y.isValidElement(e)){const n=e.props,s=/language-([\w+-]+)/.exec(n.className??"")?.[1]??"";return a.jsx(Cy,{language:s,code:CU(n.children).replace(/\n$/,""),highlight:!t})}return a.jsx("pre",{children:e})}function K5({node:e,children:t,...n}){return a.jsx("a",{...n,target:"_blank",rel:"noreferrer",children:t})}const NU={pre:e=>a.jsx(G5,{streaming:!0,children:e.children}),a:K5},TU={pre:e=>a.jsx(G5,{streaming:!1,children:e.children}),a:K5},ed=y.memo(function({text:t,streaming:n=!1}){return a.jsx(Zu,{remarkPlugins:Ju,components:n?NU:TU,children:t})});function Ys({src:e,alt:t,className:n}){const[s,o]=y.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"block cursor-zoom-in",onClick:()=>o(!0),children:a.jsx("img",{src:e,alt:t,className:n})}),s&&a.jsx(MU,{src:e,alt:t,onClose:()=>o(!1)})]})}function MU({src:e,alt:t,onClose:n}){return y.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),ss.createPortal(a.jsx("div",{className:"anim-fade fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-10",onMouseDown:s=>{s.target===s.currentTarget&&n()},children:a.jsxs("div",{className:"anim-pop relative",children:[a.jsx("button",{type:"button","aria-label":d.common.close,onClick:n,className:"absolute right-2 top-2 flex h-7 w-7 items-center justify-center rounded-full bg-black/50 text-white transition-colors duration-150 hover:bg-black/70",children:a.jsx(Hl,{})}),a.jsx("img",{src:e,alt:t,className:"max-h-[85vh] max-w-[88vw] rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900"})]})}),document.body)}const EU=new Set(["txt","md","json","js","mjs","cjs","ts","tsx","jsx","py","sh","bash","yaml","yml","toml","css","html","htm","csv","log","xml","ini","conf","rs","go","java","c","h","cpp","hpp","sql","rb","php","png","jpg","jpeg","gif","webp","svg","pdf","doc","docx","xls","xlsx","ppt","pptx","zip","tar","gz","mp4","mp3","wav"]),AU=/^[a-z][a-z0-9+.-]*:\/\//i;function _U(e){const t=e.trim();if(t.length===0||t.length>200||/\s/.test(t)||AU.test(t)||t.startsWith("www."))return!1;const n=/\.([A-Za-z0-9]{1,8})$/.exec(t);if(!n)return!1;const s=n[1].toLowerCase();return/^\d+$/.test(s)?!1:EU.has(s)}function Ym(e,t){return e===""?t:`${e}/${t}`}const RU=512;function IU(e,t){const n=e.trim();if(n.length===0||n.length>RU||n.startsWith("~"))return null;const s=t!==null&&t.length>0?t:null,o=s!==null&&(s.includes("\\")||/^[A-Za-z]:/.test(s)),c=g=>{if(!o)return g;const v=g.replaceAll("\\","/");return/^[A-Za-z]:/.test(v)?v[0].toLowerCase()+v.slice(1):v},u=c(n),f=s===null?null:c(s),p=u.startsWith("/")||o&&/^[a-z]:/.test(u);let h=u;if(p){if(f===null||!u.startsWith(`${f}/`))return null;h=u.slice(f.length+1)}const x=[];for(const g of h.split("/"))if(!(g===""||g===".")){if(g===".."){if(x.length===0)return null;x.pop();continue}x.push(g)}return x.length>0?x.join("/"):null}const kS="M6 3h8l4 4v14H6zM14 3v4h4",wS=3;function LU(e){const t=[],n=new Set;for(const s of e.matchAll(/`([^`\n]+)`/g)){const o=s[1].trim();!_U(o)||n.has(o)||(n.add(o),t.push(o))}return t}function W5({path:e}){const t=e.lastIndexOf("/"),n=t>=0?e.slice(0,t+1):"",s=t>=0?e.slice(t+1):e;return a.jsxs("span",{className:"flex min-w-0 items-baseline font-mono text-sm",children:[n&&a.jsx("span",{className:"min-w-0 shrink-[9999] truncate text-gray-400 dark:text-gray-500",children:n}),a.jsx("span",{className:"min-w-0 truncate font-semibold text-gray-800 dark:text-gray-100",children:s})]})}function SS({text:e,workspace:t,statFiles:n,onOpenFile:s}){const o=y.useMemo(()=>{const g=[],v=new Set;for(const w of LU(e)){const S=IU(w,t);S===null||v.has(S)||(v.add(S),g.push(S))}return g},[e,t]),[c,u]=y.useState(null);y.useEffect(()=>{if(u(null),o.length===0)return;let g=!1;return n(o).then(v=>{g||u(o.filter(w=>v.has(w)))}).catch(()=>{}),()=>{g=!0}},[o,n]);const[f,p]=y.useState(!1);if(c===null||c.length===0)return null;const h=f?c:c.slice(0,wS),x=c.length-h.length;return a.jsxs("div",{className:"anim-msg my-3 overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-100 bg-gray-50 px-3 py-2 dark:border-gray-800/60 dark:bg-gray-800/40",children:[a.jsx(Oe,{d:kS,size:Ye.rowLead,className:"text-gray-400"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:d.chat.filesInMessage(c.length)})]}),a.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[h.map(g=>a.jsxs("button",{type:"button",title:g,onClick:()=>s(g),className:"group flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[a.jsx(Oe,{d:kS,size:Ye.rowLead,className:"text-gray-400"}),a.jsx(W5,{path:g}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-xs text-gray-400 transition-colors duration-150 group-hover:text-gray-600 dark:text-gray-500 dark:group-hover:text-gray-300",children:d.chat.openPreview})]},g)),(x>0||f)&&c.length>wS&&a.jsxs("button",{type:"button",onClick:()=>p(g=>!g),className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-50 dark:text-gray-400 dark:hover:bg-gray-800/50",children:[f?d.chat.showLess:d.chat.showMoreFiles(x),a.jsx(Zn,{open:f,size:Ye.chevronDense})]})]})]})}function Y5(e){return e.replace(/^\ufeff?---\r?\n[\s\S]*?\r?\n---\r?\n?/,"")}function OU(e){return e?.target!=null?{kind:"detail",target:e.target}:{kind:"list"}}function DU(){return{kind:"list"}}function z0(e,t){return e.scope==="user"?{scope:"user",file:t}:{scope:"workspace",scopeKey:e.scopeKey,file:t}}function $U(e,t){if(e===null){const s=[];for(const o of t){const c=o.scope==="user"?"user":o.scopeKey??"";let u=s.find(f=>f.scope===o.scope&&f.scopeKey===c);u===void 0&&(u={scope:o.scope,scopeKey:c,rows:[]},o.scope==="user"?s.unshift(u):s.push(u)),u.rows.push({target:z0(u,o.file),title:o.file,changed:o.op})}return s}const n=new Map(t.map(s=>[Qa(s),s.op]));return e.map(({info:s,files:o})=>{const c={scope:s.kind,scopeKey:s.scopeKey,...s.workspacePath!==void 0?{workspacePath:s.workspacePath}:{},rows:[]};for(const u of o){const f=z0(c,u.name),p=n.get(Qa(f));c.rows.push({target:f,title:u.title,...u.description!==""?{description:u.description}:{},...u.updatedAt!==void 0?{updatedAt:u.updatedAt}:{},modifiedAt:u.modifiedAt,...p!==void 0?{changed:p}:{}})}return c})}function UU(e,t){if(e===null)return null;const n=new Set;for(const{info:o,files:c}of e){const u={scope:o.kind,scopeKey:o.scopeKey};for(const f of c)n.add(Qa(z0(u,f.name)))}const s=new Set;for(const o of t){const c=Qa(o);n.has(c)||s.add(c)}return s}const X5="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M12 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8z",Q5="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",PU="M14 4h6v6M20 4 10 14M9 5H6a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-3",zU="M19 12H5m6-6-6 6 6 6";function Z5(e,t){return{d:e==="user"?X5:Q5,title:e==="user"?d.memory.userScope:d.chat.memoryScopeWorkspace(t??"")}}function BU(e){return e.scope==="user"?d.memory.userScope:e.workspacePath?.split(/[\\/]/).filter(Boolean).at(-1)??e.scopeKey}function HU({session:e,changes:t,scopes:n,listingError:s,request:o,active:c,onOpenSettings:u}){const{locale:f}=Dr(),[p,h]=y.useState({kind:"list"});y.useEffect(()=>{o!==null&&h(OU(o))},[o]);const x=p.kind==="detail"?Qa(p.target):null,[g,v]=y.useState(null);y.useEffect(()=>{if(!c||p.kind!=="detail")return;const S=p.target,C=Qa(S);let N=!1;return v({key:C,content:null,failed:!1}),nC(e.projectId,e.agentId,S.scope==="user"?"user":S.scopeKey??"",S.file).then(T=>{N||v({key:C,content:T.content,failed:!1})}).catch(()=>{N||v({key:C,content:null,failed:!0})}),()=>{N=!0}},[c,x,e.projectId,e.agentId,t]);const w=$U(n,t);if(p.kind==="detail"){const S=p.target,C=w.flatMap(_=>_.rows).find(_=>Qa(_.target)===x),N=g!==null&&g.key===x,T=Z5(S.scope,S.scopeKey);return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-gray-100 px-3 py-2 dark:border-gray-800/60",children:[a.jsxs("button",{type:"button",onClick:()=>h(DU()),title:d.chat.memoryBack,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[a.jsx(Oe,{d:zU,size:Ye.iconButton}),a.jsx("span",{className:"sr-only",children:d.chat.memoryBack})]}),a.jsxs("span",{title:T.title,className:"shrink-0 text-gray-400",children:[a.jsx(Oe,{d:T.d,size:Ye.rowLead}),a.jsx("span",{className:"sr-only",children:T.title})]}),a.jsx("p",{className:"min-w-0 flex-1 truncate font-mono text-[13px] font-semibold",children:C?.title??S.file}),C&&(C.updatedAt!==void 0||C.modifiedAt!==void 0)&&a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-gray-400 dark:text-gray-500",children:C.updatedAt??(C.modifiedAt!==void 0?Al(C.modifiedAt,f):"")})]}),a.jsxs("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto px-3.5 py-3",children:[C?.description!==void 0&&a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:C.description}),!N||!g.failed&&g.content===null?a.jsx(Sr,{rows:3}):g.failed?a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:d.chat.memoryContentUnavailable}):a.jsx("div",{className:"md-body text-sm",children:a.jsx(ed,{text:Y5(g.content??"")})})]})]})}return a.jsxs("div",{className:"h-full min-h-0 overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center gap-1 px-3.5 pb-1 pt-2",children:[a.jsx("span",{className:"min-w-0 flex-1"}),u&&a.jsxs("button",{type:"button",onClick:u,title:d.chat.openAgentMemory,className:"flex min-w-0 cursor-pointer items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[a.jsx(Oe,{d:PU,size:Ye.inlineGlyph}),a.jsx("span",{className:"truncate",children:d.chat.openAgentMemory})]})]}),s!==null&&w.length===0?a.jsx("p",{className:"px-3.5 py-2 text-xs text-gray-500 dark:text-gray-400",children:s}):n===null&&w.length===0?a.jsx("div",{className:"px-3.5 py-2",children:a.jsx(Sr,{rows:3})}):w.every(S=>S.rows.length===0)?a.jsx("p",{className:"px-3.5 py-2 text-xs text-gray-400 dark:text-gray-500",children:d.chat.memoryEmptyAll}):w.map(S=>S.rows.length===0?null:a.jsxs("div",{className:"pb-2",children:[a.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-1.5",children:[a.jsx("span",{className:"shrink-0 text-gray-400",children:a.jsx(Oe,{d:S.scope==="user"?X5:Q5,size:Ye.inlineGlyph})}),a.jsx("p",{className:"min-w-0 flex-1 truncate text-xs text-gray-500 dark:text-gray-400",title:S.workspacePath,children:BU(S)}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-gray-400 dark:text-gray-500",children:d.memory.itemCount(S.rows.length)})]}),a.jsx("ul",{children:S.rows.map(C=>a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>h({kind:"detail",target:C.target}),className:"flex w-full cursor-pointer items-center gap-3 px-3.5 py-2 text-left transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("p",{className:"flex items-center gap-1.5 truncate font-mono text-[13px] font-medium text-gray-800 dark:text-gray-200",children:[C.changed!==void 0&&a.jsx("span",{title:d.chat.memoryChangedMark,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-brand-500",children:a.jsx("span",{className:"sr-only",children:d.chat.memoryChangedMark})}),a.jsx("span",{className:"min-w-0 truncate",children:C.title})]}),C.description!==void 0&&a.jsx("p",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:C.description})]}),(C.updatedAt!==void 0||C.modifiedAt!==void 0)&&a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-gray-400 dark:text-gray-500",children:C.updatedAt??(C.modifiedAt!==void 0?Al(C.modifiedAt,f):"")})]})},Qa(C.target)))})]},`${S.scope} ${S.scopeKey}`))]})}const jS=3,CS="M4 19.5A2.5 2.5 0 0 1 6.5 17H20M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z",FU="M6 3h8l4 4v14H6zM12 11v6M9 14h6",qU="M12 20h9M16.5 3.5a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z";function VU({rows:e,deletedKeys:t,onLocateChange:n,onOpenPanel:s}){const[o,c]=y.useState(!1),u=t?e.filter(x=>!t.has(Qa(x))):e;if(u.length===0)return null;const f=o?u:u.slice(0,jS),p=u.length-f.length,h=x=>{const g=Z5(x.scope,x.scopeKey);return a.jsxs(a.Fragment,{children:[a.jsxs("span",{title:g.title,className:"shrink-0 text-gray-400",children:[a.jsx(Oe,{d:g.d,size:Ye.rowLead}),a.jsx("span",{className:"sr-only",children:g.title})]}),a.jsx(W5,{path:x.file}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx("span",{title:x.op==="write"?d.chat.memoryOpWrite:d.chat.memoryOpEdit,className:"shrink-0 text-gray-400",children:a.jsx(Oe,{d:x.op==="write"?FU:qU,size:Ye.inlineGlyph})})]})};return a.jsxs("div",{className:"anim-msg my-3 overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-100 bg-gray-50 px-3 py-2 dark:border-gray-800/60 dark:bg-gray-800/40",children:[a.jsx(Oe,{d:CS,size:Ye.rowLead,className:"shrink-0 text-gray-400"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:d.chat.memoryChangesTitle(u.length)}),s&&a.jsxs("button",{type:"button",title:d.chat.memoryViewTitle,onClick:s,className:"flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:hover:text-gray-300",children:[a.jsx(Oe,{d:CS,size:Ye.inlineGlyph}),a.jsx("span",{className:"sr-only",children:d.chat.memoryViewTitle})]})]}),a.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[f.map(x=>{const g=Qa(x);return n?a.jsxs("button",{type:"button",title:d.chat.memoryRowOpen,onClick:()=>n(x),className:"group flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[h(x),a.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-xs text-gray-400 transition-colors duration-150 group-hover:text-gray-600 dark:text-gray-500 dark:group-hover:text-gray-300",children:d.chat.memoryRowOpen})]},g):a.jsx("div",{className:"flex w-full items-center gap-2 px-3 py-2",children:h(x)},g)}),(p>0||o)&&u.length>jS&&a.jsxs("button",{type:"button",onClick:()=>c(x=>!x),className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-50 dark:text-gray-400 dark:hover:bg-gray-800/50",children:[o?d.chat.showLess:d.chat.memoryShowMore(p),a.jsx(Zn,{open:o,className:"text-gray-400",size:Ye.chevronDense})]})]})]})}const GU={waiting:"M6 3h12M6 21h12M8 3v3.5L12 10l4-3.5V3M8 21v-3.5L12 14l4 3.5V21",done:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm-3.5-9.2 2.4 2.5 4.6-4.8",failed:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9 9l6 6m0-6-6 6",stopped:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM8.5 8.5h7v7h-7z"},NS={running:sn.busy,waiting:sn.attention,done:sn.muted,failed:sn.danger,stopped:sn.muted};function Di({state:e,size:t=13,label:n}){return e==="running"?a.jsx("span",{...n?{title:n,"aria-label":n,role:"status"}:{"aria-hidden":!0},style:{width:t,height:t},className:`inline-block shrink-0 animate-spin rounded-full border-[1.5px] border-current border-t-transparent ${NS.running}`}):a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",...n?{role:"img","aria-label":n}:{"aria-hidden":!0},className:`block shrink-0 ${NS[e]}`,children:[n&&a.jsx("title",{children:n}),a.jsx("path",{d:GU[e]})]})}const J5="flex w-full items-center gap-2 bg-white px-3 py-1.5 text-left transition-colors duration-150 hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800",eT="sticky top-4 z-[4]",KU="shrink-0 text-xs text-gray-500 dark:text-gray-400",tT="flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-800",nT="sticky -top-4 z-[5]",rT="shrink-0 text-[11px] font-semibold uppercase tracking-wide",aT="max-h-72 overflow-auto whitespace-pre-wrap border-t border-gray-100 px-3 py-2 text-xs leading-5 text-gray-600 dark:border-gray-800 dark:text-gray-300",sT="anim-msg my-2 overflow-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900";function iT({icon:e,label:t,trailing:n,variant:s="row",sticky:o=!1,defaultOpen:c=!1,children:u}){const[f,p]=y.useState(c),h=y.useRef(null),x=s==="header",g=x?tT:J5,v=x?nT:eT,w=x?`${rT} text-gray-500 dark:text-gray-400`:KU;return a.jsxs("div",{ref:h,children:[a.jsxs("button",{type:"button",onClick:()=>{const S=f;p(C=>!C),S&&requestAnimationFrame(()=>h.current?.scrollIntoView({block:"nearest"}))},"aria-expanded":f,className:`${o?`${v} `:""}${g}`,children:[e,a.jsx("span",{className:w,children:t}),n,a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx(Zn,{open:f,className:"text-gray-400"})]}),f&&u]})}function Ll({sinceMs:e,offsetMs:t=0}){const[n,s]=y.useState(()=>Date.now());return y.useEffect(()=>{const o=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(o)},[]),e===void 0?a.jsx("span",{className:"animate-pulse",children:"…"}):a.jsx(a.Fragment,{children:ZC(Math.max(0,t)+Math.max(0,n-e))})}function WU({item:e}){const t=e.stopReason!==void 0&&e.stopReason!=="completed",n=e.streaming?"running":t?"failed":"done",s=e.streaming?d.chat.workRunning:t?e.stopReason:d.chat.workDone;return a.jsx(iT,{sticky:!0,icon:a.jsx(Di,{state:n,label:s}),label:d.chat.thinking,trailing:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-500 dark:text-gray-400",children:e.streaming?a.jsx(Ll,{sinceMs:e.startedAtMs}):e.durationMs!==void 0?Pn(e.durationMs):null}),t&&a.jsxs("span",{className:"font-mono text-xs text-gray-400",children:["[",e.stopReason,"]"]})]}),children:a.jsx("div",{className:"md-body anim-fade mx-3 mb-2 rounded-md bg-gray-50 px-3 py-2 text-sm leading-relaxed text-gray-600 dark:bg-gray-900/60 dark:text-gray-400",children:a.jsx(ed,{text:e.thinking,streaming:e.streaming})})})}const YU=/\x1b(?:\[[0-9:;<=>?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\^_])/g,XU=/\x1b(?:\[[0-9:;<=>?]*[ -/]*|\][^\x07]*)?$/;function oT(e){return e.includes("\x1B")?e.replace(YU,"").replace(XU,""):e}function QU({onDecide:e}){const[t,n]=y.useState(!1),s=async o=>{n(!0);try{await e(o)}finally{n(!1)}};return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ge,{size:"sm",variant:"primary",disabled:t,onClick:()=>{s("allow")},children:d.chat.approve}),a.jsx(ge,{size:"sm",disabled:t,onClick:()=>{s("deny")},children:d.chat.deny})]})}const ZU=rL,JU=iL;function eP(e,t){const n=t.trim().toLowerCase();return n?e.filter(s=>s.agentId.toLowerCase().includes(n)||(s.name??"").toLowerCase().includes(n)):e}function tP({handoffTarget:e,pendingModel:t,canSwitchModel:n,sessionBusy:s}){return e?"handoff":!t||!n?"post":s?"blocked":"model"}const nP="background_task_done";function Au(e){return e.kind==="user_image"?!0:e.kind!=="user_text"?!1:e.text.includes(`[${nP}]`)?_l(e.text)===null:!0}function lT(e){for(let t=e.length-1;t>=0;t--)if(Au(e[t]))return t;return 0}function rP(e){let t=0;for(const n of e)(n.kind==="user_text"||n.kind==="user_image")&&(t+=1);return t}function aP(e){let t=0;for(const n of e)Au(n)&&(t+=1);return t}function Ny(e,t){try{const n=JSON.parse(e);if(n!==null&&typeof n=="object"){const s=n[t];if(typeof s=="string"&&s.length>0)return s}}catch{}return null}function cT(e){return Ny(e,"agent_id")}function sP(e){return Ny(e,"description")}function TS(e,t,n){for(let s=t;s<n;s++){const o=e[s];if(o.kind==="tool_call"&&o.subagent!==void 0||o.kind==="subagent")return!0}return!1}function iP(e,t,n,s){const o=e.items;let c=lT(o),u=o.length;if(!TS(o,c,u))for(let f=c;f>0;){let p=0;for(let h=f-1;h>=0;h--)if(Au(o[h])){p=h;break}if(TS(o,p,f)){c=p,u=f;break}if(p===0)break;f=p}return uT(o.slice(c,u),t,{running:u===o.length&&n},s)}function oP(e,t,n,s,o){const c=e.items,u=c.findIndex(h=>h.kind==="tool_call"&&h.subagentSessionId===s||h.kind==="subagent"&&h.sessionId===s);if(u===-1)return null;let f=0;for(let h=u;h>=0;h--)if(Au(c[h])){f=h;break}let p=c.length;for(let h=u+1;h<c.length;h++)if(Au(c[h])){p=h;break}return uT(c.slice(f,p),t,{running:p===c.length&&n},o)}const lP=/\[subagent running in background with subagent_id (subagent-[0-9a-f]+)/;function cP(e){const t=new Map;for(const n of e){if(n.kind==="user_text"||n.kind==="background_notice"){const s=_l(n.text);s!==null&&s.done.kind==="subagent"&&t.set(s.done.id,"done");continue}if(!(n.kind!=="tool_call"||n.output.length===0)){for(const s of n.output.matchAll(/\[subagent (?:running in background|still running) with subagent_id (subagent-[0-9a-f]+)/g))t.set(s[1],"running");for(const s of n.output.matchAll(/\[subagent idle with subagent_id (subagent-[0-9a-f]+)|\[subagent (subagent-[0-9a-f]+) (?:aborted and removed|was idle; session removed)/g))t.set(s[1]??s[2],"done")}}return t}function uT(e,t,n,s){const o=[{sessionId:t,agentId:null,description:null,spawnThinkingLevel:null,running:n.running,depth:0,origin:[],parentId:null}],c=new Set([t]),u=(h,x,g,v,w,S,C,N)=>{if(c.has(h))return;c.add(h);const T=[...w,h],_=x.firstTsMs??x.firstSeenLocalMs,R=x.firstTsMs!==void 0&&x.lastActivityTsMs!==void 0?Math.max(0,x.lastActivityTsMs-x.firstTsMs):x.firstSeenLocalMs!==void 0&&x.lastActivityLocalMs!==void 0?Math.max(0,x.lastActivityLocalMs-x.firstSeenLocalMs):void 0;o.push({sessionId:h,agentId:x.meta?.agentId??S,description:C,spawnThinkingLevel:N,running:s?.get(h)??g,depth:T.length,origin:T,parentId:v,..._!==void 0?{startedMs:_}:{},...R!==void 0?{elapsedMs:R}:{}}),p(x.items,h,T)},f=cP(e),p=(h,x,g)=>{for(const v of h)if(v.kind==="tool_call"&&v.subagent&&v.subagentSessionId){const w=lP.exec(v.output)?.[1]??null;u(v.subagentSessionId,v.subagent,w!==null?f.get(w)!=="done":!v.outputComplete,x,g,cT(v.argumentsText),sP(v.argumentsText),Ny(v.argumentsText,"thinking_level"))}else v.kind==="subagent"&&u(v.sessionId,v.model,!1,x,g,null,null,null)};return p(e,t,[]),o}function uP(e){const t=e.items;for(let n=lT(t);n<t.length;n++){const s=t[n];if(s.kind==="tool_call"&&s.subagent!==void 0||s.kind==="subagent")return!0}return!1}function dP(e,t){if(t.length===0)return null;let n=e;for(const s of t){const o=n.subagents.get(s);if(!o)return null;n=o}return n}const Xm=200,iu=46,zg=32,MS=10,Nm=6;function mP(e){const t=new Map;for(const x of e){if(x.parentId===null)continue;const g=t.get(x.parentId);g?g.push(x):t.set(x.parentId,[x])}const n=new Map;let s=0;const o=x=>{const g=t.get(x.sessionId)??[];let v;if(g.length===0)v=s++;else{const w=g.map(o);v=(w[0]+w[w.length-1])/2}return n.set(x.sessionId,v),v};for(const x of e)x.parentId===null&&o(x);const c=e.map(x=>({node:x,x:Nm+x.depth*(Xm+zg),y:Nm+(n.get(x.sessionId)??0)*(iu+MS)})),u=new Map(c.map(x=>[x.node.sessionId,x])),f=[];for(const x of c){if(x.node.parentId===null)continue;const g=u.get(x.node.parentId);if(!g)continue;const v=g.x+Xm,w=g.y+iu/2,S=x.x,C=x.y+iu/2,N=v+zg/2;f.push({fromId:g.node.sessionId,toId:x.node.sessionId,path:w===C?`M ${v} ${w} H ${S}`:`M ${v} ${w} H ${N} V ${C} H ${S}`})}const p=e.reduce((x,g)=>Math.max(x,g.depth),0),h=Math.max(1,s);return{width:Nm*2+(p+1)*Xm+p*zg,height:Nm*2+h*iu+(h-1)*MS,nodes:c,edges:f}}function B0(e,t,n){const s=n.find(c=>c.sessionId===e.sessionId),o=e.agentId??s?.agentId??null;if(o!==null){const c=t.find(u=>u.agentId===o);return c?c.name?.length?c.name:c.agentId:o}return s?.title??null}function H0(e){return e.length>8?e.slice(-8):e}function dT({sessionId:e,model:t,running:n,ctx:s,agentId:o=null}){const{agents:c}=en(),{sessions:u}=Ii(),f=B0({sessionId:e,agentId:t.meta?.agentId??o},c,u)??d.chat.subagent,p=ML(s.pendingApprovals.keys(),[...s.origin,e]),h=`${d.chat.subagent} ${f}${p?` · ${d.chat.approvalWaiting}`:""}`;return a.jsxs("button",{type:"button","aria-label":h,title:h,onClick:()=>s.onOpenSubagent?.(e,s.origin),className:"flex w-full items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-100 dark:border-gray-800 dark:bg-gray-900/60 dark:hover:bg-gray-800/60",children:[a.jsx(Ha,{id:t.meta?.agentId??o??e,name:f,size:16}),a.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-gray-700 dark:text-gray-300",children:f}),e&&a.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:H0(e)}),n&&a.jsx("span",{"aria-hidden":!0,className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border border-gray-400 border-t-transparent"}),p&&a.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${Fl.attention}`}),a.jsx("span",{className:"min-w-0 flex-1"})]})}const ES=new Set(["exec_command","input_command","run_subagent","input_subagent"]),gf=new Set(["read_file","edit_file","write_file"]);function mT(e){const t=e.split("/").filter(n=>n.length>0);return t.length<=2?e:`…/${t[t.length-2]}/${t[t.length-1]}`}function fP(e,t){if(e==="exec_command"){const n=xf(t,"cmd");if(n!==null)return`$ ${n.value.replace(/\s+/g," ").trim()}`}if(gf.has(e)){const n=xf(t,"file_path");if(n!==null)return mT(n.value.replace(/\s+/g," ").trim())}return t.replace(/\s+/g," ").trim()}function pP(e,t,n=!0){if(ES.has(e)||gf.has(e)){const s=xf(t,"description");if(s!==null){if(!s.complete&&!n)return null;const o=s.value.replace(/\s+/g," ").trim();if(o)return o}if(ES.has(e))return null}if(gf.has(e)){const s=xf(t,"file_path");if(s!==null){if(!s.complete&&!n)return null;const o=s.value.replace(/\s+/g," ").trim();if(o)return mT(o)}}return null}function hP(e,t){if(!gf.has(e))return null;let n;try{n=JSON.parse(t)}catch{return null}if(n===null||typeof n!="object")return null;const s=n,o=[],c=(u,f)=>{f!==void 0&&(typeof f=="string"&&f.includes(`
166
- `)?o.push(`${u}:
167
- ${f}`):o.push(`${u}: ${typeof f=="string"?f:JSON.stringify(f)}`))};return c("file_path",s.file_path),e==="read_file"?(c("offset",s.offset),c("limit",s.limit)):e==="edit_file"?(c("old_string",s.old_string),c("new_string",s.new_string),s.replace_all===!0&&c("replace_all",!0)):e==="write_file"&&c("content",s.content),o.join(`
168
- `)}function xf(e,t){const n=`"${t}"`,s=e.indexOf(n);if(s===-1)return null;let o=s+n.length;for(;/\s/.test(e[o]??"");)o+=1;if(e[o]!==":")return null;for(o+=1;/\s/.test(e[o]??"");)o+=1;if(e[o]!=='"')return null;o+=1;let c="",u=!1;for(;o<e.length;o+=1){const f=e[o];if(u){c+=f==="n"?`
169
- `:f==="t"?" ":f,u=!1;continue}if(f==="\\"){u=!0;continue}if(f==='"')return{value:c,complete:!0};c+=f}return{value:c,complete:!1}}function gP({item:e,ctx:t}){const[n,s]=y.useState(!1),o=y.useRef(!1),c=y.useRef(null),u=t.pendingApprovals.get(Rl(t.origin,e.toolCallId)),f=fP(e.name,e.argumentsText),p=y.useMemo(()=>oT(e.output),[e.output]),h=pP(e.name,e.argumentsText,!e.callStreaming),x=e.callComplete&&!e.outputComplete&&!u,g=e.argStartedAtMs!==void 0&&e.callStartedAtMs!==void 0?Math.max(0,e.callStartedAtMs-e.argStartedAtMs):0,v=e.callStopReason!==void 0&&e.callStopReason!=="completed"||e.outputStopReason!==void 0&&e.outputStopReason!=="completed",w=u?"waiting":x||e.callStreaming?"running":v?"failed":"done",S=e.decision?`${e.decision==="allow"?d.chat.decisionAllow:d.chat.decisionDeny} · ${e.decision==="forbidden"?d.chat.decisionPolicy:e.decisionSource==="manual"?d.chat.decisionManual:d.chat.decisionAuto}`:null,C=(e.decision==="deny"||e.decision==="forbidden")&&e.outputStopReason==="aborted",N=u?d.chat.approvalWaiting:w==="running"?d.chat.workRunning:w==="done"?S??d.chat.workDone:C?S??void 0:e.outputStopReason??e.callStopReason;return a.jsxs("div",{ref:c,children:[a.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>{o.current=!0;const T=n;s(_=>!_),T&&requestAnimationFrame(()=>c.current?.scrollIntoView({block:"nearest"}))},className:`${eT} ${J5}`,children:[a.jsx(Di,{state:w,label:N}),a.jsx("span",{className:"shrink-0 truncate font-mono text-xs font-semibold text-gray-700 dark:text-gray-300",children:e.name||d.chat.unknownTool}),h&&a.jsx("span",{className:"min-w-0 shrink truncate text-xs text-gray-500 dark:text-gray-400",children:h}),a.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-500 dark:text-gray-400",children:e.durationMs!==void 0?Pn(e.durationMs):x?a.jsx(Ll,{sinceMs:e.approvalAtMs??e.callStartedAtMs,offsetMs:g}):u?g>0?Pn(g):null:e.callStreaming?e.argStartedAtMs!==void 0?a.jsx(Ll,{sinceMs:e.argStartedAtMs}):a.jsx("span",{className:"animate-pulse",children:"…"}):null}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx(Zn,{open:n,className:"text-gray-400"})]}),u&&a.jsxs("div",{className:"border-t border-gray-100 bg-amber-50 px-3 py-2 dark:border-gray-800 dark:bg-amber-950/30",children:[a.jsxs("div",{className:"mb-2 flex items-start gap-2 sm:items-center",children:[a.jsx("span",{className:"shrink-0 rounded-md bg-white px-1.5 py-0.5 font-mono text-xs font-semibold text-gray-700 dark:bg-gray-900 dark:text-gray-300",children:e.name||d.chat.unknownTool}),a.jsx("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs text-gray-600 sm:truncate dark:text-gray-400",children:f})]}),(()=>{const T=hP(e.name,e.argumentsText);return T!==null?a.jsx("pre",{className:"mb-2 max-h-72 overflow-auto whitespace-pre-wrap break-all rounded-md bg-white/70 px-2 py-1.5 text-xs leading-5 text-gray-700 dark:bg-gray-950/40 dark:text-gray-300",children:T}):null})(),a.jsx(QU,{onDecide:T=>t.onApprove(e.toolCallId,T,t.origin)})]}),n&&a.jsxs("div",{className:"anim-fade",children:[e.argumentsText&&a.jsx("pre",{className:"whitespace-pre-wrap break-all border-t border-gray-100 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-950/60 dark:text-gray-400",children:e.argumentsText}),(e.output||e.outputStreaming)&&a.jsxs("pre",{className:aT,children:[p,e.outputStreaming&&a.jsx("span",{className:"animate-pulse",children:"▌"})]}),e.images&&e.images.length>0&&a.jsx("div",{className:"flex flex-wrap gap-2 border-t border-gray-100 px-3 py-2 dark:border-gray-800",children:e.images.map((T,_)=>a.jsx(Ys,{src:T,alt:d.chat.toolImageAlt,className:"max-h-40 max-w-full rounded-md border border-gray-200 dark:border-gray-700"},_))})]}),e.subagent&&a.jsx("div",{className:"px-3 pb-2 pt-2",children:a.jsx(dT,{sessionId:e.subagentSessionId??"",model:e.subagent,running:!e.outputComplete,agentId:cT(e.argumentsText),ctx:t})})]})}function xP(e){const t=e.summaryText;return t?tL(t).trim():""}function yf({state:e,title:t,detail:n,liveSinceMs:s,durationMs:o,children:c}){const[u,f]=y.useState(!1),p=y.useRef(null),h=e==="running",x=c!=null,g=a.jsxs(a.Fragment,{children:[a.jsx(Di,{state:e}),a.jsx("span",{className:`shrink-0 text-[11px] font-semibold tracking-wide uppercase ${h?sn.busy:"text-gray-500 dark:text-gray-400"}`,children:t}),n!==void 0&&a.jsx("span",{title:n,className:"min-w-0 truncate font-mono text-xs text-gray-400",children:n}),h?s!==void 0&&a.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:a.jsx(Ll,{sinceMs:s})}):o!==void 0&&o>0&&a.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:Pn(o)}),a.jsx("span",{className:"min-w-0 flex-1"}),x&&a.jsx(Zn,{open:u,className:"text-gray-400"})]});return a.jsxs("div",{ref:p,className:"anim-msg my-2 overflow-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[x?a.jsx("button",{type:"button","aria-expanded":u,onClick:()=>{const v=u;f(w=>!w),v&&requestAnimationFrame(()=>p.current?.scrollIntoView({block:"nearest"}))},className:"sticky -top-4 z-[5] flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-800",children:g}):a.jsx("div",{className:"flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left dark:bg-gray-900",children:g}),x&&u&&a.jsx("div",{className:"anim-fade divide-y divide-gray-100 border-t border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:c})]})}function yP({text:e,streaming:t}){return a.jsx("div",{className:"md-body px-3 py-2 text-sm leading-relaxed text-gray-600 dark:text-gray-400",children:a.jsx(ed,{text:e,streaming:t})})}function bP({item:e}){const t=xP(e),s=t!==""||e.running&&e.mode==="summarize"?a.jsx(yP,{text:t,streaming:e.running}):null;if(e.running)return a.jsx(yf,{state:"running",title:d.chat.compactionTitle(e.mode),...e.beginTsMs!==void 0?{liveSinceMs:e.beginTsMs}:{},children:s});const o=e.status==="completed";return a.jsx(yf,{state:o?"done":"failed",title:d.chat.compactionTitle(e.mode),detail:o?void 0:d.chat.compactionFailed(e.status??"failed",e.errorMessage),...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:s})}function vP(e,t){let n=null;for(const s of t)e.startsWith(`mcp__${s}__`)&&(n===null||s.length>n.length)&&(n=s);return n}function kP({outcome:e,tools:t}){const[n,s]=y.useState(!1),o=e.status==="fatal"||e.status==="failed",c=o?e.error!==void 0:t.length>0,u=o?d.chat.mcpServerFailed:d.chat.mcpToolsCount(e.tools??0),f=a.jsxs(a.Fragment,{children:[a.jsx(Di,{state:o?"failed":"done",size:11}),a.jsx("code",{className:"shrink-0 font-mono text-xs text-gray-700 dark:text-gray-300",children:e.server}),a.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-gray-400",children:u}),e.durationMs>0&&a.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:Pn(e.durationMs)}),a.jsx("span",{className:"min-w-0 flex-1"}),c&&a.jsx(Zn,{open:n,size:12,className:"text-gray-400"})]});return c?a.jsxs("div",{children:[a.jsx("button",{type:"button","aria-expanded":n,onClick:()=>s(p=>!p),className:"sticky top-4 z-[4] flex w-full items-center gap-2 bg-white px-3 py-1.5 text-left transition-colors duration-150 hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800",children:f}),n&&(o?a.jsx("p",{className:"anim-fade px-3 pt-0.5 pb-2 pl-8 font-mono text-xs break-all text-gray-500 dark:text-gray-400",children:e.error}):a.jsx("ul",{className:"anim-fade pb-1",children:t.map(p=>a.jsxs("li",{className:"flex items-baseline gap-2 py-1 pr-3 pl-8",children:[a.jsx("code",{className:"shrink-0 font-mono text-xs text-gray-700 dark:text-gray-300",children:p.name}),p.description!==void 0&&a.jsx("span",{title:p.description,className:"min-w-0 truncate text-xs text-gray-400 dark:text-gray-500",children:p.description})]},p.name))}))]}):a.jsx("div",{className:"flex w-full items-center gap-2 px-3 py-1.5",children:f})}function wP({item:e}){if(e.running)return a.jsx(yf,{state:"running",title:d.chat.mcpConnectTitle,detail:d.chat.mcpServerList(e.servers),...e.beginTsMs!==void 0?{liveSinceMs:e.beginTsMs}:{}});const t=e.aborted||(e.failed?.length??0)>0,n=e.aborted?d.chat.mcpConnectAborted:d.chat.mcpConnectResult(e.toolCount??0,e.failed??[]),s=e.results??[],o=e.tools??[],c=s.map(u=>u.server);return a.jsx(yf,{state:t?"failed":"done",title:d.chat.mcpConnectTitle,detail:n,...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:s.length>0?s.map(u=>a.jsx(kP,{outcome:u,tools:o.filter(f=>vP(f.name,c)===u.server)},u.server)):void 0})}const Ty=-1,_u="M21 12A9 9 0 1 1 12 3M17 12A5 5 0 1 1 12 7M12 12L15 9V5L18 2V6H22L19 9H15";function Tm(e){const t=e.trim();if(t==="")return Ty;const n=/^(\d+(?:\.\d+)?)([km])?$/i.exec(t);if(!n)return null;const s=n[2]?.toLowerCase()==="m"?1e6:n[2]?.toLowerCase()==="k"?1e3:1,o=Math.round(Number(n[1])*s);return o>0?o:null}const SP="M3 5h18v14H3zM3 16l5-5 4 4 3-3 6 6M15.5 8.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0";function jP({images:e,showFull:t,onExpand:n}){return e.length===0?null:t?a.jsx("div",{className:"mt-1.5 flex max-w-[88%] flex-wrap justify-end gap-1.5 md:max-w-[75%]",children:e.map((s,o)=>a.jsx(Ys,{src:s,alt:d.chat.imageAlt,className:"max-h-40 max-w-full rounded-md"},o))}):a.jsxs("button",{type:"button",onClick:n,className:"mt-1.5 flex items-center gap-1.5 rounded-md border border-gray-200 bg-gray-50 px-2 py-1 text-xs text-gray-500 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-400 dark:hover:bg-gray-800",children:[a.jsx(Oe,{d:SP,size:12,className:"shrink-0"}),d.chat.goalRoundImages(e.length)]})}function CP({round:e,objective:t,images:n=[]}){const[s,o]=y.useState(!1),c=n.length>0&&(e===1||s);return t!==void 0&&t!==""?a.jsxs("div",{className:"anim-msg my-4 flex flex-col items-end",children:[a.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 px-4 py-2.5 md:max-w-[75%] dark:bg-gray-800",children:a.jsx("p",{className:"wrap-anywhere whitespace-pre-wrap text-base leading-relaxed text-gray-900 dark:text-gray-100",children:t})}),a.jsx(jP,{images:n,showFull:c,onExpand:()=>o(!0)}),a.jsxs("p",{className:"mt-1 flex items-center gap-1.5 px-0.5 text-xs text-gray-400 dark:text-gray-500",children:[a.jsx(Oe,{d:_u,size:12,className:"shrink-0"}),d.chat.goalRoundBanner(e)]})]}):a.jsxs("p",{className:"anim-msg my-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[a.jsx(Oe,{d:_u,className:"text-gray-400 dark:text-gray-500"}),d.chat.goalRoundBanner(e)]})}function NP({goal:e}){const t=e.budget>0&&e.budget!==Ty?`${It(e.used)}/${It(e.budget)}`:It(e.used),n=e.status!=="active";return a.jsxs("div",{className:"anim-fade mb-2 flex items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[a.jsx(Oe,{d:_u,className:"shrink-0 text-gray-400 dark:text-gray-500"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",title:e.objective,children:e.objective}),a.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:d.chat.goalProgress(e.rounds,t)}),a.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 ${n?e.status==="complete"?bo.success:bo.attention:"bg-gray-200 text-gray-600 dark:bg-gray-800 dark:text-gray-300"}`,children:d.chat.goalStatus[e.status]})]})}function TP(e){return e.agentName&&e.agentName!==e.agentId?`${e.agentName} (${e.agentId})`:e.agentId}const F0="anim-msg my-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400";function MP({origin:e}){const t=yr(),n=d.chat.handoffFrom(TP(e));if(!e.sessionId)return a.jsx("p",{className:F0,children:n});const s=e.sessionId;return a.jsxs("button",{type:"button",title:d.chat.handoffBack(e.sessionTitle),onClick:()=>t(`/chat/${s}`),className:`${F0} transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200`,children:[n,a.jsx("span",{"aria-hidden":!0,className:"text-gray-400 dark:text-gray-500",children:"→"})]})}function EP({origin:e}){const t=yr(),n=e.sessionId;return a.jsxs("button",{type:"button",title:d.chat.handoffBack(e.sessionTitle),onClick:()=>t(`/chat/${n}`),className:`${F0} transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200`,children:[d.chat.modelSwitchFrom(e.prevModelId),a.jsx("span",{"aria-hidden":!0,className:"text-gray-400 dark:text-gray-500",children:"→"})]})}function AP({origin:e}){return a.jsxs("p",{className:"anim-msg my-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[d.chat.scheduledFrom(e.name),e.firedAt&&a.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:Jr(e.firedAt)})]})}const My="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2zM22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z";function _P(e,t,n){return e==="zh"&&n?n:t}function Wl(e,t){return e==="zh"?t.shortDescriptionZh||t.shortDescription||t.description:t.shortDescription||t.description}function RP(e,t,n){const s=n.trim().toLowerCase();return s?e.filter(o=>o.name.toLowerCase().includes(s)||Wl(t,o).toLowerCase().includes(s)):e}function IP(e,t){return e.map(n=>({name:n.name,cmd:`/${n.name}`,desc:Wl(t,n)}))}function AS({names:e}){return a.jsxs("p",{className:"anim-msg my-2 flex w-fit items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[a.jsx(Oe,{d:My,className:"text-gray-400 dark:text-gray-500"}),d.chat.skillsBanner(e)]})}const bf="M21.4 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.2-9.19a4 4 0 0 1 5.65 5.66l-9.19 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48";function _S({files:e}){const t=d.chat.attachedFilesBanner(e.map(WL));return a.jsxs("p",{title:t,className:"flex w-fit max-w-full items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400",children:[a.jsx(Oe,{d:bf,className:"shrink-0 text-gray-400 dark:text-gray-500"}),a.jsx("span",{className:"min-w-0 truncate",children:t})]})}function RS({done:e,body:t}){const n=e.status==="completed"?"done":e.status==="stopped"?"stopped":"failed";return a.jsx("div",{className:sT,children:a.jsx(iT,{variant:"header",sticky:!0,icon:a.jsx(Di,{state:n,label:e.status}),label:d.chat.backgroundDone(e.kind,e.status),children:a.jsx("pre",{className:aT,children:t?`${e.id}
170
- ${t}`:e.id})})})}function Wc({icon:e,value:t,compactValue:n,label:s,display:o="flex"}){return a.jsxs("span",{title:s,"aria-label":s,className:`${o} items-center gap-1`,children:[a.jsx(Oe,{d:e}),n!==void 0&&n!==t?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"sm:hidden",children:n}),a.jsx("span",{className:"hidden sm:inline",children:t})]}):t]})}function LP({stats:e,assistantText:t,cost:n,atMs:s,forkPosition:o,onFork:c}){const{currency:u}=as(),{locale:f}=Dr(),[p,h]=y.useState(!1),[x,g]=y.useState(!1),v=e?.tokensByBucket,w=v?v.cacheRead+v.cacheWrite:0,S=()=>t?.trim()||e===null?t??"":kL(e,{stats:d.chat.statsLabel,input:d.chat.statInput,cached:d.chat.statCached,output:d.chat.statOutput,parenOpen:d.chat.statParenOpen,parenClose:d.chat.statParenClose});return a.jsxs("div",{className:"-mt-2 flex h-5 items-center justify-start gap-x-2 overflow-hidden whitespace-nowrap text-[11px] text-gray-400 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 sm:gap-x-3 sm:opacity-0 dark:text-gray-500",children:[a.jsxs("span",{className:"no-scrollbar flex min-w-0 items-center gap-x-2 overflow-x-auto sm:gap-x-3",children:[s!==void 0&&a.jsx("span",{children:eN(s,f)}),e&&v&&a.jsxs(a.Fragment,{children:[a.jsx(Wc,{icon:Xn.input,value:It(w),label:d.chat.statInput}),a.jsx(Wc,{icon:Xn.output,value:It(v.output),label:d.chat.statOutput}),a.jsx(Wc,{icon:Xn.tps,value:sf(e.outputTps),label:d.chat.statTps,display:"hidden sm:flex"}),n!=null&&a.jsx(Wc,{icon:Xn.cost,value:rs(n,u),compactValue:rs(n,u,{compact:!0}),label:`${d.common.cost}(${u})`}),a.jsx(Wc,{icon:Xn.elapsed,value:Pn(e.elapsedDeltaMs),compactValue:Pn(e.elapsedDeltaMs,{compact:!0}),label:d.chat.statElapsed})]})]}),a.jsx(Wu,{text:S,label:d.chat.copyReply,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300"}),c&&t?.trim()&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",disabled:p,title:d.chat.forkSession,"aria-label":d.chat.forkSession,onClick:()=>g(!0),className:"flex h-5 w-5 shrink-0 items-center justify-center rounded transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 disabled:cursor-wait disabled:opacity-50 dark:hover:bg-gray-800 dark:hover:text-gray-300",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:p?"animate-pulse":"",children:[a.jsx("circle",{cx:"6",cy:"5",r:"2"}),a.jsx("circle",{cx:"18",cy:"7",r:"2"}),a.jsx("circle",{cx:"6",cy:"19",r:"2"}),a.jsx("path",{d:"M6 7v8M8 11h4a6 6 0 0 0 6-2"})]})}),a.jsx(ln,{open:x,title:d.chat.forkSession,tone:"primary",confirmLabel:d.chat.forkSessionConfirmAction,busy:p,onClose:()=>g(!1),onConfirm:()=>{g(!1),h(!0),c({assistantText:t,...s!==void 0?{atMs:s}:{},...o!==void 0?{position:o}:{}}).finally(()=>h(!1))},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.chat.forkSessionConfirmBody})})]})]})}const OP="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0";function Yc({atMs:e,text:t,align:n="left"}){const{locale:s}=Dr();return a.jsxs("div",{className:`flex h-5 items-center gap-2 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 sm:opacity-0 ${n==="right"?"justify-end":"justify-start"}`,children:[e!==void 0&&a.jsx("span",{className:"text-[11px] text-gray-400",children:eN(e,s)}),t!==void 0&&a.jsx(Wu,{text:t,label:d.chat.copyMessage})]})}const DP=2e3;function $P({item:e,ctx:t}){const n=e.gaveUp?"gaveUp":e.retrying?"retried":"waiting",s=n==="waiting"&&e.plannedDelayMs!==void 0&&e.plannedDelayMs>=DP&&e.arrivedAtMs!==void 0?e.arrivedAtMs+e.plannedDelayMs:null,[o,c]=y.useState(()=>Date.now()),[u,f]=y.useState(!1);y.useEffect(()=>{if(s===null||Date.now()>=s)return;const v=setInterval(()=>{c(Date.now()),Date.now()>=s&&clearInterval(v)},250);return()=>clearInterval(v)},[s]);const p=s!==null?s-o:0,h=s!==null&&p>0,x=h?Math.ceil(p/1e3):void 0,g=h&&t.origin.length===0&&(t.onRetryNow!==void 0||t.onGiveUp!==void 0);return a.jsxs("p",{className:`anim-msg my-1 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-xs ${sn.attention}`,children:[a.jsx("span",{children:d.chat.reconnect(e.status,n,e.attempt,x,e.errorMessage,e.errorCode)}),g&&a.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[t.onRetryNow&&a.jsx("button",{type:"button",disabled:u,onClick:()=>{f(!0),t.onRetryNow()},className:"rounded border border-amber-300 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 transition-colors duration-150 hover:bg-amber-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-amber-700 dark:text-amber-400 dark:hover:bg-amber-950/40",children:d.chat.reconnectRetryNow}),t.onGiveUp&&a.jsx("button",{type:"button",disabled:u,onClick:()=>{f(!0),t.onGiveUp()},className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] text-gray-500 transition-colors duration-150 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:text-gray-400 dark:hover:bg-gray-800",children:d.chat.reconnectGiveUp})]})]})}function fT({item:e,ctx:t}){switch(e.kind){case"user_text":{const n=TN(e.text);if(n)return a.jsx(MP,{origin:n});const s=EN(e.text);if(s)return a.jsx(EP,{origin:s});const o=_l(e.text);if(o)return a.jsx(RS,{done:o.done,body:o.rest});const c=AN(e.text),u=c?c.rest:e.text,f=MN(u),p=f?f.rest:u,h=CN(p),{text:x,images:g,files:v}=df(h?h.rest:p);return c?a.jsxs(a.Fragment,{children:[h&&a.jsx(AS,{names:h.skills}),a.jsx(CP,{round:c.round,objective:x,images:g})]}):a.jsxs(a.Fragment,{children:[f&&a.jsx(AP,{origin:f.origin}),h&&a.jsx(AS,{names:h.skills}),x&&a.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[a.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 px-4 py-2.5 md:max-w-[75%] dark:bg-gray-800",children:a.jsx("p",{className:"wrap-anywhere whitespace-pre-wrap text-base leading-relaxed text-gray-900 dark:text-gray-100",children:x})}),a.jsx(Yc,{...e.atMs!==void 0?{atMs:e.atMs}:{},text:x,align:"right"})]}),v.length>0&&a.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[a.jsx(_S,{files:v}),a.jsx(Yc,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]}),g.map((w,S)=>a.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[a.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 p-1.5 md:max-w-[75%] dark:bg-gray-800",children:a.jsx(Ys,{src:w,alt:d.chat.imageAlt,className:"max-h-48 max-w-full rounded-md"})}),a.jsx(Yc,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]},S))]})}case"background_notice":{const n=_l(e.text);return n?a.jsx(RS,{done:n.done,body:n.rest}):null}case"user_steering":{const{text:n,images:s,files:o}=df(e.text),c=[...s,...e.images??[]];return a.jsxs("div",{className:"anim-msg group my-2 flex flex-col items-end",children:[a.jsxs("div",{className:"flex max-w-[88%] flex-col gap-1.5 rounded-md border border-gray-200 bg-gray-100 px-3 py-1.5 md:max-w-[75%] dark:border-gray-700 dark:bg-gray-800",children:[a.jsxs("div",{className:"flex items-start gap-1.5",children:[a.jsx(Oe,{d:OP,className:"mt-1 shrink-0 text-gray-400 dark:text-gray-500"}),a.jsxs("p",{className:"wrap-anywhere whitespace-pre-wrap text-sm leading-relaxed text-gray-800 dark:text-gray-100",children:[a.jsx("span",{className:"mr-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",children:d.chat.userSteering}),n]})]}),c.length>0&&a.jsx("div",{className:"flex flex-wrap justify-end gap-1.5",children:c.map((u,f)=>a.jsx(Ys,{src:u,alt:d.chat.imageAlt,className:"max-h-28 max-w-full rounded-md"},f))}),o.length>0&&a.jsx("div",{className:"flex justify-end",children:a.jsx(_S,{files:o})})]}),a.jsx(Yc,{...e.atMs!==void 0?{atMs:e.atMs}:{},text:n,align:"right"})]})}case"user_image":return a.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[a.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 p-1.5 md:max-w-[75%] dark:bg-gray-800",children:a.jsx(Ys,{src:e.imageUrl,alt:d.chat.imageAlt,className:"max-h-48 max-w-full rounded-md"})}),a.jsx(Yc,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]});case"assistant_text":return a.jsxs("div",{className:"md-body anim-msg my-3 text-base leading-relaxed text-gray-800 dark:text-gray-100",children:[a.jsx(ed,{text:e.text,streaming:e.streaming}),e.streaming&&a.jsx("span",{className:"animate-pulse text-gray-400",children:"▌"}),e.stopReason&&e.stopReason!=="completed"&&a.jsxs("span",{className:"ml-1 font-mono text-xs text-gray-400",children:["[",e.stopReason,"]"]}),t.origin.length>0&&!e.streaming&&t.onOpenFile&&t.statFiles&&a.jsx(SS,{text:e.text,workspace:t.workspace??null,statFiles:t.statFiles,onOpenFile:t.onOpenFile})]});case"thinking":return a.jsx(WU,{item:e});case"tool_call":return a.jsx(gP,{item:e,ctx:t});case"subagent":return a.jsx("div",{className:"anim-msg my-2",children:a.jsx(dT,{sessionId:e.sessionId,model:e.model,running:!1,ctx:t})});case"abort":return a.jsx("p",{className:"anim-msg my-1 font-mono text-xs text-gray-500 dark:text-gray-400",children:d.chat.aborted(e)});case"llm_error":return a.jsx("p",{className:"anim-msg my-1 font-mono text-xs text-gray-500 dark:text-gray-400",children:d.chat.llmError(e.errorMessage)});case"reconnect":return a.jsx($P,{item:e,ctx:t});case"compaction":return a.jsx(bP,{item:e});case"mcp_connect":return a.jsx(wP,{item:e});case"task_stats":return a.jsxs(a.Fragment,{children:[t.origin.length===0&&t.onOpenFile&&t.statFiles&&e.assistantText.trim()!==""&&a.jsx(SS,{text:e.assistantText,workspace:t.workspace??null,statFiles:t.statFiles,onOpenFile:t.onOpenFile}),t.origin.length===0&&e.memoryChanges!==void 0&&a.jsx(VU,{rows:e.memoryChanges,...t.deletedMemoryKeys?{deletedKeys:t.deletedMemoryKeys}:{},...t.onLocateMemoryChange?{onLocateChange:t.onLocateMemoryChange}:{},...t.onOpenMemory?{onOpenPanel:t.onOpenMemory}:{}}),a.jsx(LP,{stats:e.stats,assistantText:e.assistantText,cost:e.stats?t.taskCost?.(e.stats)??null:null,...e.atMs!==void 0?{atMs:e.atMs}:{},...t.origin.length===0&&e.forkable&&t.onFork?{onFork:t.onFork}:{},...e.forkPosition!==void 0?{forkPosition:e.forkPosition}:{}})]})}}function UP(e){let t=0,n=0,s,o;const c=p=>{p!==void 0&&(s===void 0||p<s)&&(s=p)},u=(p,h)=>{if(h<=0)return;if(p===void 0){n+=h;return}c(p);const x=p+h;(o===void 0||x>o)&&(o=x)};for(const p of e){if(p.kind==="thinking"){c(p.startedAtMs),p.durationMs!==void 0&&u(p.startedAtMs,p.durationMs);continue}if(p.kind!=="tool_call"||(t+=1,c(p.argStartedAtMs??p.callStartedAtMs??p.approvalAtMs),p.durationMs===void 0))continue;const h=p.argStartedAtMs!==void 0&&p.callStartedAtMs!==void 0?Math.min(p.durationMs,Math.max(0,p.callStartedAtMs-p.argStartedAtMs)):0;u(p.argStartedAtMs,h),u(p.approvalAtMs??p.callStartedAtMs,p.durationMs-h)}const f=s!==void 0&&o!==void 0?o-s:0;return{steps:t,durationMs:f+n,...s!==void 0?{startMs:s}:{}}}function PP(e){return e.kind==="thinking"||e.kind==="tool_call"}function zP(e,t){return e.kind==="thinking"?e.streaming:e.kind==="tool_call"?e.callStreaming||e.outputStreaming||e.callComplete&&!e.outputComplete?!0:t.pendingApprovals.has(Rl(t.origin,e.toolCallId)):!1}function BP(e,t){return e.some(n=>n.kind==="tool_call"&&t.pendingApprovals.has(Rl(t.origin,n.toolCallId)))}function HP({items:e,ctx:t,isLast:n}){const s=e.some(S=>zP(S,t)),o=n&&t.taskRunning||s,c=BP(e,t),[u,f]=y.useState(n),p=y.useRef(!1),h=y.useRef(null);y.useEffect(()=>{p.current||f(n)},[n]);const x=u||c,{steps:g,durationMs:v,startMs:w}=UP(e);return a.jsxs("div",{ref:h,className:sT,children:[a.jsxs("button",{type:"button","data-group-header":!0,"aria-expanded":x,onClick:()=>{p.current=!0;const S=u&&!c;f(C=>!C),S&&requestAnimationFrame(()=>h.current?.scrollIntoView({block:"nearest"}))},className:`${nT} ${tT}`,children:[a.jsx(Di,{state:o?"running":"done"}),a.jsx("span",{className:`${rT} ${o?sn.busy:"text-gray-500 dark:text-gray-400"}`,children:o?d.chat.workRunning:d.chat.workDone}),g>0&&a.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 sm:inline",children:d.chat.workGroupSteps(g)}),s?w!==void 0&&a.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:a.jsx(Ll,{sinceMs:w})}):v>0&&a.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:Pn(v)}),c&&!x&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`hidden shrink-0 rounded px-1 text-[10px] font-medium sm:inline ${bo.attention}`,children:d.chat.approvalWaiting}),a.jsx("span",{role:"img",title:d.chat.approvalWaiting,"aria-label":d.chat.approvalWaiting,className:`h-1.5 w-1.5 shrink-0 rounded-full sm:hidden ${Fl.attention}`})]}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx(Zn,{open:x,className:"text-gray-400"})]}),x&&a.jsx("div",{className:"anim-fade divide-y divide-gray-100 border-t border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:e.map(S=>a.jsx(fT,{item:S,ctx:t},S.id))})]})}function FP(){let e=!0,t=null,n=null;return{get stick(){return e},wheel(s){s<0&&(e=!1)},touchStart(s){n=s},touchMove(s){n!==null&&s>n&&(e=!1),n=s},touchEnd(){n=null},scrolled(s){const o=s.scrollHeight-s.scrollTop-s.clientHeight,c=t;if(t=s.scrollTop,c===null){e=o<80;return}if(s.scrollTop<c&&o>1){e=!1;return}o<80&&(e=!0)},resume(){e=!0,t=null}}}function Mm(e,t){e.scrollTop=e.scrollHeight,t.scrolled({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})}function qP({items:e,ctx:t}){const n=[];let s=[];const o=()=>{s.length>0&&(n.push({type:"group",items:s}),s=[])};for(const h of e)PP(h)?s.push(h):(o(),n.push({type:"single",item:h}));o();const c=(h,x)=>h.type==="group"?a.jsx(HP,{items:h.items,ctx:t,isLast:x===n.length-1},`wg-${h.items[0].id}`):a.jsx(fT,{item:h.item,ctx:t},h.item.id),u=[];let f=[];const p=()=>{if(f.length===0)return;const h=f[0].seg,x=h.type==="group"?h.items[0].id:h.item.id,g=f;f=[],u.push(a.jsx("div",{className:"group",children:g.map(v=>c(v.seg,v.i))},`turn-${x}`))};for(let h=0;h<n.length;h++){const x=n[h];if(x.type==="single"&&(x.item.kind==="user_text"||x.item.kind==="user_image")){p(),u.push(t.origin.length===0?a.jsx("div",{"data-outline-anchor":x.item.id,children:c(x,h)},`anchor-${x.item.id}`):c(x,h));continue}f.push({seg:x,i:h}),x.type==="single"&&x.item.kind==="task_stats"&&p()}return p(),a.jsx(a.Fragment,{children:u})}const VP=300;function pT({items:e,version:t,ctx:n,scrollElRef:s,outline:o,older:c}){const u=y.useRef(null),f=y.useRef(null),p=f.current??=FP(),[h,x]=y.useState(!1),g=y.useRef(!1),v=y.useRef(null),w=()=>{v.current!==null&&(cancelAnimationFrame(v.current),v.current=null),g.current=!1};y.useEffect(()=>()=>w(),[]);const S=y.useRef(null),C=()=>{const E=u.current;x(!g.current&&!p.stick&&E!==null&&E.scrollHeight-E.scrollTop-E.clientHeight>1)},N=y.useRef(c);N.current=c;const T=y.useRef(c?.prependedCount??0),_=y.useRef(0),R=E=>{const L=N.current;!L||!L.hasMore||L.loading||L.error!==null||E.scrollTop<VP&&L.onLoad()},D=()=>{const E=u.current;if(!E)return;const L=S.current;S.current=E.scrollTop,g.current&&L!==null&&E.scrollTop<L-1&&w(),p.scrolled({scrollTop:E.scrollTop,scrollHeight:E.scrollHeight,clientHeight:E.clientHeight}),R(E),C()};y.useLayoutEffect(()=>{const E=u.current,L=c?.prependedCount??0;E&&L>T.current&&!p.stick&&!g.current&&(E.scrollTop+=E.scrollHeight-_.current),T.current=L,E&&(_.current=E.scrollHeight),E&&p.stick&&!g.current&&Mm(E,p),C()},[t,p,c?.prependedCount]),y.useEffect(()=>{const E=u.current;if(!E||typeof ResizeObserver>"u")return;const L=new ResizeObserver(()=>{_.current=E.scrollHeight,p.stick&&!g.current&&Mm(E,p),C()});return L.observe(E),E.firstElementChild&&L.observe(E.firstElementChild),()=>L.disconnect()},[p]);const z=()=>{const E=u.current;if(!E)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){p.resume(),Mm(E,p),C();return}w(),g.current=!0,E.scrollHeight-E.clientHeight-E.scrollTop>3*E.clientHeight&&(E.scrollTop=E.scrollHeight-4*E.clientHeight);let F=performance.now();const V=P=>{v.current=null;const B=u.current;if(!B||!g.current)return;const Y=Math.min(.05,Math.max(.001,(P-F)/1e3));F=P;const q=B.scrollHeight-B.clientHeight-B.scrollTop;if(q<=1){g.current=!1,p.resume(),Mm(B,p),C();return}const K=Math.max(q*Math.min(1,Y*10),3200*Y);B.scrollTop+=Math.min(K,q),v.current=requestAnimationFrame(V)};v.current=requestAnimationFrame(V),C()};return a.jsxs("div",{className:"relative h-full min-h-0",children:[a.jsx("div",{ref:E=>{u.current=E,s&&(s.current=E)},onScroll:D,onWheel:E=>{p.wheel(E.deltaY),E.deltaY<0&&w(),C()},onTouchStart:E=>{const L=E.touches[0];L&&p.touchStart(L.clientY)},onTouchMove:E=>{const L=E.touches[0];L&&p.touchMove(L.clientY),g.current&&w(),C()},onTouchEnd:()=>p.touchEnd(),className:"anim-fade h-full overflow-y-auto px-4 py-4 md:px-6",children:a.jsxs("div",{className:"mx-auto max-w-3xl",children:[c&&e.length>0&&a.jsx("div",{className:"flex justify-center pb-2",children:c.loading?a.jsxs("span",{className:"flex items-center gap-2 py-1 text-xs text-gray-400 dark:text-gray-500",children:[a.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}),d.chat.loadingEarlier]}):c.error!==null?a.jsx("button",{type:"button",onClick:c.onLoad,className:"py-1 text-xs text-red-600 transition-colors duration-150 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:d.chat.loadEarlierRetry}):!c.hasMore&&c.prependedCount>0?a.jsx("span",{className:"py-1 text-xs text-gray-400 dark:text-gray-500",children:d.chat.historyBeginning}):null}),e.length===0?a.jsx(Fa,{title:d.chat.emptyStream}):a.jsx(qP,{items:e,ctx:n})]})}),o,h&&a.jsx("button",{type:"button","aria-label":d.chat.jumpToLatest,title:d.chat.jumpToLatest,onClick:z,className:"anim-pop absolute bottom-3 left-1/2 z-10 -translate-x-1/2 rounded-full border border-gray-300 bg-white p-1.5 text-gray-500 shadow-sm transition-colors duration-150 hover:bg-gray-50 hover:text-gray-900 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M6 13l6 6 6-6",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}const GP=/[\s"'/]on[a-z]+\s*=/i,KP=/href\s*=/i;function WP(e){if(!e)return null;const t=e.trim();if(!/^<svg[\s>]/i.test(t))return null;const n=t.toLowerCase();return n.includes("<script")||n.includes("foreignobject")||KP.test(t)||GP.test(t)?null:t}const Bg=["bg-sky-50 text-sky-600 dark:bg-sky-950/60 dark:text-sky-400","bg-emerald-50 text-emerald-600 dark:bg-emerald-950/60 dark:text-emerald-400","bg-violet-50 text-violet-600 dark:bg-violet-950/60 dark:text-violet-400","bg-amber-50 text-amber-600 dark:bg-amber-950/60 dark:text-amber-400","bg-rose-50 text-rose-600 dark:bg-rose-950/60 dark:text-rose-400","bg-cyan-50 text-cyan-600 dark:bg-cyan-950/60 dark:text-cyan-400","bg-indigo-50 text-indigo-600 dark:bg-indigo-950/60 dark:text-indigo-400","bg-teal-50 text-teal-600 dark:bg-teal-950/60 dark:text-teal-400"],YP={firecrawl:3,"data-analysis":1,"web-design":2,"penguin-sdk":0};function hT(e){const t=YP[e];if(t!==void 0)return Bg[t];let n=0;for(let s=0;s<e.length;s++)n=n*31+e.charCodeAt(s)>>>0;return Bg[n%Bg.length]}function Yf({icon:e,size:t=20,className:n=""}){const s=WP(e);return s?a.jsx("span",{"aria-hidden":!0,style:{width:t,height:t},className:`block shrink-0 [&>svg]:block [&>svg]:h-full [&>svg]:w-full ${n}`,dangerouslySetInnerHTML:{__html:s}}):a.jsx(Oe,{d:My,size:t,className:n})}const IS="rounded px-1 py-0.5 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200";function q0({skills:e,selected:t,onToggle:n,onSelectAll:s,onSelectNone:o,emptyHint:c}){const{locale:u}=Dr(),[f,p]=y.useState(""),h=RP(e,u,f),x=s!==void 0&&o!==void 0;return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"border-b border-gray-100 px-2 pb-1.5 pt-0.5 dark:border-gray-800",children:a.jsx("input",{autoFocus:!0,value:f,onChange:g=>p(g.target.value),placeholder:d.chat.skillsSearchPlaceholder,"aria-label":d.chat.skillsSearchPlaceholder,...Gu,className:"w-full rounded border border-transparent bg-transparent px-1 py-0.5 text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:text-gray-200 dark:placeholder:text-gray-500"})}),x&&e.length>0&&a.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-gray-100 px-3 py-1 dark:border-gray-800",children:[a.jsx("span",{className:"min-w-0 truncate text-xs text-gray-400 dark:text-gray-500",children:d.skills.selectedCount(t.length)}),a.jsxs("span",{className:"flex shrink-0 items-center gap-0.5",children:[a.jsx("button",{type:"button",className:IS,onClick:()=>s(h.map(g=>g.name)),children:d.skills.selectAll}),a.jsx("button",{type:"button",className:IS,onClick:()=>o(h.map(g=>g.name)),children:d.skills.selectNone})]})]}),a.jsx("div",{className:"max-h-56 overflow-y-auto",children:e.length===0?a.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:c}):h.length===0?a.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:d.chat.skillsNoMatch}):h.map(g=>{const v=t.includes(g.name);return a.jsxs("button",{type:"button","aria-pressed":v,onClick:()=>n(g.name),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${v?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[a.jsx(Yf,{icon:g.icon,size:Ye.inlineGlyph,className:"shrink-0 text-gray-400 dark:text-gray-500"}),a.jsx("span",{className:"shrink-0 font-mono",children:g.name}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:Wl(u,g)}),a.jsx("span",{className:"w-3 shrink-0 text-center",children:v?"✓":""})]},g.name)})})]})}function V0(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function LS(e,t){return[...e,...t.filter(n=>!e.includes(n))]}function OS(e,t){return e.filter(n=>!t.includes(n))}const DS={viewBox:"-0.76 -0.47 28.6 28.6",path:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M26.59,15.92L22.82,13.75C22.92,13.59,22.97,13.4,22.97,13.21L22.97,12.05C22.97,11.66,22.76,11.31,22.43,11.12L21.42,10.54C21.09,10.34,20.68,10.34,20.35,10.54L17.26,12.32C16.93,12.51,16.73,12.86,16.73,13.25L16.73,14.41C16.73,14.79,16.93,15.15,17.26,15.34L24.51,19.53C24.84,19.72,25.25,19.72,25.58,19.53L26.59,18.94C26.92,18.75,27.13,18.4,27.13,18.01L27.13,16.85C27.13,16.47,26.92,16.11,26.59,15.92L26.59,15.92Z"}),a.jsx("path",{d:"M21.88,3.58L18.11,5.75C18.02,5.59,17.89,5.46,17.72,5.36L16.71,4.78C16.38,4.59,15.97,4.59,15.64,4.78L14.63,5.36C14.3,5.55,14.09,5.9,14.09,6.29L14.09,9.86C14.09,10.24,14.3,10.59,14.63,10.78L15.64,11.37C15.97,11.56,16.38,11.56,16.71,11.37L23.96,7.18C24.29,6.99,24.5,6.64,24.5,6.25L24.5,5.09C24.5,4.71,24.29,4.35,23.96,4.16L22.95,3.58C22.62,3.39,22.21,3.39,21.88,3.58L21.88,3.58Z"}),a.jsx("path",{d:"M8.83,1.48L8.83,5.83C8.65,5.83,8.46,5.88,8.3,5.98L7.29,6.56C6.95,6.75,6.75,7.11,6.75,7.49L6.75,8.65C6.75,9.04,6.95,9.39,7.29,9.58L10.37,11.37C10.71,11.56,11.11,11.56,11.45,11.37L12.45,10.78C12.79,10.59,12.99,10.24,12.99,9.85L12.99,1.48C12.99,1.1,12.79,0.75,12.45,0.56L11.45,-0.03C11.11,-0.22,10.71,-0.22,10.37,-0.03L9.37,0.56C9.03,0.75,8.83,1.1,8.83,1.48L8.83,1.48Z"}),a.jsx("path",{d:"M0.5,11.74L4.26,13.91C4.17,14.07,4.12,14.26,4.12,14.45L4.12,15.61C4.12,16,4.32,16.35,4.65,16.54L5.66,17.13C6,17.32,6.4,17.32,6.73,17.13L9.82,15.34C10.15,15.15,10.36,14.8,10.36,14.41L10.36,13.25C10.36,12.87,10.15,12.51,9.82,12.32L2.57,8.14C2.24,7.94,1.84,7.94,1.5,8.14L0.5,8.72C0.16,8.91,-0.04,9.26,-0.04,9.65L-0.04,10.81C-0.04,11.19,0.16,11.55,0.5,11.74Z"}),a.jsx("path",{d:"M5.21,24.08L8.97,21.91C9.07,22.07,9.2,22.21,9.37,22.3L10.38,22.88C10.71,23.08,11.11,23.08,11.45,22.88L12.46,22.3C12.79,22.11,12.99,21.76,12.99,21.37L12.99,17.81C12.99,17.42,12.79,17.07,12.46,16.88L11.45,16.29C11.11,16.1,10.71,16.1,10.38,16.29L3.13,20.48C2.8,20.67,2.59,21.02,2.59,21.41L2.59,22.57C2.59,22.95,2.8,23.31,3.13,23.5L4.14,24.08C4.47,24.28,4.88,24.28,5.21,24.08L5.21,24.08Z"}),a.jsx("path",{d:"M18.26,26.18L18.26,21.83C18.44,21.83,18.63,21.78,18.79,21.68L19.8,21.1C20.13,20.91,20.34,20.56,20.34,20.17L20.34,19.01C20.34,18.62,20.13,18.27,19.8,18.08L16.71,16.3C16.38,16.1,15.97,16.1,15.64,16.3L14.63,16.88C14.3,17.07,14.1,17.42,14.1,17.81L14.1,26.18C14.1,26.56,14.3,26.91,14.63,27.11L15.64,27.69C15.97,27.88,16.38,27.88,16.71,27.69L17.72,27.11C18.05,26.91,18.26,26.56,18.26,26.18L18.26,26.18Z"})]})},XP={anthropic:{path:a.jsx("path",{d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})},openai:{path:a.jsx("path",{d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})},google:{path:a.jsx("path",{d:"M12 24A14.304 14.304 0 0 0 0 12 14.304 14.304 0 0 0 12 0a14.305 14.305 0 0 0 12 12 14.305 14.305 0 0 0-12 12"})},deepseek:{path:a.jsx("path",{d:"M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.328.14a5.526 5.526 0 0 1-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 0 0-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 0 1-.465.137 9.597 9.597 0 0 0-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.034-.237.23-.256a4.173 4.173 0 0 0 1.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 0 1 1.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.615zm1-6.44a.306.306 0 0 1 .415-.287.302.302 0 0 1 .2.288.306.306 0 0 1-.31.307.303.303 0 0 1-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 0 1-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 0 1 .016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 0 1-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.191-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.196-.02.354-.25.452z"})},zhipu:{path:a.jsx("path",{d:"M4.6 3.2h14.8a.9.9 0 0 1 .73 1.43L9.9 18.6h9.2a.9.9 0 0 1 0 1.8H4.6a.9.9 0 0 1-.73-1.43L14.1 5.4H4.6a1.1 1.1 0 0 1 0-2.2Z"})},moonshot:{path:a.jsx("path",{d:"m1.053 16.91 9.538 2.55a21 20.981 0 0 0 .06 2.031l5.956 1.592a12 11.99 0 0 1-15.554-6.172m-1.02-5.79 11.352 3.035a21 20.981 0 0 0-.469 2.01l10.817 2.89a12 11.99 0 0 1-1.845 2.004L.658 15.918a12 11.99 0 0 1-.625-4.796m1.593-5.146L13.573 9.17a21 20.981 0 0 0-1.01 1.874l11.297 3.02a21 20.981 0 0 1-.67 2.362l-11.55-3.087L.125 10.26a12 11.99 0 0 1 1.499-4.285ZM6.067 1.58l11.285 3.016a21 20.981 0 0 0-1.688 1.719l7.824 2.091a21 20.981 0 0 1 .513 2.664L2.107 5.218a12 11.99 0 0 1 3.96-3.638M21.68 4.866 7.222 1.003A12 11.99 0 0 1 21.68 4.866"})},openrouter:{path:a.jsx("path",{d:"M16.778 1.844v1.919q-.569-.026-1.138-.032-.708-.008-1.415.037c-1.93.126-4.023.728-6.149 2.237-2.911 2.066-2.731 1.95-4.14 2.75-.396.223-1.342.574-2.185.798-.841.225-1.753.333-1.751.333v4.229s.768.108 1.61.333c.842.224 1.789.575 2.185.799 1.41.798 1.228.683 4.14 2.75 2.126 1.509 4.22 2.11 6.148 2.236.88.058 1.716.041 2.555.005v1.918l7.222-4.168-7.222-4.17v2.176c-.86.038-1.611.065-2.278.021-1.364-.09-2.417-.357-3.979-1.465-2.244-1.593-2.866-2.027-3.68-2.508.889-.518 1.449-.906 3.822-2.59 1.56-1.109 2.614-1.377 3.978-1.466.667-.044 1.418-.017 2.278.02v2.176L24 6.014Z"})},siliconflow:{viewBox:"0 0 53.021 25.354",path:a.jsx("path",{d:"M50.7172 0H27.6622C26.3877 0 25.3586 1.03397 25.3586 2.30358V9.21911C25.3586 10.4935 24.3294 11.5227 23.055 11.5227H2.30357C1.02914 11.5227 0 12.5567 0 13.8263V23.0502C0 24.3246 1.03395 25.3538 2.30357 25.3538H25.3586C26.633 25.3538 27.6622 24.3198 27.6622 23.0502V16.1347C27.6622 14.8602 28.6913 13.8311 29.9657 13.8311H50.7172C51.9916 13.8311 53.0207 12.7971 53.0207 11.5275V2.30358C53.0207 1.02916 51.9868 0 50.7172 0Z"})},tokendance:{viewBox:"50.79 100 378.72 280.5",path:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M159 162H52.789C51.4198 162 50.4555 160.655 50.8947 159.358L66.8591 112.225C69.3344 104.918 76.192 100 83.9077 100H321.388C324.459 100 327.524 100.21 330.551 100.726C336.545 101.747 347.179 103.791 354.5 106.5C395.04 121.504 418.5 160 426 191C433.5 222 432 274.5 390.5 327C349 379.5 284 380.5 282 380.5H175.767C174.399 380.5 173.451 379.159 173.886 377.863L192.567 322.275C193.123 320.623 194.677 319.52 196.42 319.545C207.729 319.703 230.558 319.865 251 319.5C279 319 286 318.5 310 305.5C334 292.5 360.5 252.5 352 209.5C345.2 175.1 315.5 163.5 301.5 162H228.992C221.236 162 214.351 166.969 211.908 174.331L147.592 368.169C145.149 375.531 138.264 380.5 130.508 380.5H73.7532C72.3943 380.5 71.4179 379.214 71.8379 377.922C89.6259 323.19 124.669 214.961 129 200C133.4 184.8 150.833 168.333 159 162Z"}),a.jsx("path",{d:"M233 264L248 216",fill:"none",stroke:"currentColor",strokeWidth:25,strokeLinecap:"round"}),a.jsx("path",{d:"M280 264L295 216",fill:"none",stroke:"currentColor",strokeWidth:25,strokeLinecap:"round"})]})},"qwen-token-plan":DS,"qwen-pay-as-you-go":DS,minimax:{path:a.jsx("path",{fillRule:"evenodd",d:"M16.278 2c1.156 0 2.093.927 2.093 2.07v12.501a.74.74 0 00.744.709.74.74 0 00.743-.709V9.099a2.06 2.06 0 012.071-2.049A2.06 2.06 0 0124 9.1v6.561a.649.649 0 01-.652.645.649.649 0 01-.653-.645V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v7.472a2.037 2.037 0 01-2.048 2.026 2.037 2.037 0 01-2.048-2.026v-12.5a.785.785 0 00-.788-.753.785.785 0 00-.789.752l-.001 15.904A2.037 2.037 0 0113.441 22a2.037 2.037 0 01-2.048-2.026V18.04c0-.356.292-.645.652-.645.36 0 .652.289.652.645v1.934c0 .263.142.506.372.638.23.131.514.131.744 0a.734.734 0 00.372-.638V4.07c0-1.143.937-2.07 2.093-2.07zm-5.674 0c1.156 0 2.093.927 2.093 2.07v11.523a.648.648 0 01-.652.645.648.648 0 01-.652-.645V4.07a.785.785 0 00-.789-.78.785.785 0 00-.789.78v14.013a2.06 2.06 0 01-2.07 2.048 2.06 2.06 0 01-2.071-2.048V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v3.8a2.06 2.06 0 01-2.071 2.049A2.06 2.06 0 010 12.9v-1.378c0-.357.292-.646.652-.646.36 0 .653.29.653.646V12.9c0 .418.343.757.766.757s.766-.339.766-.757V9.099a2.06 2.06 0 012.07-2.048 2.06 2.06 0 012.071 2.048v8.984c0 .419.343.758.767.758.423 0 .766-.339.766-.758V4.07c0-1.143.937-2.07 2.093-2.07z"})},fireworks:{viewBox:"0 0 638 315",path:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M318.563 221.755C300.863 221.755 284.979 211.247 278.206 194.978L196.549 0H244.342L318.842 178.361L393.273 0H441.066L358.92 195.048C352.112 211.247 336.263 221.755 318.563 221.755Z"}),a.jsx("path",{d:"M425.111 314.933C407.481 314.933 391.667 304.494 384.824 288.366C377.947 272.097 381.507 253.524 393.936 240.921L542.657 90.2803L561.229 134.094L425.076 271.748L619.147 270.666L637.72 314.479L425.146 315.003L425.076 314.933H425.111Z"}),a.jsx("path",{d:"M0 314.408L18.5727 270.595L212.643 271.677L76.525 133.988L95.0977 90.1748L243.819 240.816C256.247 253.384 259.843 272.026 252.93 288.26C246.088 304.424 230.203 314.827 212.643 314.827L0.0698221 314.339L0 314.408Z"})]})},custom:{stroke:!0,path:a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M12 2.8 20.5 7.4v9.2L12 21.2 3.5 16.6V7.4L12 2.8Z"}),a.jsx("path",{d:"M3.5 7.4 12 12l8.5-4.6M12 12v9.2"})]})}};function jo({provider:e,className:t}){const n=XP[e];if(!n){const s=yN(e);return a.jsxs("svg",{viewBox:"0 0 24 24",className:t,style:{"--tile-fg":s.fg,"--tile-fg-dark":s.fgDark},"aria-hidden":!0,children:[a.jsx("rect",{x:"0",y:"0",width:"24",height:"24",rx:"5",fill:s.bg}),a.jsx("text",{x:"12",y:"12",textAnchor:"middle",dominantBaseline:"central",fontSize:"13",fontWeight:"700",className:"[fill:var(--tile-fg)] dark:[fill:var(--tile-fg-dark)]",children:bN(e)})]})}return a.jsx("svg",{viewBox:n.viewBox??"0 0 24 24",className:t,"aria-hidden":!0,...n.stroke?{fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinejoin:"round"}:{fill:"currentColor"},children:n.path})}var Tt="https://openrouter.ai/api/v1",Mi="https://api.siliconflow.cn/v1",gl="https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",fo="https://dashscope.aliyuncs.com/compatible-mode/v1",Ks="https://api.fireworks.ai/inference/v1",Ei="https://tokendance.space/gateway/v1",QP="https://api.minimax.io/v1",es=[{id:"deepseek",label:"DeepSeek",envKey:"DEEPSEEK_API_KEY",envBaseUrlKey:"DEEPSEEK_BASE_URL",apiKeyUrl:"https://platform.deepseek.com/api_keys",modelsUrl:"https://api-docs.deepseek.com/quick_start/pricing"},{id:"openrouter",label:"OpenRouter",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://openrouter.ai/workspaces/default/keys",modelsUrl:"https://openrouter.ai/models",gatewayBaseUrl:Tt},{id:"fireworks",label:"Fireworks AI",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://app.fireworks.ai/settings/users/api-keys",modelsUrl:"https://app.fireworks.ai/models",gatewayBaseUrl:Ks},{id:"google",label:"Google Gemini",envKey:"GEMINI_API_KEY",envBaseUrlKey:"GEMINI_BASE_URL",apiKeyUrl:"https://aistudio.google.com/api-keys",modelsUrl:"https://ai.google.dev/gemini-api/docs/models"},{id:"openai",label:"OpenAI",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://platform.openai.com/api-keys",modelsUrl:"https://platform.openai.com/docs/models"},{id:"anthropic",label:"Anthropic",envKey:"ANTHROPIC_API_KEY",envBaseUrlKey:"ANTHROPIC_BASE_URL",apiKeyUrl:"https://platform.claude.com/settings/keys",modelsUrl:"https://docs.claude.com/en/docs/about-claude/models/overview"},{id:"siliconflow",label:"SiliconFlow",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://cloud.siliconflow.cn/me/account/ak",modelsUrl:"https://cloud.siliconflow.cn/models",gatewayBaseUrl:Mi},{id:"tokendance",label:"TokenDance",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://tokendance.space/keys",modelsUrl:"https://tokendance.space/models",gatewayBaseUrl:Ei,oauth:{authorizeUrl:"https://tokendance.space/auth",exchangeUrl:"https://tokendance.space/portal/api/v1/auth/keys",keyName:"PenguinHarness"}},{id:"zhipu",label:"Z.AI (GLM)",envKey:"ZAI_API_KEY",envBaseUrlKey:"ZAI_BASE_URL",apiKeyUrl:"https://open.bigmodel.cn/apikey/platform",modelsUrl:"https://docs.z.ai/guides/overview/pricing"},{id:"moonshot",label:"Moonshot (Kimi)",envKey:"MOONSHOT_API_KEY",envBaseUrlKey:"MOONSHOT_BASE_URL",apiKeyUrl:"https://platform.kimi.com/console/api-keys",modelsUrl:"https://platform.kimi.com/docs/pricing"},{id:"minimax",label:"MiniMax",envKey:"MINIMAX_API_KEY",envBaseUrlKey:"MINIMAX_BASE_URL",apiKeyUrl:"https://platform.minimax.io/user-center/basic-information/interface-key",modelsUrl:"https://platform.minimax.io/docs/guides/models-intro"},{id:"qwen-pay-as-you-go",label:"Qwen Pay-As-You-Go",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://platform.qianwenai.com/docs/api-reference/preparation/api-key",modelsUrl:"https://www.qianwenai.com/models",gatewayBaseUrl:fo},{id:"qwen-token-plan",label:"Qwen Token Plan",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL",apiKeyUrl:"https://platform.qianwenai.com/pricing/token-plan",modelsUrl:"https://platform.qianwenai.com/docs/token-plan/personal/token-plan-personal-overview",gatewayBaseUrl:gl},{id:"custom",label:"Custom",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL"}];function Kt(e,t,n){const s=o=>Math.round(o/7*1e6)/1e6;return Fe(s(e),s(t),s(n))}function Fe(e,t,n){return{unit:"usd_per_mtok",cache_read:e,cache_write:t,output:n}}var gT=[{modelId:"deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"deepseek",contextWindow:1e6,pricing:Kt(.05,1.5,4.5),supportsVision:!1},{modelId:"deepseek-v4-flash-vision-exp",displayName:"DeepSeek V4 Flash Vision Exp",provider:"deepseek",contextWindow:1e6,pricing:Kt(.05,1.5,4.5),supportsVision:!0},{modelId:"deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"deepseek",contextWindow:1e6,pricing:Kt(.15,4.5,13.5),supportsVision:!1},{modelId:"anthropic/claude-fable-5",displayName:"Claude Fable 5",provider:"openrouter",contextWindow:1e6,pricing:Fe(1,12.5,50),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"anthropic/claude-opus-5",displayName:"Claude Opus 5",provider:"openrouter",contextWindow:1e6,pricing:Fe(.5,6.25,25),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"anthropic/claude-opus-4.8",displayName:"Claude Opus 4.8",provider:"openrouter",contextWindow:1e6,pricing:Fe(.5,6.25,25),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"anthropic/claude-opus-4.7",displayName:"Claude Opus 4.7",provider:"openrouter",contextWindow:1e6,pricing:Fe(.5,6.25,25),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"anthropic/claude-sonnet-5",displayName:"Claude Sonnet 5",provider:"openrouter",contextWindow:1e6,pricing:Fe(.2,2.5,10),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"deepseek/deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"openrouter",contextWindow:1e6,pricing:Fe(.0157192,.078596,.157192),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"deepseek/deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"openrouter",contextWindow:1e6,pricing:Fe(.0168,.0679,.168),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"deepseek/deepseek-v4-flash-vision-exp",displayName:"DeepSeek V4 Flash Vision Exp",provider:"openrouter",contextWindow:1048576,pricing:Fe(.007,.22,.66),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"deepseek/deepseek-v4-pro-0813",displayName:"DeepSeek V4 Pro 0813",provider:"openrouter",contextWindow:1048576,pricing:Fe(.022,.66,1.98),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"deepseek/deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"openrouter",contextWindow:1e6,pricing:Fe(.022,.66,1.98),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"google/gemini-3.7-flash",displayName:"Gemini 3.7 Flash",provider:"openrouter",contextWindow:1048576,pricing:Fe(.0375,.375,1.875),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"google/gemini-3.6-flash",displayName:"Gemini 3.6 Flash",provider:"openrouter",contextWindow:1048576,pricing:Fe(.15,1.5,7.5),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"google/gemini-3.5-flash",displayName:"Gemini 3.5 Flash",provider:"openrouter",contextWindow:1048576,pricing:Fe(.15,1.5,9),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"google/gemini-3.5-flash-lite",displayName:"Gemini 3.5 Flash-Lite",provider:"openrouter",contextWindow:1048576,pricing:Fe(.03,.3,2.5),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"minimax/minimax-m3",displayName:"MiniMax M3",provider:"openrouter",contextWindow:1048576,pricing:Fe(.06,.3,1.2),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"moonshotai/kimi-k3",displayName:"Kimi K3",provider:"openrouter",contextWindow:1e6,pricing:Fe(.3,3,15),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"moonshotai/kimi-k2.6",displayName:"Kimi K2.6",provider:"openrouter",contextWindow:262144,pricing:Fe(.0992,.589,2.48),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"nvidia/nemotron-3-ultra-550b-a55b:free",displayName:"Nemotron 3 Ultra (free)",provider:"openrouter",contextWindow:1e6,pricing:Fe(0,0,0),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"openai/gpt-5.6-luna",displayName:"GPT-5.6 Luna",provider:"openrouter",contextWindow:105e4,pricing:Fe(.02,.25,1.2),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openai/gpt-5.6-sol",displayName:"GPT-5.6 Sol",provider:"openrouter",contextWindow:105e4,pricing:Fe(.25,3.125,15),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openai/gpt-5.6-terra",displayName:"GPT-5.6 Terra",provider:"openrouter",contextWindow:105e4,pricing:Fe(.2,2.5,12),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openai/gpt-5.5",displayName:"GPT-5.5",provider:"openrouter",contextWindow:105e4,pricing:Fe(.5,5,30),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openai/gpt-5.5-pro",displayName:"GPT-5.5 Pro",provider:"openrouter",contextWindow:105e4,pricing:Fe(30,30,180),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openai/gpt-5.4",displayName:"GPT-5.4",provider:"openrouter",contextWindow:105e4,pricing:Fe(.25,2.5,15),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openai/gpt-5.4-mini",displayName:"GPT-5.4 mini",provider:"openrouter",contextWindow:4e5,pricing:Fe(.075,.75,4.5),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openai/gpt-5.4-nano",displayName:"GPT-5.4 nano",provider:"openrouter",contextWindow:4e5,pricing:Fe(.02,.2,1.25),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openai/gpt-5.4-pro",displayName:"GPT-5.4 Pro",provider:"openrouter",contextWindow:105e4,pricing:Fe(30,30,180),supportsVision:!0,clientType:"openai-responses",baseUrl:Tt},{modelId:"openrouter/free",displayName:"Free Models Router",provider:"openrouter",contextWindow:128e3,pricing:Fe(0,0,0),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"qwen/qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"openrouter",contextWindow:1e6,pricing:Fe(.25,2.5,6),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"qwen/qwen3.6-35b-a3b",displayName:"Qwen 3.6 35B A3B",provider:"openrouter",contextWindow:262144,pricing:Fe(.05,.14,1),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"stepfun/step-3.7-flash",displayName:"Step 3.7 Flash",provider:"openrouter",contextWindow:256e3,pricing:Fe(.04,.2,1.15),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"tencent/hy3",displayName:"Hy3",provider:"openrouter",contextWindow:262144,pricing:Fe(.033,.132,.528),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"thinkingmachines/inkling",displayName:"Inkling",provider:"openrouter",contextWindow:1e6,pricing:Fe(.17,1,4.05),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"x-ai/grok-4.6",displayName:"Grok 4.6",provider:"openrouter",contextWindow:5e5,pricing:Fe(.5,2,6),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"x-ai/grok-4.5",displayName:"Grok 4.5",provider:"openrouter",contextWindow:5e5,pricing:Fe(.3,2,6),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"xiaomi/mimo-v2.5",displayName:"MiMo-V2.5",provider:"openrouter",contextWindow:1048576,pricing:Fe(.0028,.14,.28),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"z-ai/glm-5.3",displayName:"GLM-5.3",provider:"openrouter",contextWindow:1048576,pricing:Fe(.26,1.4,4.4),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"z-ai/glm-5.3-flash",displayName:"GLM-5.3 Flash",provider:"openrouter",contextWindow:1048576,pricing:Fe(.015,.075,.25),supportsVision:!0,clientType:"openai-chat",baseUrl:Tt},{modelId:"z-ai/glm-5.2",displayName:"GLM-5.2",provider:"openrouter",contextWindow:1e6,pricing:Fe(.1261,.679,2.134),supportsVision:!1,clientType:"openai-chat",baseUrl:Tt},{modelId:"accounts/fireworks/models/deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"fireworks",contextWindow:1e6,pricing:Fe(.028,.14,.28),supportsVision:!1,clientType:"openai-chat",baseUrl:Ks},{modelId:"accounts/fireworks/models/deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"fireworks",contextWindow:1e6,pricing:Fe(.03,.14,.28),supportsVision:!1,clientType:"openai-chat",baseUrl:Ks},{modelId:"accounts/fireworks/models/deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"fireworks",contextWindow:1e6,pricing:Fe(.15,1.74,3.48),supportsVision:!1,clientType:"openai-chat",baseUrl:Ks},{modelId:"accounts/fireworks/models/glm-5p2",displayName:"GLM-5.2",provider:"fireworks",contextWindow:1e6,pricing:Fe(.14,1.4,4.4),supportsVision:!1,clientType:"openai-chat",baseUrl:Ks},{modelId:"accounts/fireworks/models/inkling",displayName:"Inkling",provider:"fireworks",contextWindow:1e6,pricing:Fe(.17,1,4.05),supportsVision:!0,clientType:"openai-chat",baseUrl:Ks},{modelId:"accounts/fireworks/models/kimi-k3",displayName:"Kimi K3",provider:"fireworks",contextWindow:1e6,pricing:Fe(.3,3,15),supportsVision:!0,clientType:"openai-chat",baseUrl:Ks},{modelId:"accounts/fireworks/models/kimi-k2p7-code",displayName:"Kimi K2.7 Code",provider:"fireworks",contextWindow:262144,pricing:Fe(.19,.95,4),supportsVision:!0,clientType:"openai-chat",baseUrl:Ks},{modelId:"accounts/fireworks/models/minimax-m3",displayName:"MiniMax M3",provider:"fireworks",contextWindow:524288,pricing:Fe(.06,.3,1.2),supportsVision:!0,clientType:"openai-chat",baseUrl:Ks},{modelId:"deepseek-ai/DeepSeek-V4-Flash",displayName:"DeepSeek V4 Flash",provider:"siliconflow",contextWindow:1e6,pricing:Kt(.02,1,2),supportsVision:!1,clientType:"openai-chat",baseUrl:Mi},{modelId:"deepseek-ai/DeepSeek-V4-Pro",displayName:"DeepSeek V4 Pro",provider:"siliconflow",contextWindow:1e6,pricing:Kt(.1,12,24),supportsVision:!1,clientType:"openai-chat",baseUrl:Mi},{modelId:"meituan-longcat/LongCat-2.0",displayName:"LongCat 2.0",provider:"siliconflow",contextWindow:1e6,pricing:Kt(.1,5,20),supportsVision:!1,clientType:"openai-chat",baseUrl:Mi},{modelId:"moonshotai/Kimi-K2.7-Code",displayName:"Kimi K2.7 Code",provider:"siliconflow",contextWindow:262144,pricing:Kt(1.3,6.5,27),supportsVision:!0,clientType:"openai-chat",baseUrl:Mi},{modelId:"Pro/moonshotai/Kimi-K2.6",displayName:"Kimi K2.6",provider:"siliconflow",contextWindow:262144,pricing:Kt(1.1,6.5,27),supportsVision:!0,clientType:"openai-chat",baseUrl:Mi},{modelId:"Qwen/Qwen3.6-35B-A3B",displayName:"Qwen 3.6 35B A3B",provider:"siliconflow",contextWindow:262144,pricing:Kt(1.8,1.8,10.8),supportsVision:!0,clientType:"openai-chat",baseUrl:Mi},{modelId:"zai-org/GLM-5.2",displayName:"GLM-5.2",provider:"siliconflow",contextWindow:1e6,pricing:Kt(2,8,28),supportsVision:!1,clientType:"openai-chat",baseUrl:Mi},{modelId:"deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"tokendance",contextWindow:1048576,pricing:Kt(.05,1.5,4.5),supportsVision:!1,clientType:"openai-chat",baseUrl:Ei},{modelId:"deepseek-v4-flash-vision-exp",displayName:"DeepSeek V4 Flash Vision Exp",provider:"tokendance",contextWindow:1e6,pricing:Kt(.05,1.5,4.5),supportsVision:!0,clientType:"openai-chat",baseUrl:Ei},{modelId:"deepseek-v4-pro-0813",displayName:"DeepSeek V4 Pro 0813",provider:"tokendance",contextWindow:1e6,pricing:Kt(.15,4.5,13.5),supportsVision:!1,clientType:"openai-chat",baseUrl:Ei},{modelId:"glm-5.3",displayName:"GLM-5.3",provider:"tokendance",contextWindow:1e6,pricing:Kt(2,8,28),supportsVision:!1,clientType:"openai-chat",baseUrl:Ei},{modelId:"glm-5.3-flash",displayName:"GLM-5.3 Flash",provider:"tokendance",contextWindow:1e6,pricing:Kt(.23,.8,2.8),supportsVision:!0,clientType:"openai-chat",baseUrl:Ei},{modelId:"kimi-k3",displayName:"Kimi K3",provider:"tokendance",contextWindow:1048576,pricing:Kt(2,20,100),supportsVision:!0,clientType:"openai-chat",baseUrl:Ei},{modelId:"qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"tokendance",contextWindow:1e6,pricing:Kt(1.5,12,36),supportsVision:!0,clientType:"openai-chat",baseUrl:Ei},{modelId:"deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"qwen-token-plan",contextWindow:1e6,pricing:Kt(.2,1,2),supportsVision:!1,clientType:"openai-chat",baseUrl:gl},{modelId:"deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"qwen-token-plan",contextWindow:1e6,pricing:Kt(1,12,24),supportsVision:!1,clientType:"openai-chat",baseUrl:gl},{modelId:"glm-5.2",displayName:"GLM-5.2",provider:"qwen-token-plan",contextWindow:1048576,pricing:Kt(2,8,28),supportsVision:!1,clientType:"openai-chat",baseUrl:gl},{modelId:"qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"qwen-token-plan",contextWindow:1e6,pricing:Kt(1.5,12,36),supportsVision:!0,clientType:"openai-chat",baseUrl:gl},{modelId:"qwen3.7-plus",displayName:"Qwen 3.7 Plus",provider:"qwen-token-plan",contextWindow:1e6,pricing:Kt(.4,2,8),supportsVision:!0,clientType:"openai-chat",baseUrl:gl},{modelId:"deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:Kt(.2,1,2),supportsVision:!1,clientType:"openai-chat",baseUrl:fo},{modelId:"kimi/kimi-k3",displayName:"Kimi K3",provider:"qwen-pay-as-you-go",contextWindow:1048576,pricing:Kt(2,20,100),supportsVision:!0,clientType:"openai-chat",baseUrl:fo},{modelId:"qwen3.8-flash",displayName:"Qwen 3.8 Flash",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:Kt(.1,1,3),supportsVision:!0,clientType:"openai-chat",baseUrl:fo},{modelId:"qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:Kt(1.5,12,36),supportsVision:!0,clientType:"openai-chat",baseUrl:fo},{modelId:"qwen3.7-plus",displayName:"Qwen 3.7 Plus",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:Kt(.4,2,8),supportsVision:!0,clientType:"openai-chat",baseUrl:fo},{modelId:"ZHIPU/GLM-5.2",displayName:"GLM-5.2",provider:"qwen-pay-as-you-go",contextWindow:1048576,pricing:Kt(2,8,28),supportsVision:!1,clientType:"openai-chat",baseUrl:fo},{modelId:"MiniMax-M3",displayName:"MiniMax M3",provider:"minimax",contextWindow:1e6,pricing:Fe(.06,.3,1.2),supportsVision:!0,clientType:"minimax-m3",baseUrl:QP},{modelId:"gemini-3.7-flash",displayName:"Gemini 3.7 Flash",provider:"google",contextWindow:1048576,pricing:Fe(.15,1.5,7.5),supportsVision:!0},{modelId:"gemini-3.6-flash",displayName:"Gemini 3.6 Flash",provider:"google",contextWindow:1048576,pricing:Fe(.15,1.5,7.5),supportsVision:!0},{modelId:"gemini-3.5-flash",displayName:"Gemini 3.5 Flash",provider:"google",contextWindow:1048576,pricing:Fe(.15,1.5,9),supportsVision:!0},{modelId:"gemini-3.5-flash-lite",displayName:"Gemini 3.5 Flash-Lite",provider:"google",contextWindow:1048576,pricing:Fe(.03,.3,2.5),supportsVision:!0},{modelId:"gemini-3.1-flash-lite",displayName:"Gemini 3.1 Flash-Lite",provider:"google",contextWindow:1048576,pricing:Fe(.025,.25,1.5),supportsVision:!0},{modelId:"gemini-3.1-pro-preview",displayName:"Gemini 3.1 Pro (Preview)",provider:"google",contextWindow:1048576,pricing:Fe(.2,2,12),supportsVision:!0},{modelId:"gemini-3-flash-preview",displayName:"Gemini 3 Flash (Preview)",provider:"google",contextWindow:1048576,pricing:Fe(.05,.5,3),supportsVision:!0},{modelId:"claude-fable-5",displayName:"Claude Fable 5",provider:"anthropic",contextWindow:1e6,pricing:Fe(1,12.5,50),supportsVision:!0},{modelId:"claude-opus-5",displayName:"Claude Opus 5",provider:"anthropic",contextWindow:1e6,pricing:Fe(.5,6.25,25),supportsVision:!0},{modelId:"claude-opus-4-8",displayName:"Claude Opus 4.8",provider:"anthropic",contextWindow:1e6,pricing:Fe(.5,6.25,25),supportsVision:!0},{modelId:"claude-opus-4-7",displayName:"Claude Opus 4.7",provider:"anthropic",contextWindow:1e6,pricing:Fe(.5,6.25,25),supportsVision:!0},{modelId:"claude-sonnet-5",displayName:"Claude Sonnet 5",provider:"anthropic",contextWindow:1e6,pricing:Fe(.2,2.5,10),supportsVision:!0},{modelId:"claude-sonnet-4-6",displayName:"Claude Sonnet 4.6",provider:"anthropic",contextWindow:1e6,pricing:Fe(.3,3.75,15),supportsVision:!0},{modelId:"gpt-5.6",displayName:"GPT-5.6 Sol",provider:"openai",contextWindow:105e4,pricing:Fe(.5,5,30),supportsVision:!0},{modelId:"gpt-5.6-luna",displayName:"GPT-5.6 Luna",provider:"openai",contextWindow:105e4,pricing:Fe(.02,.2,1.2),supportsVision:!0},{modelId:"gpt-5.6-terra",displayName:"GPT-5.6 Terra",provider:"openai",contextWindow:105e4,pricing:Fe(.2,2,12),supportsVision:!0},{modelId:"gpt-5.5",displayName:"GPT-5.5",provider:"openai",contextWindow:105e4,pricing:Fe(.5,5,30),supportsVision:!0},{modelId:"gpt-5.5-pro",displayName:"GPT-5.5 Pro",provider:"openai",contextWindow:105e4,pricing:Fe(30,30,180),supportsVision:!0},{modelId:"gpt-5.4",displayName:"GPT-5.4",provider:"openai",contextWindow:105e4,pricing:Fe(.25,2.5,15),supportsVision:!0},{modelId:"gpt-5.4-mini",displayName:"GPT-5.4 mini",provider:"openai",contextWindow:4e5,pricing:Fe(.075,.75,4.5),supportsVision:!0},{modelId:"gpt-5.4-nano",displayName:"GPT-5.4 nano",provider:"openai",contextWindow:4e5,pricing:Fe(.02,.2,1.25),supportsVision:!0},{modelId:"gpt-5.4-pro",displayName:"GPT-5.4 Pro",provider:"openai",contextWindow:105e4,pricing:Fe(30,30,180),supportsVision:!0},{modelId:"glm-5.3",displayName:"GLM-5.3",provider:"zhipu",contextWindow:1e6,pricing:Fe(.26,1.4,4.4),supportsVision:!1},{modelId:"glm-5.3-flash",displayName:"GLM-5.3 Flash",provider:"zhipu",contextWindow:1e6,pricing:Fe(.03,.15,.5),supportsVision:!0},{modelId:"glm-5.2",displayName:"GLM-5.2",provider:"zhipu",contextWindow:1e6,pricing:Fe(.26,1.4,4.4),supportsVision:!1},{modelId:"glm-5.1",displayName:"GLM-5.1",provider:"zhipu",contextWindow:2e5,pricing:Fe(.26,1.4,4.4),supportsVision:!1},{modelId:"glm-5",displayName:"GLM-5",provider:"zhipu",contextWindow:2e5,pricing:Fe(.2,1,3.2),supportsVision:!1},{modelId:"kimi-k3",displayName:"Kimi K3",provider:"moonshot",contextWindow:1048576,pricing:Kt(2,20,100),supportsVision:!0},{modelId:"kimi-k2.6",displayName:"Kimi K2.6",provider:"moonshot",contextWindow:262144,pricing:Kt(1.1,6.5,27),supportsVision:!0},{modelId:"kimi-k2.5",displayName:"Kimi K2.5",provider:"moonshot",contextWindow:262144,pricing:Kt(.7,4,21),supportsVision:!0}];function ZP(e){if(e!==void 0)return e.trim().toLowerCase()==="openai"?"openai-chat":e}function G0(e,t){return gT.find(n=>n.provider===e&&n.modelId===t)}function Ws(e){return es.find(t=>t.id===e)}function JP(e,t){const s=t?.toLowerCase()||e.toLowerCase(),o=c=>({envKey:`${c}_API_KEY`,envBaseUrlKey:`${c}_BASE_URL`});if(s.includes("gemini-3")||s.includes("gemini-embedding"))return o("GEMINI");if(s.includes("claude")&&(s.includes("4-7")||s.includes("4-8")||s.includes("-5")||s.includes("4-6")))return o("ANTHROPIC");if(s.includes("gpt-5.4")||s.includes("gpt-5.5")||s.includes("gpt-5.6"))return o("OPENAI");if(s.includes("glm-5"))return o("ZAI");if(s.includes("kimi-k3")||s.includes("kimi-k2.5")||s.includes("kimi-k2.6"))return o("MOONSHOT");if(s==="minimax-m3"&&e.toLowerCase()==="minimax-m3")return o("MINIMAX");if(s.includes("deepseek-v4"))return o("DEEPSEEK");if(s.includes("ant-messages"))return o("ANTHROPIC");if(s.includes("openai"))return o("OPENAI")}function ez(e,t,n){const s=t?.toLowerCase()||e.toLowerCase();if(s==="minimax-m3")return"openai";if(!(s.includes("gemini-3")||s.includes("gemini-embedding"))){if(s.includes("claude")&&(s.includes("4-6")||s.includes("4-7")||s.includes("4-8")||s.includes("-5")))return n?.startsWith("bedrock://")||e.includes("4-6")?void 0:"anthropic";if(s.includes("gpt-5.4")||s.includes("gpt-5.5")||s.includes("gpt-5.6"))return"openai";if(!s.includes("glm-5")&&!(s.includes("kimi-k3")||s.includes("kimi-k2.5")||s.includes("kimi-k2.6"))&&!s.includes("deepseek-v4")){if(s.includes("ant-messages"))return"anthropic";if(s.includes("openai-responses"))return"openai";if(!(s.includes("openai")&&s.includes("embedding"))&&s.includes("openai"))return"openai"}}}function tz(){return gT.map(e=>({provider:e.provider,model_id:e.modelId,...e.contextWindow!==void 0?{context_window:e.contextWindow}:{},...e.clientType!==void 0?{client_type:e.clientType}:{},...e.pricing?{pricing:{...e.pricing}}:{},...e.supportsVision?{}:{vision:!1},...e.baseUrl!==void 0?{base_url:e.baseUrl}:{}}))}function $S(e,t){if(e==="openrouter")return`https://openrouter.ai/${t}`;if(e==="qwen-token-plan")return`https://www.qianwenai.com/models/${t}`;if(e==="fireworks"){const n=/^accounts\/([^/]+)\/models\/(.+)$/.exec(t);return n?`https://app.fireworks.ai/models/${n[1]}/${n[2]}`:Ws(e)?.modelsUrl}if(e==="tokendance")return`https://tokendance.space/models/${t}`;if(e==="qwen-pay-as-you-go")return`https://www.qianwenai.com/models/${encodeURIComponent(t)}`;if(e==="zhipu")return`https://docs.z.ai/guides/llm/${t}`;if(e==="moonshot"){const n=/^kimi-k(\d+)\.(\d+)$/.exec(t);return n?`https://platform.kimi.com/docs/pricing/chat-k${n[1]}${n[2]}`:Ws(e)?.modelsUrl}if(e!=="custom")return Ws(e)?.modelsUrl}const xT=e=>`penguin.modelsGroupOrder.${e}`;function K0(e,t){return e===null?[]:Kx(xT(e),t)}function nz(e,t,n){e!==null&&Wx(xT(e),t,n)}function rz(e,t,n){if(n.length===0)return[...e];const s=new Map(n.map((u,f)=>[u,f])),o=[],c=[];for(const u of e)(s.has(t(u))?o:c).push(u);return o.sort((u,f)=>(s.get(t(u))??0)-(s.get(t(f))??0)),[...o,...c]}function az(e,t,n,s,o){const c=new Set(e),u=[...e,...t.filter(p=>!c.has(p))],f=Yx(u,n,s,o);return f===u?e:f}function zt(e,t){return!!e&&!!t&&e.provider===t.provider&&e.modelId===t.modelId}function Qm(e){return{id:e,label:e,envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL"}}function yT(e,t){const n=t.trim().toLowerCase();if(!n)return!0;const s=es.find(o=>o.id===e.provider);return e.modelId.toLowerCase().includes(n)||(e.displayName??"").toLowerCase().includes(n)||e.provider.toLowerCase().includes(n)||(s?.label??"").toLowerCase().includes(n)}function bT(e){return[...new Set(e.map(t=>t.provider).filter(t=>!es.some(n=>n.id===t)))].sort()}function sz(e){return[...es.map(t=>t.id),...bT(e)]}function vT(e,t,n=[]){const s=t.trim()!=="",o=e.filter(p=>yT(p,t)),c=es.map(p=>({provider:p,rows:o.filter(h=>h.provider===p.id)})),u=bT(o).map(p=>({provider:Qm(p),rows:o.filter(h=>h.provider===p)}));return rz([...c,...u],p=>p.provider.id,n).filter(p=>p.rows.length>0||!s&&p.provider.id==="custom")}function iz(e,t=[]){return vT(e,"",t).flatMap(n=>n.rows)}function Ol(e){return!!e.credential?.apiKeyMasked||!!e.envKeyMasked}function kT(e){return e?[e.cacheRead,e.cacheWrite,e.output].every(t=>typeof t=="string"?t.trim()!==""&&Number(t)===0:t===0):!1}function US(e,{showAll:t,query:n,selected:s,defaultModel:o,groupOrder:c}){const u=iz(e,c);return(t||!u.some(Ol)?u:u.filter(p=>Ol(p)||zt(p,s)||zt(p,o))).filter(p=>yT(p,n))}function Ru({open:e,setOpen:t,leading:n,label:s,labelClassName:o="",muted:c=!1,title:u,ariaLabel:f,ariaHaspopup:p="listbox",disabled:h=!1,menuClass:x,children:g}){return a.jsx(Qn,{open:e,setOpen:t,menuClass:x,portal:{direction:"down",align:"left"},button:a.jsxs("button",{type:"button",title:u,"aria-label":f,"aria-haspopup":p,"aria-expanded":e,disabled:h,onClick:()=>t(!e),className:`flex w-full items-center gap-2 text-left ${Uf} ${Pf.sm} disabled:cursor-not-allowed disabled:opacity-60`,children:[n,a.jsx("span",{className:`min-w-0 flex-1 truncate ${c?"text-gray-400":""} ${o}`,children:s}),a.jsx(ns,{className:"text-gray-400"})]}),children:g})}function hu(e){return e.displayName??e.modelId}const oz="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4M2 2l20 20";function Ey({items:e,itemKey:t,isCurrent:n,query:s,onQueryChange:o,searchPlaceholder:c,emptyText:u,onPick:f,renderRow:p,footer:h}){const[x,g]=y.useState(-1),v=x>=0&&x<e.length?t(e[x]):null,w=S=>{if(e.length!==0){if(S.key==="ArrowDown"){S.preventDefault(),g(C=>(C+1)%e.length);return}if(S.key==="ArrowUp"){S.preventDefault(),g(C=>C<=0?e.length-1:C-1);return}(S.key==="Enter"&&!S.shiftKey||S.key==="Tab")&&!S.nativeEvent.isComposing&&(S.preventDefault(),f(e[x>=0?x:0]))}};return a.jsxs("div",{className:"contents",onKeyDown:w,children:[a.jsx("div",{className:"border-b border-gray-100 px-2 pb-1.5 pt-0.5 dark:border-gray-800",children:a.jsx("input",{autoFocus:!0,value:s,onChange:S=>{o(S.target.value),g(-1)},placeholder:c,"aria-label":c,...Gu,className:"w-full rounded border border-transparent bg-transparent px-1 py-0.5 text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:text-gray-200 dark:placeholder:text-gray-500"})}),a.jsxs("div",{className:"max-h-56 overflow-y-auto",children:[e.length===0&&a.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:u}),e.map(S=>{const C=t(S),N=n?.(S)??!1;return a.jsxs("button",{type:"button",ref:C===v?T=>T?.scrollIntoView({block:"nearest"}):void 0,onClick:()=>f(S),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${N?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}${C===v?" bg-gray-100 dark:bg-gray-800":""}`,children:[p(S),a.jsx("span",{className:"w-3 shrink-0 text-center text-xs",children:N?"✓":""})]},C)})]}),h]})}function wT({models:e,value:t,defaultModel:n,onPick:s}){const[o,c]=y.useState(""),[u,f]=y.useState(!1),{currentProject:p}=en(),h=p?.projectId??null,x=y.useMemo(()=>K0(h),[h]),g=US(e,{showAll:u,query:o,selected:t,defaultModel:n,groupOrder:x}),v=u?0:US(e,{showAll:!0,query:o,selected:t,defaultModel:n,groupOrder:x}).length-g.length;return a.jsx(Ey,{items:g,itemKey:w=>`${w.provider}:${w.modelId}`,isCurrent:w=>zt(w,t),query:o,onQueryChange:c,searchPlaceholder:d.models.searchPlaceholder,emptyText:d.models.noSearchResults,onPick:s,renderRow:w=>a.jsxs(a.Fragment,{children:[a.jsx(jo,{provider:w.provider,className:"h-4 w-4 shrink-0"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:hu(w)}),kT(w.pricing)&&a.jsx("span",{className:"shrink-0",children:a.jsx(On,{tone:"yellow",children:d.models.freeBadge})}),!Ol(w)&&a.jsx("span",{role:"img",title:d.models.noKey,"aria-label":d.models.noKey,className:"shrink-0 text-gray-400 dark:text-gray-500",children:a.jsx(Oe,{d:oz,size:13})}),zt(w,n)&&a.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:d.models.default})]}),...v>0?{footer:a.jsx("div",{className:"border-t border-gray-100 dark:border-gray-800",children:a.jsx("button",{type:"button",onClick:()=>f(!0),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-600 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-300",children:d.models.showModelsWithoutKey(v)})})}:{}})}function Ay({models:e,value:t,defaultModel:n,onChange:s,disabled:o,variant:c="pill"}){const[u,f]=y.useState(!1),p=e.find(v=>zt(v,t)),h=p?hu(p):t?.modelId??"…",x=a.jsx(jo,{provider:p?.provider??t?.provider??"custom",className:"h-4 w-4 shrink-0"}),g=a.jsx(wT,{models:e,value:t,...n!==void 0?{defaultModel:n}:{},onPick:v=>{s({provider:v.provider,modelId:v.modelId}),f(!1)}});return c==="form"?a.jsx(Ru,{open:u,setOpen:f,leading:x,label:h,title:`${d.chat.chooseModel}:${h}`,ariaLabel:d.chat.chooseModel,ariaHaspopup:"listbox",disabled:o||e.length===0,menuClass:"w-max min-w-56 origin-top-left",children:g}):a.jsx(Qn,{open:u,setOpen:f,menuClass:"w-max min-w-56 origin-top-right",portal:{direction:"down",align:"right"},button:a.jsxs("button",{type:"button",title:`${d.chat.chooseModel}:${h}`,"aria-label":d.chat.chooseModel,disabled:o||e.length===0,onClick:()=>f(!u),className:"flex h-8 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[x,a.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:h}),a.jsx(ns,{size:Ye.caretDense})]}),children:g})}const lz=/^[\w-]*$/;function PS(e,t){const n=e.slice(0,t),s=n.lastIndexOf("/");if(s<0||s>0&&!/\s/.test(n[s-1]))return null;const o=n.slice(s+1);if(!lz.test(o))return null;const c=/^[\w-]*/.exec(e.slice(t))[0];return{start:s,end:t+c.length,query:o}}function cz(e,t){const n=e.slice(0,t.start),s=e.slice(t.end),o=n.endsWith(" ")&&s.startsWith(" ")?n+s.slice(1):n+s;return/^\s*$/.test(o)?"":o}const uz=["none","low","medium","high","xhigh","max"],ST=["low","medium","high","xhigh","max"];function dz(e,t){return e||(t??"medium")}function W0(e,t){return t&&uz.includes(t)?e[t]??t:null}function Hg(e,t){return e||t}function mz(e,t,n){const s=e.filter(([o])=>o!=="").map(([o,c])=>({value:o,triggerLabel:o,label:o,description:c}));return n==="none"&&s.push({value:"none",triggerLabel:"none",label:"none",description:t}),s}function fz(e){let t=e.length-1,n=!1;for(;t>=0&&e[t].kind==="compaction";){const s=e[t];!s.running&&s.status==="completed"&&(n=!0),t--}return t<0?!1:!n}function pz(e,t,n){return t!==""&&n===t?!1:fz(e)}function jT(e){let t=0,n=0;for(const s of e)s.kind!=="compaction"||s.running===!0||(t++,s.status==="completed"&&n++);return{settled:t,completed:n}}function hz(e,t){const n=jT(e);return n.completed>t.completed?"completed":n.settled>t.settled?"failed":"pending"}function gz(e,t){if(e.phase==="ask")return{act:"wait"};if(e.phase==="settle")return{act:"apply",level:e.level,notice:"none"};const n=hz(t,e.baseline);return n==="pending"?{act:"wait"}:{act:"apply",level:e.level,notice:n==="completed"?"compacted":"compaction-failed"}}function xz(e){const t=e.currentText;return{text:t.trim()?e.recalledText?`${e.recalledText}
171
- ${t}`:t:e.recalledText,dropGoal:e.goalOn&&e.recalledFiles>0}}function yz(e){const t=e.exampleSkills.filter(n=>e.installedSkills.includes(n)&&!e.selectedSkills.includes(n));return{text:e.prompt,skills:[...e.selectedSkills,...t]}}function CT(e){if(TN(e)||EN(e))return null;const t=_l(e);if(t)return{body:t.rest.trim(),scheduled:!1,backgroundDone:!0};const n=AN(e),s=n?n.rest:e,o=MN(s),c=o?o.rest:s,u=CN(c),{text:f}=df(u?u.rest:c);return{body:f.trim(),...n?{goalRound:n.round}:{},scheduled:o!==null}}function bz(e){const t=[],n=s=>{s!==""&&t[t.length-1]!==s&&t.push(s)};for(const s of e)if(s.kind==="user_text"){const o=CT(s.text);if(!o||o.scheduled||o.backgroundDone||o.goalRound!==void 0&&o.goalRound>1)continue;n(o.body)}else s.kind==="user_steering"&&n(df(s.text).text.trim());return t}function vz(e,t,n){if(e.length===0)return null;if(t===null){if(n.trim()!=="")return null;const c=e.length-1,u=e[c];return{nav:{index:c,stash:n,recalled:u},text:u}}if(n!==t.recalled)return null;if(t.index===0)return{nav:t,text:t.recalled};const s=t.index-1,o=e[s];return{nav:{...t,index:s,recalled:o},text:o}}function kz(e,t,n){if(t===null||n!==t.recalled)return null;if(t.index>=e.length-1)return{nav:null,text:t.stash};const s=t.index+1,o=e[s];return{nav:{...t,index:s,recalled:o},text:o}}function wz(e,t){return!e.slice(0,t).includes(`
172
- `)}function Sz(e,t){return!e.slice(t).includes(`
173
- `)}function jz(e){if(e.sending)return"disabled";const t=!e.goalOn;return t&&e.canSteerChannel&&!e.hasHandoffTarget&&!e.hasPendingModel&&(e.hasText||e.hasImages||e.hasFiles)&&!e.followUpMode?"steer":t&&e.canQueueChannel&&e.stagedRoute!=="blocked"&&e.hasContent?"queue":"stop"}function Cz(e,t){return e==="compacting"?!0:e==="running"&&t==="stop"}function _y(e){return e!=null&&e.includes("Files")}function Nz(e,t,n){const s=t&&n;switch(e){case"over":return{active:s,claim:s,accept:!1};case"leave":return{active:s,claim:!1,accept:!1};case"drop":return{active:!1,claim:s,accept:s};case"end":return{active:!1,claim:!1,accept:!1}}}function Tz(e){const t=[],n=[];for(const s of e)(s.type.startsWith("image/")?t:n).push(s);return{images:t,files:n}}function zS(e){e.defaultPrevented||!_y(e.dataTransfer?.types)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))}function BS(e){e.defaultPrevented||!_y(e.dataTransfer?.types)||e.preventDefault()}const NT=y.createContext(null);function Mz({className:e,children:t}){const[n,s]=y.useState(null);return a.jsx("div",{className:e,ref:s,children:a.jsx(NT.Provider,{value:n,children:t})})}function Ez({onFiles:e}){const t=y.useContext(NT),[n,s]=y.useState(!1),o=y.useRef(!1),c=y.useRef(e);return y.useEffect(()=>{c.current=e}),y.useEffect(()=>{if(!t)return;const u=v=>v instanceof Node&&t.contains(v),f=(v,w,S)=>{const C=Nz(v,_y(w.dataTransfer?.types),S);return o.current!==C.active&&(o.current=C.active,s(C.active)),C.claim&&(w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="copy")),C},p=v=>{f("over",v,u(v.target))},h=v=>{f("leave",v,u(v.relatedTarget))},x=v=>{if(!f("drop",v,u(v.target)).accept||!v.dataTransfer)return;const S=Array.from(v.dataTransfer.files);S.length>0&&c.current(S)},g=v=>{f("end",v,!1)};return window.addEventListener("dragover",p),window.addEventListener("dragleave",h),window.addEventListener("drop",x),window.addEventListener("dragend",g),()=>{window.removeEventListener("dragover",p),window.removeEventListener("dragleave",h),window.removeEventListener("drop",x),window.removeEventListener("dragend",g),o.current=!1,s(!1)}},[t]),!n||!t?null:ss.createPortal(a.jsx("div",{"aria-hidden":!0,className:"anim-fade pointer-events-none absolute inset-0 z-50 flex items-center justify-center bg-white/70 p-6 backdrop-blur-sm dark:bg-gray-950/70",children:a.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-xl border-2 border-dashed border-gray-400 bg-white/80 px-10 py-8 text-center dark:border-gray-500 dark:bg-gray-900/80",children:[a.jsx(Oe,{d:bf,size:28,className:"text-gray-400 dark:text-gray-500"}),a.jsx("p",{className:"text-base font-medium text-gray-800 dark:text-gray-100",children:d.chat.dropFilesTitle}),a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.chat.dropFilesDesc})]})}),t)}const Az=128e3;function TT(e){const t=typeof e=="string"?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:Az}const Y0=[{text:"text-violet-500",swatch:"bg-violet-500"},{text:"text-amber-500 dark:text-amber-600",swatch:"bg-amber-500 dark:bg-amber-600"},{text:"text-sky-500 dark:text-sky-600",swatch:"bg-sky-500 dark:bg-sky-600"},{text:"text-rose-500",swatch:"bg-rose-500"}];function Ry(e){return Y0[e%Y0.length]}const _z=["bg-sky-500 dark:bg-sky-600","bg-amber-500 dark:bg-amber-600","bg-fuchsia-500 dark:bg-fuchsia-600","bg-rose-500","bg-violet-500","bg-emerald-500 dark:bg-emerald-600"],Xf={text:"text-gray-400 dark:text-gray-500",swatch:"bg-gray-400 dark:bg-gray-500"},HS=["systemPrompt","toolDefs","userMessages","assistantMessages","toolRequests","toolResults"];function Rz(e,t){if(e.contextClosed||e.total<=0)return null;const n=HS.map(c=>e[c]),s=FS(n,t),o=FS(n,100);return{parts:HS.map((c,u)=>({key:c,color:_z[u]??"",tokens:s[u]??0,percent:o[u]??0})),tools:e.topTools.map(c=>({name:c.name,tokens:Math.round(c.tokens/e.total*t),percent:Math.round(c.tokens/e.total*100)}))}}function FS(e,t){const n=e.reduce((f,p)=>f+p,0);if(n<=0)return e.map(()=>0);const s=e.map(f=>f/n*t),o=s.map(f=>Math.floor(f));let c=Math.round(t)-o.reduce((f,p)=>f+p,0);const u=s.map((f,p)=>({i:p,frac:f-Math.floor(f)})).sort((f,p)=>p.frac-f.frac||f.i-p.i);for(const{i:f}of u){if(c<=0)break;o[f]=(o[f]??0)+1,c-=1}return o}const qS=300,Iz="calc(100vw - 32px)",Lz=264,Oz=2,Fg=4;function Dz({now:e,window:t,unknown:n=!1,sessionId:s}){const o=TT(t),c=n?0:Math.min(1,e/o),[u,f]=y.useState(!1),p=y.useId(),{triggerRef:h,panelRef:x,position:g}=$f({open:u,onClose:()=>f(!1),estimatedHeight:Lz,panelWidth:qS}),v=n||c<=.8?"text-gray-400 dark:text-gray-500":c>.95?sn.danger:sn.attention,w=n?d.chat.contextUnknown:`${d.chat.contextUsage} ${Math.round(c*100)}% · ${It(e)}/${It(o)}`,S=5,C=2*Math.PI*S,N=a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":!0,className:"block shrink-0",children:[a.jsx("circle",{cx:"7",cy:"7",r:S,fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"2"}),a.jsx("circle",{cx:"7",cy:"7",r:S,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:`${C*c} ${C}`,transform:"rotate(-90 7 7)"})]}),T=`flex h-8 w-8 shrink-0 items-center justify-center ${v}`;return s===void 0?a.jsx("span",{title:w,"aria-label":w,role:"img",className:T,children:N}):a.jsxs(a.Fragment,{children:[a.jsx("button",{ref:h,type:"button",title:w,"aria-label":w,"aria-expanded":u,"aria-controls":p,onClick:()=>f(_=>!_),className:`${T} rounded-md transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800`,children:N}),u&&g&&ss.createPortal(a.jsx("div",{ref:x,id:p,role:"group","aria-label":d.chat.contextComposition,style:{position:"fixed",top:g.topPx,bottom:g.bottomPx,left:g.left,width:qS,maxWidth:Iz},className:"anim-pop z-[60] rounded-md border border-gray-200 bg-white p-2.5 text-xs shadow-lg dark:border-gray-700 dark:bg-gray-900",children:a.jsx($z,{sessionId:s,now:e,max:o,pct:c,unknown:n})}),document.body)]})}function $z({sessionId:e,now:t,max:n,pct:s,unknown:o}){const[c,u]=y.useState({status:"loading"}),[f,p]=y.useState(null);y.useEffect(()=>{let S=!1;return u({status:"loading"}),pA(e).then(C=>{S||u({status:"ready",data:C})},()=>{S||u({status:"failed"})}),()=>{S=!0}},[e]);const h=c.status==="ready"?c.data:null,x=o||h?.contextClosed===!0,g=h===null?null:Rz(h,t),v=g?.parts.some(S=>S.key===f)?f:null,w=h!==null&&h.compactionThreshold!==null&&h.compactionThreshold<n?h.compactionThreshold:null;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[a.jsxs("span",{className:"flex items-baseline gap-1.5",children:[a.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:d.chat.contextUsage}),a.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:x?"—":Lf(s)})]}),a.jsxs("span",{className:"font-mono text-gray-500 dark:text-gray-400",children:[x?"—":It(t)," / ",It(n)]})]}),x?a.jsx("p",{className:"mt-2 leading-relaxed text-gray-400 dark:text-gray-500",children:d.chat.contextUnknownHint}):c.status==="loading"?a.jsx("p",{className:"mt-2 text-gray-400 dark:text-gray-500",children:d.common.loading}):c.status==="failed"?a.jsx("p",{className:"mt-2 text-gray-400 dark:text-gray-500",children:d.chat.contextBreakdownFailed}):g===null?a.jsx("p",{className:"mt-2 text-gray-400 dark:text-gray-500",children:d.chat.contextBreakdownEmpty}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{"aria-hidden":!0,className:"relative mt-2 h-2 bg-gray-200 dark:bg-gray-800",style:{marginBottom:Fg},children:[a.jsx("div",{className:"absolute inset-y-0 left-0 flex overflow-hidden",style:{width:`${t/n*100}%`,minWidth:t>0?Oz:0},children:g.parts.map(S=>S.tokens>0?a.jsx("span",{title:`${VS[S.key]()} ~${It(S.tokens)} · ${S.percent}%`,onMouseEnter:()=>p(S.key),onMouseLeave:()=>p(null),style:{flexGrow:S.tokens,flexBasis:0},className:`h-full transition-opacity duration-150 ${S.color} ${v!==null&&v!==S.key?"opacity-25":""}`},S.key):null)}),w!==null&&a.jsx("span",{title:d.chat.contextCompactAt(It(w)),style:{left:`${w/n*100}%`,top:-Fg,bottom:-Fg},className:"absolute border-l border-dashed border-gray-500 dark:border-gray-400"})]}),a.jsx("ul",{className:"mt-2 space-y-0.5",children:g.parts.map(S=>a.jsx(GS,{label:VS[S.key](),swatch:S.color,tokens:S.tokens,percent:S.percent,highlighted:f===S.key,onHover:C=>p(C?S.key:null)},S.key))}),g.tools.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("p",{title:d.chat.contextTopToolsHint,className:"mt-2 border-t border-gray-100 pt-1.5 text-gray-400 dark:border-gray-800 dark:text-gray-500",children:d.chat.contextTopTools}),a.jsx("ul",{className:"mt-1 space-y-0.5",children:g.tools.map(S=>a.jsx(GS,{label:S.name,mono:!0,tokens:S.tokens,percent:S.percent,highlighted:f===`tool:${S.name}`,onHover:C=>p(C?`tool:${S.name}`:null)},S.name))})]})]})]})}const VS={systemPrompt:()=>d.chat.contextPartSystemPrompt,toolDefs:()=>d.chat.contextPartToolDefs,userMessages:()=>d.chat.contextPartUserMessages,assistantMessages:()=>d.chat.contextPartAssistantMessages,toolRequests:()=>d.chat.contextPartToolRequests,toolResults:()=>d.chat.contextPartToolResults};function GS({label:e,swatch:t,tokens:n,percent:s,mono:o=!1,highlighted:c=!1,onHover:u}){return a.jsxs("li",{onMouseEnter:()=>u?.(!0),onMouseLeave:()=>u?.(!1),className:`-mx-1 flex items-center gap-1.5 rounded px-1 py-px transition-colors duration-150 ${c?"bg-gray-100 dark:bg-gray-800":""}`,children:[t!==void 0&&a.jsx("span",{"aria-hidden":!0,className:`h-2 w-2 shrink-0 rounded-[2px] ${t}`}),a.jsx("span",{title:e,className:`min-w-0 flex-1 truncate text-gray-600 dark:text-gray-300 ${o?"font-mono":""}`,children:e}),a.jsxs("span",{className:"shrink-0 font-mono font-medium text-gray-900 dark:text-gray-100",children:["~",It(n)]}),a.jsxs("span",{className:"w-8 shrink-0 text-right font-mono text-gray-400 dark:text-gray-500",children:[s,"%"]})]})}const Uz=1024*1024;function KS(e,t){const n=t*Uz,s=[],o=[];for(const c of e)c.size>n?o.push(c):s.push(c);return{accepted:s,rejected:o}}const Pz=["always-ask","read-only","allow-all","deny-all"],WS={"allow-all":"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0zM12 9v4m0 4h.01","deny-all":"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM5.64 5.64l12.72 12.72","read-only":"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7zM15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0z","always-ask":"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9.1 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3m.07 4h.01"};function zz({value:e,onChange:t,disabled:n,direction:s="up"}){const[o,c]=y.useState(!1);return a.jsx(Qn,{open:o,setOpen:c,menuClass:"w-max",portal:{direction:s,align:"left"},button:a.jsxs("button",{type:"button","aria-label":d.chat.approvalMode,title:`${d.chat.approvalMode}:${d.chat.approvalModeNames[e]??e}`,disabled:n,onClick:()=>c(u=>!u),className:"flex h-8 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[a.jsx(Oe,{d:WS[e]}),a.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:d.chat.approvalModeNames[e]??e}),a.jsx(ns,{size:Ye.caretDense})]}),children:Pz.map(u=>a.jsxs("button",{type:"button",onClick:()=>{t(u),c(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${u===e?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"shrink-0 text-gray-400 dark:text-gray-500",children:a.jsx("path",{d:WS[u]})}),a.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-nowrap",children:d.chat.approvalModes[u]??u}),a.jsx("span",{className:"w-3 shrink-0 text-center",children:u===e?"✓":""})]},u))})}function Bz({agents:e,currentAgentId:t,onPick:n}){const[s,o]=y.useState("");return a.jsx(Ey,{items:eP(e,s),itemKey:c=>c.agentId,isCurrent:c=>c.agentId===t,query:s,onQueryChange:o,searchPlaceholder:d.chat.agentSearchPlaceholder,emptyText:d.chat.agentsNoMatch,onPick:n,renderRow:c=>a.jsxs(a.Fragment,{children:[a.jsx(Ha,{id:c.agentId,name:_n(c),size:16,className:"shrink-0 rounded"}),a.jsx("span",{className:"shrink-0 font-mono text-gray-800 dark:text-gray-200",children:c.agentId}),c.name&&c.name!==c.agentId&&a.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:c.name})]})})}function YS({panelRef:e,maxHeight:t,title:n,children:s}){return a.jsxs("div",{ref:e,style:{maxHeight:t},className:"anim-pop absolute bottom-full left-0 z-40 mb-1.5 flex w-80 max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[a.jsx("div",{className:"border-b border-gray-100 px-3 pb-1.5 pt-0.5 text-xs font-semibold text-gray-500 dark:border-gray-800 dark:text-gray-400",children:n}),s]})}const Hz="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z";function XS({value:e,onChange:t,disabled:n,direction:s="down"}){const[o,c]=y.useState(!1),u=e===null?"…":W0(d.chat.thinkingLevelNames,e)??"—";return a.jsxs(Qn,{open:o,setOpen:c,menuClass:"w-max min-w-36",portal:{direction:s,align:"right"},button:a.jsxs("button",{type:"button",title:`${d.chat.thinkingLevel}:${u}`,"aria-label":d.chat.thinkingLevel,disabled:n||e===null,onClick:()=>c(!o),className:"flex h-8 max-w-36 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[a.jsx(Oe,{d:Hz,className:"shrink-0"}),a.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:u}),a.jsx(ns,{size:Ye.caretDense})]}),children:[a.jsx("div",{className:"border-b border-gray-100 px-3 pb-1.5 pt-0.5 text-xs font-semibold text-gray-500 dark:border-gray-800 dark:text-gray-400",children:d.chat.thinkingLevel}),ST.map(f=>a.jsxs("button",{type:"button",onClick:()=>{t(f),c(!1)},className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${f===e?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[a.jsx("span",{className:"min-w-0 flex-1 truncate",children:d.chat.thinkingLevelMenuName(d.chat.thinkingLevelNames[f]??f,f)}),a.jsx("span",{className:"w-3 shrink-0 text-center",children:f===e?"✓":""})]},f))]})}const MT="penguin.steerMode";function Fz(){return localStorage.getItem(MT)==="followup"?"followup":"steer"}const qz="M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6";function Vz({steerMode:e,onChangeSteerMode:t}){const n=(s,o,c)=>a.jsx("button",{type:"button",title:c,"aria-pressed":e===s,onClick:()=>t(s),className:`h-5 rounded px-1.5 text-xs transition-colors duration-150 ${e===s?"bg-gray-200 font-medium text-gray-800 dark:bg-gray-700 dark:text-gray-100":"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200"}`,children:o});return a.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-1 text-xs",children:[a.jsx(Oe,{d:qz,className:"shrink-0 text-gray-400 dark:text-gray-500"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-600 dark:text-gray-400",children:d.chat.steerModeLabel}),a.jsxs("div",{role:"group","aria-label":d.chat.steerModeLabel,className:"flex shrink-0 items-center gap-0.5",children:[n("steer",d.chat.steerModeSteer,d.chat.steerModeSteerHint),n("followup",d.chat.steerModeFollowUp,d.chat.steerModeFollowUpHint)]})]})}function Gz({skills:e,selected:t,onToggle:n,disabled:s,direction:o="up"}){const[c,u]=y.useState(!1);return a.jsx(Qn,{open:c,setOpen:u,menuClass:"w-[26rem]",portal:{direction:o,align:"left"},button:a.jsxs("button",{type:"button","aria-label":d.chat.skillsSelect,title:d.chat.skillsSelect,disabled:s,onClick:()=>u(!c),className:"flex h-8 max-w-44 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[a.jsx(Oe,{d:My,className:"shrink-0"}),a.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:d.chat.skillsSelect}),t.length>0&&a.jsx("span",{className:"shrink-0 rounded-full bg-gray-200/80 px-1.5 py-px font-mono text-[10px] font-semibold text-gray-700 dark:bg-gray-700/60 dark:text-gray-200",children:t.length}),a.jsx(ns,{size:Ye.caretDense})]}),children:a.jsx(q0,{skills:e,selected:t,onToggle:n,emptyHint:d.chat.skillsEmptyHint})})}const Kz="M6 5h12a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3zM3 15l5-5 4 4 3-3 6 6";function Wz({items:e,footer:t,direction:n="up"}){const[s,o]=y.useState(!1);return a.jsxs(Qn,{open:s,setOpen:o,menuClass:"w-72",portal:{direction:n,align:"left"},button:a.jsx("button",{type:"button","aria-label":d.chat.plusMenu,title:d.chat.plusMenu,onClick:()=>o(!s),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(Oe,{d:"M12 5v14M5 12h14",size:15,className:"shrink-0"})}),children:[e.map(c=>a.jsxs("button",{type:"button","aria-pressed":c.active,disabled:c.disabled,onClick:()=>{o(!1),c.onSelect()},className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors duration-150 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent dark:hover:bg-gray-800 dark:disabled:hover:bg-transparent ${c.active?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[a.jsx(Oe,{d:c.icon,className:"shrink-0 text-gray-400 dark:text-gray-500"}),a.jsx("span",{className:"shrink-0",children:c.label}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:c.desc}),a.jsx("span",{className:"w-3 shrink-0 text-center",children:c.active?"✓":""})]},c.key)),t&&a.jsx("div",{className:"mt-1 border-t border-gray-100 pt-1 dark:border-gray-800",children:t})]})}function Yz(e){return new Promise(t=>{const n=new FileReader;n.onload=()=>t(typeof n.result=="string"?n.result:null),n.onerror=()=>t(null),n.readAsDataURL(e)})}function Xz(e){const t=e.slice(e.indexOf(",")+1).replace(/[=\s]+/g,"");return Math.floor(t.length*3/4)}function QS(e){const t=[],n=e.text.replace(/\s+/g," ").trim();return n&&t.push(n),e.images>0&&t.push(d.chat.imagesInMessage(e.images)),e.files>0&&t.push(d.chat.filesInMessage(e.files)),t.join(" · ")}const Qz="M9 14L4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11";function ZS({label:e,onRecall:t,disabled:n}){return a.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[a.jsx("p",{className:"min-w-0 truncate text-xs text-gray-400 dark:text-gray-500",children:e}),t&&a.jsx("button",{type:"button","aria-label":d.chat.recallQueued,title:d.chat.recallQueuedTitle,disabled:n,onClick:t,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 disabled:cursor-not-allowed disabled:opacity-40 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(Oe,{d:Qz,size:13})})]})}function Zz(e,t,n){for(const s of t)e.push({type:"image_url",imageUrl:s});for(const s of n)e.push({type:"file",fileName:s.name,dataUrl:s.dataUrl})}function Iy({status:e,onSend:t,onSteer:n,steeringDeliveredCount:s,pendingSteering:o=[],onRecallSteering:c,onQueueFollowUp:u,queuedFollowUps:f=0,pendingFollowUps:p=[],onRecallFollowUp:h,onStop:x,onCompact:g,modelRef:v,models:w,onChangeModel:S,onSwitchModel:C,defaultModel:N,thinkingLevel:T,onChangeThinkingLevel:_,turnThinkingLevel:R,onChangeTurnThinkingLevel:D,contextWindow:z,contextNow:E,contextStale:L=!1,sessionId:F,vision:V,approvalMode:P,onChangeApprovalMode:B,modeSaving:Y,autoFocus:q,agents:K,currentAgentId:H,skills:$,initialSkills:X,onSkillsChange:le,onHandoff:ie,initialText:I,onTextChange:A,history:Q=[],initialHandoffTargetId:j,onHandoffTargetChange:U,initialPendingModelRef:ee,onPendingModelChange:re,controlRef:ke,variant:be="session"}){const{locale:ye}=Dr(),{uploadLimits:Se}=mn(),[Me,ze]=y.useState(I??""),De=y.useRef(Me);De.current=Me;const[ct,bt]=y.useState([]),[he,ne]=y.useState([]),[oe,J]=y.useState(!1),[ht,ve]=y.useState(0),[Xe,Ge]=y.useState(null),[He,Pe]=y.useState(!1),W=y.useRef(null),[me,Ue]=y.useState(!1),pe=y.useRef(null),$e=y.useRef(null),[nt,gt]=y.useState(),[Ke,dt]=y.useState(null),[pt,wt]=y.useState(null),[st,Bt]=y.useState(X??[]),[Sn,Dn]=y.useState(0),Vt=y.useRef(null),ar=y.useRef(null),[zn]=y.useState(()=>window.matchMedia("(max-width: 767px)").matches),Xt=e==="running",Cn=e==="compacting",lr=Me.trim().length>0||ct.length>0||he.length>0||Ke!==null||pt!==null||st.length>0,[Mt,Pr]=y.useState(!1),[Bn,Nr]=y.useState(""),[Tr,Te]=y.useState(!1),[Ie,ut]=y.useState(""),St=Mt?Tm(Bn):null,Nn=Tm(Ie)===null,Hn=St!==null&&St!==Ty?d.chat.goalBudgetValue(It(St)):d.chat.goalBudgetUnlimited,Dt=tP({handoffTarget:Ke!==null,pendingModel:pt!==null,canSwitchModel:C!==void 0,sessionBusy:Xt||Cn}),Rn=!Xt&&!Cn&&!oe&&(Mt?Me.trim().length>0&&he.length===0&&St!==null&&!(Tr&&Nn):lr),zr=y.useCallback(ae=>{if(ae){ut(Bn),Te(!0);return}Tm(Ie)!==null&&(Nr(Ie.trim()),Te(!1))},[Bn,Ie]),cr=y.useCallback(()=>{Te(!1),Vt.current?.focus()},[]),Js=y.useCallback(()=>{Tm(Ie)!==null&&(Nr(Ie.trim()),Te(!1),Vt.current?.focus())},[Ie]),Mr=y.useCallback(ae=>{Pr(ae),Te(!1),ut(""),ae&&(Nr(""),dt(null),U?.(null),wt(null),re?.(null),ne([]))},[U,re]),[ta,Br]=y.useState(Fz),is=ae=>{Br(ae),localStorage.setItem(MT,ae)},Hr=ta==="followup"&&u!==void 0,fn=jz({sending:oe,goalOn:Mt,canSteerChannel:n!==void 0,canQueueChannel:u!==void 0,followUpMode:Hr,stagedRoute:Dt,hasHandoffTarget:Ke!==null,hasPendingModel:pt!==null,hasText:Me.trim().length>0,hasImages:ct.length>0,hasFiles:he.length>0,hasContent:lr}),Fr=Xt&&fn==="steer",qr=Xt&&fn==="queue",pn=Fr||qr,na=fn==="queue"?d.chat.followUpSend:d.chat.steerSend,Jn=Cz(e,fn),Er=(()=>{const ae=w?.find(_e=>zt(_e,v));return ae?hu(ae):v?.modelId??"…"})(),[ur,os]=y.useState(!1),ls=y.useRef(0);y.useEffect(()=>{ur&&(!Xt||(s??0)>ls.current||o.length>0)&&os(!1)},[ur,Xt,s,o.length]);const[ra,cs]=y.useState(null),ka=ae=>{const{text:_e,dropGoal:et}=xz({recalledText:ae.text,currentText:Vt.current?.value??Me,recalledFiles:ae.files.length,goalOn:Mt});ze(_e),A?.(_e),Dn(_e.length),ae.images.length>0&&bt(qe=>[...ae.images,...qe]),ae.files.length>0&&(et&&Mr(!1),ne(qe=>[...ae.files.map(vt=>({name:vt.fileName,size:Xz(vt.dataUrl),dataUrl:vt.dataUrl})),...qe])),requestAnimationFrame(()=>{const qe=Vt.current;qe&&(qe.focus(),qe.setSelectionRange(qe.value.length,qe.value.length),qe.scrollTop=qe.scrollHeight)})},Ar=async(ae,_e)=>{if(!(ra!==null||oe)){cs(ae);try{const et=await _e(ae);et&&(os(!1),ka(et))}finally{cs(null)}}},er=y.useCallback(ae=>{const _e=V0(st,ae);Bt(_e),le?.(_e)},[st,le]),Tn=y.useCallback((ae,_e)=>{const et=yz({prompt:ae,exampleSkills:_e,installedSkills:$.map(qe=>qe.name),selectedSkills:st});ze(et.text),A?.(et.text),Dn(0),et.skills.length!==st.length&&(Bt(et.skills),le?.(et.skills)),requestAnimationFrame(()=>{const qe=Vt.current;qe&&(qe.focus(),qe.setSelectionRange(0,0),qe.scrollTop=0)})},[$,st,A,le]);y.useImperativeHandle(ke,()=>({fillExample:Tn}),[Tn]);const Vr=y.useRef(null),wa=y.useMemo(()=>{const ae=()=>{const _e=Vr.current,et=_e?cz(De.current,_e):"";ze(et),A?.(et)};return[...g?[{cmd:"/compact",desc:d.chat.compact,run:()=>{ae(),g()}}]:[],...be==="session"?[{cmd:"/goal",desc:d.chat.goalModeDesc,run:()=>{ae(),Mr(!Mt)}}]:[],...C&&w&&w.length>0?[{cmd:"/model",desc:d.chat.switchModel,run:()=>{ae(),Pe(!0)}}]:[],...ie&&K.length>0?[{cmd:"/agent",desc:d.chat.switchAgent,run:()=>{ae(),Ue(!0)}}]:[],...IP($,ye).map(_e=>({cmd:_e.cmd,desc:_e.desc,run:()=>{ae(),er(_e.name)}}))]},[g,C,w,K,A,$,ye,er,Mr,Mt]),Mn=!Xt&&!Cn&&!He&&!me?PS(Me,Sn):null;Vr.current=Mn;const Gr=Mn&&Mn.start!==Xe?wa.filter(ae=>ae.cmd.startsWith(`/${Mn.query}`)):[],En=Gr.length>0,us=Gr[Math.min(ht,Gr.length-1)];y.useEffect(()=>{if(!He&&!me)return;const ae=()=>{Pe(!1),Ue(!1),Vt.current?.focus()},_e=qe=>{const vt=He?W.current:pe.current;vt&&!vt.contains(qe.target)&&ae()},et=qe=>{qe.key==="Escape"&&!qe.isComposing&&ae()};return window.addEventListener("mousedown",_e),window.addEventListener("keydown",et),()=>{window.removeEventListener("mousedown",_e),window.removeEventListener("keydown",et)}},[He,me]);const hn=ae=>{wt(ae),re?.(ae?{provider:ae.provider,modelId:ae.modelId}:null)},Sa=ae=>{if(Pe(!1),Vt.current?.focus(),zt(ae,v)){hn(null);return}hn(ae),dt(null),U?.(null),Pr(!1)},Ts=ae=>{Ue(!1),dt(ae),U?.(ae.agentId),hn(null),Pr(!1),Vt.current?.focus()},Ga=()=>{Ke!==null&&(dt(null),U?.(null)),hn(null)};y.useEffect(()=>{if(!En&&!He&&!me)return;const ae=()=>{const _e=$e.current;if(!_e)return;let et=0;for(let vt=_e.parentElement;vt;vt=vt.parentElement)if(getComputedStyle(vt).overflowY!=="visible"){et=vt.getBoundingClientRect().top;break}const qe=_e.getBoundingClientRect().top-et-14;gt(Math.max(96,Math.min(320,Math.round(qe))))};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[En,He,me]);const Ct=()=>{const ae=Vt.current;ae&&(ae.style.height="auto",ae.style.height=`${Math.min(ae.scrollHeight,176)}px`)};y.useLayoutEffect(Ct,[Me]),y.useEffect(()=>{const ae=ar.current;ae&&Me!==ae.recalled&&(ar.current=null)},[Me]),y.useEffect(()=>{const ae=Vt.current;if(ae&&ae.value.length>0){const _e=ae.value.length;ae.setSelectionRange(_e,_e),ae.scrollTop=ae.scrollHeight,Dn(_e)}},[]);const ds=y.useRef(!1);y.useEffect(()=>{if(!ds.current&&(ds.current=!0,$.length===0))return;const ae=st.filter(_e=>$.some(et=>et.name===_e));ae.length!==st.length&&(Bt(ae),le?.(ae))},[$,st,le]);const ja=Ke!==null||pt!==null||Mt,br=y.useRef(!1);y.useEffect(()=>{if(br.current||!j||K.length===0||(br.current=!0,ja))return;const ae=K.find(_e=>_e.agentId===j);ae&&dt(ae)},[K,j,ja]);const Ca=y.useRef(!1);y.useEffect(()=>{if(Ca.current||!ee||!w||w.length===0||(Ca.current=!0,ja||!C))return;const ae=w.find(_e=>zt(_e,ee));ae&&!zt(ae,v)&&wt(ae)},[w,ee,v,C,ja]);const de=async(ae=t)=>{const _e=Me.trim();if(Mt){J(!0);try{const tr=[{type:"text",text:jw(st,_e)}];for(const ei of ct)tr.push({type:"image_url",imageUrl:ei});await t(tr,{budget:St})&&(ze(""),bt([]),Bt([]),Mr(!1))}finally{J(!1),Vt.current?.focus()}return}if(Dt==="blocked")return;const et=Dt==="model"?pt:null,qe=_e!==""?_e:st.length>0?d.chat.skillsAutoMessage(st):et?d.chat.modelSwitchAutoMessage:_e,vt=jw(st,qe),xn=[];vt&&xn.push({type:"text",text:vt}),Zz(xn,ct,he),J(!0);try{(Ke?await ie(Ke,xn):et?await C({provider:et.provider,modelId:et.modelId},xn):await ae(xn,null))&&(ze(""),bt([]),ne([]),dt(null),wt(null),Bt([]))}finally{J(!1),Vt.current?.focus()}},Re=async()=>{if(Xt){if(qr){await de(u);return}if(!Fr)return;const ae=Me.trim(),_e=ct,et=he.map(vt=>({fileName:vt.name,dataUrl:vt.dataUrl}));J(!0);let qe="failed";try{qe=await n(ae,_e,et),qe==="queued"&&(ls.current=s??0,os(!0),ze(""),bt([]),ne([]))}finally{J(!1),Vt.current?.focus()}qe==="not_running"&&await de(u??t);return}Rn&&await de()},Qe=ae=>{ar.current=ae.nav,ze(ae.text),A?.(ae.text),Dn(ae.text.length),requestAnimationFrame(()=>{const _e=Vt.current;_e&&(_e.setSelectionRange(_e.value.length,_e.value.length),_e.scrollTop=_e.scrollHeight)})},mt=ae=>{if(En){if(ae.key==="ArrowDown"){ae.preventDefault(),ve(_e=>(_e+1)%Gr.length);return}if(ae.key==="ArrowUp"){ae.preventDefault(),ve(_e=>(_e-1+Gr.length)%Gr.length);return}if((ae.key==="Enter"&&!ae.shiftKey||ae.key==="Tab")&&!ae.nativeEvent.isComposing){ae.preventDefault(),us?.run();return}if(ae.key==="Escape"){Ge(Mn?.start??null);return}}if((ae.key==="ArrowUp"||ae.key==="ArrowDown")&&!ae.nativeEvent.isComposing){const _e=ae.currentTarget.selectionStart??0,et=ae.currentTarget.selectionEnd??_e,qe=ae.key==="ArrowUp"?wz(Me,_e)?vz(Q,ar.current,Me):null:Sz(Me,et)?kz(Q,ar.current,Me):null;if(qe){ae.preventDefault(),Qe(qe);return}}if(ae.key==="Backspace"&&(Ke!==null||pt!==null)&&ae.currentTarget.selectionStart===0&&ae.currentTarget.selectionEnd===0){ae.preventDefault(),Ga();return}ae.key==="Enter"&&!ae.shiftKey&&!ae.nativeEvent.isComposing&&(ae.preventDefault(),Re())},Et=ae=>{const _e=[];for(const vt of ae)vt.type.startsWith("image/")&&_e.push(vt);const{accepted:et,rejected:qe}=KS(_e,Se.imageMaxMb);for(const vt of qe)Be(d.chat.attachmentTooLarge(vt.name,Se.imageMaxMb));for(const vt of et){const xn=new FileReader;xn.onload=()=>{typeof xn.result=="string"&&bt(tr=>[...tr,xn.result])},xn.readAsDataURL(vt)}},Pt=ae=>{if(be!=="session")return;const _e=[];for(const et of ae.clipboardData.items)if(et.kind==="file"){const qe=et.getAsFile();qe&&_e.push(qe)}_e.length>0&&(ae.preventDefault(),Et(_e))},Wt=ae=>{ae.target.files&&Et(ae.target.files),ae.target.value=""},Ka=ae=>{if(Mt)return;const{accepted:_e,rejected:et}=KS(ae,Se.attachmentMaxMb);for(const qe of et)Be(d.chat.attachmentTooLarge(qe.name,Se.attachmentMaxMb));_e.length!==0&&Promise.all(_e.map(Yz)).then(qe=>{const vt=_e.flatMap((xn,tr)=>qe[tr]?[{name:xn.name,size:xn.size,dataUrl:qe[tr]}]:[]);vt.length>0&&ne(xn=>[...xn,...vt])})},_r=ae=>{ae.target.files&&Ka(ae.target.files),ae.target.value=""},Rr=ae=>{if(be!=="session")return;const _e=Tz(ae);_e.images.length>0&&Et(_e.images),_e.files.length>0&&(Mt?wr(d.chat.dropFilesGoalHint):Ka(_e.files))},Ir=y.useRef(null),Ui=y.useRef(null);return a.jsxs("div",{className:"relative",ref:$e,children:[be==="session"&&a.jsx(Ez,{onFiles:Rr}),En&&a.jsx("div",{style:{maxHeight:nt},className:"anim-pop absolute bottom-full left-0 z-40 mb-1.5 w-80 max-w-[calc(100vw-2rem)] overflow-y-auto overscroll-contain rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:Gr.map((ae,_e)=>a.jsxs("button",{type:"button",ref:ae===us?et=>et?.scrollIntoView({block:"nearest"}):void 0,onMouseEnter:()=>ve(_e),onClick:()=>ae.run(),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm ${ae===us?"bg-gray-100 dark:bg-gray-800":""}`,children:[a.jsx("span",{className:"shrink-0 font-mono text-gray-800 dark:text-gray-200",children:ae.cmd}),a.jsx("span",{title:ae.desc,className:"min-w-0 flex-1 truncate text-xs text-gray-500 dark:text-gray-400",children:ae.desc})]},ae.cmd))}),He&&w&&a.jsx(YS,{panelRef:W,maxHeight:nt,title:d.chat.switchModelTitle,children:a.jsx(wT,{models:w,value:v,...N!==void 0?{defaultModel:N}:{},onPick:Sa})}),me&&a.jsx(YS,{panelRef:pe,maxHeight:nt,title:d.chat.switchAgentTitle,children:a.jsx(Bz,{agents:K,...H!==void 0?{currentAgentId:H}:{},onPick:Ts})}),ct.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:ct.map((ae,_e)=>a.jsxs("div",{className:"anim-pop relative",children:[a.jsx(Ys,{src:ae,alt:d.chat.imageAlt,className:"h-16 w-16 rounded-md border border-gray-200 object-cover dark:border-gray-700"}),a.jsx("button",{type:"button","aria-label":d.chat.removeImage,onClick:()=>bt(et=>et.filter((qe,vt)=>vt!==_e)),className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full bg-gray-700 text-[10px] text-white transition-colors duration-150 hover:bg-gray-900",children:"×"})]},_e))}),he.length>0&&a.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:he.map((ae,_e)=>a.jsxs("span",{title:ae.name,className:`anim-pop flex max-w-56 items-center ${Ro.tight} rounded-md border border-gray-200 bg-gray-50 py-1 pl-2 pr-1 text-xs text-gray-700 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200`,children:[a.jsx(Oe,{d:bf,size:13,className:"shrink-0 text-gray-400 dark:text-gray-500"}),a.jsx("span",{className:"min-w-0 truncate",children:ae.name}),a.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:ju(ae.size)}),a.jsx("button",{type:"button","aria-label":`${d.chat.removeFile} ${ae.name}`,onClick:()=>ne(et=>et.filter((qe,vt)=>vt!==_e)),className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]},_e))}),!V&&ct.length>0&&a.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:d.chat.imagesAsPathHint}),Dt==="blocked"&&a.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:d.chat.modelSwitchBusyHint}),o.length>0?a.jsx("div",{className:"anim-fade mb-1",children:o.map((ae,_e)=>a.jsx(ZS,{label:d.chat.steerQueuedItem(QS(ae)),disabled:ra!==null||oe,...c&&ae.id?{onRecall:()=>{Ar(ae.id,c)}}:{}},ae.id??_e))}):ur&&a.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:d.chat.steerQueuedIndicator}),p.length>0?a.jsx("div",{className:"anim-fade mb-1",children:p.map(ae=>a.jsx(ZS,{label:d.chat.followUpQueuedItem(QS(ae)),disabled:ra!==null||oe,...h?{onRecall:()=>{Ar(ae.id,h)}}:{}},ae.id))}):f>0&&a.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:d.chat.followUpQueuedChip(f)}),a.jsxs("div",{className:"@container rounded-lg border border-gray-300 bg-white px-2.5 pb-2 pt-2 transition-[border-color,box-shadow] duration-200 focus-within:border-gray-500 focus-within:ring-2 focus-within:ring-gray-400/30 dark:border-gray-700 dark:bg-gray-900 dark:focus-within:border-gray-400",children:[(Ke!==null||pt!==null||st.length>0||Mt)&&a.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-1",children:[Mt&&a.jsxs("span",{className:"anim-pop flex max-w-full items-center gap-1 rounded-md bg-gray-100 py-0.5 pl-2 pr-1 text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200",children:[a.jsxs("span",{className:"flex shrink-0 items-center gap-1",title:d.chat.goalModeDesc,children:[a.jsx(Oe,{d:_u,size:13,className:"text-gray-500 dark:text-gray-400"}),a.jsx("span",{children:d.chat.goalMode})]}),a.jsx("span",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px shrink-0 bg-gray-300 dark:bg-gray-600"}),a.jsx(Qn,{open:Tr,setOpen:zr,onEscape:cr,className:"min-w-0",menuClass:"bottom-full left-1/2 -ml-32 mb-2 w-64 max-w-[calc(100vw-2rem)] origin-bottom",button:a.jsxs("button",{type:"button","aria-label":Hn,"aria-expanded":Tr,onClick:()=>zr(!Tr),className:"flex h-5 min-w-0 items-center gap-1 rounded px-1.5 text-xs text-gray-600 transition-colors duration-150 hover:bg-white/80 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-700 dark:hover:text-white",children:[a.jsx("span",{className:"truncate",children:Hn}),a.jsx(ns,{size:Ye.caretDense})]}),children:a.jsxs("div",{className:"px-3 py-2",children:[a.jsx("label",{htmlFor:"goal-budget-input",className:"block text-xs font-medium text-gray-700 dark:text-gray-200",children:d.chat.goalBudgetLabel}),a.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[a.jsx("input",{id:"goal-budget-input",autoFocus:!0,value:Ie,onChange:ae=>ut(ae.target.value),onFocus:ae=>ae.currentTarget.select(),onKeyDown:ae=>{ae.key==="Enter"&&(ae.preventDefault(),ae.stopPropagation(),Js())},placeholder:d.chat.goalBudgetPlaceholder,"aria-invalid":Nn,"aria-describedby":"goal-budget-hint",...Gu,title:Nn?d.chat.goalBudgetInvalid:d.chat.goalBudgetHint,className:`min-w-0 flex-1 rounded-md border bg-white px-2 py-1 font-mono text-sm leading-5 placeholder:text-gray-400 focus:outline-none focus:ring-2 dark:bg-gray-950 dark:placeholder:text-gray-500 ${Nn?"border-red-400 text-red-600 focus:border-red-500 focus:ring-red-400/20 dark:border-red-500 dark:text-red-400":"border-gray-300 text-gray-800 focus:border-gray-500 focus:ring-gray-400/20 dark:border-gray-700 dark:text-gray-100 dark:focus:border-gray-500"}`}),a.jsx("button",{type:"button","aria-label":d.chat.goalBudgetSave,title:d.chat.goalBudgetSave,disabled:Nn,onClick:Js,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-gray-900 text-white transition-colors duration-150 hover:bg-gray-700 disabled:cursor-not-allowed disabled:opacity-35 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-white",children:a.jsx(qu,{size:14})})]}),a.jsx("p",{id:"goal-budget-hint",className:`mt-1.5 text-[11px] leading-4 ${Nn?"text-red-500 dark:text-red-400":"text-gray-400 dark:text-gray-500"}`,children:Nn?d.chat.goalBudgetInvalid:d.chat.goalBudgetHint})]})}),a.jsx("button",{type:"button","aria-label":d.chat.goalRemove,onClick:()=>Mr(!1),className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]}),Ke!==null&&a.jsxs("span",{title:d.chat.handoffTargetTitle(_n(Ke)),className:"anim-pop flex max-w-48 items-center gap-1 rounded-md bg-gray-100 py-0.5 pl-2 pr-1 font-mono text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200",children:[a.jsx(Ha,{id:Ke.agentId,name:_n(Ke),size:13,className:"shrink-0 rounded-sm"}),a.jsx("span",{className:"truncate",children:Ke.agentId}),a.jsx("button",{type:"button","aria-label":d.chat.handoffRemove,onClick:()=>{dt(null),U?.(null),Vt.current?.focus()},className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]}),pt!==null&&a.jsxs("span",{title:d.chat.modelSwitchTargetTitle(hu(pt)),className:"anim-pop flex max-w-48 items-center gap-1 rounded-md bg-gray-100 py-0.5 pl-2 pr-1 text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200",children:[a.jsx(jo,{provider:pt.provider,className:"h-3.5 w-3.5 shrink-0"}),a.jsx("span",{className:"truncate",children:hu(pt)}),a.jsx("button",{type:"button","aria-label":d.chat.modelSwitchRemove,onClick:()=>{hn(null),Vt.current?.focus()},className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]}),st.map(ae=>{const _e=$.find(et=>et.name===ae);return a.jsxs("span",{className:"anim-pop flex max-w-48 items-center gap-1 rounded-md bg-gray-100 py-0.5 pl-2 pr-1 font-mono text-sm text-gray-800 dark:bg-gray-800 dark:text-gray-200",..._e?{title:Wl(ye,_e)}:{},children:[a.jsx(Yf,{icon:_e?.icon,size:13,className:"shrink-0 text-gray-500 dark:text-gray-400"}),a.jsx("span",{className:"truncate",children:ae}),a.jsx("button",{type:"button","aria-label":`${d.chat.skillRemove} ${ae}`,onClick:()=>er(ae),className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]},ae)})]}),a.jsx("textarea",{ref:Vt,rows:2,value:Me,autoFocus:q,onChange:ae=>{const _e=ae.target.value,et=ae.target.selectionStart??_e.length;ze(_e),A?.(_e),Dn(et),ve(0),Ge(qe=>{if(qe===null)return null;const vt=PS(_e,et);return vt&&vt.start===qe?qe:null})},onSelect:ae=>Dn(ae.currentTarget.selectionStart??0),onKeyDown:mt,onPaste:Pt,placeholder:Xt&&Hr?zn?d.chat.followUpPlaceholderShort:d.chat.followUpPlaceholder:Xt&&n?zn?d.chat.steerPlaceholderShort:d.chat.steerPlaceholder:zn?d.chat.inputPlaceholderShort:d.chat.inputPlaceholder,className:"block max-h-44 min-h-[60px] w-full resize-none bg-transparent px-1 py-0.5 text-base leading-6 placeholder:text-gray-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-60 dark:placeholder:text-gray-500"}),a.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2 text-xs",children:[a.jsxs("div",{className:"no-scrollbar flex min-w-0 flex-1 items-center gap-2 overflow-x-auto",children:[a.jsx("input",{ref:Ir,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Wt}),a.jsx("input",{ref:Ui,type:"file",multiple:!0,disabled:Mt,className:"hidden",onChange:_r}),be==="session"&&a.jsx(Wz,{items:[{key:"image",icon:Kz,label:d.chat.uploadImage,desc:V&&!Mt?d.chat.uploadImageDesc:d.chat.imagesAsPathHint,active:ct.length>0,onSelect:()=>Ir.current?.click()},{key:"file",icon:bf,label:d.chat.uploadFile,desc:d.chat.uploadFileDesc,active:he.length>0,disabled:Mt,onSelect:()=>Ui.current?.click()},{key:"goal",icon:_u,label:d.chat.goalMode,desc:d.chat.goalModeDesc,active:Mt,disabled:Xt||Cn||oe,onSelect:()=>Mr(!Mt)}],footer:a.jsx(Vz,{steerMode:ta,onChangeSteerMode:is}),direction:w&&S?"down":"up"}),a.jsx(zz,{value:P,onChange:B,disabled:Y,direction:w&&S?"down":"up"}),a.jsx(Gz,{skills:$,selected:st,onToggle:er,disabled:Xt||Cn||oe,direction:w&&S?"down":"up"}),a.jsx("span",{title:d.chat.slashHint,className:"hidden min-w-0 truncate text-gray-300 @lg:block dark:text-gray-600",children:d.chat.slashHint})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!S&&a.jsx(Dz,{now:E,unknown:L,...z!==void 0?{window:z}:{},...F!==void 0?{sessionId:F}:{}}),w&&S&&_&&a.jsx(XS,{value:T??null,onChange:_,disabled:oe}),!S&&D&&a.jsx(XS,{value:R??"",onChange:D,disabled:oe,direction:"up"}),w&&S?a.jsx(Ay,{models:w,value:v,...N!==void 0?{defaultModel:N}:{},onChange:S,disabled:oe}):be==="subagent"?a.jsxs("span",{title:v?.modelId??"",className:"flex h-8 min-w-0 max-w-44 shrink items-center gap-1.5 rounded-md px-1 text-gray-400 dark:text-gray-500",children:[a.jsx(jo,{provider:v?.provider??"custom",className:"h-4 w-4 shrink-0"}),a.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:Er})]}):a.jsxs("button",{type:"button",title:v?.modelId??"","aria-label":`${d.chat.model} ${v?.modelId??""}`,onClick:()=>wr(d.chat.modelLockedHint),className:"flex h-8 min-w-0 max-w-44 shrink cursor-pointer items-center gap-1.5 rounded-md px-1 text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",children:[a.jsx(jo,{provider:v?.provider??"custom",className:"h-4 w-4 shrink-0"}),a.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:Er})]}),a.jsx("button",{type:"button",title:Jn?d.chat.stop:Xt?na:d.chat.send,"aria-label":Jn?d.chat.stop:Xt?na:d.chat.send,disabled:Jn?!1:Xt?!pn:!Rn,onClick:()=>Jn?void x():void Re(),className:Jn?"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-red-50 text-red-600 transition-colors duration-150 hover:bg-red-100 dark:bg-red-950/60 dark:text-red-400 dark:hover:bg-red-950":"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-gray-900 text-white transition-colors duration-150 hover:bg-gray-700 disabled:cursor-not-allowed disabled:bg-gray-200 disabled:text-gray-400 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-300 dark:disabled:bg-gray-800 dark:disabled:text-gray-600",children:Jn?a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":!0,className:"block",children:a.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"2",fill:"currentColor"})}):a.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"block",children:a.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]})]})]})]})}const JS=500,Jz=5;function eB(e,t){return e+t+1}function X0(e,t){return e+t>=Jz}const ET=20,tB=20;function nB(e,t,n=ET,s=tB){const o=n+1+s;if(e<=o)return{start:0,end:e};if(t===null||t<0||t>=e)return{start:e-o,end:e};const c=Math.min(Math.max(0,t-n),e-o);return{start:c,end:c+o}}const rB=12,AT=5,_T=48;function aB(e,t){return Math.max(AT,Math.min(rB,Math.floor((e-_T)/Math.max(1,t))))}function sB(e){const t=Math.floor((e-_T)/AT);return Math.min(ET,Math.max(0,Math.floor((t-1)/2)))}function iB(e){const t=[];let n=null,s=!1;for(const o of e){if(o.kind==="user_text"||o.kind==="user_image"){let c="";if(o.kind==="user_text"){const u=CT(o.text);if(!u||u.goalRound!==void 0&&u.goalRound>1){s=!1;continue}c=u.body}s&&n?n.question===""&&c!==""&&(n.question=c):(n={anchorId:o.id,question:c,answer:""},t.push(n)),s=!0;continue}if(s=!1,o.kind==="assistant_text"&&n&&n.answer.length<JS){const c=o.text.trim();c!==""&&(n.answer=(n.answer===""?c:`${n.answer} ${c}`).slice(0,JS))}}return t}function oB(e,t){let n=e.replace(/```[^\n]*/g,"").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/^[ \t]*(?:#{1,6}[ \t]+|>[ \t]?|[-*+][ \t]+|\d+[.)][ \t]+)/gm,"").replace(/[*_`~]/g,"").replace(/\s+/g," ").trim();return n.length>t&&(n=`${n.slice(0,t).trimEnd()}…`),n}const lB="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zm4 0v16M12 9h5m-5 4h5",cB=96,uB=1e3,dB=56,mB=48,e2="(hover: hover) and (pointer: fine)";function fB(e,t){const[n,s]=y.useState(()=>window.matchMedia(e2).matches),[o,c]=y.useState({gutterOk:!1,height:0});return y.useEffect(()=>{const u=window.matchMedia(e2),f=p=>s(p.matches);return u.addEventListener("change",f),()=>u.removeEventListener("change",f)},[]),y.useEffect(()=>{const u=e.current;if(!u)return;const f=()=>{const h=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,x=(u.clientWidth-mB*h)/2;c({gutterOk:x>=dB,height:u.clientHeight})};f();const p=new ResizeObserver(f);return p.observe(u),()=>p.disconnect()},[e,t]),{shown:n&&o.gutterOk,height:o.height}}function RT(e,t){const n=e.querySelectorAll("[data-outline-anchor]");if(n.length===0)return null;let s=null,o=null;const c=e.scrollTop+cB;for(const f of n){const p=Number(f.dataset.outlineAnchor);t.has(p)&&(s=p,f.offsetTop<=c&&(o=p))}return e.scrollHeight-e.scrollTop-e.clientHeight<2?s:o}let t2=null,n2;function IT(e,t){const n=e?.querySelector(`[data-outline-anchor="${t}"]`);!e||!n||(e.scrollTo({top:Math.max(0,n.offsetTop-8)}),window.clearTimeout(n2),t2?.classList.remove("outline-flash"),t2=n,n.classList.remove("outline-flash"),n.offsetWidth,n.classList.add("outline-flash"),n2=window.setTimeout(()=>n.classList.remove("outline-flash"),uB))}function r2({edge:e}){return a.jsx("div",{"data-outline-overflow":e,"aria-hidden":!0,className:`flex w-10 flex-col items-start gap-[3px] pl-4 ${e==="above"?"pb-1.5":"pt-1.5"}`,children:[0,1,2].map(t=>a.jsx("span",{className:"h-[2px] w-[2px] rounded-full bg-gray-300 dark:bg-gray-700"},t))})}function LT(e,t,n,s){return e.answer?oB(e.answer,s):n&&e===t[t.length-1]?d.chat.outlineAnswering:""}function pB({entries:e,turnOffset:t=0,version:n,scrollRef:s,running:o,fit:c}){const[u,f]=y.useState(null),[p,h]=y.useState(null),x=y.useRef(null);if(y.useEffect(()=>{const R=s.current;if(!c.shown||!R||!X0(t,e.length))return;const D=new Set(e.map(F=>F.anchorId));let z=null;const E=()=>{z=null;const F=s.current;F&&f(RT(F,D))},L=()=>{z??=requestAnimationFrame(E)};return E(),R.addEventListener("scroll",L,{passive:!0}),()=>{R.removeEventListener("scroll",L),z!==null&&cancelAnimationFrame(z)}},[c.shown,s,e.length,t,n]),!c.shown||!X0(t,e.length))return null;const g=R=>{const D=R.currentTarget.getBoundingClientRect();return D.top+D.height/2-(x.current?.getBoundingClientRect().top??0)},v=sB(c.height),{start:w,end:S}=nB(e.length,e.findIndex(R=>R.anchorId===u),v,v),C=e.slice(w,S),N=aB(c.height,C.length),T=p===null?null:C.find(R=>R.anchorId===p.id)??null,_=T===null?"":LT(T,e,o,160);return a.jsxs("nav",{ref:x,"aria-label":d.chat.outlineTitle,className:"pointer-events-none absolute inset-y-0 left-0 z-10 flex flex-col items-start justify-center",children:[a.jsxs("div",{className:"max-h-full overflow-hidden",children:[(w>0||t>0)&&a.jsx(r2,{edge:"above"}),C.map((R,D)=>{const z=R.anchorId===u;return a.jsx("button",{type:"button","data-outline-tick":R.anchorId,"aria-current":z||void 0,"aria-label":d.chat.outlineTickLabel(eB(t,w+D),R.question||d.chat.outlineNoText),style:{height:N},onMouseEnter:E=>h({id:R.anchorId,top:g(E)}),onMouseLeave:()=>h(null),onFocus:E=>h({id:R.anchorId,top:g(E)}),onBlur:()=>h(null),onClick:()=>{IT(s.current,R.anchorId),f(R.anchorId)},className:"group/tick pointer-events-auto flex w-10 items-center pl-2.5",children:a.jsx("span",{className:`h-[2px] rounded-full transition-all duration-150 ${z?"w-5 bg-gray-800 dark:bg-gray-200":"w-3.5 bg-gray-300 group-hover/tick:bg-gray-500 dark:bg-gray-700 dark:group-hover/tick:bg-gray-400"}`})},R.anchorId)}),S<e.length&&a.jsx(r2,{edge:"below"})]}),T&&a.jsxs("div",{"data-outline-card":!0,"aria-hidden":!0,className:"anim-pop pointer-events-none absolute left-10 w-80 -translate-y-1/2 rounded-xl border border-gray-200 bg-white px-4 py-3 shadow-lg dark:border-gray-700 dark:bg-gray-900",style:{top:Math.min(Math.max(p.top,56),Math.max(56,c.height-56))},children:[a.jsx("p",{className:`truncate text-sm ${T.question===""?"italic text-gray-500 dark:text-gray-400":"font-semibold text-gray-900 dark:text-gray-100"}`,children:T.question||d.chat.outlineNoText}),_!==""&&a.jsx("p",{className:`mt-1 line-clamp-3 text-sm leading-snug text-gray-500 dark:text-gray-400 ${T.answer===""?"animate-pulse":""}`,children:_})]})]})}function hB({entries:e,turnOffset:t=0,scrollRef:n,running:s}){const[o,c]=y.useState(!1),[u,f]=y.useState(null);if(!X0(t,e.length))return null;const p=h=>{h&&n.current&&f(RT(n.current,new Set(e.map(x=>x.anchorId)))),c(h)};return a.jsx(Qn,{open:o,setOpen:p,menuClass:"right-0 top-full mt-1 w-72 max-w-[calc(100vw-1.5rem)] origin-top-right",button:a.jsx("button",{type:"button",title:d.chat.outlineTitle,"aria-label":d.chat.outlineTitle,onClick:()=>p(!o),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(Oe,{d:lB,size:15})}),children:a.jsx("div",{className:"max-h-[60vh] overflow-y-auto py-1",children:e.map(h=>{const x=LT(h,e,s,80),g=h.anchorId===u;return a.jsxs("button",{type:"button","data-outline-menu-entry":h.anchorId,"aria-current":g||void 0,onClick:()=>{IT(n.current,h.anchorId),c(!1)},className:`block w-full px-3 py-1.5 text-left transition-colors duration-150 ${g?"bg-gray-100 dark:bg-gray-800":"hover:bg-gray-50 dark:hover:bg-gray-800/60"}`,children:[a.jsx("span",{className:`block truncate text-sm ${h.question===""?"italic text-gray-500 dark:text-gray-400":"font-medium text-gray-800 dark:text-gray-200"}`,children:h.question||d.chat.outlineNoText}),x!==""&&a.jsx("span",{className:`mt-0.5 block truncate text-xs text-gray-500 dark:text-gray-400 ${h.answer===""?"animate-pulse":""}`,children:x})]},h.anchorId)})})})}function OT({className:e}){return a.jsx("img",{src:"/penguin-logo.svg",alt:"","aria-hidden":!0,draggable:!1,className:`select-none ${e??"h-9 w-9 rounded-lg"}`})}const Ly="penguin.dock.layout",a2=40,DT=["agents","workspace","memory","trace","messaging"];function kn(e){return e.kind==="panel"?e.panel:`terminal:${e.terminalId}`}function gB(e){return DT.includes(e)?{kind:"panel",panel:e}:e.startsWith("terminal:")&&e.length>9?{kind:"terminal",terminalId:e.slice(9)}:null}const $T=.4,xB=.15,Oy=.85,UT=140;function PT(e){return Number.isFinite(e)?Math.min(Oy,Math.max(xB,e)):$T}function s2(){return{tabs:[],active:null,open:!1}}function Dy(){return{right:s2(),bottom:s2(),focus:"bottom"}}const Q0="~none";function yB(e,t){try{const n=localStorage.getItem(e);if(n===null)return t;const s=JSON.parse(n);return typeof s=="object"&&s!==null?s:t}catch{return t}}function zT(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function i2(e){const t=e??{},n=(Array.isArray(t.tabs)?t.tabs:[]).map(u=>typeof u=="string"?gB(u):null).filter(u=>u!==null),s=new Set,o=n.filter(u=>{const f=kn(u);return s.has(f)?!1:(s.add(f),!0)}),c=typeof t.active=="string"&&o.some(u=>kn(u)===t.active)?t.active:o.length>0?kn(o[o.length-1]):null;return{tabs:o,active:c,open:t.open===!0}}function bB(e){const t=e??{},n=i2(t.right),s=i2(t.bottom),o=new Set(n.tabs.map(kn));return s.tabs=s.tabs.filter(c=>!o.has(kn(c))),s.active!==null&&!s.tabs.some(c=>kn(c)===s.active)&&(s.active=s.tabs.length>0?kn(s.tabs[s.tabs.length-1]):null),{right:n,bottom:s,focus:t.focus==="right"?"right":"bottom"}}function vB(){const e=yB(Ly,{}),t={};if(typeof e.scopes=="object"&&e.scopes!==null)for(const[n,s]of Object.entries(e.scopes))t[n]=bB(s);return{scopes:t,bottomRatio:PT(typeof e.bottomRatio=="number"?e.bottomRatio:NaN)}}let{scopes:Wn,bottomRatio:Dl}=vB(),za=Q0,Jt=Wn[za]??Dy();function kB(e){return e.right.tabs.length===0&&e.bottom.tabs.length===0&&!e.right.open&&!e.bottom.open}function Ur(){if(kB(Jt)){const{[za]:t,...n}=Wn;Wn=n}else{const{[za]:t,...n}=Wn;Wn={...n,[za]:Jt}}const e=Object.keys(Wn);e.length>a2&&(Wn=Object.fromEntries(e.slice(e.length-a2).map(t=>[t,Wn[t]]))),zT(Ly,{scopes:Object.fromEntries(Object.entries(Wn).map(([t,n])=>[t,{right:{...n.right,tabs:n.right.tabs.map(kn)},bottom:{...n.bottom,tabs:n.bottom.tabs.map(kn)},focus:n.focus}])),bottomRatio:Dl})}const Z0=new Set;let BT=0,Qf=0;function Cr(){BT+=1;for(const e of[...Z0])e()}function $y(){return BT}function wB(){return Qf}function Zf(e){return Z0.add(e),()=>Z0.delete(e)}function SB(e){FT(e??Q0,za===Q0)}function HT(e){FT(e,!0)}function FT(e,t){if(e===za)return;Qf+=1,Ur();const n=Wn[za];if(t&&n!==void 0&&Wn[e]===void 0){const{[za]:o,...c}=Wn;Wn={...c,[e]:n},zT(Ly,{scopes:Object.fromEntries(Object.entries(Wn).map(([u,f])=>[u,{right:{...f.right,tabs:f.right.tabs.map(kn)},bottom:{...f.bottom,tabs:f.bottom.tabs.map(kn)},focus:f.focus}])),bottomRatio:Dl})}za=e,Jt=Wn[za]??Dy(),Cr()}function jB(){return za}let Iu=!1;if(typeof window<"u"&&typeof window.matchMedia=="function"){const e=window.matchMedia("(max-width: 1023.98px)");Iu=e.matches,e.addEventListener("change",t=>{Iu=t.matches,Cr()})}function or(e){return Jt[e]}function td(e){for(const t of["right","bottom"]){const n=Jt[t].tabs.findIndex(s=>kn(s)===e);if(n!==-1)return{position:t,index:n}}return null}function Lu(e){return td(e)?.position??null}function Ba(e){return or(e).open}function CB(e){return or(e).active}function Uy(){const e=Jt.focus,t=e==="right"?"bottom":"right";return Ba(e)&&or(e).active!==null?or(e).active:Ba(t)?or(t).active:null}function NB(){return Iu?!Ba("right")&&!Ba("bottom")?[]:[{position:"bottom",merged:!0,tabs:[...Ba("bottom")?Jt.bottom.tabs:[],...Ba("right")?Jt.right.tabs:[]],activeKey:Uy()}]:["right","bottom"].filter(Ba).map(t=>({position:t,merged:!1,tabs:or(t).tabs,activeKey:or(t).active}))}function TB(e){const t=Lu(e);return t===null||!Ba(t)?!1:Iu?Uy()===e:or(t).active===e}function Py(e,t){const n=or(e);n.active=t,n.open=!0,Jt.focus=e}function qg(e){const t=td(e);t&&(Py(t.position,e),Ur(),Cr())}function zy(e,t){const n=kn(e),s=td(n);if(s&&s.position!==t&&(Jt[s.position].tabs=Jt[s.position].tabs.filter(o=>kn(o)!==n),Jt[s.position].active===n)){const o=Jt[s.position].tabs;Jt[s.position].active=o.length>0?kn(o[o.length-1]):null}(!s||s.position!==t)&&(Jt[t].tabs=[...Jt[t].tabs,e]),Py(t,n)}function J0(e){const t=td(e);if(!t)return;const n=or(t.position);n.tabs=n.tabs.filter(s=>kn(s)!==e),n.active===e&&(n.active=n.tabs.length>0?kn(n.tabs[n.tabs.length-1]):null),n.tabs.length===0&&(n.open=!1),Ur(),Cr()}function MB(e,t){const n=td(e);if(!n)return;Qf+=1;const s=Jt[n.position].tabs[n.index];zy(s,t),Jt[n.position].tabs.length===0&&(Jt[n.position].open=!1),Ur(),Cr()}function o2(e,t){if(e===t)return;const n=or(e);if(n.tabs.length===0)return;Qf+=1;const s=n.active,o=or(t);o.tabs=[...o.tabs,...n.tabs],n.tabs=[],n.active=null,n.open=!1,s!==null?Py(t,s):Jt.focus=t,o.open=!0,Ur(),Cr()}function EB(e,t){const n=or(e),s=new Map(n.tabs.map(c=>[kn(c),c])),o=t.map(c=>s.get(c)).filter(c=>c!==void 0);o.length===n.tabs.length&&(o.every((c,u)=>c===n.tabs[u])||(n.tabs=o,Ur(),Cr()))}function AB(e){const t=or(e);t.open=!t.open,t.open&&(Jt.focus=e),Ur(),Cr()}function _B(e){e.merged?(Jt.right.open=!1,Jt.bottom.open=!1):or(e.position).open=!1,Ur(),Cr()}function vl(e){return Lu(e)}function ho(e,t){const n=t??vl(e)??"right";zy({kind:"panel",panel:e},n),Ur(),Cr()}function qT(e){return`terminal:${e}`}function RB(e){return Lu(qT(e))}function IB(){return[...Jt.bottom.tabs,...Jt.right.tabs].filter(e=>e.kind==="terminal").map(e=>e.terminalId)}function By(e){const t=new Set;for(const n of[Jt,...Object.values(Wn)])for(const s of[...n.right.tabs,...n.bottom.tabs])s.kind==="terminal"&&t.add(s.terminalId);return e.filter(n=>!t.has(n))}function nd(e,t){zy({kind:"terminal",terminalId:e},t??RB(e)??"bottom"),Ur(),Cr()}function LB(e){nd(e)}function OB(e,t,n){if(By([t]).length===0)return;if(e===za){nd(t,n);return}const s=Wn[e]??Dy(),o=s[n];o.tabs=[...o.tabs,{kind:"terminal",terminalId:t}],o.active=qT(t),o.open=!0;const{[e]:c,...u}=Wn;Wn={...u,[e]:s},Ur(),Cr()}function DB(e){let t=!1;const n=s=>{const o=s.tabs.filter(c=>c.kind!=="terminal"||e.has(c.terminalId));return o.length===s.tabs.length?!1:(s.tabs=o,s.active!==null&&!o.some(c=>kn(c)===s.active)&&(s.active=o.length>0?kn(o[o.length-1]):null),o.length===0&&(s.open=!1),!0)};for(const s of Object.values(Wn))s!==Jt&&(n(s.right)&&(t=!0),n(s.bottom)&&(t=!0));n(Jt.right)&&(t=!0),n(Jt.bottom)&&(t=!0),t&&(Ur(),Cr())}function $B(){const e=IB();if(e.length===0)return!1;const t=["right","bottom"].filter(s=>or(s).tabs.some(o=>o.kind==="terminal"));if(t.some(s=>Ba(s)&&(Iu?Uy()?.startsWith("terminal:")===!0:or(s).active?.startsWith("terminal:")===!0))){for(const s of t)or(s).open=!1;return Ur(),Cr(),!0}return LB(e[e.length-1]),!0}function VT(){return Dl}function UB(e){const t=PT(e);t!==Dl&&(Dl=t,Ur(),Cr())}function PB(){Dl=$T,Ur(),Cr()}const ou={Output:1,Input:2,Resize:3,Restore:5,Exit:6},zB=new TextEncoder,BB=new TextDecoder;function GT(e,t=""){const n=typeof t=="string"?zB.encode(t):t,s=new Uint8Array(2+n.byteLength);return s[0]=e,s[1]=0,s.set(n,2),s}function HB(e){if(e.byteLength<2)return null;const t=new Uint8Array(e,0,2);return{opcode:t[0],slot:t[1],text:BB.decode(new Uint8Array(e,2))}}function l2(e,t,n){return GT(ou.Resize,JSON.stringify({cols:e,rows:t,intent:n}))}function FB(){return Promise.all([an(()=>import("./xterm-fEUfDV0F.js").then(e=>e.x),[]),an(()=>import("./addon-fit-BXTX0Xqu.js").then(e=>e.a),[]),an(()=>import("./addon-web-links-KebkunbU.js").then(e=>e.a),[])])}const qB={background:"#000000",foreground:"#f3f4f6",cursor:"#f3f4f6",cursorAccent:"#000000",selectionBackground:"rgba(255, 255, 255, 0.18)",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff"},VB={background:"#ffffff",foreground:"#111827",cursor:"#111827",cursorAccent:"#ffffff",selectionBackground:"rgba(0, 0, 0, 0.12)",black:"#000000",red:"#cd3131",green:"#00bc00",yellow:"#949800",blue:"#0451a5",magenta:"#bc05bc",cyan:"#0598bc",white:"#555555",brightBlack:"#666666",brightRed:"#cd3131",brightGreen:"#14ce14",brightYellow:"#b5ba00",brightBlue:"#0451a5",brightMagenta:"#bc05bc",brightCyan:"#0598bc",brightWhite:"#a5a5a5"};function c2(e){return e?qB:VB}async function KT(e,t){return fetch(e,{credentials:"same-origin",...t,headers:{"Content-Type":"application/json",...t?.headers??{}}})}class Hy extends Error{constructor(t,n){super(n),this.status=t,this.name="HttpStatusError"}status}function WT(e,t,n,s){const o=t?.method??"GET",c=s.trim()===""?n.statusText:s.trim();return new Hy(n.status,`${o} ${e} → ${n.status} ${c}`)}async function Fy(e,t){const n=await KT(e,t);if(!n.ok)throw WT(e,t,n,await n.text());return await n.json()}async function vf(e,t){const n=await KT(e,t);if(n.status===404)return null;if(!n.ok)throw WT(e,t,n,await n.text());return await n.json()}function GB(e,t,n){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/api/terminals/${e}/stream?cols=${t}&rows=${n}`}function YT({ensure:e,onStatus:t,onInfo:n,onTitle:s,className:o}){const c=y.useRef(null),{terminalDark:u}=as(),f=y.useRef(u);f.current=u;const p=y.useRef(null);y.useEffect(()=>{p.current&&(p.current.options.theme=c2(u))},[u]);const h=y.useRef({ensure:e,onStatus:t,onInfo:n,onTitle:s});return h.current={ensure:e,onStatus:t,onInfo:n,onTitle:s},y.useEffect(()=>{const x=c.current;if(!x)return;let g=!1,v=null;const w=setTimeout(()=>{g||S(x).then(C=>{g?C():v=C})},0);return()=>{g=!0,clearTimeout(w),v?.()};async function S(C){const[{Terminal:N},{FitAddon:T},{WebLinksAddon:_}]=await FB();let R=!1,D=null,z=!1;const E=(H,$="")=>{R||h.current.onStatus?.(H,$)},L=new N({allowProposedApi:!0,cursorBlink:!0,fontFamily:'"JetBrains Mono", "Fira Code", Menlo, Monaco, "DejaVu Sans Mono", Consolas, monospace',fontSize:13,lineHeight:1.2,scrollback:5e3,theme:c2(f.current)}),F=new T;L.loadAddon(F),L.loadAddon(new _),p.current=L,L.open(C),F.fit();const V=()=>{const H=L.getSelection();H&&(navigator.clipboard?.writeText(H).catch(()=>{}),L.clearSelection())},P=()=>{navigator.clipboard?.readText().then(H=>H&&L.paste(H)).catch(()=>{})};L.attachCustomKeyEventHandler(H=>{if(H.type!=="keydown")return!0;const $=H.key.toLowerCase();return H.ctrlKey&&H.shiftKey&&$==="c"||H.ctrlKey&&!H.shiftKey&&H.key==="Insert"||H.ctrlKey&&!H.shiftKey&&!H.altKey&&$==="c"&&L.hasSelection()?(V(),!1):!(H.ctrlKey&&!H.altKey&&$==="v"||!H.ctrlKey&&H.shiftKey&&H.key==="Insert")});const B=new AbortController,{signal:Y}=B,q=()=>L.modes.mouseTrackingMode!=="none";C.addEventListener("contextmenu",H=>{H.preventDefault(),!q()&&(L.hasSelection()?V():P())},{signal:Y}),C.addEventListener("mousedown",H=>{H.button===1&&!q()&&(H.preventDefault(),P())},{signal:Y}),C.addEventListener("mouseup",()=>L.focus(),{signal:Y}),C.addEventListener("focusin",()=>{D?.readyState===WebSocket.OPEN&&D.send(l2(L.cols,L.rows,"claim"))},{signal:Y}),L.onData(H=>{D?.readyState===WebSocket.OPEN&&D.send(GT(ou.Input,H))}),L.onTitleChange(H=>{R||h.current.onTitle?.(H)}),(async()=>{try{const H=await h.current.ensure(L.cols,L.rows);if(R)return;h.current.onInfo?.(H),D=new WebSocket(GB(H.id,L.cols,L.rows)),D.binaryType="arraybuffer",D.onopen=()=>E("ready"),D.onmessage=$=>{if(!($.data instanceof ArrayBuffer))return;const X=HB($.data);if(X)switch(X.opcode){case ou.Restore:case ou.Output:L.write(X.text);break;case ou.Exit:{const{exitCode:le}=JSON.parse(X.text);z=!0,E("exited",String(le));break}default:break}},D.onerror=()=>E("error","stream error"),D.onclose=()=>{z||E("error","stream closed")}}catch(H){E("error",H instanceof Error?H.message:String(H))}})();const K=new ResizeObserver(()=>{R||(F.fit(),D?.readyState===WebSocket.OPEN&&D.send(l2(L.cols,L.rows,"update")))});return K.observe(C),L.focus(),()=>{R=!0,p.current=null,B.abort(),K.disconnect(),D?.close(),L.dispose()}}},[]),a.jsx("div",{ref:c,className:o??"min-h-0 flex-1 overflow-hidden"})}function KB(e){return(e??"").trim().replace(/^[^@\s]+@[^:\s]+:?\s*/,"").trim()}const WB=3e4;let $l=[],XT=[],u2="",Xc=null;const kl=new Set;let Em=null,Zm=!1;const Ou=new Map;function YB(e){const t=Ou.get(e);return t===void 0?!1:Date.now()>t?(Ou.delete(e),!1):!0}function Jf(e){$l=e;const t=JSON.stringify(e);if(t!==u2){XT=e,u2=t;for(const n of[...kl])n()}}function XB(e,t){$l.some(n=>n.id===e&&(n.title??"")!==t)&&Jf($l.map(n=>n.id===e?{...n,title:t}:n))}function QT(){return XT}function d2(){return!Zm}function Xs(){return Xc||(Xc=(async()=>{try{const e=await fetch("/api/terminals",{credentials:"same-origin"});if(e.status===404&&!Zm){Zm=!0;for(const o of[...kl])o();return}if(!e.ok)return;Zm=!1;const t=await e.json(),n=new Set(t.terminals.map(o=>o.id));for(const o of Ou.keys())n.has(o)||Ou.delete(o);const s=t.terminals.filter(o=>o.alive&&!YB(o.id));DB(new Set(s.map(o=>o.id))),Jf(s)}catch{}finally{Xc=null}})(),Xc)}const m2=()=>{Xs()};function ZT(e){return kl.size===0&&(Xs(),Em=setInterval(()=>{Xs()},WB),window.addEventListener("focus",m2)),kl.add(e),()=>{kl.delete(e),kl.size===0&&Em!==null&&(clearInterval(Em),Em=null,window.removeEventListener("focus",m2))}}function QB(e){$l.some(t=>t.id===e.id)||Jf([...$l,e])}async function ZB(e){Ou.set(e,Date.now()+1e4),Jf($l.filter(t=>t.id!==e));try{await fetch(`/api/terminals/${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"})}catch{}for(const t of[300,1500])setTimeout(()=>{Xs()},t)}const Vg="~";let ex=null;function JT(e){ex=e!==null&&e.trim()!==""?e:null}function JB(e){return e instanceof Hy&&e.status===400&&e.message.includes("cwd_not_")}async function eM(e){const t=n=>Fy("/api/terminals",{method:"POST",body:JSON.stringify({cwd:n})});try{let n;try{n=await t(ex??Vg)}catch(s){if(ex===null||!JB(s))throw s;console.warn(`[terminal] Workspace unusable as cwd, opening in ${Vg}:`,s),n=await t(Vg)}QB(n),nd(n.id,e)}catch(n){const s=n instanceof Error?n.message:String(n),o=n instanceof Hy&&n.status===404?`${s} — ${d.terminal.noTerminalApi}`:s;console.error("[terminal] create failed:",o),Be(`${d.terminal.createFailed}: ${o}`)}finally{Xs()}}async function tM(e){const n=((await Fy("/api/terminals").catch(()=>null))?.terminals??QT()).filter(o=>o.alive),s=By(n.map(o=>o.id)).at(-1);if(s!==void 0){nd(s,e),Xs();return}await eM(e)}function eH(e,t){const n=jB(),s=window.open(`/terminal?id=${encodeURIComponent(e)}`,"_blank");if(J0(`terminal:${e}`),!s)return;const o=window.setInterval(()=>{s.closed&&(window.clearInterval(o),(async()=>(await vf(`/api/terminals/${encodeURIComponent(e)}`).catch(()=>null))?.alive===!0&&(OB(n,e,t),Xs()))())},600)}function tH(){$B()||tM()}typeof window<"u"&&window.addEventListener("keydown",e=>{!e.ctrlKey||e.metaKey||e.altKey||e.shiftKey||e.key!=="`"&&e.code!=="Backquote"||(e.preventDefault(),tH())});const tx=[{id:"webapps",tasks:[{id:"game",skills:["web-design"]},{id:"gamecenter",skills:["web-design"]},{id:"lol",skills:["web-design"]},{id:"rhythmRunner",skills:["web-design"]}]},{id:"agents",tasks:[{id:"investmentCopilot",skills:["penguin-sdk","web-design"]},{id:"rag",skills:["penguin-sdk","web-design"]},{id:"agentBenchmarkBuild",skills:[]},{id:"agentOptimization",skills:[]}]},{id:"schedules",tasks:[{id:"dailyPlan",skills:[]},{id:"githubDigest",skills:[]},{id:"memoryReview",skills:[]}]}];tx.flatMap(e=>[...e.tasks]);function nM({open:e,glyph:t,label:n,count:s,onOpen:o}){return a.jsxs("button",{type:"button","aria-expanded":e,onClick:o,className:`flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 ${e?"bg-gray-100 dark:bg-gray-800/70":"hover:bg-gray-100 dark:hover:bg-gray-800/70"}`,children:[a.jsx("span",{className:"shrink-0 text-brand-500 dark:text-brand-400",children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:t})})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-gray-700 dark:text-gray-300",children:n}),a.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:s}),a.jsx(Zn,{open:e,size:Ye.chevron,className:"text-gray-400"})]})}const nx="rounded-md px-2 py-1.5 text-left text-sm text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 disabled:cursor-default disabled:opacity-60 disabled:hover:bg-transparent dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200",qy=3,Nl=40,gu=4e3;function nH(){return`sc-${crypto.randomUUID().replace(/-/g,"").slice(0,12)}`}function Gg(e,t){if(typeof e!="string")return null;const n=e.trim();return n===""?null:n.slice(0,t)}function rH(e){if(!Array.isArray(e))return[];const t=[],n=new Set;for(const s of e){if(t.length>=qy)break;if(s===null||typeof s!="object"||Array.isArray(s))continue;const o=s,c=Gg(o.id,64),u=Gg(o.title,Nl),f=Gg(o.prompt,gu);c===null||u===null||f===null||n.has(c)||(n.add(c),t.push({id:c,title:u,prompt:f}))}return t}function f2(e){const t=e.title.trim(),n=e.prompt.trim();return t===""?"titleRequired":t.length>Nl?"titleTooLong":n===""?"promptRequired":n.length>gu?"promptTooLong":null}function rM(e){return e.length<qy}function aH(e,t){const n={id:t.id??nH(),title:t.title.trim(),prompt:t.prompt.trim()},s=e.findIndex(o=>o.id===n.id);return s!==-1?e.map((o,c)=>c===s?n:o):rM(e)?[...e,n]:[...e]}function sH(e,t){return e.filter(n=>n.id!==t)}function iH(e){const t=e.split(`
174
- `).find(n=>n.trim()!=="");return t===void 0?"":t.trim().replace(/\s+/g," ").slice(0,Nl)}const p2="shortcuts",oH="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z";function h2({label:e,glyph:t,danger:n=!1,onClick:s}){return a.jsx("button",{type:"button",title:e,"aria-label":e,onClick:s,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-400 transition-colors duration-150 dark:text-gray-500 ${n?"hover:text-red-600 dark:hover:text-red-400":"hover:text-gray-700 dark:hover:text-gray-200"}`,children:a.jsx(Oe,{d:t,size:Ye.rowLead})})}function lH({open:e,onOpen:t,readComposerText:n,onFill:s}){const[o,c]=y.useState([]),[u,f]=y.useState(!1),[p,h]=y.useState(null),[x,g]=y.useState(null);y.useEffect(()=>{let _=!1;return Sx().then(R=>{_||c(rH(R.prefs.draftShortcuts))}).catch(()=>{}).finally(()=>{_||f(!0)}),()=>{_=!0}},[]);const v=y.useRef(o);v.current=o;const w=y.useCallback(_=>{const R=v.current;c(_),Nf({draftShortcuts:_}).catch(D=>{c(R),Be(Ae(D))})},[]),S=()=>{const _=n().trim();h({id:null,title:iH(_),prompt:_})},C=()=>{p===null||f2(p)!==null||(w(aH(o,p)),h(null))},N=p===null?null:f2(p),T=p!==null&&p.id!==null;return a.jsxs("div",{children:[a.jsx(nM,{open:e,glyph:oH,label:d.chat.shortcuts.folder,count:`${o.length}/${qy}`,onOpen:t}),e&&a.jsx("div",{className:"mt-0.5 pl-4",children:u&&a.jsxs("ul",{className:"space-y-0.5",children:[o.map(_=>a.jsxs("li",{className:"flex items-center gap-1",children:[a.jsx("button",{type:"button",title:`${_.title}
175
- ${d.chat.exampleFillHint}`,onClick:()=>s(_.prompt),className:`flex min-w-0 flex-1 items-center gap-2 ${nx}`,children:a.jsx("span",{className:"min-w-0 flex-1 truncate",children:_.title})}),a.jsx(h2,{label:d.common.edit,glyph:Zx,onClick:()=>h({..._})}),a.jsx(h2,{label:d.common.delete,glyph:Jx,danger:!0,onClick:()=>g(_)})]},_.id)),rM(o)&&a.jsx("li",{children:a.jsxs("button",{type:"button",title:d.chat.shortcuts.newFromComposer,onClick:S,className:`flex w-full items-center gap-2 ${nx}`,children:[a.jsx(_I,{size:Ye.inlineGlyph}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:d.chat.shortcuts.new})]})})]})}),a.jsx(Yt,{open:p!==null,title:T?d.chat.shortcuts.editTitle:d.chat.shortcuts.createTitle,onClose:()=>h(null),widthClass:"sm:max-w-lg",footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:()=>h(null),children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:N!==null,onClick:C,children:d.common.save})]}),children:p!==null&&a.jsxs("div",{className:"space-y-3",children:[a.jsx(at,{label:d.chat.shortcuts.titleLabel,hint:d.chat.shortcuts.titleHint(Nl),error:N==="titleTooLong"?d.chat.shortcuts.titleTooLong(Nl):void 0,value:p.title,autoFocus:!0,maxLength:Nl,onChange:_=>h({...p,title:_.target.value}),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing&&C()}}),a.jsx(ir,{label:d.chat.shortcuts.promptLabel,info:d.chat.shortcuts.promptInfo,infoLabel:d.common.moreInfoAbout(d.chat.shortcuts.promptLabel),hint:d.chat.shortcuts.promptHint(gu),error:N==="promptTooLong"?d.chat.shortcuts.promptTooLong(gu):void 0,value:p.prompt,rows:8,size:"sm",maxLength:gu,onChange:_=>h({...p,prompt:_.target.value})})]})}),a.jsx(ln,{open:x!==null,title:d.chat.shortcuts.deleteTitle,confirmLabel:d.common.delete,onClose:()=>g(null),onConfirm:()=>{x!==null&&w(sH(o,x.id)),g(null)},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:x!==null?d.chat.shortcuts.deleteConfirm(x.title):""})})]})}const cH=["always-ask","read-only","allow-all","deny-all"],ks=(e,t)=>`penguin.chatDraft.${e}.${t}`,aM=(e,t)=>`penguin.chatDraft.session.${e}.${t}`;function g2(e){if(typeof e!="object"||e===null)return;const t=e;if(!(typeof t.provider!="string"||typeof t.modelId!="string"))return{provider:t.provider,modelId:t.modelId}}function uH(e){if(!e)return{};try{return sM(JSON.parse(e))}catch{return{}}}function sM(e){if(typeof e!="object"||e===null)return{};const t=e,n={};typeof t.text=="string"&&(n.text=t.text),typeof t.agentId=="string"&&(n.agentId=t.agentId),typeof t.workspace=="string"&&(n.workspace=t.workspace);const s=g2(t.modelRef);s&&(n.modelRef=s),typeof t.handoffAgentId=="string"&&(n.handoffAgentId=t.handoffAgentId);const o=g2(t.switchModelRef);if(o&&(n.switchModelRef=o),Array.isArray(t.skills)){const c=t.skills.filter(u=>typeof u=="string");c.length>0&&(n.skills=c)}return typeof t.approvalMode=="string"&&cH.includes(t.approvalMode)&&(n.approvalMode=t.approvalMode),n}function $i(e,t=localStorage){try{return uH(t.getItem(e))}catch{return{}}}function Qs(e,t,n=localStorage){try{n.setItem(e,JSON.stringify(t))}catch{}}function Du(e,t=localStorage){try{t.removeItem(e)}catch{}}function iM(e,t,n=localStorage){const s=ks(e,t),o=$i(s,n);o.modelRef&&Qs(s,{...o,modelRef:void 0},n)}function dH(e,t,n=localStorage){const s=ks(e,t),o=$i(s,n);(o.agentId!==void 0||o.workspace!==void 0||o.approvalMode!==void 0)&&Qs(s,{...o,agentId:void 0,workspace:void 0,approvalMode:void 0},n)}const rd=(e,t)=>`penguin.chatDrafts.${e}.${t}`,mH=50,rx="penguin:draft-flush";function fH(e){if(!e)return[];try{const t=JSON.parse(e);if(!Array.isArray(t))return[];const n=[];for(const s of t){if(typeof s!="object"||s===null)continue;const o=s;typeof o.id!="string"||!o.id.startsWith("draft-")||n.push({id:o.id,savedAt:typeof o.savedAt=="string"?o.savedAt:"",draft:sM(o.draft)})}return n}catch{return[]}}const Vy=zl(()=>({cache:new Map})),ax=[];function oM(e){try{return localStorage}catch{return null}}function ad(e,t){const{cache:n}=Vy.getState(),s=n.get(e);if(s)return s;const o=oM();let c=ax;if(o)try{c=fH(o.getItem(e))}catch{c=ax}return n.set(e,c),c}function Gy(e,t,n){const s=oM();if(s)try{t.length===0?s.removeItem(e):s.setItem(e,JSON.stringify(t))}catch{}Vy.setState(o=>({cache:new Map(o.cache).set(e,t)}))}function pH(e,t){return Bl(Vy,()=>e&&t?ad(rd(e,t)):ax)}const hH=()=>`draft-${crypto.randomUUID().replace(/-/g,"").slice(0,8)}`;function Yl(e,t,n){typeof window<"u"&&window.dispatchEvent(new Event(rx));const s=ks(e,t),o=$i(s,n);if(!o.text||o.text.trim()==="")return null;const c=rd(e,t),u={id:hH(),savedAt:new Date().toISOString(),draft:o};return Gy(c,[u,...ad(c)].slice(0,mH)),o.modelRef?Qs(s,{modelRef:o.modelRef},n):Du(s,n),u.id}function x2(e,t,n,s){return ad(rd(e,t)).find(o=>o.id===n)??null}function gH(e,t,n,s,o){const c=rd(e,t),u=ad(c);u.some(f=>f.id===n)&&Gy(c,u.map(f=>f.id===n?{...f,draft:s}:f))}function lM(e,t,n,s){const o=rd(e,t),c=ad(o);c.some(u=>u.id===n)&&Gy(o,c.filter(u=>u.id!==n))}function sx(e){return((e.draft.text??"").split(`
176
- `).map(n=>n.trim()).find(n=>n!=="")??"").slice(0,80)}const $u="penguin:chat-defaults-changed";function xH(e){window.dispatchEvent(new CustomEvent($u,{detail:e}))}function cM(e,t){const n=e.detail;return n&&n.projectId===t?n:null}const uM="flex max-w-64 items-center gap-1.5 rounded-full border border-gray-300 bg-white py-1 pl-1.5 pr-2 text-xs text-gray-600 transition-colors duration-150 hover:bg-gray-50 hover:text-gray-900 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100";function sd({projectId:e,workspace:t,onChange:n,variant:s="pill",trigger:o,fieldLabel:c,emptyLabel:u,menuHint:f,clearLabel:p}){const h=c??d.chat.workspace,[x,g]=y.useState(!1),[v,w]=y.useState({right:!1}),S=y.useRef(!1),[C,N]=y.useState(null),[T,_]=y.useState(!1),[R,D]=y.useState(null),[z,E]=y.useState("");y.useEffect(()=>{E(C?.path??"")},[C]);const L=y.useRef(0),F=y.useCallback((ie,I)=>{const A=++L.current;_(!0),D(null),GE(e,ie).then(Q=>{A===L.current&&N(Q)}).catch(Q=>{A===L.current&&(I?.onError?I.onError():D(Ae(Q)))}).finally(()=>{A===L.current&&_(!1)})},[e]),V=ie=>{if(ie&&!S.current){S.current=!0;const I=t.trim();F(I.startsWith("/")?I:"")}},P=ie=>{g(ie),V(ie)},B=ie=>{const I=!x;if(I){const A=ie.currentTarget.getBoundingClientRect(),Q=parseFloat(getComputedStyle(document.documentElement).fontSize),j=12,U=Math.min(20*Q,window.innerWidth-2*Q),ee=window.innerWidth-j-A.left,re=A.right-j;ee>=U?w({right:!1}):re>ee?w({right:!0,...re<U?{maxWidth:re}:{}}):w({right:!1,maxWidth:ee})}g(I),V(I)},Y=()=>{const ie=z.trim();if(!ie||ie===C?.path){E(C?.path??"");return}F(ie,{onError:()=>{Be(d.chat.workspaceDirInvalid),E(C?.path??"")}})},q=t.trim(),K=q?q.split("/").filter(Boolean).pop()??"/":u??d.chat.workspaceAuto,H=C?.parent??null,$=(C?.entries??[]).filter(ie=>!ie.name.startsWith(".")),X=ie=>a.jsx(Oe,{d:El,size:Ye.rowLead,className:`text-gray-400 ${ie}`}),le=a.jsxs("div",{className:"space-y-1.5 px-2.5 pb-2.5 pt-2",children:[a.jsxs("div",{className:"rounded-md border border-gray-200 dark:border-gray-800",children:[a.jsxs("div",{className:"flex items-center gap-1.5 border-b border-gray-100 px-1.5 py-1 dark:border-gray-800",children:[a.jsx("input",{value:z,placeholder:"…","aria-label":h,...Gu,onChange:ie=>E(ie.target.value),onBlur:Y,onKeyDown:ie=>{ie.key==="Enter"&&!ie.nativeEvent.isComposing?(ie.preventDefault(),Y()):ie.key==="Escape"&&E(C?.path??"")},className:"min-w-0 flex-1 rounded border border-transparent bg-transparent px-1 py-0.5 font-mono text-xs text-gray-600 focus:border-gray-300 focus:outline-none dark:text-gray-300 dark:focus:border-gray-600"}),a.jsx("button",{type:"button",disabled:!C,onClick:()=>{C&&(n(C.path),g(!1))},className:"shrink-0 rounded border border-gray-300 px-1.5 py-0.5 text-xs text-gray-700 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:d.chat.workspaceUseThis})]}),a.jsxs("ul",{className:"max-h-40 overflow-y-auto py-1",children:[H!==null&&a.jsx("li",{children:a.jsxs("button",{type:"button",disabled:T,onClick:()=>F(H),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-400 dark:hover:bg-gray-800",children:["↰ ",d.chat.workspaceUp]})}),$.map(ie=>a.jsx("li",{children:a.jsxs("button",{type:"button",disabled:T,onClick:()=>F(ie.path),className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left font-mono text-xs text-gray-700 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-300 dark:hover:bg-gray-800",children:[a.jsx(Oe,{d:El,className:"text-gray-400"}),a.jsx("span",{className:"min-w-0 flex-1 truncate",title:ie.name,children:ie.name})]})},ie.path)),C&&$.length===0&&a.jsx("li",{className:"px-2.5 py-1.5 text-xs text-gray-400",children:d.chat.workspaceNoSubdirs}),T&&a.jsx("li",{className:"px-2.5 py-1.5 text-xs text-gray-400",children:d.common.loading}),R&&a.jsxs("li",{className:"flex items-center justify-between gap-2 px-2.5 py-1.5 text-xs text-red-500",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate",title:R,children:R}),a.jsx("button",{type:"button",disabled:T,onClick:()=>F(""),className:"shrink-0 rounded border border-gray-300 px-1.5 py-0.5 text-xs text-gray-700 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:d.common.retry})]})]})]}),q&&a.jsx("button",{type:"button",onClick:()=>{n(""),g(!1)},className:"text-xs text-gray-500 underline decoration-gray-300 underline-offset-2 transition-colors duration-150 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200",children:p??d.chat.workspaceClear}),a.jsx("p",{className:"px-0.5 text-xs leading-5 text-gray-400 dark:text-gray-500",children:f??d.chat.workspaceHint})]});return o?a.jsx(Qn,{open:x,setOpen:P,portal:{direction:"down",align:"right"},menuClass:"w-64",button:o(x,()=>P(!x)),children:le}):s==="form"?a.jsx(Ru,{open:x,setOpen:P,leading:X(""),label:K,...q?{labelClassName:"font-mono"}:{},title:q?`${h}:${q}`:f??d.chat.workspaceHint,ariaLabel:h,ariaHaspopup:"dialog",menuClass:"w-80",children:le}):a.jsx(Qn,{open:x,setOpen:g,menuClass:`top-full mt-1 w-80 max-w-[calc(100vw-2rem)] ${v.right?"right-0 origin-top-right":"left-0 origin-top-left"}`,...v.maxWidth!==void 0?{menuStyle:{maxWidth:v.maxWidth}}:{},button:a.jsxs("button",{type:"button",title:q?`${h}:${q}`:f??d.chat.workspaceHint,"aria-label":h,onClick:B,className:uM,children:[X("ml-0.5"),a.jsx("span",{className:`min-w-0 truncate ${q?"font-mono":""}`,children:K}),a.jsx(Zn,{open:x,size:12,className:"shrink-0 text-gray-400"})]}),children:le})}const yH=300;function y2(e){try{return sessionStorage.getItem(`penguin.chatRouteApplied.${e}`)}catch{return null}}function b2(e,t){try{sessionStorage.setItem(`penguin.chatRouteApplied.${e}`,t)}catch{}}const bH={webapps:"M3 6a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6zM3 9h18M6 6.5h.01M9 6.5h.01",agents:"M12 3v3m-6 4a6 6 0 0 1 12 0v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5zm3 3h.01M15 13h.01",schedules:"M12 2a10 10 0 1 0 0 20 10 10 0 1 0 0-20M12 6.5V12l3.5 2"};function vH({projectId:e,models:t,draftId:n}){const s=yr(),o=$r(),{agents:c,currentAgent:u,setCurrentAgentId:f}=en(),{add:p}=Ii(),h=mn().user?.userId??null,[x]=y.useState(()=>n!==void 0&&(!h||x2(h,e,n)===null)),[g]=y.useState(()=>h?n!==void 0?x2(h,e,n)?.draft??{}:$i(ks(h,e)):{});y.useEffect(()=>{x&&s("/chat/new",{replace:!0})},[x,s]);const[v,w]=y.useState(g.agentId??u?.agentId??null),[S,C]=y.useState(g.workspace??"");y.useEffect(()=>{JT(S||null)},[S]);const[N,T]=y.useState(g.approvalMode??"allow-all"),[_,R]=y.useState(g.modelRef??null),D=y.useRef(g.text??""),z=y.useRef(g.skills??[]),[E,L]=y.useState(null),F=y.useRef(!1);y.useEffect(()=>{let pe=!1;return Qj(e).then($e=>{!pe&&!F.current&&L($e)}).catch(()=>{!pe&&!F.current&&L({})}),()=>{pe=!0}},[e]);const V=y.useRef({agent:!1,workspace:!1,approval:!1}),P=o.state,B=P?.agentId,Y=y.useRef(null),q=y.useRef(!1);y.useEffect(()=>{if(c.length===0)return;const pe=$e=>!!$e&&c.some(nt=>nt.agentId===$e);if(B&&Y.current!==o.key&&y2("agentId")!==o.key&&(Y.current=o.key,b2("agentId",o.key),pe(B))){w(B);return}if(E?.agentId!==void 0&&!q.current&&(q.current=!0,Y.current===null&&g.agentId===void 0&&!V.current.agent&&pe(E.agentId))){w(E.agentId);return}pe(v)||w((c.find($e=>$e.agentId==="default_agent")??c[0])?.agentId??null)},[c,v,o.key,B,E,g.agentId]);const K=P?.workspace,H=y.useRef(null);y.useEffect(()=>{K===void 0||H.current===o.key||y2("workspace")===o.key||(H.current=o.key,b2("workspace",o.key),C(K))},[o.key,K]);const $=y.useRef(!1);y.useEffect(()=>{E===null||$.current||($.current=!0,E.workspace!==void 0&&K===void 0&&g.workspace===void 0&&!V.current.workspace&&C(E.workspace),E.approvalMode!==void 0&&g.approvalMode===void 0&&!V.current.approval&&T(E.approvalMode))},[E,K,g.workspace,g.approvalMode]),y.useEffect(()=>{if(!t||_&&t.models.some($e=>zt($e,_)))return;const pe=t.models[0];R(t.defaultModel??(pe?{provider:pe.provider,modelId:pe.modelId}:null))},[t,_]);const X=y.useCallback(pe=>{if(pe.defaults){const $e=pe.defaults;F.current=!0,L($e),V.current={agent:!1,workspace:!1,approval:!1},C($e.workspace??""),T($e.approvalMode??"allow-all"),(gt=>gt!==void 0&&c.some(Ke=>Ke.agentId===gt))($e.agentId)?w($e.agentId):c.length>0&&w(u?.agentId??(c.find(gt=>gt.agentId==="default_agent")??c[0])?.agentId??null)}pe.defaultModel!==void 0&&R(pe.defaultModel)},[c,u]),le=y.useRef(X);le.current=X,y.useEffect(()=>{const pe=$e=>{const nt=cM($e,e);nt&&le.current(nt)};return window.addEventListener($u,pe),()=>window.removeEventListener($u,pe)},[e]);const[ie,I]=y.useState(null);y.useEffect(()=>{if(I(null),!v)return;let pe=!1;return Ao(e,v).then($e=>{pe||I($e.config.model?.thinkingLevel??"")}).catch(()=>{}),()=>{pe=!0}},[e,v]);const A=ie===null||E===null?null:dz(ie,E.thinkingLevel),Q=y.useRef(null);Q.current=ie;const j=y.useCallback(pe=>{if(!v||!pe)return;const $e=Q.current;I(pe),To(e,v,{config:{model:{thinkingLevel:pe}}}).catch(nt=>{I($e),Be(Ae(nt))})},[e,v]),[U,ee]=y.useState([]),[re,ke]=y.useState(!1);y.useEffect(()=>{if(ee($e=>$e.length>0?[]:$e),ke(!1),!v)return;let pe=!1;return Bu(e,v).then($e=>{pe||ee($e.skills)}).catch(()=>{}).finally(()=>{pe||ke(!0)}),()=>{pe=!0}},[e,v]);const be=y.useRef(null),ye=y.useCallback(()=>{be.current!==null&&(window.clearTimeout(be.current),be.current=null)},[]),Se=y.useCallback(()=>{if(ye(),!h)return;const pe={text:D.current,workspace:S,approvalMode:N};v&&(pe.agentId=v),_&&(pe.modelRef=_),z.current.length>0&&(pe.skills=z.current),n!==void 0?gH(h,e,n,pe):Qs(ks(h,e),pe)},[ye,h,e,n,v,S,N,_]),Me=y.useRef(Se);y.useEffect(()=>{Me.current=Se,Se()},[Se]);const ze=y.useCallback(pe=>{D.current=pe,ye(),be.current=window.setTimeout(()=>{be.current=null,Me.current()},yH)},[ye]),De=y.useCallback(pe=>{z.current=pe,Me.current()},[]);y.useEffect(()=>()=>{be.current!==null&&(window.clearTimeout(be.current),Me.current())},[]),y.useEffect(()=>{const pe=()=>{be.current!==null&&(window.clearTimeout(be.current),be.current=null,Me.current())};return window.addEventListener(rx,pe),()=>window.removeEventListener(rx,pe)},[]);const ct=y.useCallback(()=>{if(ye(),z.current=[],D.current="",!!h){if(n!==void 0){lM(h,e,n);return}_?Qs(ks(h,e),{modelRef:_}):Du(ks(h,e))}},[ye,h,e,n,_]),bt=pe=>{V.current.agent=!0,w(pe.agentId),f(pe.agentId)},he=y.useCallback(pe=>{V.current.workspace=!0,C(pe)},[]),ne=y.useCallback(pe=>{V.current.approval=!0,T(pe)},[]),oe=y.useRef(!1),J=y.useCallback(async(pe,$e=null)=>{if(!v||oe.current)return!1;oe.current=!0;let nt=null;try{const gt={approvalMode:N};_&&(gt.modelId=_.modelId,gt.provider=_.provider),S.trim()&&(gt.workspace=S.trim());const Ke=await u0(e,v,gt);nt=Ke.session.sessionId;const dt=await su(nt,{input:pe,...$e?{goal:$e}:{}}),pt=await d0(dt.sessionId).catch(()=>null);return p(pt?.session??Ke.session),ct(),HT(dt.sessionId),s(`/chat/${dt.sessionId}`,{replace:!0}),!0}catch(gt){return nt&&nf(nt).catch(()=>{}),Be(Ae(gt,_?{modelId:_.modelId}:{})),!1}finally{oe.current=!1}},[e,v,N,_,S,p,ct,s]),ht=y.useRef(null),ve=y.useCallback(pe=>{ht.current?.fillExample(d.chat.exampleTasks[pe.id].prompt,pe.skills)},[]),Xe=y.useCallback(pe=>{ht.current?.fillExample(pe,[])},[]),[Ge,He]=y.useState(tx[0].id),Pe=c.find(pe=>pe.agentId===v)??null,W=t?.models.find(pe=>zt(pe,_)),me=W?.contextWindow,Ue=W?.vision!==!1;return a.jsxs("div",{className:"anim-fade flex min-h-0 flex-1 flex-col overflow-y-auto px-3 py-6 md:px-4",children:[a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"mx-auto w-full max-w-3xl",children:[a.jsxs("div",{className:"mb-10 text-center",children:[a.jsx(OT,{className:"mx-auto mb-1 h-36 w-36 rounded-3xl"}),a.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-gray-900 dark:text-gray-100",children:d.appName}),a.jsx("p",{className:"mt-2 text-base text-gray-400 dark:text-gray-500",children:d.chat.draftSubtitle}),a.jsx(kH,{})]}),a.jsx(Iy,{status:"idle",controlRef:ht,onSend:J,onStop:async()=>{},onCompact:async()=>{},modelRef:_,models:t?.models??[],onChangeModel:R,thinkingLevel:A,onChangeThinkingLevel:j,...t?.defaultModel!==void 0?{defaultModel:t.defaultModel}:{},...me!==void 0?{contextWindow:me}:{},contextNow:0,vision:Ue,approvalMode:N,onChangeApprovalMode:ne,modeSaving:!1,autoFocus:!0,agents:c,...v?{currentAgentId:v}:{},skills:U,...g.skills&&g.skills.length>0?{initialSkills:g.skills}:{},onSkillsChange:De,initialText:g.text??"",onTextChange:ze}),a.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[a.jsx(wH,{agents:c,selected:Pe,onSelect:bt}),a.jsx(sd,{projectId:e,workspace:S,onChange:he})]}),a.jsxs("div",{className:"mt-6 space-y-1",children:[tx.map(pe=>{const $e=pe.id===Ge;return a.jsxs("div",{children:[a.jsx(nM,{open:$e,glyph:bH[pe.id],label:d.chat.exampleFolders[pe.id],count:pe.tasks.length,onOpen:()=>He(pe.id)}),$e&&a.jsx("ul",{className:"mt-0.5 space-y-0.5 pl-4",children:pe.tasks.map(nt=>{const gt=d.chat.exampleTasks[nt.id];return a.jsx("li",{children:a.jsx("button",{type:"button",title:`${gt.desc}
177
- ${d.chat.exampleFillHint}`,disabled:!re,onClick:()=>ve(nt),className:`flex w-full items-center gap-2 ${nx}`,children:a.jsx("span",{className:"min-w-0 flex-1 truncate",children:gt.label})})},nt.id)})})]},pe.id)}),a.jsx(lH,{open:Ge===p2,onOpen:()=>He(p2),readComposerText:()=>D.current,onFill:Xe})]})]}),a.jsx("div",{className:"flex-1"})]})}const v2="ml-1.5 inline-block align-super text-[10px] leading-4 text-gray-400 dark:text-gray-500";function kH(){const{locale:e}=Dr(),{version:t,update:n}=Px(!0);if(t===null)return null;const s=t.buildDate;return a.jsxs("p",{className:"mt-1.5 text-xs text-gray-400 dark:text-gray-500",children:[`v${t.version}${s!==null?` · ${d.update.lastUpdated(k0(s,e))}`:""}`,n!==null&&n.updateAvailable&&n.latestVersion!==null&&(n.releaseUrl!==null?a.jsx("a",{href:n.releaseUrl,target:"_blank",rel:"noopener noreferrer",title:d.update.newVersion(n.latestVersion),"aria-label":d.update.newVersion(n.latestVersion),className:`${v2} hover:underline`,children:d.update.newVersionBadge}):a.jsx("span",{className:v2,children:d.update.newVersionBadge}))]})}function wH({agents:e,selected:t,onSelect:n}){const[s,o]=y.useState(!1);return a.jsx(Qn,{open:s,setOpen:o,menuClass:"left-0 top-full mt-1 w-72 max-w-[calc(100vw-2rem)] origin-top-left",button:a.jsxs("button",{type:"button",title:d.chat.chooseAgent,"aria-label":d.chat.chooseAgent,onClick:()=>o(!s),className:uM,children:[t?a.jsx(Ha,{id:t.agentId,name:_n(t),size:16,className:"shrink-0 rounded"}):null,a.jsx("span",{className:"min-w-0 truncate",children:t?_n(t):d.common.loading}),a.jsx(Zn,{open:s,size:12,className:"shrink-0 text-gray-400"})]}),children:a.jsxs("div",{className:"max-h-56 overflow-y-auto",children:[e.length===0&&a.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:d.common.loading}),e.map(c=>{const u=c.agentId===t?.agentId;return a.jsxs("button",{type:"button","aria-pressed":u,onClick:()=>{n(c),o(!1)},className:`flex w-full items-center ${Ro.menu} px-3 py-1.5 text-left transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800`,children:[a.jsx(Ha,{id:c.agentId,name:_n(c),size:20,className:"shrink-0 rounded"}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:`block truncate text-xs ${u?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:_n(c)}),c.description&&a.jsx("span",{className:"block truncate text-[11px] text-gray-400 dark:text-gray-500",children:c.description})]}),a.jsx("span",{className:"w-4 shrink-0 text-center text-xs text-gray-500 dark:text-gray-400",children:u?"✓":""})]},c.agentId)})]})})}function SH(e,t){return e.projectId===t?e:null}function jH(e,t){return`${e}:${t}`}function dM(){return{sessionId:null,taskCount:0,sessionCost:null,costUncosted:!1,settledUsd:0,lastLiveUsd:0,liveAtFetchUsd:0,pendingFetchSnapshot:!1,shownUsd:null,shownUncosted:!1}}function CH(e,t,n){e.sessionId===t&&n!==null&&(e.costUncosted=n.hasUncosted,n.cost!=null&&(e.sessionCost=n.cost,e.settledUsd=0,e.pendingFetchSnapshot=!0))}function k2(e){return e.sessionCost!=null||e.settledUsd>0?(e.sessionCost??0)+e.settledUsd:null}function w2(e,t,n,s){return t!=null&&(e.shownUsd=t,e.shownUncosted=n),{costText:t!=null?rs(t,s):null,costUncosted:n}}function NH(e,t){if(t.sessionId!==e.sessionId&&Object.assign(e,dM(),{sessionId:t.sessionId}),t.loading){const f=e.shownUsd??k2(e),p=e.shownUsd!=null?e.shownUncosted:e.costUncosted;return w2(e,f,p,t.currency)}if(t.taskCount<e.taskCount&&(e.taskCount=t.taskCount,e.lastLiveUsd=0,e.liveAtFetchUsd=0),e.pendingFetchSnapshot&&(!t.taskOpen||t.liveUsd!=null)){e.pendingFetchSnapshot=!1;const f=t.taskOpen?t.liveUsd??0:0;e.liveAtFetchUsd=f,e.lastLiveUsd=f}(t.taskCount>e.taskCount||!t.taskOpen&&(e.lastLiveUsd>0||e.liveAtFetchUsd>0))&&(e.settledUsd+=Math.max(0,e.lastLiveUsd-e.liveAtFetchUsd),e.lastLiveUsd=0,e.liveAtFetchUsd=0),e.taskCount=t.taskCount,t.taskOpen&&t.liveUsd!=null&&(e.lastLiveUsd=t.liveUsd);const n=k2(e),s=t.taskOpen&&t.liveUsd!=null?Math.max(0,t.liveUsd-e.liveAtFetchUsd):null,o=s!=null&&(s>0||n!=null)?(n??0)+s:n;let c;o==null||t.taskOpen&&e.shownUsd!=null&&o<e.shownUsd?c=e.shownUsd:c=o;const u=o==null?e.shownUncosted:e.costUncosted;return w2(e,c,u,t.currency)}function Xl(e){return a.jsx("span",{className:"absolute",children:a.jsx("input",{type:"file",className:"sr-only",...e})})}const mM=new Set(["text","plaintext","txt"]),TH=new Map(Object.entries({c:()=>an(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>an(()=>import("./cpp-DIPi6g--.js"),__vite__mapDeps([0,1,2])),css:()=>an(()=>import("./css-CLj8gQPS.js"),[]),diff:()=>an(()=>import("./diff-D97Zzqfu.js"),[]),go:()=>an(()=>import("./go-C27-OAKa.js"),[]),html:()=>an(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),ini:()=>an(()=>import("./ini-BEwlwnbL.js"),[]),java:()=>an(()=>import("./java-CylS5w8V.js"),[]),javascript:()=>an(()=>import("./javascript-wDzz0qaB.js"),[]),json:()=>an(()=>import("./json-Cp-IABpG.js"),[]),jsx:()=>an(()=>import("./jsx-g9-lgVsj.js"),[]),log:()=>an(()=>import("./log-2UxHyX5q.js"),[]),markdown:()=>an(()=>import("./markdown-Cvjx9yec.js"),[]),php:()=>an(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([6,3,4,5,7,8,2,9])),python:()=>an(()=>import("./python-B6aJPvgy.js"),[]),ruby:()=>an(()=>import("./ruby-B13GW9FM.js"),__vite__mapDeps([10,3,4,5,7,8,2,11,12,13,0,1,14,15])),rust:()=>an(()=>import("./rust-B1yitclQ.js"),[]),shellscript:()=>an(()=>import("./shellscript-Yzrsuije.js"),[]),sql:()=>an(()=>import("./sql-CRqJ_cUM.js"),[]),toml:()=>an(()=>import("./toml-vGWfd6FD.js"),[]),tsx:()=>an(()=>import("./tsx-COt5Ahok.js"),[]),typescript:()=>an(()=>import("./typescript-BPQ3VLAy.js"),[]),xml:()=>an(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])),yaml:()=>an(()=>import("./yaml-Buea-lGh.js"),[])})),MH=new Map(Object.entries({"c++":"cpp",bash:"shellscript",cjs:"javascript",cts:"typescript",js:"javascript",md:"markdown",mjs:"javascript",mts:"typescript",properties:"ini",py:"python",rb:"ruby",rs:"rust",sh:"shellscript",shell:"shellscript",ts:"typescript",yml:"yaml",zsh:"shellscript"})),EH=new Map(Object.entries({html:"html",htm:"html",css:"css",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",json:"json",md:"markdown",py:"python",rb:"ruby",php:"php",go:"go",rs:"rust",java:"java",c:"c",h:"c",cpp:"cpp",hpp:"cpp",sh:"shellscript",bash:"shellscript",yml:"yaml",yaml:"yaml",toml:"toml",ini:"ini",conf:"ini",xml:"xml",sql:"sql",log:"log"})),fM="text";function AH(e){return EH.get(e.toLowerCase())??fM}function $W(e){const t=e.trim().toLowerCase();if(!t||mM.has(t))return fM;const n=MH.get(t)??t;return TH.has(n)?n:void 0}function UW(e){return mM.has(e)}const _H=new Set(["txt","md","json","js","mjs","cjs","ts","tsx","jsx","py","sh","bash","yaml","yml","toml","css","html","htm","csv","log","xml","ini","conf","rs","go","java","c","h","cpp","hpp","sql","rb","php","gitignore","env"]),RH=new Set(["png","jpg","jpeg","gif","webp","svg"]),IH=new Set(["html","htm"]),Am=256*1024,S2=64*1024;function j2(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():e.toLowerCase()}function C2(e){return e.includes("/")?e.slice(0,e.lastIndexOf("/")):""}const N2=/^[a-z][a-z0-9+.-]*:/i;function T2(e,t){const n=t.startsWith("/")||e===""?[]:e.split("/");for(const s of t.split("/"))s===""||s==="."||(s===".."?n.pop():n.push(s));return n.join("/")}const Kg="<script>(function(){function mk(){var m={};return{getItem:function(k){return k in m?m[k]:null},setItem:function(k,v){m[k]=String(v)},removeItem:function(k){delete m[k]},clear:function(){m={}},key:function(i){return Object.keys(m)[i]||null},get length(){return Object.keys(m).length}}}['localStorage','sessionStorage'].forEach(function(n){try{window[n].length}catch(e){Object.defineProperty(window,n,{value:mk(),configurable:true})}})})();<\/script>";function LH(e){return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,t=>t+Kg):/<html[^>]*>/i.test(e)?e.replace(/<html[^>]*>/i,t=>t+Kg):Kg+e}let _m=0;function OH({session:e,openRequest:t,active:n,onPreviewOpen:s,reloadSignal:o}){const{previewIsolated:c}=mn(),[u,f]=y.useState(""),[p,h]=y.useState(null),[x,g]=y.useState(null),[v,w]=y.useState(null),[S,C]=y.useState(!1),[N,T]=y.useState(null),[_,R]=y.useState(0),[D,z]=y.useState(!1),[E,L]=y.useState("rendered"),[F,V]=y.useState(null),P=y.useRef(c);P.current=c,y.useEffect(()=>{let j=!1;return g(null),wA(e.sessionId,u).then(U=>{j||h({base:u,res:U})}).catch(U=>{j||g(U instanceof xr?U.message:d.files.loadFailed)}),()=>{j=!0}},[e.sessionId,u,_,o]);const[B,Y]=y.useState(e.sessionId);B!==e.sessionId&&(Y(e.sessionId),f(""),w(null),h(null),V(null),_m++);const q=y.useRef(n);y.useEffect(()=>{n&&!q.current&&R(j=>j+1),q.current=n},[n]);const K=y.useRef(s);K.current=s;const H=y.useCallback(async(j,U)=>{const ee=U?.refresh===!0;ee||K.current?.();const re=j.includes("/")?j.slice(j.lastIndexOf("/")+1):j,ke=j2(re),be=++_m,ye=ze=>{be===_m&&w(ze)};if(ee||(L("rendered"),V(null)),RH.has(ke)){ye({path:j,name:re,kind:"image",nonce:be});return}if(ke==="pdf"){ye({path:j,name:re,kind:"pdf",nonce:be});return}const Se=IH.has(ke),Me=ke==="md";if(!Se&&!_H.has(ke)){ye({path:j,name:re,kind:"unsupported",nonce:be});return}if(Se&&P.current){ye({path:j,name:re,kind:"html",nonce:be});return}try{const ze=await fetch(ji(e.sessionId,j),{credentials:"same-origin"});if(!ze.ok)throw new Error(String(ze.status));const De=await ze.text(),ct=De.length>Am;!ee&&Me&&De.length>S2&&be===_m&&L("source"),ye({path:j,name:re,kind:Se?"html":Me?"md":"text",content:ct?De.slice(0,Am):De,truncated:ct,nonce:be})}catch{ee||ye({path:j,name:re,kind:"unsupported",nonce:be})}},[e.sessionId]);y.useEffect(()=>{if(v?.kind!=="html"||v.content!==void 0||E!=="source"&&c)return;const j=v.path;let U=!1;return V(null),(async()=>{try{const ee=await fetch(ji(e.sessionId,j),{credentials:"same-origin"});if(!ee.ok)throw new Error(String(ee.status));const re=await ee.text();if(U)return;const ke=re.length>Am;w(be=>be!==null&&be.kind==="html"&&be.path===j&&be.content===void 0?{...be,content:ke?re.slice(0,Am):re,truncated:ke}:be)}catch{U||V(d.files.loadFailed)}})(),()=>{U=!0}},[v,E,c,e.sessionId]);const $=y.useRef(null);$.current=v?.path??null;const X=y.useRef(o);y.useEffect(()=>{if(o===X.current)return;X.current=o;const j=$.current;j!==null&&H(j,{refresh:!0})},[o,H]);const le=y.useRef(null);y.useEffect(()=>{if(!t||le.current===t)return;le.current=t;const j=t.path,U=j.includes("/")?j.slice(0,j.lastIndexOf("/")):"";f(U),R(ee=>ee+1),H(j)},[t,H]);const ie=j=>{C(!0),g(null),(async()=>{try{for(const U of j){const ee=await new Promise((re,ke)=>{const be=new FileReader;be.onload=()=>{const ye=be.result;re(ye.slice(ye.indexOf(",")+1))},be.onerror=()=>ke(new Error("read failed")),be.readAsDataURL(U)});await SA(e.sessionId,Ym(u,U.name),ee)}yt(d.files.uploaded),R(U=>U+1)}catch(U){Be(Ae(U))}finally{C(!1)}})()},I=j=>{const U=j.target.files?[...j.target.files]:[];if(j.target.value="",U.length===0)return;const ee=new Set((p?.res.entries??[]).map(ke=>ke.name)),re=U.filter(ke=>ee.has(ke.name)).map(ke=>ke.name);re.length>0?T({files:U,clashes:re}):ie(U)},A=u===""?[]:u.split("/"),Q=x===null&&p!==null&&p.base!==u;return v!==null?a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[a.jsxs("button",{type:"button",onClick:()=>{w(null),R(j=>j+1)},title:d.files.backToList,className:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-sm text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[a.jsx(Oe,{d:"M15 18l-6-6 6-6",size:Ye.rowLead}),d.files.backToList]}),a.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-sm font-semibold",title:v.path,children:v.name}),(v.kind==="html"||v.kind==="md")&&a.jsx("div",{className:"flex shrink-0 rounded-md bg-gray-100 p-0.5 dark:bg-gray-800",children:[["rendered",d.files.htmlRendered],["source",d.files.htmlSource]].map(([j,U])=>a.jsx("button",{type:"button",onClick:()=>L(j),className:`rounded px-2 py-0.5 text-xs transition-colors duration-150 ${E===j?"bg-white font-medium text-gray-900 shadow-sm dark:bg-gray-600 dark:text-gray-100":"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200"}`,children:U},j))}),/\.html?$/i.test(v.name)&&a.jsxs("a",{href:V1(e.sessionId,v.path),target:"_blank",rel:"noopener noreferrer",title:c?void 0:d.files.previewNotIsolatedHint,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-transparent bg-transparent px-2.5 py-1 text-xs font-medium text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:[d.files.openInNewTab,!c&&a.jsx("span",{"aria-label":d.files.previewNotIsolatedHint,className:sn.attention,children:"⚠"})]}),a.jsx("a",{href:ji(e.sessionId,v.path,!0),download:v.name,className:"inline-flex shrink-0 items-center rounded-md border border-transparent bg-transparent px-2.5 py-1 text-xs font-medium text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:d.files.download})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3 [scrollbar-gutter:stable]",children:v.kind==="image"?a.jsx("img",{src:ji(e.sessionId,v.path),alt:v.name,className:"max-w-full rounded-md border border-gray-200 dark:border-gray-800"},v.nonce):v.kind==="pdf"?a.jsx("iframe",{src:ji(e.sessionId,v.path),title:v.name,className:"h-full min-h-[60vh] w-full rounded-md border border-gray-200 dark:border-gray-800"},v.nonce):v.kind==="html"&&E==="rendered"?c?a.jsx("iframe",{src:V1(e.sessionId,v.path),title:v.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-downloads",className:"h-full min-h-[60vh] w-full rounded-md border border-gray-200 bg-white dark:border-gray-800"},v.nonce):v.content===void 0?F!==null?a.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:F}):a.jsx(Sr,{rows:6}):a.jsx("iframe",{srcDoc:LH(v.content),title:v.name,sandbox:"allow-scripts",className:"h-full min-h-[60vh] w-full rounded-md border border-gray-200 bg-white dark:border-gray-800"}):v.kind==="md"&&E==="rendered"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"md-body text-base leading-relaxed text-gray-800 dark:text-gray-100",children:a.jsx(Zu,{remarkPlugins:Ju,components:{img:({src:j,alt:U})=>a.jsx("img",{src:typeof j=="string"&&!N2.test(j)?`${ji(e.sessionId,T2(C2(v.path),j))}&v=${v.nonce}`:j,alt:U??"",loading:"lazy",className:"max-w-full"}),a:({href:j,children:U})=>{if(typeof j!="string"||j.startsWith("#"))return a.jsx("a",{href:j,children:U});if(N2.test(j))return a.jsx("a",{href:j,target:"_blank",rel:"noreferrer",children:U});const ee=T2(C2(v.path),j);return a.jsx("a",{href:ji(e.sessionId,ee),onClick:re=>{re.preventDefault(),H(ee)},children:U})}},children:v.content??""})}),v.truncated&&a.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["… ",d.files.previewTruncated]})]}):v.kind==="text"||v.kind==="html"||v.kind==="md"?v.content===void 0?F!==null?a.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:F}):a.jsx(Sr,{rows:6}):a.jsxs(a.Fragment,{children:[a.jsx(Cy,{language:AH(j2(v.name)),code:v.content,highlight:v.content.length<=S2}),v.truncated&&a.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["… ",d.files.previewTruncated]})]}):a.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:d.files.previewUnsupported})})]}):a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[a.jsx("button",{type:"button",disabled:Q,onClick:()=>{f("")},className:"rounded px-1.5 py-0.5 text-sm text-gray-600 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-300 dark:hover:bg-gray-800",children:d.files.root}),A.map((j,U)=>a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-gray-300 dark:text-gray-700",children:"/"}),a.jsx("button",{type:"button",disabled:Q,onClick:()=>f(A.slice(0,U+1).join("/")),className:"max-w-32 truncate rounded px-1 py-0.5 text-sm text-gray-600 transition-colors duration-150 hover:bg-gray-100 disabled:opacity-50 dark:text-gray-300 dark:hover:bg-gray-800",children:j})]},U)),a.jsx("span",{className:"flex-1"}),a.jsx(Qn,{open:D,setOpen:z,menuClass:"right-0 top-full mt-1 w-max max-w-72 origin-top-right",button:a.jsx(ge,{size:"sm",variant:D?"primary":"ghost",onClick:()=>z(j=>!j),children:d.files.details}),children:a.jsxs("div",{className:"px-3.5 py-2.5",children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.files.workspacePath}),a.jsx("p",{className:"mt-1 break-all font-mono text-xs leading-5",children:e.workspace})]})}),a.jsx(ge,{size:"sm",variant:"ghost",onClick:()=>R(j=>j+1),children:d.files.refresh}),a.jsxs("label",{className:"inline-flex cursor-pointer items-center rounded-md border border-transparent bg-transparent px-2.5 py-1 text-xs font-medium text-gray-600 transition-colors duration-150 focus-within:ring-2 focus-within:ring-gray-400/30 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:[a.jsx(Xl,{multiple:!0,onChange:I,disabled:S}),S?d.common.saving:d.files.upload]})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:x?a.jsx("p",{className:"px-3 py-3 text-sm text-red-600 dark:text-red-400",children:x}):p===null?a.jsx(Sr,{rows:6}):p.res.entries.length===0?a.jsx("p",{className:"px-3 py-3 text-sm text-gray-400",children:d.files.empty}):a.jsx("ul",{"aria-busy":Q,className:`divide-y divide-gray-100 dark:divide-gray-800/60 ${Q?"opacity-60":""}`,children:p.res.entries.map(j=>a.jsx("li",{children:a.jsxs("div",{className:"group flex items-center gap-2 px-3 py-1.5 transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[a.jsxs("button",{type:"button",disabled:Q,onClick:()=>{const U=Ym(p.base,j.name);j.kind==="dir"?f(U):H(U)},className:"flex min-w-0 flex-1 items-center gap-2 text-left",title:j.name,children:[a.jsx("span",{className:"shrink-0 text-gray-400","aria-hidden":!0,children:j.kind==="dir"?a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:a.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"})}):a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:a.jsx("path",{d:"M6 3h8l4 4v14H6zM14 3v4h4"})})}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:j.name})]}),a.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400 dark:text-gray-500",children:j.kind==="file"?ju(j.sizeBytes):""}),a.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 sm:block dark:text-gray-500",children:j.mtime?Jr(j.mtime):""}),j.kind==="file"&&a.jsx("a",{href:ji(e.sessionId,Ym(p.base,j.name),!0),download:j.name,title:d.files.download,className:"shrink-0 rounded p-1 text-gray-300 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 group-hover:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M4 21h16"})})})]})},j.name))})}),a.jsx(ln,{open:N!==null,title:d.files.overwriteTitle,tone:"primary",confirmLabel:d.files.upload,onClose:()=>T(null),onConfirm:()=>{N&&ie(N.files),T(null)},children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.files.overwriteConfirm(N?.clashes.length??0)}),a.jsx("ul",{className:"max-h-40 overflow-y-auto rounded-md border border-gray-200 px-3 py-1.5 dark:border-gray-800",children:(N?.clashes??[]).map(j=>a.jsx("li",{className:"truncate py-0.5 font-mono text-xs",title:j,children:j},j))})]})})]})}function DH(e,t,n,s){const[o,c]=y.useState({forAgent:null,scopes:null,error:null});return y.useEffect(()=>{if(!n||e===null||t===null)return;let u=!1;return(async()=>{try{const f=await eC(e,t),p=await Promise.all(f.scopes.map(async h=>({info:h,files:(await tC(e,t,h.scopeKey)).files})));u||c({forAgent:t,scopes:p,error:null})}catch(f){u||c({forAgent:t,scopes:null,error:Ae(f)})}})(),()=>{u=!0}},[n,e,t,s]),o.forAgent!==t?{scopes:null,error:null}:{scopes:o.scopes,error:o.error}}function $H({nodes:e,selectedId:t,labelFor:n,onSelect:s}){const o=mP(e);return a.jsx("div",{role:"group","aria-label":d.subagentPanel.topologyLabel,className:"overflow-x-auto",children:a.jsxs("div",{className:"relative",style:{width:o.width,height:o.height},children:[a.jsx("svg",{width:o.width,height:o.height,className:"absolute inset-0 text-gray-300 dark:text-gray-700","aria-hidden":!0,children:o.edges.map(c=>a.jsx("path",{d:c.path,fill:"none",stroke:"currentColor",strokeWidth:"1.5"},`${c.fromId}>${c.toId}`))}),o.nodes.map(({node:c,x:u,y:f})=>{const p=n(c),h=c.sessionId===t,x=c.running?d.subagentPanel.nodeRunning:d.subagentPanel.nodeDone,g=c.description!==null?`${p} · ${x}
178
- ${c.description}`:`${p} · ${x}`;return a.jsxs("button",{type:"button","aria-label":`${p} · ${x}`,"aria-pressed":h,title:g,onClick:()=>s(c),style:{left:u,top:f,width:Xm,height:iu},className:`absolute flex flex-col justify-center gap-0.5 rounded-md border bg-white px-2 text-left transition-colors duration-150 dark:bg-gray-900 ${h?"border-brand-500 ring-1 ring-brand-500":"border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-gray-700 dark:hover:border-gray-600 dark:hover:bg-gray-800/60"}`,children:[a.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[a.jsx(Ha,{id:c.agentId??c.sessionId,name:p,size:18}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium text-gray-700 dark:text-gray-300",children:p}),c.running?c.startedMs!==void 0&&a.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:a.jsx(Ll,{sinceMs:c.startedMs})}):c.elapsedMs!==void 0&&a.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:Pn(c.elapsedMs)}),a.jsx(Di,{state:c.running?"running":"done",size:10})]}),c.description!==null&&a.jsx("span",{className:"w-full truncate pl-[24px] text-[10px] leading-tight text-gray-400 dark:text-gray-500",children:c.description})]},c.sessionId)})]})})}function UH({session:e,model:t,version:n,taskRunning:s,ctx:o,focusRequest:c,taskScope:u,subagents:f,models:p,approvalMode:h,onChangeApprovalMode:x,modeSaving:g,parentThinkingLevel:v}){const{agents:w,setCurrentAgentId:S}=en(),{sessions:C}=Ii(),N=yr(),[T,_]=y.useState(null);y.useEffect(()=>{c&&_({sessionId:c.sessionId,origin:c.origin})},[c]);const R=y.useMemo(()=>new Map(f.map(H=>[H.sessionId,H.running])),[f]),D=y.useMemo(()=>(u?oP(t,e.sessionId,s,u.anchorSessionId,R):null)??iP(t,e.sessionId,s,R),[t,n,e.sessionId,s,u,R]),z=D.find(H=>H.depth>0)??null,E=T??(z?{sessionId:z.sessionId,origin:z.origin}:null),L=H=>{if(H.depth===0){const $=w.find(X=>X.agentId===e.agentId);return $?$.name?.length?$.name:$.agentId:e.agentId}return B0(H,w,C)??H0(H.sessionId)},F=E!==null&&E.origin.length===0,V=E?D.find(H=>H.sessionId===E.sessionId)??null:null,P=E&&!F?dP(t,E.origin):null,B=V?L(V):E?B0({sessionId:E.sessionId,agentId:P?.meta?.agentId??null},w,C)??d.chat.subagent:"",Y=V?.running??!1,q=E?{...o,origin:E.origin,taskRunning:Y}:null,K=()=>{if(!E)return;const H=C.find(X=>X.sessionId===E.sessionId);H&&Gx(H.projectId,H.sessionId,H.lastActiveAt);const $=H?.agentId??P?.meta?.agentId??null;$!==null&&S($),N(`/chat/${E.sessionId}`)};return a.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[a.jsxs("div",{className:"shrink-0 border-b border-gray-200 px-3 pb-2 pt-1.5 dark:border-gray-800",children:[a.jsx("p",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:d.subagentPanel.topologyLabel}),D.length>1?a.jsx("div",{className:"max-h-48 overflow-y-auto",children:a.jsx($H,{nodes:D,selectedId:E?.sessionId??null,labelFor:L,onSelect:H=>_({sessionId:H.sessionId,origin:H.origin})})}):a.jsx("p",{className:"py-1 text-xs text-gray-400 dark:text-gray-500",children:d.subagentPanel.empty})]}),E===null?a.jsx("div",{className:"min-h-0 flex-1",children:a.jsx(Fa,{title:d.subagentPanel.empty})}):F?a.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4",children:a.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:d.subagentPanel.mainSessionNote})}):P===null?a.jsx("div",{className:"min-h-0 flex-1",children:a.jsx(Fa,{title:d.subagentPanel.empty})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-gray-100 px-3 py-1.5 dark:border-gray-800/60",children:[a.jsx(Ha,{id:P.meta?.agentId??E.sessionId,name:B,size:16}),a.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-gray-700 dark:text-gray-300",children:B}),a.jsx("span",{title:E.sessionId,className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:H0(E.sessionId)}),Y&&a.jsx(Di,{state:"running",size:10,label:d.chat.subagentRunning}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx("button",{type:"button",title:d.subagentPanel.openAsSession,"aria-label":d.subagentPanel.openAsSession,"data-testid":"subagent-open-session",onClick:K,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(Oe,{d:"M14 4h6v6M20 4l-8 8M10 6H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5",size:Ye.rowLead})})]}),a.jsx("div",{className:"min-h-0 flex-1",children:q&&a.jsx(pT,{items:P.items,version:n,ctx:q},E.sessionId)}),a.jsx(zH,{sessionId:e.sessionId,childSessionId:E.sessionId,running:Y,meta:P.meta,contextNow:P.stats.contextNow,deliveredInputs:PH(P),models:p,approvalMode:h,onChangeApprovalMode:x,modeSaving:g,fallbackThinkingLevel:V?.spawnThinkingLevel??v},`composer-${E.sessionId}`)]})]})}function PH(e){let t=0;for(const n of e.items)(n.kind==="user_text"||n.kind==="user_steering")&&(t+=1);return t}function zH({sessionId:e,childSessionId:t,running:n,meta:s,contextNow:o,deliveredInputs:c,models:u,approvalMode:f,onChangeApprovalMode:p,modeSaving:h,fallbackThinkingLevel:x}){const{currentProject:g}=en(),v=g?.projectId??null,[w,S]=y.useState([]);y.useEffect(()=>{let z=!1;S([]);const E=s?.agentId;if(!(!v||!E))return Bu(v,E).then(L=>{z||S(L.skills)}).catch(()=>{}),()=>{z=!0}},[v,s?.agentId]);const[C,N]=y.useState(""),T=s?{provider:s.provider,modelId:s.modelId}:null,_=T?u.find(z=>z.provider===T.provider&&z.modelId===T.modelId)?.contextWindow:void 0,R=z=>cA(e,t,z,C||void 0),D=z=>{Be(z instanceof xr&&z.code==="subagent_gone"?d.subagentPanel.subagentGone:z instanceof Error?z.message:String(z))};return a.jsx("div",{className:"shrink-0 border-t border-gray-100 px-2 pb-2 pt-2 dark:border-gray-800/60",children:a.jsx(Iy,{variant:"subagent",status:n?"running":"idle",onSend:async z=>{const E=z.filter(L=>L.type==="text").map(L=>L.text).join(`
179
-
180
- `).trim();if(!E)return!1;try{return await R(E),!0}catch(L){return D(L),!1}},onSteer:async z=>{try{return await R(z),"queued"}catch(E){return D(E),"failed"}},steeringDeliveredCount:c,onStop:async()=>{await uA(e,t).catch(()=>{})},modelRef:T,models:u,turnThinkingLevel:C||x,onChangeTurnThinkingLevel:N,..._!==void 0?{contextWindow:_}:{},contextNow:o,vision:!1,approvalMode:f,onChangeApprovalMode:p,modeSaving:h,agents:[],skills:w})})}const Tl={cacheRead:"#7dd3fc",cacheWrite:"#0ea5e9",output:"#0369a1"};function BH({cacheRead:e,cacheWrite:t,output:n,max:s,size:o=44}){const c=e+t+n,u=Math.max(2,Math.round(o*.16)),f=o/2,p=(o-u)/2,h=2*Math.PI*p,x=Math.max(s,c,1),g=s>0?c/s:0,v=g>.95?sn.danger:g>.8?sn.attention:"text-gray-300 dark:text-gray-700",w=[{key:"cacheRead",value:e,color:Tl.cacheRead,label:d.usage.colCacheRead},{key:"cacheWrite",value:t,color:Tl.cacheWrite,label:d.usage.colCacheWrite},{key:"output",value:n,color:Tl.output,label:d.usage.colOutput}],S=`${d.chat.contextUsage} ${It(c)}/${It(s)}`+w.map(N=>` · ${N.label} ${It(N.value)}`).join("");let C=0;return a.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,className:`block shrink-0 ${v}`,role:"img","aria-label":S,children:[a.jsx("title",{children:S}),a.jsx("circle",{cx:f,cy:f,r:p,fill:"none",stroke:"currentColor",strokeOpacity:.35,strokeWidth:u}),w.map(N=>{if(N.value<=0)return null;const T=N.value/x*h,_=-(C/x)*h;return C+=N.value,a.jsx("circle",{cx:f,cy:f,r:p,fill:"none",stroke:N.color,strokeWidth:u,strokeDasharray:`${T} ${h}`,strokeDashoffset:_,transform:`rotate(-90 ${f} ${f})`},N.key)})]})}function HH(e,t){const n=Math.min(e.callMs,e.approvalMs??e.callMs),s=Math.max(n,e.approvalMs??n,e.outputMs??t);return{startMs:n,endMs:s}}function FH(e){const t=new Map,n=[...e].sort((o,c)=>o.startMs-c.startMs||o.endMs-c.endMs);for(const o of n){let c=t.get(o.name);c||(c=[],t.set(o.name,c));const u=c.find(f=>o.startMs>=f.lastEnd);u?(u.spans.push(o),u.lastEnd=Math.max(u.lastEnd,o.endMs)):c.push({spans:[o],lastEnd:o.endMs})}const s=[];for(const[o,c]of t)for(const u of c)s.push({name:o,spans:u.spans});return s}const fa={thinking:"bg-violet-500 dark:bg-violet-400",text:"bg-sky-500 dark:bg-sky-400",toolgen:"bg-amber-500 dark:bg-amber-400",approvalWait:"bg-rose-400 dark:bg-rose-300",exec:"bg-emerald-500 dark:bg-emerald-400",other:"bg-gray-400 dark:bg-gray-500"},kf="sticky left-0 z-10 flex h-4 w-[5.5rem] shrink-0 items-center justify-end bg-white pr-2 dark:bg-gray-950",ix="truncate font-mono text-[11px]",M2=.25,ox=24,qH=1/ox,qs=(e,t,n)=>Math.min(n,Math.max(t,e));function VH(e){return e==="thinking"?fa.thinking:e==="text"?fa.text:fa.toolgen}function GH(e){return e==="thinking"?d.traces.kindThinking:e==="text"?d.traces.kindModelReply:d.traces.kindToolGen}function KH(e){return e==="thinking"?"thinking":e==="text"?"text":"toolgen"}function co(e){if(e===void 0)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null}function WH(e,t,n){const s=new Map,o=u=>{let f=s.get(u);return f||(f={segs:[],spans:[],others:[]},s.set(u,f)),f};for(const u of e){const f=co(u.startTs),p=co(u.endTs);f===null||p===null||o(u.taskIndex).segs.push({kind:u.kind,...u.name!==void 0?{name:u.name}:{},ts:u.endTs,startMs:f,endMs:p})}for(const u of t){const f=co(u.callTs);f!==null&&o(u.taskIndex).spans.push({name:u.name||u.toolCallId,toolCallId:u.toolCallId,callTs:u.callTs,...u.approvalTs!==void 0?{approvalTsRaw:u.approvalTs}:{},...u.outputTs!==void 0?{outputTsRaw:u.outputTs}:{},callMs:f,approvalMs:co(u.approvalTs),outputMs:co(u.outputTs),failed:u.stopReason!==void 0&&u.stopReason!=="completed",...u.stopReason!==void 0?{status:u.stopReason}:{},...u.decision!==void 0?{decision:u.decision}:{}})}for(const u of n){const f=co(u.startTs),p=co(u.endTs);f===null||p===null||o(u.taskIndex).others.push({key:u.key,name:u.name,ts:u.endTs,startMs:f,endMs:p,failed:u.failed===!0})}const c=[];for(const[u,{segs:f,spans:p,others:h}]of[...s.entries()].sort((x,g)=>x[0]-g[0])){if(f.length===0&&p.length===0&&h.length===0)continue;const x=[...f.map(N=>N.startMs),...p.map(N=>N.callMs),...h.map(N=>N.startMs)],g=[...f.map(N=>N.endMs),...p.map(N=>N.outputMs??N.approvalMs??N.callMs),...h.map(N=>N.endMs)],v=Math.min(...x),w=Math.max(...g,...x),S=Math.max(1,w-v);p.sort((N,T)=>N.callMs-T.callMs),h.sort((N,T)=>N.startMs-T.startMs);const C=FH(p.map(N=>({...N,...HH(N,v+S)})));c.push({taskIndex:u,segs:f,others:h,t0:v,total:S,toolRows:C})}return c}function lx({children:e}){return a.jsx("div",{className:"relative h-4 min-w-0 flex-1 overflow-hidden bg-gray-100 dark:bg-gray-800/60",children:e})}function YH({label:e,children:t}){return a.jsxs("div",{className:"flex items-center",children:[a.jsx("span",{className:`${kf} text-gray-400 dark:text-gray-500`,title:e,children:a.jsx("span",{className:ix,children:e})}),a.jsx(lx,{children:t})]})}function XH({total:e}){const t=[0,.25,.5,.75,1];return a.jsxs("div",{className:"flex items-center",children:[a.jsx("span",{className:kf}),a.jsx("div",{className:"relative h-4 min-w-0 flex-1",children:t.map((n,s)=>a.jsx("span",{className:`absolute top-0 font-mono text-[11px] text-gray-400 dark:text-gray-500 ${s===0?"":s===t.length-1?"-translate-x-full":"-translate-x-1/2"}`,style:{left:`${n*100}%`},children:Pn(n*e)},s))})]})}function QH({segments:e,toolSpans:t,otherSpans:n=[],highlight:s,onHighlight:o,onJump:c,hideTaskLabel:u=!1}){const f=y.useMemo(()=>WH(e,t,n),[e,t,n]),{firstBarKeyByTs:p,barKeys:h}=y.useMemo(()=>{const j=new Map,U=new Set,ee=(re,ke)=>{U.add(ke),j.has(re)||j.set(re,ke)};for(const re of f){re.segs.forEach((ke,be)=>ee(ke.ts,`s-${re.taskIndex}-${be}`));for(const ke of re.toolRows)for(const be of ke.spans)be.approvalMs!==null&&be.approvalMs>be.callMs&&ee(be.approvalTsRaw??be.callTs,`w-${be.toolCallId}`),be.approvalMs===null&&be.outputMs===null?ee(be.callTs,`p-${be.toolCallId}`):ee(be.outputTsRaw??be.callTs,`e-${be.toolCallId}`);for(const ke of re.others)ee(ke.ts,`o-${ke.key}`)}return{firstBarKeyByTs:j,barKeys:U}},[f]),[x,g]=y.useState(null),[v,w]=y.useState(1),[S,C]=y.useState({left:0,width:1}),N=y.useRef(null),T=y.useRef(null),_=y.useRef(S);_.current=S;const R=y.useRef(v);R.current=v;const D=y.useRef(null),z=y.useRef(null),E=y.useCallback(()=>{const j=N.current;if(!j)return;const U=j.scrollWidth||1;C({left:j.scrollLeft/U,width:Math.min(1,j.clientWidth/U)})},[]);if(y.useLayoutEffect(()=>{const j=N.current;if(j){if(D.current){const U=j.scrollWidth-j.clientWidth;j.scrollLeft=qs(D.current(j),0,Math.max(0,U)),D.current=null}E()}},[v,f,E]),y.useLayoutEffect(()=>{const j=N.current;if(!j||typeof ResizeObserver>"u")return;const U=new ResizeObserver(()=>E());return U.observe(j),()=>U.disconnect()},[E]),y.useLayoutEffect(()=>()=>z.current?.(),[]),f.length===0)return a.jsx("p",{className:"text-xs text-gray-400",children:d.common.none});const L=s?.ts,F=s?.key,V=(j,U)=>o?.(U?{ts:U,key:j}:null),P=()=>o?.(null),B=F??(L!==void 0?p.get(L):void 0),Y=B!==void 0&&h.has(B)?B:void 0,q=Y!==void 0,K=j=>Y===j,H=(j,U)=>x!==null&&!U||q&&!j?"opacity-15":"",$=(j,U,ee,re)=>{const ke=qs((j-ee)/re*100,0,100),be=qs((U-j)/re*100,0,100-ke);return ke>=100?{left:"100%",width:"0%",marginLeft:"-2px"}:{left:`${ke}%`,width:`${be}%`}},X=[{key:"thinking",className:fa.thinking,label:d.traces.kindThinking},{key:"text",className:fa.text,label:d.traces.kindModelReply},{key:"toolgen",className:fa.toolgen,label:d.traces.kindToolGen},{key:"approvalWait",className:fa.approvalWait,label:d.traces.legendApprovalWait},{key:"exec",className:fa.exec,label:d.traces.legendToolExec},{key:"other",className:fa.other,label:d.traces.legendOther}],le=(j,U)=>{const ee=qs(U,qH,1),re=qs(1/ee,M2,ox),ke=qs(j,0,1-ee);D.current=be=>ke*be.scrollWidth,w(re)},ie=j=>{j.preventDefault();const U=T.current,ee=N.current;if(!U||!ee)return;const re=U.getBoundingClientRect().width||1,ke=j.clientX,be=ee.scrollLeft,ye=Math.max(0,ee.scrollWidth-ee.clientWidth),Se=ze=>{const De=(ze.clientX-ke)/re;ee.scrollLeft=qs(be+De*ee.scrollWidth,0,ye),E()},Me=()=>{window.removeEventListener("pointermove",Se),window.removeEventListener("pointerup",Me),window.removeEventListener("pointercancel",Me),z.current=null};window.addEventListener("pointermove",Se),window.addEventListener("pointerup",Me),window.addEventListener("pointercancel",Me),z.current=Me},I=j=>U=>{U.preventDefault(),U.stopPropagation();const ee=T.current;if(!ee)return;const re=ee.getBoundingClientRect(),ke=ye=>{const Se=qs((ye.clientX-re.left)/(re.width||1),0,1),Me=_.current;if(j==="right")le(Me.left,Se-Me.left);else{const ze=Me.left+Me.width;le(Se,ze-Se)}},be=()=>{window.removeEventListener("pointermove",ke),window.removeEventListener("pointerup",be),window.removeEventListener("pointercancel",be),z.current=null};window.addEventListener("pointermove",ke),window.addEventListener("pointerup",be),window.addEventListener("pointercancel",be),z.current=be},A=()=>{D.current=()=>0,w(1)},Q=j=>{const U=N.current,ee=qs(R.current*j,M2,ox);if(ee!==R.current){if(U){const re=U.clientWidth/2,ke=(U.scrollLeft+re)/(U.scrollWidth||1);D.current=be=>ke*be.scrollWidth-re}w(ee)}};return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{ref:N,className:"no-scrollbar overflow-x-auto overflow-y-hidden",children:a.jsx("div",{className:"space-y-4",style:{width:`${v*100}%`},children:f.map(j=>a.jsxs("div",{className:"space-y-1",children:[!u&&a.jsxs("div",{className:"flex items-center gap-2 pl-[5.5rem]",children:[a.jsx("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-[11px] font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:d.traces.task(j.taskIndex+1)}),a.jsx("span",{className:"font-mono text-[11px] text-gray-400",children:Pn(j.total)})]}),a.jsx(YH,{label:d.traces.laneLLM,children:j.segs.map((U,ee)=>{const re=KH(U.kind),ke=x===null||x===re,be=`s-${j.taskIndex}-${ee}`,ye=K(be);return a.jsx("span",{onMouseEnter:()=>V(be,U.ts),onMouseLeave:P,onClick:()=>c?.(U.ts),title:`${GH(U.kind)}${U.name?` ${U.name}`:""} · ${Pn(U.endMs-U.startMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${VH(U.kind)} ${H(ye,ke)}`,style:$(U.startMs,U.endMs,j.t0,j.total)},ee)})}),j.toolRows.map((U,ee)=>a.jsxs("div",{className:"flex items-center",children:[a.jsx("span",{className:`${kf} text-gray-500 dark:text-gray-400`,title:U.name,children:a.jsx("span",{className:ix,children:U.name})}),a.jsx(lx,{children:U.spans.map(re=>{const ke=re.approvalMs??re.callMs,be=re.outputMs===null,ye=re.outputMs??j.t0+j.total,Se=re.approvalTsRaw??re.callTs,Me=re.outputTsRaw??re.callTs;return a.jsxs(y.Fragment,{children:[re.approvalMs!==null&&re.approvalMs>re.callMs&&a.jsx("span",{onMouseEnter:()=>V(`w-${re.toolCallId}`,Se),onMouseLeave:P,onClick:()=>c?.(Se),title:`${re.name} · ${d.traces.legendApprovalWait}${re.decision?` (${re.decision})`:""} · ${Pn(re.approvalMs-re.callMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${fa.approvalWait} ${H(K(`w-${re.toolCallId}`),x===null||x==="approvalWait")}`,style:$(re.callMs,re.approvalMs,j.t0,j.total)}),re.approvalMs===null&&be?(()=>{const ze=H(K(`p-${re.toolCallId}`),x===null||x==="approvalWait");return a.jsx("span",{onMouseEnter:()=>V(`p-${re.toolCallId}`,re.callTs),onMouseLeave:P,onClick:()=>c?.(re.callTs),title:`${re.name} · ${d.traces.legendApprovalWait} · ${d.traces.inProgress}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${fa.approvalWait} ${ze||"animate-pulse"}`,style:$(re.callMs,ye,j.t0,j.total)})})():(()=>{const ze=H(K(`e-${re.toolCallId}`),x===null||x==="exec"),De=be&&!ze;return a.jsx("span",{onMouseEnter:()=>V(`e-${re.toolCallId}`,Me),onMouseLeave:P,onClick:()=>c?.(Me),title:`${re.name} · ${d.traces.legendToolExec} · ${be?d.traces.inProgress:Pn(ye-ke)}${re.failed?` · ${re.status}`:""}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${fa.exec} ${re.failed?"ring-1 ring-red-500":""} ${De?"animate-pulse opacity-70":ze}`,style:$(ke,ye,j.t0,j.total)})})()]},re.toolCallId)})})]},`${ee}-${U.name}`)),j.others.map(U=>{const ee=H(K(`o-${U.key}`),x===null||x==="other");return a.jsxs("div",{className:"flex items-center",children:[a.jsx("span",{className:`${kf} text-gray-500 dark:text-gray-400`,title:U.name,children:a.jsx("span",{className:ix,children:U.name})}),a.jsx(lx,{children:a.jsx("span",{onMouseEnter:()=>V(`o-${U.key}`,U.ts),onMouseLeave:P,onClick:()=>c?.(U.ts),title:`${U.name} · ${d.traces.legendOther} · ${Pn(U.endMs-U.startMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${fa.other} ${U.failed?"ring-1 ring-red-500":""} ${ee}`,style:$(U.startMs,U.endMs,j.t0,j.total)})})]},U.key)}),a.jsx(XH,{total:j.total})]},j.taskIndex))})}),a.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-gray-100 pt-2.5 dark:border-gray-800",children:X.map(j=>a.jsxs("button",{type:"button",onMouseEnter:()=>g(j.key),onMouseLeave:()=>g(null),className:`flex items-center gap-1 px-1 font-mono text-[11px] text-gray-500 transition-opacity duration-150 dark:text-gray-400 ${x!==null&&x!==j.key?"opacity-30":""}`,children:[a.jsx("span",{className:`inline-block h-2 w-3 rounded-sm ${j.className}`}),j.label]},j.key))}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:d.traces.zoom}),a.jsx("button",{type:"button","aria-label":d.traces.zoomOut,title:d.traces.zoomOut,onClick:()=>Q(1/1.4),className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border border-gray-200 text-gray-500 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800",children:a.jsx("span",{className:"text-[11px] leading-none",children:"−"})}),a.jsx("div",{ref:T,onDoubleClick:A,title:d.traces.zoomReset,className:"relative h-3 min-w-0 flex-1 rounded bg-gray-100 dark:bg-gray-800",children:a.jsxs("div",{role:"scrollbar","aria-label":d.traces.zoom,onPointerDown:ie,className:"absolute inset-y-0 flex cursor-grab items-center justify-between rounded bg-gray-400/70 active:cursor-grabbing dark:bg-gray-500/70",style:{left:`${S.left*100}%`,width:`${Math.max(S.width*100,3)}%`},children:[a.jsx("span",{onPointerDown:I("left"),className:"h-full w-1.5 shrink-0 cursor-ew-resize rounded-l bg-gray-500/80 dark:bg-gray-400/80"}),a.jsx("span",{onPointerDown:I("right"),className:"h-full w-1.5 shrink-0 cursor-ew-resize rounded-r bg-gray-500/80 dark:bg-gray-400/80"})]})}),a.jsx("button",{type:"button","aria-label":d.traces.zoomIn,title:d.traces.zoomIn,onClick:()=>Q(1.4),className:"flex h-4 w-4 shrink-0 items-center justify-center rounded border border-gray-200 text-gray-500 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800",children:a.jsx("span",{className:"text-[11px] leading-none",children:"+"})}),a.jsxs("span",{className:"w-9 shrink-0 text-right font-mono text-[11px] tabular-nums text-gray-400",children:[v.toFixed(2),"×"]})]}),o&&a.jsx("p",{className:"text-[11px] text-gray-400 dark:text-gray-600",children:d.traces.linkHint})]})}function ZH(e){return e==="session_meta"?"brand":e==="model_msg"?"gray":"amber"}const JH={text:"M8 10h8M8 14h5M21 12a9 9 0 1 1-4-7.5",thinking:"M9 18h6M10 21h4M12 3a6 6 0 0 0-3 11v2h6v-2a6 6 0 0 0-3-11z",image_url:"M3 5h18v14H3zM3 15l5-5 4 4 3-3 6 6",inline_data:"M3 5h18v14H3zM3 15l5-5 4 4 3-3 6 6",tool_call:"M14.7 6.3a4 4 0 0 0-5 5L4 17v3h3l5.7-5.7a4 4 0 0 0 5-5l-2.5 2.5-2-2 2.5-2.5z",tool_call_output:"M4 6l4 4-4 4M12 18h8",token_usage:"M4 20V10m6 10V4m6 16v-7m4 7H2",request_begin:"M5 12h14M13 6l6 6-6 6",request_end:"M19 12H5M11 6l-6 6 6 6",approval_decision:"M9 12l2 2 4-4M12 3l7 3v6c0 4.5-3 7.5-7 9-4-1.5-7-4.5-7-9V6z",compaction_begin:"M8 3H4v4M16 3h4v4M8 21H4v-4M16 21h4v-4M9 12h6",compaction_end:"M8 3H4v4M16 3h4v4M8 21H4v-4M16 21h4v-4M9 12h6",abort:"M6 6h12v12H6z",subagent:"M12 3v6m0 0l-5 4v8m5-12l5 4v8M4 21h16",mcp_connect_begin:"M9 7V3m6 4V3M7 7h10v4a5 5 0 0 1-10 0zM12 16v5",mcp_connect_end:"M9 7V3m6 4V3M7 7h10v4a5 5 0 0 1-10 0zM12 16v5",tool_list_ready:"M14.7 6.3a4 4 0 0 0-5 5L4 17v3h3l5.7-5.7a4 4 0 0 0 5-5l-2.5 2.5-2-2 2.5-2.5z"},eF="M12 8v5m0 3h.01M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z";function tF({type:e}){return a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-gray-400 dark:text-gray-500","aria-hidden":!0,children:a.jsx("path",{d:JH[e]??eF})})}function nF(e){const t=e.payload;switch(t.type){case void 0:return"";case"text":return`${String(t.role)}: ${String(t.text??"").slice(0,120)}`;case"thinking":return String(t.thinking??"").slice(0,120);case"image_url":return"[image]";case"inline_data":return`[image] ${String(t.mime_type??"")}`;case"tool_call":return`${String(t.name)} ${String(t.arguments??"").slice(0,100)}`;case"tool_call_output":{const n=String(t.output??"").slice(0,120);return Array.isArray(t.images)&&t.images.length>0?`[image] ${n}`:n}case"token_usage":{const n=t.request,s=t.session;return`request.total=${n?.total??0} session.total=${s?.total??0}`}case"request_end":return`status=${String(t.status)}`;case"approval_decision":return`${String(t.decision)} · ${String(t.tool_call_id)}`;case"compaction_begin":case"compaction_end":return`${String(t.mode)} (${String(t.reason)})${t.status?` · ${String(t.status)}`:""}`;case"mcp_connect_begin":return Array.isArray(t.servers)?t.servers.map(String).join(", "):"";case"mcp_connect_end":{const s=(Array.isArray(t.results)?t.results:[]).map(o=>`${String(o.server)}:${String(o.status)}(${String(o.duration_ms)}ms)`);return[String(t.status??""),s.join(" ")].filter(Boolean).join(" · ")}case"tool_list_ready":return Array.isArray(t.tools)?d.traces.toolDefs(t.tools.length):"";case"abort":{const n=t.error_code!=null?String(t.error_code):"",s=t.error_message!=null?String(t.error_message):"",o=t.reason!=null?String(t.reason):"";return[n||o,s].filter(Boolean).join(" · ")}case"goal_finished":return`${String(t.outcome)} · rounds=${String(t.rounds)} · tokens=${String(t.tokens_used)}`;case"subagent":return String(t.session_id??"");default:return e.type==="session_meta"?`${String(t.session_id??"")} · ${String(t.model_id??"")}`:""}}function rF(e){const t=e.payload;return t.stop_reason??t.status}const lu="max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-gray-100 px-2.5 py-2 text-xs dark:bg-gray-800/70";function aF({p:e}){const t=e.request??{},n=e.session??{},s=(o,c)=>a.jsxs("tr",{children:[a.jsx("td",{className:"pr-3 text-gray-400",children:o}),a.jsx("td",{className:"pr-3 text-right font-mono",children:It(c.cache_read??0)}),a.jsx("td",{className:"pr-3 text-right font-mono",children:It(c.cache_write??0)}),a.jsx("td",{className:"pr-3 text-right font-mono",children:It(c.output??0)}),a.jsx("td",{className:"text-right font-mono",children:It(c.total??0)})]});return a.jsxs("table",{className:"text-xs",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-gray-400",children:[a.jsx("th",{}),a.jsx("th",{className:"pr-3 text-right font-normal",children:"cacheRead"}),a.jsx("th",{className:"pr-3 text-right font-normal",children:"cacheWrite"}),a.jsx("th",{className:"pr-3 text-right font-normal",children:"output"}),a.jsx("th",{className:"text-right font-normal",children:"total"})]})}),a.jsxs("tbody",{children:[s("request",t),s("session",n)]})]})}const pM="cursor-pointer text-xs font-medium text-gray-500 marker:text-gray-400 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200";function sF({p:e}){const t=[["session_id",String(e.session_id??"")],["source",String(e.source??"")],["model_id",String(e.model_id??"")],["context_window",String(e.model_context_window??"")],...typeof e.thinking_level=="string"&&e.thinking_level?[["thinking_level",e.thinking_level]]:[],["agent_state",String(e.agent_state??"")],["workspace",String(e.workspace??"")]],n=String(e.system_prompt??"");return a.jsxs("div",{className:"space-y-2.5",children:[a.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5 text-xs",children:t.map(([s,o])=>a.jsxs(y.Fragment,{children:[a.jsx("dt",{className:"text-gray-400",children:s}),a.jsx("dd",{className:"min-w-0 break-all font-mono text-gray-700 dark:text-gray-300",children:o||"—"})]},s))}),n.trim()&&a.jsxs("details",{children:[a.jsx("summary",{className:pM,children:d.traces.systemPrompt}),a.jsx("div",{className:"md-body mt-1.5 max-h-96 overflow-auto rounded bg-gray-100 px-2.5 py-2 text-sm leading-relaxed text-gray-700 dark:bg-gray-800/70 dark:text-gray-300",children:a.jsx(Zu,{remarkPlugins:Ju,children:n})})]})]})}function iF({schema:e}){const t=e.properties!==null&&typeof e.properties=="object"?e.properties:null;if(!t||Object.keys(t).length===0)return a.jsx("pre",{className:`${lu} mt-1`,children:JSON.stringify(e,null,2)});const n=new Set(Array.isArray(e.required)?e.required.map(String):[]),s=o=>{if(Array.isArray(o.enum))return o.enum.map(String).join(" | ");const c=typeof o.type=="string"?o.type:"object";if(c==="array"){const u=o.items;return`${u!==null&&typeof u=="object"?s(u):"unknown"}[]`}return c};return a.jsx("table",{className:"mt-1 w-full text-xs",children:a.jsx("tbody",{children:Object.entries(t).map(([o,c])=>a.jsxs("tr",{className:"align-top",children:[a.jsxs("td",{className:"whitespace-nowrap pr-3 font-mono text-gray-700 dark:text-gray-300",children:[o,n.has(o)&&a.jsx(kN,{label:d.traces.requiredParam})]}),a.jsx("td",{className:"whitespace-nowrap pr-3 font-mono text-gray-400 dark:text-gray-500",children:s(c)}),a.jsx("td",{className:"text-gray-500 dark:text-gray-400",children:typeof c.description=="string"?c.description:""})]},o))})})}function oF({p:e}){const t=Array.isArray(e.tools)?e.tools:[];return t.length===0?a.jsx("p",{className:"text-xs text-gray-400",children:"—"}):a.jsx("ul",{className:"divide-y divide-gray-100 rounded-md border border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:t.map((n,s)=>a.jsxs("li",{className:"px-2.5 py-1.5 text-xs",children:[a.jsx("span",{className:"font-mono font-semibold text-gray-700 dark:text-gray-300",children:n.name??"—"}),n.description&&a.jsx("p",{className:"mt-0.5 text-gray-500 dark:text-gray-400",children:n.description}),n.parameters!==null&&typeof n.parameters=="object"&&a.jsxs("details",{className:"mt-1",children:[a.jsx("summary",{className:pM,children:d.traces.toolParams}),a.jsx(iF,{schema:n.parameters})]})]},s))})}function lF({msg:e}){const t=e.payload;if(e.type==="session_meta")return a.jsx(sF,{p:t});if(t.type==="tool_list_ready")return a.jsx(oF,{p:t});switch(t.type){case"text":case"thinking":{const n=String(t.text??t.thinking??"");return n.trim()?a.jsx("div",{className:"md-body text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:a.jsx(Zu,{remarkPlugins:Ju,children:n})}):a.jsx("p",{className:"text-xs text-gray-400",children:"—"})}case"image_url":return a.jsx(Ys,{src:String(t.image_url??""),alt:"trace",className:"max-h-48 max-w-full rounded-md"});case"inline_data":return a.jsx(Ys,{src:`data:${String(t.mime_type??"")};base64,${String(t.data??"")}`,alt:"trace",className:"max-h-48 max-w-full rounded-md"});case"tool_call":return a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"font-mono text-xs font-semibold text-gray-700 dark:text-gray-300",children:String(t.name??"")}),a.jsx("pre",{className:lu,children:String(t.arguments??"")})]});case"tool_call_output":{const n=Array.isArray(t.images)?t.images:[];return n.length===0?a.jsx("pre",{className:lu,children:String(t.output??"")}):a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("pre",{className:lu,children:String(t.output??"")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:n.map((s,o)=>a.jsx(Ys,{src:s,alt:"trace",className:"max-h-48 max-w-full rounded-md"},o))})]})}case"token_usage":return a.jsx(aF,{p:t});default:return a.jsx("pre",{className:lu,children:JSON.stringify(t,null,2)})}}function cF({msg:e,rowKey:t,matched:n,onHighlight:s}){const[o,c]=y.useState(!1),u=e.payload.type??e.type,f=rF(e);return a.jsxs("li",{"data-trace-row":t,children:[a.jsxs("button",{type:"button",onClick:()=>c(p=>!p),onMouseEnter:()=>s?.({ts:e.timestamp,rowKey:t}),onMouseLeave:()=>s?.(null),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left transition-colors duration-150 ${n?"bg-amber-50 dark:bg-amber-950/40":"hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,children:[a.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400",children:PI(e.timestamp)}),a.jsx(tF,{type:u}),a.jsx(On,{tone:ZH(e.type),children:u}),e.origin&&e.origin.length>0&&a.jsx(On,{tone:"brand",children:"origin"}),a.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-gray-500 dark:text-gray-400",children:nF(e)})]}),o&&a.jsxs("div",{className:"border-t border-gray-100 bg-gray-50/60 px-3 py-2 dark:border-gray-800 dark:bg-gray-900/40",children:[a.jsx(lF,{msg:e}),f&&a.jsx("div",{className:"mt-1.5 flex justify-end",children:a.jsx(On,{tone:P6(f),children:f})})]})]})}function uF(e){return e?.compaction!==!0?null:d.chat.compactionTitle(e.compactionMode??"summarize")}const E2=()=>({cacheRead:0,cacheWrite:0,output:0}),dF=2500,A2=(e,t)=>`${e}-${t}`;function Vs({label:e,value:t}){return a.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-0.5",children:[a.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:e}),a.jsx("span",{className:"truncate font-mono text-sm font-semibold tabular-nums",children:t})]})}const hM=e=>e.cacheRead+e.cacheWrite,gM=e=>JC(e.cacheRead,e.cacheWrite),xM="flex shrink-0 items-center font-mono text-[11px] tabular-nums text-gray-500 dark:text-gray-400";function Qc({icon:e,value:t,label:n}){return a.jsxs("span",{title:n,"aria-label":n,className:`${xM} gap-1`,children:[a.jsx(Oe,{d:e,className:"text-gray-400"}),t]})}function mF({buckets:e}){const t=hM(e),n=`${d.traces.cacheHit} ${It(e.cacheRead)} · ${d.traces.hitRate} ${Lf(gM(e))}`;return a.jsxs("span",{"aria-label":`${d.traces.taskInput} ${It(t)} · ${n}`,className:xM,children:[a.jsxs("span",{title:d.traces.taskInput,className:"flex items-center gap-1",children:[a.jsx(Oe,{d:Xn.input,className:"text-gray-400"}),It(t)]}),a.jsxs("span",{title:n,className:"ml-1 flex items-center gap-0.5 text-gray-400",children:[a.jsx("span",{children:"("}),a.jsx(Oe,{d:Xn.cacheHit}),a.jsx("span",{children:It(e.cacheRead)}),a.jsx("span",{children:")"})]})]})}function fF({projectId:e,agentId:t,sessionId:n,index:s,highlight:o,onHighlight:c}){const{currency:u}=as(),[f,p]=y.useState(null),[h,x]=y.useState([]),[g,v]=y.useState(0),[w,S]=y.useState(0),[C,N]=y.useState(null),[T,_]=y.useState(null),[R,D]=y.useState(new Set),[z,E]=y.useState(null),L=y.useRef(null),F=y.useRef(null);y.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]),y.useEffect(()=>{p(null),x([]),_(null),D(new Set),E(null);let A=!1;return Promise.all([xA(e,t,n,s),gA(e,t,n,s,0,1e3),Ml(e).catch(()=>null)]).then(([Q,j,U])=>{A||(p(Q),x(j.events),v(j.offset),S(j.total),N(U))}).catch(Q=>{A||_(Ae(Q))}),()=>{A=!0}},[e,t,n,s]);const V=y.useMemo(()=>{const A=h.find(j=>j.type==="session_meta"),Q=A?A.payload:void 0;if(!(!Q?.model_id||!Q.provider))return C?.models.find(j=>j.modelId===Q.model_id&&j.provider===Q.provider)?.pricing},[h,C]),P=A=>V?(A.cacheRead*V.cacheRead+A.cacheWrite*V.cacheWrite+A.output*V.output)/1e6:null,B=y.useMemo(()=>{const A=h.find(Q=>Q.type==="session_meta");return TT(A?A.payload.model_context_window:void 0)},[h]),{tasks:Y,global:q,statsByTask:K,globalLlmMs:H}=y.useMemo(()=>{const A={buckets:E2(),toolCalls:0},Q=new Map;if(!f)return{tasks:[],global:A,statsByTask:Q,globalLlmMs:0};const j=new Map;for(const Se of f.tasks){const Me=Date.parse(Se.startTs),ze=Date.parse(Se.endTs);Number.isFinite(Me)&&Number.isFinite(ze)&&j.set(Se.taskIndex,{min:Me,max:ze})}const U=new Map,ee=Se=>{let Me=U.get(Se);if(!Me){const ze=j.get(Se);Me={taskIndex:Se,segments:[],spans:[],otherSpans:[],messages:[],toolCalls:0,durationMs:ze?Math.max(0,ze.max-ze.min):0},U.set(Se,Me)}return Me};for(const Se of f.tasks)ee(Se.taskIndex);for(const Se of f.modelSegments)ee(Se.taskIndex).segments.push(Se);for(const Se of f.toolSpans){const Me=ee(Se.taskIndex);Me.spans.push(Se),Me.toolCalls+=1}for(const Se of f.otherSpans??[])ee(Se.taskIndex).otherSpans.push(Se);const re=Se=>{for(const Me of f.tasks)if(Se>=Me.messageFrom&&Se<=Me.messageTo)return Me.taskIndex;return null};for(let Se=0;Se<h.length;Se++){const Me=h[Se];if(Me.origin&&Me.origin.length>0)continue;const ze=re(g+Se);ze!==null&&ee(ze).messages.push(Me)}A.toolCalls=f.toolSpans.length;const ke=new Map(f.tasks.map(Se=>[Se.taskIndex,Se]));for(const Se of f.tasks)A.buckets.cacheRead+=Se.tokens.cacheRead,A.buckets.cacheWrite+=Se.tokens.cacheWrite,A.buckets.output+=Se.tokens.output;const be=f.tasks.reduce((Se,Me)=>Se+Me.llmMs,0);return{tasks:[...U.values()].sort((Se,Me)=>Se.taskIndex-Me.taskIndex),global:A,statsByTask:ke,globalLlmMs:be}},[f,h,g]);if(T)return a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:T});if(!f)return a.jsx(on,{className:"h-40"});const $=f.elapsedMs,X=A=>D(Q=>{const j=new Set(Q);return j.has(A)?j.delete(A):j.add(A),j}),le=A=>{for(const Q of Y){const j=Q.messages.findIndex(U=>U.timestamp===A);if(j>=0)return A2(Q.taskIndex,j)}return null},ie=o?.rowKey??(o?.ts!==void 0?le(o.ts):null),I=A=>{const Q=le(A);Q!==null&&(E(Q),requestAnimationFrame(()=>{L.current?.querySelector(`[data-trace-row="${Q}"]`)?.scrollIntoView({block:"center",behavior:"smooth"})}),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>E(null),dF))};return a.jsxs("div",{ref:L,className:"space-y-4",children:[a.jsxs("div",{className:"rounded-md border border-gray-200 p-3 dark:border-gray-800",children:[a.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:d.traces.globalSummary}),a.jsxs("div",{className:"grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-3",children:[a.jsxs("div",{children:[a.jsx(Vs,{label:d.traces.tasksLabel,value:String(f.tasks.length)}),a.jsx(Vs,{label:d.traces.toolCalls,value:String(q.toolCalls)}),a.jsx(Vs,{label:d.traces.compactions,value:String(f.compactionCount)})]}),a.jsxs("div",{children:[a.jsx(Vs,{label:d.chat.statInput,value:It(hM(q.buckets))}),a.jsx(Vs,{label:d.traces.cacheHit,value:`${It(q.buckets.cacheRead)} · ${Lf(gM(q.buckets))}`}),a.jsx(Vs,{label:d.chat.statOutput,value:It(q.buckets.output)})]}),a.jsxs("div",{children:[a.jsx(Vs,{label:d.common.cost,value:rs(P(q.buckets),u)}),a.jsx(Vs,{label:d.chat.statElapsed,value:Pn(Math.max(0,$))}),a.jsx(Vs,{label:d.chat.statTps,value:sf(v0(q.buckets.output,H))})]})]})]}),Y.map(A=>{const Q=!R.has(A.taskIndex),j=K.get(A.taskIndex),U=j?.context,ee=j?.tokens??E2(),re=uF(j);return a.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-800",children:[a.jsxs("button",{type:"button",onClick:()=>X(A.taskIndex),"aria-expanded":Q,className:"flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-800/60",children:[a.jsx(Zn,{open:Q,size:13,className:"text-gray-400"}),a.jsx("span",{className:"shrink-0 text-sm font-semibold",children:d.traces.task(A.taskIndex+1)}),re!==null&&a.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1.5 py-0.5 text-[10px] font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:re}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-1",children:[a.jsx(Qc,{icon:Xn.toolCalls,value:String(A.toolCalls),label:d.traces.toolCalls}),a.jsx(mF,{buckets:ee}),a.jsx(Qc,{icon:Xn.output,value:It(ee.output),label:d.traces.taskOutput}),a.jsx(Qc,{icon:Xn.cost,value:rs(P(ee),u),label:`${d.common.cost}(${u})`}),a.jsx(Qc,{icon:Xn.elapsed,value:Pn(A.durationMs),label:d.chat.statElapsed}),a.jsx(Qc,{icon:Xn.tps,value:sf(v0(ee.output,j?.llmMs??0)),label:d.chat.statTps})]}),U&&a.jsx(BH,{cacheRead:U.cacheRead,cacheWrite:U.cacheWrite,output:U.output,max:B,size:22})]}),Q&&a.jsxs("div",{className:"space-y-3 p-3",children:[(A.segments.length>0||A.spans.length>0||A.otherSpans.length>0)&&a.jsxs("div",{className:"rounded-md border border-gray-100 p-2 dark:border-gray-800/60",children:[a.jsx("p",{className:"mb-1.5 text-[11px] font-medium text-gray-500",children:d.traces.timeline}),a.jsx(QH,{segments:A.segments,toolSpans:A.spans,otherSpans:A.otherSpans,highlight:o,onHighlight:c,onJump:I,hideTaskLabel:!0})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"mb-1.5 text-[11px] font-medium text-gray-500",children:[d.traces.messages,"(",A.messages.length,")"]}),A.messages.length===0?a.jsx("p",{className:"text-xs text-gray-400",children:d.common.none}):a.jsx("ul",{className:"divide-y divide-gray-100 rounded-md border border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:A.messages.map((ke,be)=>{const ye=A2(A.taskIndex,be);return a.jsx(cF,{msg:ke,rowKey:ye,matched:ye===ie||ye===z,onHighlight:Se=>c(Se)},be)})})]})]})]},A.taskIndex)}),h.length<w&&a.jsx("p",{className:"text-xs text-gray-400",children:d.traces.truncatedNote(h.length,w)})]})}const Wg=6;function pF({session:e,active:t}){const[n,s]=y.useState(null),[o,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(!1),[x,g]=y.useState(null),[v,w]=y.useState(0),S=y.useRef(t);if(y.useEffect(()=>{t&&!S.current&&w(T=>T+1),S.current=t},[t]),y.useEffect(()=>{if(!t)return;let T=!1;return hA(e.sessionId).then(_=>{T||(s([..._.files].sort((R,D)=>D.index-R.index)),c(null))}).catch(_=>{T||(s([]),c(Ae(_)))}),()=>{T=!0}},[t,v,e.sessionId]),n===null)return a.jsxs("div",{className:"space-y-3 p-4",children:[a.jsx(on,{className:"h-5 w-2/3"}),a.jsx(on,{className:"h-5 w-1/2"})]});if(o!==null)return a.jsx(Fa,{title:d.tracePanel.loadFailed,description:o});if(n.length===0)return a.jsx(Fa,{title:d.tracePanel.empty,description:d.tracePanel.emptyHint});const C=n.find(T=>T.index===u)??n[0],N=p?n:n.slice(0,Wg);return a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx("span",{className:"mr-1 text-xs text-gray-400",children:d.traces.filesTitle}),N.map(T=>a.jsxs("button",{type:"button",onClick:()=>f(T.index),title:`${T.date} · ${ju(T.sizeBytes)}`,className:`rounded-md border px-2 py-0.5 font-mono text-xs transition-colors duration-150 ${T.index===C.index?"border-gray-400 bg-gray-200/70 font-semibold text-gray-900 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100":"border-gray-200 text-gray-500 hover:bg-gray-100 dark:border-gray-800 dark:text-gray-400 dark:hover:bg-gray-800/60"}`,children:["#",String(T.index).padStart(3,"0")]},T.index)),!p&&n.length>Wg&&a.jsxs("button",{type:"button",title:d.chat.loadMore,"aria-label":d.chat.loadMore,onClick:()=>h(!0),className:"rounded-md border border-gray-200 px-2 py-0.5 font-mono text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-800 dark:text-gray-400 dark:hover:bg-gray-800/60",children:["+",n.length-Wg]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("p",{className:"min-w-0 flex-1 truncate font-mono text-xs text-gray-400",children:[C.date," · ",ju(C.sizeBytes)]}),a.jsxs("a",{href:yA(e.projectId,e.agentId,e.sessionId,C.index),download:!0,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-gray-200 px-2 py-0.5 text-xs text-gray-500 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-800 dark:text-gray-400 dark:hover:bg-gray-800/60",children:[a.jsx(Hx,{size:Ye.rowLead}),d.traces.exportFile]})]}),a.jsx(fF,{projectId:e.projectId,agentId:e.agentId,sessionId:e.sessionId,index:C.index,highlight:x,onHighlight:g})]})})}function Co({children:e,label:t,title:n,className:s=""}){const[o,c]=y.useState(!1),u=y.useId();return a.jsxs("div",{className:s,children:[a.jsxs("button",{type:"button","aria-expanded":o,"aria-controls":u,...n===void 0&&t!==void 0?{"aria-label":d.common.moreInfoAbout(t)}:{},onClick:()=>c(f=>!f),className:`flex items-center ${Ro.tight} rounded text-xs text-gray-500 transition-colors duration-150 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:[a.jsx(Zn,{open:o,size:Ye.chevronDense}),n??d.common.moreInfo]}),a.jsx("div",{id:u,hidden:!o,className:"mt-1.5 pl-4.5 text-xs leading-relaxed text-gray-500 dark:text-gray-400",children:e})]})}const hF="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z",gF="M3 3l18 18M10.6 5.1A11 11 0 0 1 12 5c6.4 0 10 7 10 7a17.6 17.6 0 0 1-3.2 3.9M6.6 6.6C4 8.3 2 12 2 12s3.6 7 10 7a10 10 0 0 0 4.8-1.2M9.9 9.9a3 3 0 0 0 4.2 4.2";function ts({label:e,hint:t,info:n,infoLabel:s,error:o,invalid:c,required:u,size:f="base",className:p,id:h,...x}){const[g,v]=y.useState(!1),w=g?d.auth.hidePassword:d.auth.showPassword,S=y.useId(),C=y.useId(),N=h??C;return a.jsx(Vu,{label:e,hint:t,error:o,errorId:S,required:u,info:n,infoLabel:s,controlId:N,children:a.jsxs("div",{className:"relative",children:[a.jsx(at,{...x,id:n!==void 0?N:h,required:u,size:f,type:g?"text":"password",invalid:!!o||!!c,"aria-describedby":o?S:void 0,className:`${f==="sm"?"pr-8":"pr-10"} ${p??""}`}),a.jsx("button",{type:"button","aria-label":w,title:w,tabIndex:-1,onClick:()=>v(T=>!T),className:`absolute inset-y-0 right-0 flex items-center justify-center text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:hover:text-gray-300 ${f==="sm"?"w-8":"w-10"}`,children:a.jsx("svg",{width:f==="sm"?14:16,height:f==="sm"?14:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:g?gF:hF})})})]})})}function ws({options:e,value:t,onChange:n,cols:s=3}){return a.jsx("div",{className:`grid ${s===2?"grid-cols-2":"grid-cols-3"} gap-0.5 rounded-md bg-gray-100 p-0.5 dark:bg-gray-800`,children:e.map(o=>a.jsx("button",{type:"button",onClick:()=>n(o.value),className:`rounded px-1 py-1 text-xs transition-colors duration-150 ${t===o.value?"bg-white font-medium text-gray-900 shadow-sm dark:bg-gray-600 dark:text-gray-100":"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200"}`,children:o.label},o.value))})}function js({checked:e,onChange:t,disabled:n,className:s,...o}){return a.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:()=>t(!e),className:"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full inset-ring inset-ring-black/10 dark:inset-ring-white/10 transition-colors duration-200 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent-bg)]/40 disabled:cursor-not-allowed disabled:opacity-60 "+(e?"bg-[var(--accent-bg)]":"bg-gray-200 dark:bg-gray-700")+` ${s??""}`,...o,children:a.jsx("span",{"aria-hidden":!0,className:`inline-block size-4 rounded-full border border-black/10 bg-white transition-transform duration-200 ease-out ${e?"translate-x-[18px]":"translate-x-0.5"}`})})}const yM="https://open.feishu.cn",xF=/^\d+:[A-Za-z0-9_-]{5,}$/;function yF(e="feishu"){return{channel:e,feishu:{appId:"",appSecret:"",baseDomain:yM,clearSecret:!1},telegram:{botToken:"",clearToken:!1}}}function _2(e){const t=e.find(s=>s.enabled)?.channel,n=yF(t??e[0]?.channel??"feishu");for(const s of e)s.channel==="feishu"&&(n.feishu={appId:s.appId,appSecret:"",baseDomain:s.baseDomain,clearSecret:!1});return n}function bF(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function vF(e,t){const n={};if(e.channel==="telegram"){const f=e.telegram.botToken.trim(),p=f===""&&e.telegram.clearToken&&t;return f===""&&!t?n.botToken="required":f!==""&&!xF.test(f)&&(n.botToken="token_invalid"),Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,channel:"telegram",body:{...f!==""?{botToken:f}:{},...p?{clearBotToken:!0}:{}}}}const s=e.feishu.appId.trim();s===""&&(n.appId="required");const o=e.feishu.appSecret.trim(),c=o===""&&e.feishu.clearSecret&&t;o===""&&!t&&(n.appSecret="required");const u=e.feishu.baseDomain.trim()||yM;return bF(u)||(n.baseDomain="url_invalid"),Object.keys(n).length>0?{ok:!1,errors:n}:{ok:!0,channel:"feishu",body:{appId:s,...o!==""?{appSecret:o}:{},...c?{clearAppSecret:!0}:{},baseDomain:u}}}function kF(e){if(e.channel==="telegram"){const o=e.telegram.botToken.trim();return{channel:"telegram",body:{...o!==""?{botToken:o}:{}}}}const t=e.feishu.appId.trim(),n=e.feishu.appSecret.trim(),s=e.feishu.baseDomain.trim();return{channel:"feishu",body:{...t!==""?{appId:t}:{},...n!==""?{appSecret:n}:{},...s!==""?{baseDomain:s}:{}}}}function wF(e,t){return e.channel==="telegram"?e.telegram.botToken.trim()!==""||e.telegram.clearToken:e.feishu.appId!==t.feishu.appId||e.feishu.baseDomain!==t.feishu.baseDomain||e.feishu.appSecret.trim()!==""||e.feishu.clearSecret}function SF(e,t){return e.channel==="telegram"?e.telegram.botToken.trim()!==""||t:e.feishu.appId.trim()!==""&&e.feishu.appSecret.trim()!==""||t}const jF=3e3,bM={feishu:{tutorial:"https://open.feishu.cn/document/develop-an-echo-bot/introduction",console:"https://open.feishu.cn/app"},telegram:{tutorial:"https://core.telegram.org/bots/tutorial",console:"https://core.telegram.org/bots/api"}},CF={disconnected:"muted",connecting:"busy",connected:"success",error:"danger"};function Rm(e){if(e!==void 0)return e==="required"?d.common.requiredField:e==="token_invalid"?d.telegram.invalidToken:d.feishu.invalidDomain}const Uu={secretConfigured:!1,secretMasked:null,enabled:!1,status:{state:"disconnected"},lastChatKnown:!1};function vM(e,t){if(e===null)return{...Uu,status:t};const n=e.channel==="telegram"?e.botTokenMasked:e.appSecretMasked;return{secretConfigured:n!==void 0,secretMasked:n??null,enabled:e.enabled,status:t,lastChatKnown:e.lastChatKnown}}function NF(e){const t={feishu:Uu,telegram:Uu};for(const n of e.bindings)t[n.binding.channel]=vM(n.binding,n.status);return t}function kM(e,t){const{poll:n,onChanged:s,onLoadFailed:o}=t,[c,u]=y.useState(null),[f,p]=y.useState(null),[h,x]=y.useState({feishu:Uu,telegram:Uu}),[g,v]=y.useState({}),[w,S]=y.useState(!1),[C,N]=y.useState(!1),[T,_]=y.useState(!1),[R,D]=y.useState(!1),z=y.useRef(null);y.useEffect(()=>{let I=!1,A=z.current===e;const Q=async U=>{try{const ee=await YE(e);if(I)return;if(x(NF(ee)),U){const re=_2(ee.bindings.map(ke=>ke.binding));u(re),p(re),A=!0}}catch(ee){if(I)return;U&&(A=!0,Be(Ae(ee)),o?.())}};z.current!==e&&(z.current=e,u(null),p(null),Q(!0));const j=n?setInterval(()=>{Q(!1)},jF):null;return()=>{I=!0,j!==null&&clearInterval(j),!A&&z.current===e&&(z.current=null)}},[e,n]);const E=I=>{u(A=>A&&{...A,...I}),v({})},L=I=>{E({channel:I})},F=c?.channel??"feishu",V=h[F],P=h.feishu.enabled?"feishu":h.telegram.enabled?"telegram":null,B=P!==null&&P!==F,Y=c!==null&&f!==null&&wF(c,f),q=(I,A,Q)=>{if(x(j=>({...j,[I]:vM(A,Q)})),A!==null){const j=_2([A]),U=I==="feishu"?{feishu:j.feishu}:{telegram:j.telegram};u(ee=>ee&&{...ee,...U}),p(ee=>ee&&{...ee,...U})}},K=async()=>{if(c){_(!0);try{const I=kF(c);if(I.channel==="telegram"){const A=await eA(e,I.body);if(A.ok){const Q=A.latencyMs??0;yt(A.botUsername!==void 0?d.messaging.testOkAs(A.botUsername,Q):d.messaging.testOk(Q))}else Be(d.messaging.testFail(A.error??d.common.unknownError))}else{const A=await JE(e,I.body);A.ok?yt(d.messaging.testOk(A.latencyMs??0)):Be(d.messaging.testFail(A.error??d.common.unknownError))}}catch(I){Be(d.messaging.testFail(Ae(I)))}finally{_(!1)}}},H=async()=>{D(!0);try{await tA(e,F),yt(d.messaging.testMessageSent)}catch(I){Be(Ae(I))}finally{D(!1)}},$=async()=>{if(!c)return;const I=vF(c,h[c.channel].secretConfigured);if(!I.ok){v(I.errors);return}S(!0);try{const A=I.channel==="telegram"?await QE(e,I.body):await XE(e,I.body);q(I.channel,A.binding,A.status),yt(d.common.saved)}catch(A){Be(Ae(A))}finally{S(!1)}},X=async I=>{N(!0);try{const A=await ZE(e,F,I);q(F,A.binding,A.status),s?.(e,I&&A.binding?.enabled===!0?F:null)}catch(A){Be(Ae(A))}finally{N(!1)}},le=!V.enabled&&(B||!V.secretConfigured||Y),ie=!V.enabled&&P!==null&&B?d.messaging.otherEnabledHint(d.messaging.channelName[P]):!V.enabled&&!V.secretConfigured?d.messaging.credentialMissingHint:!V.enabled&&Y?d.messaging.saveBeforeEnable:null;return{form:c,patchForm:E,selectChannel:L,channels:h,fieldErrors:g,dirty:Y,busy:w,toggling:C,testing:T,sendingTest:R,testable:c!==null&&SF(c,V.secretConfigured),toggleBlocked:le||C||w,toggleHint:ie,save:$,toggleEnabled:X,testConnection:K,sendTestMessage:H}}function cx({href:e,label:t}){return a.jsxs("a",{href:e,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[t," ↗"]})}function R2({label:e,required:t,link:n,children:s}){return a.jsxs("div",{className:"block",children:[a.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[a.jsx(Yn,{block:!1,...t?{required:!0}:{},children:e}),n]}),s]})}function I2({masked:e,clearLabel:t,checked:n,enabled:s,onChange:o}){return a.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"font-mono",children:e}),a.jsxs("label",{className:`flex items-center gap-1.5 ${s?"cursor-not-allowed opacity-60":""}`,children:[a.jsx("input",{type:"checkbox",checked:n,disabled:s,onChange:c=>o(c.target.checked)}),t]}),s&&a.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:d.messaging.disableBeforeClearHint})]})}function wM({b:e}){const{form:t}=e;if(!t)return null;const n=t.channel,s=e.channels[n],o=bM[n];return a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{role:"group","aria-label":d.messaging.channelLabel,children:a.jsx(ws,{cols:2,options:[{value:"feishu",label:d.messaging.channelName.feishu},{value:"telegram",label:d.messaging.channelName.telegram}],value:n,onChange:c=>e.selectChannel(c)})}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[a.jsx(js,{checked:s.enabled,disabled:e.toggleBlocked,onChange:c=>{e.toggleEnabled(c)}}),d.messaging.enabled]}),a.jsx("span",{className:"ml-2 text-gray-500 dark:text-gray-400",children:d.messaging.statusLabel}),a.jsx("span",{className:`font-medium ${sn[CF[s.status.state]]}`,children:d.messaging.status[s.status.state]})]}),s.status.state==="error"&&s.status.lastError!==void 0&&a.jsx("p",{title:s.status.lastError,className:"line-clamp-2 text-xs break-words text-gray-500 dark:text-gray-400",children:s.status.lastError})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(ge,{size:"sm",disabled:e.testing||e.busy||!e.testable,onClick:()=>{e.testConnection()},children:e.testing?d.messaging.testing:d.messaging.test}),a.jsx(ge,{size:"sm",disabled:e.sendingTest||e.busy||s.status.state!=="connected"||!s.lastChatKnown,...s.lastChatKnown?{}:{title:n==="telegram"?d.telegram.testMessageNoChat:d.feishu.testMessageNoChat},onClick:()=>{e.sendTestMessage()},children:e.sendingTest?d.messaging.sendingTestMessage:d.messaging.sendTestMessage})]}),e.toggleHint!==null&&a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:e.toggleHint}),n==="telegram"?a.jsxs(a.Fragment,{children:[a.jsx(R2,{label:d.telegram.botToken,required:!s.secretConfigured,link:a.jsx(cx,{href:o.console,label:d.messaging.console}),children:a.jsx(ts,{size:"sm","aria-label":d.telegram.botToken,...s.secretConfigured?{placeholder:d.telegram.botTokenKeepHint}:{},error:Rm(e.fieldErrors.botToken),value:t.telegram.botToken,onChange:c=>e.patchForm({telegram:{botToken:c.target.value,clearToken:!1}}),autoComplete:"off"})}),s.secretMasked!==null&&t.telegram.botToken===""&&a.jsx(I2,{masked:s.secretMasked,clearLabel:d.telegram.clearToken,checked:t.telegram.clearToken,enabled:s.enabled,onChange:c=>e.patchForm({telegram:{...t.telegram,clearToken:c}})})]}):a.jsxs(a.Fragment,{children:[a.jsx(R2,{label:d.feishu.appId,required:!0,link:a.jsx(cx,{href:o.console,label:d.messaging.console}),children:a.jsx(at,{size:"sm","aria-label":d.feishu.appId,error:Rm(e.fieldErrors.appId),value:t.feishu.appId,onChange:c=>e.patchForm({feishu:{...t.feishu,appId:c.target.value}}),className:"font-mono",placeholder:"cli_xxxxxxxxxxxxxxxx",autoComplete:"off"})}),a.jsx(ts,{size:"sm",label:d.feishu.appSecret,...s.secretConfigured?{placeholder:d.feishu.appSecretKeepHint}:{required:!0},error:Rm(e.fieldErrors.appSecret),value:t.feishu.appSecret,onChange:c=>e.patchForm({feishu:{...t.feishu,appSecret:c.target.value,clearSecret:!1}}),autoComplete:"off"}),s.secretMasked!==null&&t.feishu.appSecret===""&&a.jsx(I2,{masked:s.secretMasked,clearLabel:d.feishu.clearSecret,checked:t.feishu.clearSecret,enabled:s.enabled,onChange:c=>e.patchForm({feishu:{...t.feishu,clearSecret:c}})}),a.jsx(at,{size:"sm",label:d.feishu.baseDomain,hint:d.feishu.baseDomainHint,error:Rm(e.fieldErrors.baseDomain),value:t.feishu.baseDomain,onChange:c=>e.patchForm({feishu:{...t.feishu,baseDomain:c.target.value}}),className:"font-mono",placeholder:"https://open.feishu.cn",autoComplete:"off"})]})]})}function SM({channel:e}){const t=e==="telegram"?d.telegram:d.feishu,n=bM[e];return a.jsxs("div",{className:"space-y-2 border-t border-gray-200 pt-3 dark:border-gray-800",children:[a.jsxs(Co,{title:d.messaging.faqSetupTitle,children:[a.jsx("ol",{className:"list-decimal space-y-1 pl-4",children:t.setupSteps.map(s=>a.jsx("li",{children:s},s))}),a.jsx("p",{className:"mt-1.5",children:a.jsx(cx,{href:n.tutorial,label:d.messaging.tutorial})})]}),a.jsx(Co,{title:d.messaging.faqWhatTitle,children:a.jsx("p",{children:t.intro})}),a.jsx(Co,{title:d.messaging.faqTroubleTitle,children:a.jsxs("ul",{className:"list-disc space-y-1 pl-4",children:[a.jsx("li",{children:d.messaging.troubleNoChat}),a.jsx("li",{children:d.messaging.troubleConnError}),e==="telegram"&&a.jsx("li",{children:d.messaging.troubleOnePoller})]})})]})}function TF({sessionId:e,active:t}){const n=kM(e,{poll:t});return a.jsx("div",{className:"h-full overflow-y-auto p-3",children:n.form===null?a.jsxs("div",{className:"space-y-2",children:[a.jsx(on,{className:"h-5 w-40"}),a.jsx(on,{className:"h-24 w-full"})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx(wM,{b:n}),a.jsx("div",{className:"flex items-center justify-end gap-2",children:a.jsx(ge,{variant:"primary",size:"sm",disabled:n.busy,onClick:()=>{n.save()},children:n.busy?d.common.saving:d.common.save})}),a.jsx(SM,{channel:n.form.channel})]})})}const MF={dark:!0,surface:"bg-gray-950 text-gray-100",border:"border-gray-800",iconButton:"text-gray-400 hover:bg-gray-800 hover:text-gray-200",grip:"text-gray-600",tabActive:"bg-gray-800 text-gray-100",tabIdle:"text-gray-400 hover:bg-gray-800 hover:text-gray-200",tabKill:"bg-gray-800 hover:bg-gray-700",muted:"text-gray-400",success:"text-emerald-400",attention:"text-amber-400",danger:"text-red-400",outlineButton:"border-gray-700 text-gray-300 hover:bg-gray-800"},EF={dark:!1,surface:"bg-white text-gray-900",border:"border-gray-200",iconButton:"text-gray-500 hover:bg-gray-100 hover:text-gray-800",grip:"text-gray-400",tabActive:"bg-gray-100 text-gray-900",tabIdle:"text-gray-500 hover:bg-gray-100 hover:text-gray-800",tabKill:"bg-gray-100 hover:bg-gray-200",muted:"text-gray-500",success:"text-emerald-600",attention:"text-amber-600",danger:"text-red-600",outlineButton:"border-gray-300 text-gray-600 hover:bg-gray-100"};function jM(){return as().terminalDark?MF:EF}const xu=new Map,wf=new Map,ux=new Set;function CM(){for(const e of[...ux])e()}function AF(e){return ux.add(e),()=>ux.delete(e)}const NM={status:"connecting",info:null};function _F(e){return(e!==null?wf.get(e):void 0)??NM}function TM(e){let t=xu.get(e);return t||(t=document.createElement("div"),t.className="flex h-full w-full min-h-0 flex-col",xu.set(e,t)),t}function L2(e,t){const n=wf.get(e)??{...NM};wf.set(e,{...n,...t}),CM()}function RF(e){return async()=>{const t=await vf(`/api/terminals/${encodeURIComponent(e)}`);if(!t)throw new Error("Terminal no longer exists.");return t}}function IF(){const e=[];for(const t of["right","bottom"]){if(!Ba(t))continue;const n=CB(t);if(n===null||!n.startsWith("terminal:"))continue;const s=n.slice(9);e.includes(s)||e.push(s)}return e}let Im=[];function LF(){const e=IF();return(e.length!==Im.length||e.some((t,n)=>t!==Im[n]))&&(Im=e),Im}function OF(){const e=y.useSyncExternalStore(Zf,LF);return y.useEffect(()=>{for(const t of[...xu.keys()])e.includes(t)||(xu.get(t)?.remove(),xu.delete(t),wf.delete(t));CM()},[e]),a.jsx(a.Fragment,{children:e.map(t=>ss.createPortal(a.jsx(YT,{ensure:RF(t),onStatus:n=>{L2(t,{status:n}),n==="exited"&&Xs()},onInfo:n=>{L2(t,{info:n}),Xs()},onTitle:n=>XB(t,n),className:"min-h-0 flex-1 overflow-hidden"},t),TM(t),t))})}const ep=320,Ky="penguin.panelWidth";function Wy(e){return Math.max(ep,Math.min(720,Math.round(e*.5)))}function MM(e){return Math.min(Wy(e),Math.max(ep,Math.round(e*.4)))}function DF(){try{const e=Number(localStorage.getItem(Ky));return Number.isFinite(e)&&e>0?e:null}catch{return null}}function $F(){const e=DF();return e===null?MM(window.innerWidth):Math.min(Wy(window.innerWidth),Math.max(ep,Math.round(e)))}const Pu=zl(()=>({width:null}));function Yy(){const{width:e}=Pu.getState();if(e!==null)return e;const t=$F();return Pu.setState({width:t}),t}function EM(e){e!==Pu.getState().width&&Pu.setState({width:e})}function UF(){return Yy()}function PF(){return Bl(Pu,()=>Yy())}function zF(e){EM(Math.min(Wy(window.innerWidth),Math.max(ep,Math.round(e))))}function BF(){try{localStorage.setItem(Ky,String(Math.round(Yy())))}catch{}}function HF(){EM(MM(window.innerWidth));try{localStorage.removeItem(Ky)}catch{}}const FF=.45;function AM(){return document.querySelector("[data-dock-host]")?.getBoundingClientRect()??null}function O2(e,t){const n=document.elementFromPoint(e,t)?.closest?.("[data-dock-pos]");if(n?.dataset.dockPos)return n.dataset.dockPos;const s=AM();if(!s||e<s.left||e>s.right||t<s.top||t>s.bottom)return null;const o=[["right",(s.right-e)/s.width],["bottom",(s.bottom-t)/s.height]];o.sort((u,f)=>u[1]-f[1]);const c=o[0];return c[1]<=FF?c[0]:null}function qF(e,t){const n=document.querySelector(`[data-testid='dock'][data-position='${t}']`)?.getBoundingClientRect()??null;if(t==="bottom"){const u=Math.min(n?.height??Math.max(UT,Math.min(Oy*e.height,VT()*e.height)),e.height);return{left:e.left,top:e.bottom-u,width:e.width,height:u}}const s=document.querySelector("[data-dock-row]")?.getBoundingClientRect()??e,o=Math.max(e.top,s.top),c=Math.min(n?.width??UF(),e.width);return{left:e.right-c,top:o,width:c,height:s.bottom-o}}function D2(e){const t=e.candidate===e.position;return a.jsx("div",{"data-dock-pos":e.position,"data-testid":"dock-layout-target",className:`${e.shape} rounded-[3px] border transition-colors duration-100 ${t?"border-sky-400 bg-sky-500/60":"border-gray-400/70 bg-gray-500/10 dark:border-white/30 dark:bg-white/10"}`})}function $2({candidate:e}){const t=AM();return t?ss.createPortal(a.jsxs(a.Fragment,{children:[e&&a.jsx("div",{"data-testid":"dock-layout-preview","data-pos":e,"aria-hidden":!0,className:"pointer-events-none fixed z-[65] rounded-sm border border-sky-400/70 bg-sky-500/20",style:qF(t,e)}),a.jsxs("div",{"data-testid":"dock-layout-widget",className:"fixed z-[70] flex items-center gap-1.5 rounded-lg border border-gray-300 bg-white/95 p-2.5 shadow-lg dark:border-white/20 dark:bg-gray-900/90",style:{left:t.right-108,top:t.bottom-96},children:[a.jsx(D2,{position:"bottom",candidate:e,shape:"h-4 w-9"}),a.jsx(D2,{position:"right",candidate:e,shape:"h-9 w-4.5"})]})]}),document.body):null}const VF="M4 19.5A2.5 2.5 0 0 1 6.5 17H20M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z";function GF({size:e=Ye.iconButton}){return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"5",cy:"12",r:"2.5"}),a.jsx("circle",{cx:"19",cy:"5.5",r:"2.5"}),a.jsx("circle",{cx:"19",cy:"18.5",r:"2.5"}),a.jsx("path",{d:"M7.4 11 16.7 6.6M7.4 13l9.3 4.4"})]})}function wl(e){switch(e){case"agents":return d.chat.openAgents;case"workspace":return d.chat.workspacePanel;case"memory":return d.chat.memoryViewTitle;case"trace":return d.nav.traces;case"messaging":return d.messaging.panelTitle}}function dx(e,t=Ye.iconButton){switch(e){case"agents":return a.jsx(GF,{size:t});case"workspace":return a.jsx(Oe,{d:El,size:t});case"memory":return a.jsx(Oe,{d:VF,size:t});case"trace":return a.jsx(Oe,{d:vs.traces,size:t});case"messaging":return a.jsx(Oe,{d:XC,size:t})}}function Yg(e){const t=y.useRef(e);t.current=e;const n=y.useRef(null);return y.useMemo(()=>({onPointerDown:s=>{if(s.button!==0)return;const o=t.current.begin(s);o!==null&&(n.current={payload:o,x:s.clientX,y:s.clientY,started:!1},s.currentTarget.setPointerCapture(s.pointerId))},onPointerMove:s=>{const o=n.current;if(o){if(!o.started){const c=t.current.threshold??5;if(Math.hypot(s.clientX-o.x,s.clientY-o.y)<c)return;o.started=!0}t.current.onMove?.(s,o.payload)}},onPointerUp:s=>{const o=n.current;n.current=null,s.currentTarget.releasePointerCapture?.(s.pointerId),o&&t.current.onEnd?.(o.payload,o.started)},onPointerCancel:()=>{n.current=null,t.current.onCancel?.()}}),[])}const U2="M12 5v14M5 12h14",KF="M4 5h16v14H4zM4 14h16",WF="M4 5h16v14H4zM14 5v14",YF="M14 4h6v6M20 4l-8 8M10 6H5a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5";function Lm(e){return a.jsx("button",{type:"button",title:e.label,"aria-label":e.label,"data-testid":e.testId,onClick:e.onClick,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:e.children})}function P2(e){return a.jsxs("div",{"data-testid":"dock-tab","data-tab-id":e.tabId,...e.terminalId!==void 0?{"data-terminal-id":e.terminalId}:{},"data-active":e.active,className:`flex h-6 max-w-44 items-center rounded-md pr-0.5 transition-colors duration-150 ${e.active?"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200":"text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-300"}`,children:[a.jsxs("button",{type:"button",title:e.title,onClick:e.onSelect,className:"flex h-full min-w-0 flex-1 items-center gap-1.5 pl-2 pr-1 text-left text-xs",children:[a.jsx("span",{"aria-hidden":!0,className:"shrink-0",children:e.glyph}),a.jsx("span",{className:"min-w-0 truncate",children:e.label}),e.badge&&a.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${Fl.attention}`})]}),a.jsx("button",{type:"button",title:e.closeLabel,"aria-label":`${e.closeLabel}: ${e.label}`,"data-testid":"dock-tab-close",onClick:e.onClose,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-gray-400 transition-colors duration-150 hover:bg-gray-200 hover:text-gray-700 dark:text-gray-500 dark:hover:bg-gray-700 dark:hover:text-gray-200",children:a.jsx(Hl,{size:10})})]})}function XF({id:e,active:t}){const n=jM(),s=y.useSyncExternalStore(AF,()=>_F(t?e:null)),o=y.useRef(null);return y.useEffect(()=>{const c=o.current;if(!c||!t)return;const u=TM(e);return c.appendChild(u),()=>{u.parentElement===c&&c.removeChild(u)}},[e,t]),a.jsx("div",{ref:o,"data-testid":"dock-terminal-body","data-status":s.status,className:`flex min-h-0 flex-1 flex-col overflow-hidden px-2 py-1 ${n.surface}`})}function z2(e,t,n){return e?`${e.seq??n}: ${KB(e.title)||e.name}`:`${n}: ${t.slice(0,6)}`}function QF({choose:e,chooseTerminal:t,terminalSupported:n,horizontal:s}){const o="flex items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",c=u=>a.jsxs("button",{type:"button","data-testid":`dock-pick-${u}`,onClick:()=>e(u),className:o,children:[a.jsx("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:dx(u)}),a.jsx("span",{className:"min-w-0 truncate",children:wl(u)})]},u);return a.jsx("div",{"data-testid":"dock-picker",className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-4",children:a.jsxs("div",{className:s?"flex max-w-full flex-wrap items-center justify-center gap-1":"flex w-60 flex-col gap-0.5",children:[c("agents"),n&&a.jsxs("button",{type:"button","data-testid":"dock-pick-terminal",onClick:t,className:o,children:[a.jsx("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:a.jsx(Oe,{d:vs.terminal,size:Ye.iconButton})}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:d.terminal.title}),a.jsx("kbd",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:"Ctrl+`"})]}),c("workspace"),c("memory"),c("trace"),c("messaging")]})})}function B2({view:e,renderPanel:t,panelBadges:n,terminalSupported:s,open:o=!0,animateEntrance:c=!0}){y.useSyncExternalStore(Zf,$y);const u=y.useSyncExternalStore(ZT,QT),f=new Map(u.map(he=>[he.id,he])),{position:p,merged:h,tabs:x,activeKey:g}=e,v=p==="bottom",w=p==="right"?"bottom":"right",[S,C]=y.useState(!1),N=x.find(he=>kn(he)===g)??null,[T,_]=y.useState(null),R=y.useCallback((he,ne)=>{if(he.kind==="terminal"){_({id:he.terminalId,label:ne});return}J0(kn(he))},[]),D=y.useCallback(()=>{T&&(ZB(T.id),J0(`terminal:${T.id}`),_(null))},[T]),z=y.useCallback(()=>{if(N?.kind!=="terminal")return;const he=h?Lu(kn(N))??"bottom":p;eH(N.terminalId,he)},[N,h,p]),E=y.useRef(null);y.useEffect(()=>{g!==null&&E.current?.querySelector(`[data-tab-id="${CSS.escape(g)}"]`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[g,x]),y.useEffect(()=>{const he=E.current;if(!he)return;const ne=oe=>{const J=Math.abs(oe.deltaX)>Math.abs(oe.deltaY)?oe.deltaX:oe.deltaY;J===0||he.scrollWidth<=he.clientWidth||(oe.preventDefault(),he.scrollLeft+=J)};return he.addEventListener("wheel",ne,{passive:!1}),()=>he.removeEventListener("wheel",ne)},[]);const[L,F]=y.useState({active:!1,candidate:null}),V=()=>F({active:!1,candidate:null}),P=Yg({begin:he=>h||he.target.closest("button, [data-testid='dock-tab']")?null:{},onMove:he=>F({active:!0,candidate:O2(he.clientX,he.clientY)}),onEnd:(he,ne)=>{const oe=L.candidate;V(),ne&&oe&&oe!==p&&o2(p,oe)},onCancel:V}),[B,Y]=y.useState({active:!1,candidate:null}),q=()=>Y({active:!1,candidate:null}),K=Yg({threshold:6,begin:he=>{if(h)return null;const ne=he.target;if(ne.closest("[data-testid='dock-tab-close']"))return null;const oe=ne.closest("[data-tab-id]")?.dataset.tabId;return oe?{id:oe}:null},onMove:(he,{id:ne})=>{const oe=he.currentTarget.getBoundingClientRect();if(he.clientY<oe.top-20||he.clientY>oe.bottom+20){Y({active:!0,candidate:O2(he.clientX,he.clientY)});return}Y({active:!1,candidate:null});const J=[...he.currentTarget.querySelectorAll("[data-tab-id]")],ht=J.map(He=>He.dataset.tabId),ve=J.filter(He=>He.dataset.tabId!==ne);let Xe=ve.length;for(let He=0;He<ve.length;He+=1){const Pe=ve[He].getBoundingClientRect();if(he.clientX<Pe.left+Pe.width/2){Xe=He;break}}const Ge=ve.map(He=>He.dataset.tabId);Ge.splice(Xe,0,ne),Ge.some((He,Pe)=>He!==ht[Pe])&&EB(p,Ge)},onEnd:({id:he},ne)=>{const{active:oe,candidate:J}=B;if(q(),!ne){qg(he);return}!oe||!J||J===Lu(he)||MB(he,J)},onCancel:q}),[H,$]=y.useState(!1),X=PF(),le=y.useRef(null),ie=Yg({threshold:0,begin:he=>(he.preventDefault(),$(!0),{}),onMove:he=>{const ne=le.current?.getBoundingClientRect();if(ne)if(v){const oe=document.querySelector("[data-dock-host]")?.getBoundingClientRect();if(!oe||oe.height===0)return;UB((ne.bottom-he.clientY)/oe.height)}else zF(ne.right-he.clientX)},onEnd:()=>{$(!1),v||BF()},onCancel:()=>$(!1)}),[I,A]=y.useState(()=>{const he=document.querySelector("[data-dock-host]");return he instanceof HTMLElement?he.getBoundingClientRect().height:0});y.useLayoutEffect(()=>{if(!v)return;const he=document.querySelector("[data-dock-host]");if(!(he instanceof HTMLElement))return;const ne=()=>A(he.getBoundingClientRect().height);ne();const oe=new ResizeObserver(ne);return oe.observe(he),()=>oe.disconnect()},[v]);const Q=Math.round(Math.min(Oy*I,Math.max(UT,VT()*I))),j=y.useCallback(()=>v?PB():HF(),[v]),U=he=>{C(!1),ho(he,h?void 0:p)},ee=new Set(By(u.map(he=>he.id))),re=u.filter(he=>ee.has(he.id)),ke=a.jsxs(Qn,{open:S,setOpen:C,portal:{direction:"down",align:"right"},menuClass:"w-56",button:a.jsx(Lm,{label:d.dock.addTab,testId:"dock-add",onClick:()=>C(!S),children:a.jsx(Oe,{d:U2,size:Ye.iconButton})}),children:[DT.map(he=>a.jsxs("button",{type:"button","data-testid":`dock-add-${he}`,onClick:()=>U(he),className:"mx-1 flex w-[calc(100%-0.5rem)] items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:[a.jsx("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:dx(he)}),a.jsx("span",{className:"min-w-0 truncate",children:wl(he)})]},he)),s&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"mx-2 my-1 border-t border-gray-100 dark:border-gray-800"}),a.jsxs("button",{type:"button","data-testid":"dock-add-terminal",onClick:()=>{C(!1),eM(h?void 0:p)},className:"mx-1 flex w-[calc(100%-0.5rem)] items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:[a.jsx("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:a.jsx(Oe,{d:U2,size:Ye.iconButton})}),a.jsx("span",{className:"min-w-0 truncate",children:d.terminal.newShell})]}),re.map((he,ne)=>a.jsx("button",{type:"button","data-testid":"dock-add-shell","data-terminal-id":he.id,onClick:()=>{C(!1),nd(he.id,h?void 0:p)},className:"mx-1 flex w-[calc(100%-0.5rem)] items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:a.jsx("span",{className:"min-w-0 truncate",children:z2(he,he.id,ne+1)})},he.id))]})]}),[be,ye]=y.useState(!c);y.useEffect(()=>{if(be)return;let he=0;const ne=requestAnimationFrame(()=>{he=requestAnimationFrame(()=>ye(!0))});return()=>{cancelAnimationFrame(ne),cancelAnimationFrame(he)}},[]);const Se=L.active||B.active,Me=L.active?L.candidate:B.candidate,ze=new Map;x.forEach(he=>{he.kind==="terminal"&&ze.set(he.terminalId,ze.size+1)});const De=a.jsxs("header",{"data-testid":"dock-header",...P,className:`flex shrink-0 items-center gap-2 border-b border-gray-200 px-2 py-1.5 text-xs dark:border-gray-800 ${h?"":"cursor-grab select-none"}`,children:[a.jsx("div",{ref:E,"data-testid":"dock-tab-strip",...K,className:"no-scrollbar flex min-w-0 items-center gap-1 overflow-x-auto",children:x.map(he=>{const ne=kn(he);if(he.kind==="panel")return a.jsx(P2,{tabId:ne,label:wl(he.panel),title:wl(he.panel),glyph:dx(he.panel,Ye.inlineGlyph),active:ne===g,badge:n?.[he.panel]===!0,closeLabel:d.dock.closeTab,onSelect:()=>qg(ne),onClose:()=>R(he,wl(he.panel))},ne);const oe=f.get(he.terminalId),J=z2(oe,he.terminalId,ze.get(he.terminalId)??1);return a.jsx(P2,{tabId:ne,terminalId:he.terminalId,label:J,title:oe?`${oe.name} — ${oe.cwd}`:J,glyph:a.jsx(Oe,{d:vs.terminal,size:Ye.inlineGlyph}),active:ne===g,badge:!1,closeLabel:d.terminal.killShell,onSelect:()=>qg(ne),onClose:()=>R(he,J)},ne)})}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[N?.kind==="terminal"&&a.jsx(Lm,{label:d.terminal.detach,testId:"dock-detach",onClick:z,children:a.jsx(Oe,{d:YF,size:Ye.rowLead})}),ke,!h&&x.length>0&&a.jsx(Lm,{label:p==="right"?d.dock.moveToBottom:d.dock.moveToRight,testId:"dock-move",onClick:()=>o2(p,w),children:a.jsx(Oe,{d:p==="right"?KF:WF,size:Ye.rowLead})}),a.jsx(Lm,{label:d.dock.hideDock,testId:"dock-close",onClick:()=>_B(e),children:a.jsx(Hl,{size:12})})]})]}),ct=x.length===0?a.jsx(QF,{choose:he=>ho(he,h?void 0:p),chooseTerminal:()=>{tM(h?void 0:p)},terminalSupported:s,horizontal:v}):a.jsx("div",{className:"relative min-h-0 flex-1",children:x.map(he=>{const ne=kn(he),oe=ne===g;return a.jsx("div",{className:oe?"flex h-full min-h-0 flex-col":"hidden",children:he.kind==="panel"?t(he.panel,oe):a.jsx(XF,{id:he.terminalId,active:oe})},ne)})}),bt=a.jsx(ln,{open:T!==null,title:d.dock.killConfirmTitle,onClose:()=>_(null),onConfirm:D,confirmLabel:d.terminal.killShell,children:T!==null&&a.jsx("p",{children:d.dock.killConfirmBody(T.label)})});return v?a.jsxs("div",{ref:le,"data-testid":"dock","data-position":"bottom",style:{height:o&&be?Q:0},inert:!o,className:`relative flex w-full shrink-0 flex-col overflow-hidden bg-white dark:bg-gray-950 ${o?"border-t border-gray-200 dark:border-gray-800":""} ${H?"":"transition-[height] duration-200"}`,children:[o&&a.jsx("div",{"data-testid":"dock-resizer",role:"separator","aria-orientation":"horizontal","aria-label":d.dock.resize,title:d.dock.resize,...ie,onDoubleClick:j,className:`absolute -top-[3px] left-0 right-0 z-20 h-1.5 cursor-ns-resize transition-colors duration-150 ${H?"bg-sky-500/60":"bg-transparent hover:bg-sky-500/40"}`}),a.jsxs("div",{style:{height:Q},className:"flex min-h-0 shrink-0 flex-col",children:[De,ct]}),Se&&a.jsx($2,{candidate:Me}),bt]}):a.jsxs(a.Fragment,{children:[o&&a.jsx("div",{"data-testid":"dock-resizer",role:"separator","aria-orientation":"vertical","aria-label":d.dock.resize,title:d.dock.resize,...ie,onDoubleClick:j,className:`w-1.5 shrink-0 cursor-col-resize transition-colors duration-150 ${H?"bg-sky-500/60":"bg-transparent hover:bg-sky-500/40"}`}),a.jsxs("div",{ref:le,"data-testid":"dock","data-position":"right",style:{width:o&&be?X:0},inert:!o,className:`relative flex min-h-0 shrink-0 flex-col overflow-hidden bg-white dark:bg-gray-950 ${o?"border-l border-gray-200 dark:border-gray-800":""} ${H?"":"transition-[width] duration-200"}`,children:[a.jsxs("div",{style:{width:X},className:"flex min-h-0 flex-1 flex-col",children:[De,ct]}),Se&&a.jsx($2,{candidate:Me}),bt]})]})}const ZF=200;function H2(e){const t=e!==null,n=wB(),s=y.useRef(null);t&&(s.current=e);const o=y.useRef({open:t,instant:n,animate:!0}),c=y.useRef(!1),[,u]=y.useState(0);if(t!==o.current.open){const f=n===o.current.instant;o.current={open:t,instant:n,animate:f},c.current=!t&&f&&s.current!==null}else n!==o.current.instant&&(o.current.instant=n);return y.useEffect(()=>{if(t||!c.current)return;const f=window.setTimeout(()=>{c.current=!1,u(p=>p+1)},ZF);return()=>window.clearTimeout(f)},[t]),t?{view:e,open:!0,animateEntrance:o.current.animate}:c.current&&s.current!==null?{view:s.current,open:!1,animateEntrance:!0}:{view:null,open:!1,animateEntrance:!0}}function JF(){return{sessionId:null,taskCount:0,autoOpenedAt:null}}function eq(e,t){const n=t.sessionId!==e.sessionId,s=!n&&t.taskCount<e.taskCount;return(n||t.taskCount!==e.taskCount)&&(e.sessionId=t.sessionId,e.taskCount=t.taskCount,e.autoOpenedAt=s?t.taskCount:null),t.liveSpawn&&e.autoOpenedAt!==e.taskCount?(e.autoOpenedAt=e.taskCount,"autoOpen"):null}const tq=300;function nq(e){const t=mn().user?.userId??null,n=t&&e?aM(t,e):null,s=y.useMemo(()=>n?$i(n):{},[n]),o=y.useRef(s.text??""),c=y.useRef(s.handoffAgentId??null),u=y.useRef(s.switchModelRef??null),f=y.useRef(s.skills??[]),p=y.useRef(null),h=y.useCallback(()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]),x=y.useCallback(()=>{if(h(),!n)return;const N=o.current,T=c.current,_=u.current,R=f.current;if(!N&&!T&&!_&&R.length===0){Du(n);return}const D={text:N};T&&(D.handoffAgentId=T),_&&(D.switchModelRef=_),R.length>0&&(D.skills=R),Qs(n,D)},[h,n]);y.useEffect(()=>(o.current=s.text??"",c.current=s.handoffAgentId??null,u.current=s.switchModelRef??null,f.current=s.skills??[],()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null,x())}),[s,x]);const g=y.useCallback(N=>{o.current=N,h(),p.current=window.setTimeout(()=>{p.current=null,x()},tq)},[h,x]),v=y.useCallback(N=>{c.current=N,x()},[x]),w=y.useCallback(N=>{u.current=N,x()},[x]),S=y.useCallback(N=>{f.current=N,x()},[x]),C=y.useCallback(()=>{h(),o.current="",f.current=[],c.current=null,u.current=null,n&&Du(n)},[h,n]);return{initial:s,onTextChange:g,onHandoffTargetChange:v,onPendingModelChange:w,onSkillsChange:S,discard:C}}function Xg(e){const t=e.lastIndexOf("-");if(t<=0)return null;const n=Number.parseInt(e.slice(t+1),10);return!Number.isInteger(n)||n<0?null:{epoch:e.slice(0,t),seq:n}}const Qg=200,rq=100,aq=1e6;function sq(e){const t=e.now??(()=>Date.now()),n=new Set,s=new Map;let o=bl(n),c=!1,u="buffering",f=[],p=null,h=null,x=0,g=!1,v=[],w=new Map,S=0,C=null,N=null;const T={hasMore:!1,loading:!1,error:null};let _=0;const R=()=>{v=[],w=new Map,S=0,C=null,N=null,T.hasMore=!1,T.loading=!1,T.error=null,_=0},D=q=>{R(),q!==void 0&&(C=q.before??null,N=q.before??null,T.hasMore=q.before!==void 0,_=q.earlierTurns)},z=()=>{s.size!==0&&(s.clear(),e.onPendingChange())},E=()=>{let q=!1;for(const[K,H]of[...s])(H.origin===void 0||H.origin.length===0)&&(s.delete(K),q=!0);q&&e.onPendingChange()},L=(q,K)=>{if(ay(q)&&q.payload.type==="approval_decision"&&s.delete(Rl(q.origin,q.payload.tool_call_id))&&e.onPendingChange(),K&&!Nu(q.payload)&&FL(K,q)){UN(o,q);return}Tu(o,q,t())},F=q=>{switch(q.type){case"approval_request":{const K=q.toolCall.payload.tool_call_id,H={toolCall:q.toolCall};if(q.origin&&(H.origin=q.origin),s.set(Rl(q.origin,K),H),!_L(o,q.origin,K)){const $={...q.toolCall};q.origin&&q.origin.length>0?$.origin=[...q.origin]:delete $.origin,Tu(o,$,t()),e.onModelChange()}e.onPendingChange();return}case"task_state":{p=q.state,e.onTaskState(q.state),e.onQueuedFollowUps?.(q.queued??0),e.onPendingSteering?.(q.pendingSteering??[]),e.onPendingFollowUps?.(q.pendingFollowUps??[]),e.onSubagents?.(q.subagents??[]),q.state==="idle"&&(EL(o),E(),e.onModelChange());return}case"resync_required":{V();return}case"credentials_updated":return;case"hello":return}},V=async()=>{x+=1,u="buffering",f=[],z(),await B(x,bl(n),{page:{kind:"tail",limit:Qg},splice:v.length>0})},P=(q,K)=>{const H=Xg(K.cursor);if(!H)return q;const $=h===null?null:Xg(h);if($!==null&&$.epoch!==H.epoch)return q;const X=[],le=[];for(const I of q){const A=I.id===null?null:Xg(I.id);A!==null&&A.epoch===H.epoch&&A.seq<=H.seq?(I.kind!=="omni"||!Nu(I.msg.payload))&&X.push(I):le.push(I)}const ie=K.fragments.map(I=>({kind:"omni",msg:I,id:null,seeded:!0}));return[...X,...ie,...le]},B=async(q,K,H={})=>{try{let $=await e.loadMessages(H.page);if(c||q!==x)return;if(H.splice===!0){const j=$.page?.before??null;if(!($.page!==void 0&&j!==null&&j===N))if($.page!==void 0&&j===null)D($.page);else{if($=await e.loadMessages(),c||q!==x)return;D(void 0)}}else H.page!==void 0?D($.page):D(void 0);const{messages:X,live:le,serverNowMs:ie}=$;K&&(o=K);const I=o;$.page!==void 0&&Nw(I.stats,$.page.prior),Mw(I,X,t(),ie??null);const A=HL(X,100),Q=le!==void 0?P(f,le):f;f=[];for(let j=0;j<Q.length;j+=1){const U=Q[j];if(U.kind==="omni"?L(U.msg,A):F(U.ev),c)return;if(q!==x){f.push(...Q.slice(j+1).filter(ee=>ee.kind!=="omni"||!ee.seeded));return}}u="live",p==="idle"&&j0(I),g=!1,e.onError(null),e.onLoading(!1),e.onModelChange()}catch($){if(c||q!==x)return;g=!0,e.onLoading(!1),e.onError($ instanceof Error?$.message:String($))}};return{get model(){return o},get prefixItems(){return v},get prefixSubagents(){return w},get outlineOffset(){return _},get older(){return T},get pendingApprovals(){return s},load:()=>(x+=1,B(x,void 0,{page:{kind:"tail",limit:Qg}})),retry:async()=>{c||!g||(e.onError(null),e.onLoading(!0),x+=1,await B(x,bl(n),{page:{kind:"tail",limit:Qg}}))},loadOlder:async()=>{if(c||u!=="live"||g||T.loading||!T.hasMore||C===null)return;const q=x;T.loading=!0,T.error=null,e.onModelChange();try{const K=await e.loadMessages({kind:"before",cursor:C,limit:rq});if(c||q!==x)return;if(K.page===void 0)throw new Error("windowed history not supported");S+=1;const H=bl(n);H.nextItemId=-S*aq,Nw(H.stats,K.page.prior),Mw(H,K.messages,t(),null),j0(H),v=[...H.items,...v];const $=new Map(H.subagents);for(const[X,le]of w)$.set(X,le);w=$,C=K.page.before??null,T.hasMore=K.page.before!==void 0,_=K.page.earlierTurns}catch(K){if(c||q!==x)return;T.error=K instanceof Error?K.message:String(K)}finally{!c&&q===x&&(T.loading=!1,e.onModelChange())}},handleOmni:(q,K=null)=>{if(!c){if(K!==null&&(h=K),u==="buffering"){f.push({kind:"omni",msg:q,id:K});return}L(q,null),e.onModelChange()}},handleServer:(q,K=null)=>{if(!c){if(K!==null&&(h=K),q.type==="session_title"){e.onSessionTitle?.(q.sessionId,q.title);return}if(q.type==="session_created"){e.onSessionCreated?.(q.sessionId);return}if(q.type==="goal_started"||q.type==="goal_round"||q.type==="goal_finished"){e.onGoalEvent?.(q);return}if(u==="buffering"){q.type==="task_state"&&(p=q.state,e.onTaskState(q.state),e.onQueuedFollowUps?.(q.queued??0),e.onPendingSteering?.(q.pendingSteering??[]),e.onPendingFollowUps?.(q.pendingFollowUps??[])),f.push({kind:"server",ev:q,id:K});return}F(q)}},markLocalDecision:q=>{AL(o,q)},resolveApproval:q=>{s.delete(q)&&e.onPendingChange()},dispose:()=>{c=!0}}}const iq=120,oq=new Map,lq=[],cq=new Map,uq={hasMore:!1,loading:!1,error:null};function dq(e,t,n,s){const[o,c]=y.useState(0),[u,f]=y.useState(!0),[p,h]=y.useState(t),[x,g]=y.useState(0),[v,w]=y.useState([]),[S,C]=y.useState([]),[N,T]=y.useState([]),[_,R]=y.useState(null),[D,z]=y.useState(0),[E,L]=y.useState(null),F=y.useCallback(A=>{L(Q=>A.type==="goal_started"?{objective:A.objective,status:"active",budget:A.budget,used:0,rounds:0}:A.type==="goal_round"?{objective:Q?.objective??"",status:"active",budget:A.budget,used:A.used,rounds:A.round}:{objective:Q?.objective??"",status:A.outcome,budget:Q?.budget??-1,used:A.used,rounds:A.rounds})},[]),V=y.useRef(n);V.current=n;const P=y.useRef(s);P.current=s;const B=y.useRef(null),Y=y.useRef(null);Y.current===null&&(Y.current=bl());const q=y.useRef(null),K=y.useRef(null),H=y.useRef(0),$=y.useCallback(()=>{if(q.current!==null||K.current!==null)return;const A=()=>{H.current=Date.now(),c(j=>j+1)},Q=H.current+iq-Date.now();if(Q>0){K.current=window.setTimeout(()=>{K.current=null,A()},Q);return}q.current=requestAnimationFrame(()=>{q.current=null,A()})},[]);y.useEffect(()=>{if(!e){B.current?.dispose(),B.current=null,h("idle"),g(0),w([]),C([]),T([]),f(!1),R(null),L(null),z(ee=>ee+1),c(ee=>ee+1);return}c(ee=>ee+1),f(!0),R(null),h(t),L(null),g(0),w([]),C([]),T([]),z(ee=>ee+1);let A=!1;const Q=()=>{nA(e).then(ee=>{A||!ee.goal||ee.goal.status!=="active"||L(re=>re??ee.goal)}).catch(()=>{})},j=sq({loadMessages:ee=>sC(e,ee),onTaskState:h,onQueuedFollowUps:g,onPendingSteering:w,onPendingFollowUps:C,onSubagents:T,onLoading:f,onError:R,onModelChange:$,onPendingChange:()=>z(ee=>ee+1),onSessionTitle:(ee,re)=>V.current?.(ee,re),onSessionCreated:()=>P.current?.(),onGoalEvent:F});B.current=j;const U=_R(e,{onOmniMessage:j.handleOmni,onServerEvent:j.handleServer,onOpen:Q,onError:ee=>{ee&&qm().catch(()=>{})}});return j.load(),()=>{A=!0,j.dispose(),U.close(),q.current!==null&&(cancelAnimationFrame(q.current),q.current=null),K.current!==null&&(window.clearTimeout(K.current),K.current=null)}},[e]);const X=y.useCallback(A=>{B.current?.markLocalDecision(A)},[]),le=y.useCallback(A=>{B.current?.resolveApproval(A)},[]),ie=y.useCallback(()=>{B.current?.retry()},[]),I=y.useCallback(()=>{B.current?.loadOlder()},[]);return{model:B.current?.model??Y.current,prefixItems:B.current?.prefixItems??lq,prefixSubagents:B.current?.prefixSubagents??cq,outlineOffset:B.current?.outlineOffset??0,older:B.current?.older??uq,loadOlder:I,version:o,loading:u,taskState:p,queuedFollowUps:x,pendingSteering:v,pendingFollowUps:S,subagents:N,pendingApprovals:B.current?.pendingApprovals??oq,markLocalDecision:X,resolveApproval:le,error:_,retry:ie,goal:E}}const mq="M4 5h16v14H4zM4 14h16",fq="M4 5h16v14H4zM14 5v14",pq=e=>`relative flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors duration-150 ${e?"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200":"text-gray-500 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"}`;function hq({agentsPending:e}){y.useSyncExternalStore(Zf,$y);const t=vl("agents")??"right",n=[{position:"bottom",label:d.dock.bottomDock,icon:mq},{position:"right",label:d.dock.rightDock,icon:fq}];return a.jsx("div",{className:"flex shrink-0 items-center gap-1","data-testid":"panels-toolbar",children:n.map(({position:s,label:o,icon:c})=>a.jsxs("button",{type:"button","aria-expanded":Ba(s),onClick:()=>AB(s),title:o,"aria-label":o,"data-testid":`dock-toggle-${s}`,className:pq(Ba(s)),children:[a.jsx(Oe,{d:c,size:Ye.iconButton}),e&&t===s&&a.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 rounded-full ${Fl.attention}`})]},s))})}const gq=15e3;function Zg({icon:e,value:t,label:n}){return a.jsxs("span",{title:n,className:`flex shrink-0 items-center ${Ro.tight} font-mono text-xs text-gray-500 dark:text-gray-400`,children:[a.jsx(Oe,{d:e}),t]})}function xq({sessionId:e}){return a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.chat.sessionIdLabel}),a.jsxs("div",{className:"flex items-start gap-1.5",children:[a.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-xs leading-5",children:e}),a.jsx(Wu,{text:e,label:d.chat.copySessionId,className:PN})]})]})}function yq({stats:e,taskOpen:t,taskStartLocalMs:n}){const[s,o]=y.useState(()=>Date.now());return y.useEffect(()=>{if(!t)return;o(Date.now());const c=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(c)},[t]),t?a.jsx(a.Fragment,{children:ZC(vL(e,t,n,s))}):a.jsx(a.Fragment,{children:Pn(e.sessionElapsedMs)})}function bq(e,t){const n=e.stats;return{tokensText:It(n.sessionTotal+n.subagentTotal),costText:t.costText,costUncosted:t.costUncosted,elapsedNode:a.jsx(yq,{stats:n,taskOpen:e.taskOpen,taskStartLocalMs:e.taskStartLocalMs})}}const ya="new",vq=e=>e!==null&&e.startsWith("draft-")?e:null,F2=100;function kq(){const e=yr(),t=$r(),n=MC(),{user:s}=mn(),{currency:o}=as(),{currentProject:c,currentAgent:u,setCurrentAgentId:f,reloadAgents:p,agents:h}=en(),x=c?.projectId??null,g=u?.agentId??null,{sessions:v,loading:w,reload:S,add:C,isDeleted:N,replace:T,setStatus:_,setTitle:R}=Ii(),D=y.useRef(dM()),z=y.useRef(null),[,E]=y.useState(0),[L,F]=y.useState(!1),[V,P]=y.useState(!1),[B,Y]=y.useState(!1),[q,K]=y.useState(null),[H,$]=y.useState([]),[X,le]=y.useState(null),[ie,I]=y.useState(null),[A,Q]=y.useState(null),j=n.sessionId??null;y.useSyncExternalStore(Zf,$y),y.useSyncExternalStore(ZT,d2);const[U,ee]=y.useState(null),[re,ke]=y.useState(null),[be,ye]=y.useState(null),[Se,Me]=y.useState(null);y.useEffect(()=>{ee(null),ke(null),ye(null),Me(null)},[j]);const ze=vl("workspace")!==null,De=vl("memory")!==null,ct=vl("agents")!==null;y.useEffect(()=>{ze||ee(null)},[ze]),y.useEffect(()=>{De||ke(null)},[De]),y.useEffect(()=>{ct||(ye(null),Me(null))},[ct]);const bt=vq(j),he=j===ya||bt!==null,ne=he?null:v.find(de=>de.sessionId===j)??null;y.useEffect(()=>{he||JT(ne?.workspace??null)},[he,ne?.workspace]);const oe=ne?{provider:ne.provider,modelId:ne.modelId}:null;Li(ne?ne.title??d.chat.defaultSessionTitle:d.nav.chat);const J=dq(ne?.sessionId??null,ne?.status??"idle",R,()=>{S()}),{initial:ht,onTextChange:ve,onHandoffTargetChange:Xe,onPendingModelChange:Ge,onSkillsChange:He,discard:Pe}=nq(ne?.sessionId??null),W=y.useMemo(()=>J.prefixItems.length>0?[...J.prefixItems,...J.model.items]:J.model.items,[J.version,j]),me=y.useMemo(()=>bz(W),[J.version,j]),Ue=y.useMemo(()=>iB(W),[J.version,j]),pe=y.useMemo(()=>J.prefixItems.length>0||J.prefixSubagents.size>0?{...J.model,items:[...W],subagents:new Map([...J.prefixSubagents,...J.model.subagents])}:J.model,[J.version,j]),$e=y.useMemo(()=>jL(W.flatMap(de=>de.kind==="task_stats"&&de.memoryChanges!==void 0?[de.memoryChanges]:[])),[J.version,j]),nt=y.useRef($e);SL(nt.current,$e)||(nt.current=$e);const gt=nt.current,Ke=DH(x,ne?.agentId??null,vl("memory")!==null||gt.length>0,gt),dt=y.useMemo(()=>UU(Ke.scopes,gt)??void 0,[Ke.scopes,gt]),pt=y.useRef(null),wt=fB(pt,J.version),st=ne?.sessionId??null,Bt=ne?.agentId??null,Sn=ne?.thinkingLevel??"";y.useEffect(()=>{st&&Bt&&f(Bt)},[st,Bt,f]);const Dn=y.useRef(JF()),Vt=aP(J.model.items),ar=J.taskState!=="idle"&&uP(J.model);y.useEffect(()=>{eq(Dn.current,{sessionId:st,taskCount:Vt,liveSpawn:ar})==="autoOpen"&&!TB("agents")&&ho("agents")},[st,Vt,ar]);const[zn,Xt]=y.useState([]);y.useEffect(()=>{if(Xt(Re=>Re.length>0?[]:Re),!x||!Bt)return;let de=!1;return Bu(x,Bt).then(Re=>{de||Xt(Re.skills)}).catch(()=>{}),()=>{de=!0}},[x,Bt]);const[Cn,lr]=y.useState("");y.useEffect(()=>{if(lr(""),!x||!Bt)return;let de=!1;return Ao(x,Bt).then(Re=>{de||lr(Re.config.model?.thinkingLevel??"")}).catch(()=>{}),()=>{de=!0}},[x,Bt]);const Mt=x&&j?jH(x,j):null,[Pr,Bn]=y.useState(null);y.useEffect(()=>{if(he||!x||!j||!Mt||w||v.some(Re=>Re.sessionId===j))return;if(N(j)){Bn(Mt);return}let de=!1;return d0(j).then(Re=>{if(de)return;const Qe=SH(Re.session,x);Qe?C(Qe):Bn(Mt)},()=>{de||Bn(Mt)}),()=>{de=!0}},[he,x,j,Mt,w,v,C,N]),y.useEffect(()=>{if(w||he||j&&v.some(Re=>Re.sessionId===j)||j&&Pr!==Mt)return;const de=PC(v);e(de?`/chat/${de.sessionId}`:`/chat/${ya}`,{replace:!0})},[w,he,j,Mt,Pr,v,e]),y.useEffect(()=>{st!==null&&_(st,J.taskState)},[J.taskState,st,_]);const Nr=y.useRef({id:st,state:"idle"}),[Tr,Te]=y.useState(0);y.useEffect(()=>{const de=Nr.current,Re=de.id===st;Nr.current={id:st,state:Re?J.taskState:"idle"},!(!Re||st===null)&&de.state!=="idle"&&J.taskState==="idle"&&(S(),p(),Te(Qe=>Qe+1))},[J.taskState,st,S,p]);const Ie=ne?.lastActiveAt??null;y.useEffect(()=>{st===null||Ie===null||J.taskState==="idle"&&Gx(x,st,Ie)},[x,st,Ie,J.taskState]);const ut=y.useRef(new Map);y.useEffect(()=>{z.current=null,Q(null),ut.current=new Map,$([]),I(null)},[j]);const St=y.useCallback(async de=>{const Re=ne?.sessionId??null,Qe=ut.current,mt=Re===null?[]:de.filter(Pt=>!Qe.has(Pt));if(Re!==null&&mt.length>0)for(let Pt=0;Pt<mt.length;Pt+=F2){const Wt=mt.slice(Pt,Pt+F2),Ka=jA(Re,Wt).then(_r=>new Set(_r.existing)).catch(()=>null);for(const _r of Wt){const Rr=Ka.then(Ir=>Ir?.has(_r)??!1);Qe.set(_r,Rr),Rr.then(Ir=>{Qe.get(_r)===Rr&&(Ir?Qe.set(_r,!0):Qe.delete(_r))})}}const Et=new Set;return await Promise.all(de.map(async Pt=>{const Wt=Qe.get(Pt);(Wt===!0||Wt instanceof Promise&&await Wt)&&Et.add(Pt)})),Et},[ne?.sessionId]);y.useEffect(()=>{if(!x||!ne||z.current===ne.sessionId&&J.taskState!=="idle"&&!V)return;let de=!1;return iC(x,{groupBy:"session",agentId:ne.agentId}).then(Re=>{if(de)return;z.current=ne.sessionId;const Qe=Re.groups.find(mt=>mt.key===ne.sessionId);CH(D.current,ne.sessionId,Qe??null),I(Qe?{cacheRead:Qe.cacheRead,cacheWrite:Qe.cacheWrite,output:Qe.output}:null),E(mt=>mt+1)}).catch(()=>{}),()=>{de=!0}},[x,ne,J.taskState,V]);const gn=y.useRef(st);y.useEffect(()=>{gn.current=st},[st]);const Nn=H.filter(de=>de.running).length,Hn=J.taskState!=="idle"||Nn>0||V&&H.length>0;y.useEffect(()=>{if(!st)return;let de=!1;const Re=()=>{q1(st).then(mt=>{de||$(mt.processes)}).catch(()=>{})};if(Re(),!Hn)return()=>{de=!0};const Qe=window.setInterval(Re,gq);return()=>{de=!0,window.clearInterval(Qe)}},[st,J.taskState,Hn]);const Dt=y.useCallback(async(de,Re,Qe)=>{if(!ne||X!==null)return;const mt=ne.sessionId;le(de);try{await Re(mt,de)}catch(Et){Et instanceof xr&&Qe.includes(Et.status)||Be(Ae(Et))}finally{le(null),q1(mt).then(Et=>{gn.current===mt&&$(Et.processes)}).catch(()=>{})}},[ne,X]),Rn=y.useCallback(de=>Dt(de,iA,[404]),[Dt]),zr=y.useCallback(de=>Dt(de,oA,[404,409]),[Dt]);y.useEffect(()=>{if(!x)return;let de=!1;return K(null),(async()=>{try{const Re=await Ml(x);if(de)return;K(Re);const{prefs:Qe}=await Sx();if(de||Qe.credentialGuideSeen)return;const mt=Re.models.find(Pt=>zt(Pt,Re.defaultModel));(!Re.defaultModel||!mt||!Ol(mt))&&F(!0),Nf({credentialGuideSeen:!0}).catch(()=>{})}catch{}})(),()=>{de=!0}},[x]),y.useEffect(()=>{if(!x)return;let de=!1;const Re=Qe=>{const mt=cM(Qe,x);!mt||mt.defaultModel===void 0||(K(null),Ml(x).then(Et=>{de||K(Et)}).catch(()=>{}))};return window.addEventListener($u,Re),()=>{de=!0,window.removeEventListener($u,Re)}},[x]);const cr=y.useCallback(async(de,Re)=>{Re!==de&&(await S(),HT(Re),e(`/chat/${Re}`,{replace:!0}))},[S,e]),Js=y.useCallback(async(de,Re)=>{if(!ne)return!1;try{const Qe=await su(ne.sessionId,{input:de,...Re?{goal:Re}:{},...Sn?{thinkingLevel:Sn}:{}});return Pe(),await cr(ne.sessionId,Qe.sessionId),!0}catch(Qe){return Be(Ae(Qe,{modelId:ne.modelId})),!1}},[ne,Sn,Pe,cr]),Mr=y.useCallback(async(de,Re)=>{if(!x||!ne)return!1;const Qe=await d0(ne.sessionId).then(Pt=>Pt.session.tracePath).catch(()=>{}),mt={type:"text",text:JU({sessionId:ne.sessionId,...ne.title!==void 0?{sessionTitle:ne.title}:{},...Qe!==void 0?{tracePath:Qe}:{},workspace:ne.workspace,prevProvider:ne.provider,prevModelId:ne.modelId})};let Et=null;try{const Pt=await u0(x,ne.agentId,{provider:de.provider,modelId:de.modelId,workspace:ne.workspace,approvalMode:ne.approvalMode});Et=Pt.session.sessionId;const Wt=await su(Et,{input:[mt,...Re]});return C(Pt.session),Pe(),e(`/chat/${Wt.sessionId}`),!0}catch(Pt){return Et&&nf(Et).catch(()=>{}),Be(Ae(Pt,{modelId:de.modelId})),!1}},[x,ne,C,Pe,e]),ta=y.useCallback(async(de,Re)=>{if(!x||!u||!ne)return!1;const Qe={type:"text",text:ZU({agentId:u.agentId,...u.name!==void 0?{agentName:u.name}:{},sessionId:ne.sessionId,workspace:ne.workspace,...ne.title!==void 0?{sessionTitle:ne.title}:{}})};let mt=null;try{const Et=await u0(x,de.agentId,{approvalMode:ne.approvalMode});mt=Et.session.sessionId;const Pt=await su(mt,{input:[Qe,...Re]});return C(Et.session),Pe(),e(`/chat/${Pt.sessionId}`),!0}catch(Et){return mt&&nf(mt).catch(()=>{}),Be(Ae(Et,q?.defaultModel?{modelId:q.defaultModel.modelId}:{})),!1}},[x,u,ne,C,Pe,e,q]),Br=y.useCallback(async()=>{ne&&await aA(ne.sessionId).catch(()=>{})},[ne]),is=y.useCallback(async de=>{if(!ne)return!1;try{const Re=await su(ne.sessionId,{input:de,queueIfBusy:!0,...Sn?{thinkingLevel:Sn}:{}});return Pe(),await cr(ne.sessionId,Re.sessionId),!0}catch(Re){return Be(Ae(Re,{modelId:ne.modelId})),!1}},[ne,Sn,Pe,cr]),Hr=y.useCallback(async(de,Re=[],Qe=[])=>{if(!ne)return"failed";try{return await lA(ne.sessionId,{text:de,...Re.length>0?{images:Re}:{},...Qe.length>0?{files:Qe}:{}}),Pe(),"queued"}catch(mt){return mt instanceof xr&&mt.status===409?"not_running":(Be(Ae(mt,{modelId:ne.modelId})),"failed")}},[ne,Pe]),fn=y.useCallback(de=>{ne&&tf(ne.sessionId,{thinkingLevel:de}).then(Re=>T(Re.session)).catch(Re=>{Be(Ae(Re))})},[ne,T]),Fr=y.useCallback(async de=>{if(!ne)return null;try{return await dA(ne.sessionId,de)}catch(Re){return Be(Ae(Re)),null}},[ne]),qr=y.useCallback(async de=>{if(!ne)return null;try{const Re=await mA(ne.sessionId,de);return Re.thinkingLevel&&fn(Re.thinkingLevel),Re}catch(Re){return Be(Ae(Re)),null}},[ne,fn]),pn=y.useCallback(async(de,Re,Qe)=>{if(!ne)return;J.markLocalDecision(de);const mt=Rl(Qe,de);try{await rA(ne.sessionId,de,{decision:Re}),J.resolveApproval(mt)}catch(Et){Et instanceof xr&&Et.status===404&&J.resolveApproval(mt)}},[ne,J]),na=y.useCallback(de=>{!ne||B||(Y(!0),tf(ne.sessionId,{approvalMode:de}).then(Re=>T(Re.session)).catch(Re=>{Be(Ae(Re))}).finally(()=>Y(!1)))},[ne,B,T]),Jn=y.useCallback(async()=>{if(!ne)return!1;try{const de=await fA(ne.sessionId);return await cr(ne.sessionId,de.sessionId),!0}catch(de){return Be(Ae(de,{modelId:ne.modelId})),!1}},[ne,cr]),Er=y.useCallback(async()=>{await Jn()},[Jn]),ur=y.useCallback(de=>{pz(J.model.items,Hg(Sn,Cn),de)?Q({phase:"ask",level:de}):fn(de)},[J.model,Sn,Cn,fn]),os=y.useCallback(()=>{if(A===null||J.taskState!=="idle")return;const de={phase:"compacting",level:A.level,baseline:jT(J.model.items)};Q(de),wr(d.chat.thinkingSwitchCompacting),Jn().then(Re=>{Re||Q(Qe=>Qe===de?{phase:"settle",level:de.level}:Qe)})},[A,J.taskState,J.model,Jn]);y.useEffect(()=>{if(A===null)return;const de=gz(A,J.model.items);de.act!=="wait"&&(Q(null),fn(de.level),de.notice==="compacted"?yt(d.chat.thinkingSwitchApplied(W0(d.chat.thinkingLevelNames,de.level)??de.level)):de.notice==="compaction-failed"&&Be(d.chat.thinkingSwitchCompactFailed))},[J.version,J.model,A,fn]);const ls=y.useCallback(()=>{s&&x&&Yl(s.userId,x),e(`/chat/${ya}`)},[s,x,e]),ra=y.useCallback(async de=>{if(ne)try{let Re=de.position;if(Re===void 0){const mt=await sC(ne.sessionId),Et=bl();for(const Wt of mt.messages)Tu(Et,Wt);j0(Et);const Pt=[...Et.items].reverse().find(Wt=>Wt.kind==="task_stats"&&Wt.assistantText===de.assistantText&&Wt.atMs===de.atMs&&Wt.forkPosition!==void 0);Re=Pt?.kind==="task_stats"?Pt.forkPosition:void 0}if(Re===void 0){Be(d.chat.forkSessionFailed);return}const Qe=await WE(ne.sessionId,{position:Re});C(Qe.session),e(`/chat/${Qe.session.sessionId}`)}catch(Re){Be(Ae(Re,{modelId:ne.modelId}))}},[ne,C,e]),cs=q?.models.find(de=>zt(de,oe))?.pricing,ka={pendingApprovals:J.pendingApprovals,onApprove:pn,origin:[],taskRunning:J.taskState!=="idle",taskCost:de=>Cw(de.tokensByBucket,cs),onRetryNow:()=>{ne&&sA(ne.sessionId).catch(()=>{})},onGiveUp:()=>{Br()},onOpenFile:de=>{ho("workspace"),ee({path:de})},onOpenSubagent:(de,Re)=>{ho("agents"),Me({anchorSessionId:Re[0]??de}),ye({sessionId:de,origin:[...Re,de]})},onOpenMemory:()=>{ho("memory"),ke({target:null})},onLocateMemoryChange:de=>{ho("memory"),ke({target:{scope:de.scope,...de.scopeKey!==void 0?{scopeKey:de.scopeKey}:{},file:de.file}})},...dt!==void 0?{deletedMemoryKeys:dt}:{},workspace:ne?.workspace??null,statFiles:St,onFork:ra},Ar=[...J.pendingApprovals.keys()].some(de=>!de.startsWith(" ")),er=NB(),Tn=H2(er.find(de=>de.position==="right")??null),Vr=H2(er.find(de=>de.position==="bottom")??null),wa=d2(),Mn=(de,Re)=>{if(!ne)return a.jsx(Fa,{title:wl(de),description:d.dock.draftEmpty});switch(de){case"agents":return a.jsx(UH,{session:ne,model:pe,version:J.version,taskRunning:J.taskState!=="idle",ctx:ka,focusRequest:be,taskScope:Se,subagents:J.subagents,models:q?.models??[],approvalMode:ne.approvalMode,onChangeApprovalMode:na,modeSaving:B,parentThinkingLevel:Hg(Sn,Cn)},ne.sessionId);case"workspace":return a.jsx(OH,{session:ne,openRequest:U,active:Re,reloadSignal:Tr});case"memory":return a.jsx(HU,{session:ne,changes:gt,scopes:Ke.scopes,listingError:Ke.error,request:re,active:Re,onOpenSettings:()=>e(`/agents/${ne.agentId}?tab=memory`)},ne.sessionId);case"trace":return a.jsx(pF,{session:ne,active:Re},ne.sessionId);case"messaging":return a.jsx(TF,{sessionId:ne.sessionId,active:Re},ne.sessionId)}};if(!x||!g)return a.jsx("div",{className:"p-6",children:a.jsx(on,{className:"h-6 w-64"})});const Gr=J.model.taskOpen?Cw({cacheRead:J.model.stats.taskCacheRead,cacheWrite:J.model.stats.taskCacheWrite,output:J.model.stats.taskOutput},cs):null,En=bq(J.model,NH(D.current,{sessionId:ne?.sessionId??null,taskCount:rP(J.model.items),taskOpen:J.model.taskOpen,loading:J.loading,liveUsd:Gr,currency:o})),us=ie?ie.cacheRead+ie.cacheWrite:0,hn=ie&&us>0?`${Math.round(100*ie.cacheRead/us)}%`:null,Sa=h.find(de=>de.agentId===ne?.agentId),Ts=Sa&&Sa.name!==void 0?_n(Sa):null,Ga=q?.models.find(de=>zt(de,oe)),Ct=Ga?.contextWindow,ds=Ga?.vision!==!1,ja=ne!==null&&!J.loading&&!J.error&&J.model.items.length===0,br=ne&&a.jsx(Iy,{status:J.taskState,onSend:Js,onSteer:Hr,steeringDeliveredCount:J.model.items.filter(de=>de.kind==="user_steering").length,pendingSteering:J.pendingSteering,onRecallSteering:Fr,onQueueFollowUp:is,queuedFollowUps:J.queuedFollowUps,pendingFollowUps:J.pendingFollowUps,onRecallFollowUp:qr,onStop:Br,onCompact:Er,modelRef:oe,...q!==null?{models:q.models}:{},...q?.defaultModel!==void 0?{defaultModel:q.defaultModel}:{},onSwitchModel:Mr,turnThinkingLevel:Hg(Sn,Cn),onChangeTurnThinkingLevel:ur,...Ct!==void 0?{contextWindow:Ct}:{},contextNow:J.model.stats.contextNow,contextStale:J.model.stats.contextStale,sessionId:ne.sessionId,vision:ds,approvalMode:ne.approvalMode,onChangeApprovalMode:na,modeSaving:B,autoFocus:!0,agents:h,currentAgentId:ne.agentId,skills:zn,...ht.skills&&ht.skills.length>0?{initialSkills:ht.skills}:{},onSkillsChange:He,onHandoff:ta,initialText:ht.text??"",onTextChange:ve,history:me,...ht.handoffAgentId?{initialHandoffTargetId:ht.handoffAgentId}:{},onHandoffTargetChange:Xe,...ht.switchModelRef?{initialPendingModelRef:ht.switchModelRef}:{},onPendingModelChange:Ge}),Ca=ne===null?null:rN(J.taskState,ne.hasTrace,!1);return a.jsxs("div",{"data-dock-host":!0,className:"flex h-full flex-col bg-white dark:bg-gray-950",children:[ne&&a.jsxs("div",{className:"flex shrink-0 items-center gap-2.5 border-b border-gray-200 px-3 py-2 md:px-4 dark:border-gray-800",children:[a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[a.jsx("h1",{className:"flex min-w-0 text-[15px] font-semibold",children:a.jsx(Of,{text:ne.title??d.chat.defaultSessionTitle})}),Ca==="running"&&a.jsxs("span",{title:S0(Ca),className:"flex shrink-0 items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[a.jsx(vN,{activity:Ca}),a.jsx("span",{className:"hidden sm:inline",children:S0(Ca)})]})]}),a.jsx(hq,{agentsPending:Ar}),!wt.shown&&a.jsx(hB,{entries:Ue,turnOffset:J.outlineOffset,scrollRef:pt,running:J.taskState!=="idle"}),a.jsx(Qn,{open:V,setOpen:P,menuClass:"right-0 top-full mt-1 w-96 max-w-[calc(100vw-1.5rem)] origin-top-right",button:a.jsxs("button",{type:"button",title:d.chat.infoPanel,"aria-label":d.chat.infoPanel,"aria-expanded":V,onClick:()=>P(!V),className:`flex h-7 shrink-0 items-center rounded-md transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${V?"bg-gray-100 dark:bg-gray-800":""}`,children:[a.jsxs("span",{className:"hidden items-center gap-3 px-2 sm:flex",children:[a.jsx(Zg,{icon:Xn.tokens,value:En.tokensText,label:`${d.chat.statTokens}(Token)`}),En.costText!=null&&a.jsx(Zg,{icon:Xn.cost,value:`${En.costText}${En.costUncosted?" *":""}`,label:`${d.common.cost}(${o})${En.costUncosted?` · ${d.usage.uncostedNote}`:""}`}),a.jsx(Zg,{icon:Xn.elapsed,value:En.elapsedNode,label:d.chat.statElapsed}),Nn>0&&a.jsxs("span",{title:d.chat.runningServices(Nn),className:`flex shrink-0 items-center ${Ro.tight} font-mono text-xs ${sn.busy}`,children:[a.jsx(Oe,{d:Xn.services}),Nn]})]}),a.jsx("span",{className:"flex h-7 w-7 items-center justify-center text-gray-500 sm:hidden dark:text-gray-400",children:a.jsx(Oe,{d:RI,size:Ye.navRow})})]}),children:a.jsxs("div",{className:"space-y-3 px-3.5 py-2.5 text-sm",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.chat.agent}),a.jsxs("p",{className:"truncate text-xs",children:[a.jsx("span",{className:"font-mono",children:ne.agentId}),Ts!==null&&a.jsx("span",{className:"ml-1.5 text-gray-400 dark:text-gray-500",children:Ts})]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.chat.model}),a.jsxs("p",{className:"truncate text-xs",children:[a.jsx("span",{className:"font-mono",children:ne.modelId}),a.jsx("span",{className:"ml-1.5 text-gray-400 dark:text-gray-500",children:Ws(ne.provider)?.label??ne.provider})]})]}),a.jsx(xq,{sessionId:ne.sessionId}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.chat.workspace}),a.jsx("p",{className:"break-all font-mono text-xs leading-5",children:ne.workspace})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.common.created}),a.jsx("p",{className:"font-mono text-xs",children:Jr(ne.createdAt)})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.chat.sessionStats}),a.jsxs("ul",{className:"list-inside list-disc space-y-0.5 font-mono text-xs",children:[a.jsxs("li",{children:[d.chat.statTotalTokens," ",En.tokensText,hn!==null&&`${d.chat.statParenOpen}${d.chat.statCacheHit(hn)}${d.chat.statParenClose}`]}),En.costText!=null&&a.jsxs("li",{children:[d.common.cost," ",En.costText,En.costUncosted?" *":""]}),a.jsxs("li",{children:[d.chat.statElapsed," ",En.elapsedNode]})]})]}),H.length>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.chat.processList}),a.jsx("ul",{className:"mt-1 space-y-1.5",children:H.map(de=>a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${de.running?`animate-pulse ${Fl.busy}`:"bg-gray-300 dark:bg-gray-600"}`}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate font-mono text-xs",title:de.cmd,children:de.cmd}),a.jsxs("span",{className:"block truncate text-[11px] text-gray-400 dark:text-gray-500",children:[Jr(de.startedAt),de.pid!==null&&` · pid ${de.pid}`,de.running&&de.serviceUrl!==void 0&&a.jsxs(a.Fragment,{children:[" · ",a.jsx("a",{href:de.serviceUrl,target:"_blank",rel:"noopener noreferrer",title:de.serviceUrl,className:"text-gray-500 underline decoration-gray-300 underline-offset-2 transition-colors duration-150 hover:text-gray-700 hover:decoration-gray-500 dark:text-gray-400 dark:decoration-gray-600 dark:hover:text-gray-200",children:de.serviceUrl.replace(/^https?:\/\//i,"")})]})]})]}),de.running?a.jsx("button",{type:"button",disabled:X!==null,onClick:()=>{Rn(de.processId)},className:"shrink-0 rounded-md border border-gray-200 px-2 py-0.5 text-xs text-gray-600 transition-colors duration-150 hover:border-red-200 hover:bg-red-50 hover:text-red-600 disabled:cursor-default disabled:opacity-60 dark:border-gray-700 dark:text-gray-300 dark:hover:border-red-900 dark:hover:bg-red-950/40 dark:hover:text-red-400",children:X===de.processId?d.common.loading:d.chat.processStop}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"shrink-0 text-[11px] text-gray-400 dark:text-gray-500",children:d.chat.processExited}),a.jsx("button",{type:"button",title:d.chat.processRemoveHint,disabled:X!==null,onClick:()=>{zr(de.processId)},className:"shrink-0 rounded-md border border-gray-200 px-2 py-0.5 text-xs text-gray-600 transition-colors duration-150 hover:border-red-200 hover:bg-red-50 hover:text-red-600 disabled:cursor-default disabled:opacity-60 dark:border-gray-700 dark:text-gray-300 dark:hover:border-red-900 dark:hover:bg-red-950/40 dark:hover:text-red-400",children:X===de.processId?d.common.loading:d.chat.processRemove})]})]},de.processId))})]})]})})]}),a.jsxs("div",{"data-dock-row":!0,className:"flex min-h-0 flex-1",children:[a.jsx(Mz,{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:he?a.jsx(vH,{projectId:x,models:q,...bt!==null?{draftId:bt}:{}},`draft:${x}:${bt??t.key}`):a.jsx("div",{className:"anim-fade flex min-h-0 flex-1 flex-col",children:ne?J.error?a.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6",children:[a.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400",children:[d.chat.historyLoadFailed,":",J.error]}),a.jsx(ge,{onClick:J.retry,children:d.common.retry})]}):J.loading?a.jsxs("div",{className:"space-y-3 p-6",children:[a.jsx(on,{className:"h-5 w-1/3"}),a.jsx(on,{className:"h-5 w-2/3"}),a.jsx(on,{className:"h-5 w-1/2"})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"min-h-0 flex-1",children:ja?a.jsx("div",{className:"flex h-full items-center justify-center px-4",children:a.jsx("p",{className:"text-lg font-medium text-gray-400 dark:text-gray-500",children:d.chat.emptyGreeting})}):a.jsx(pT,{items:W,version:J.version,ctx:ka,scrollElRef:pt,older:{hasMore:J.older.hasMore,loading:J.older.loading,error:J.older.error,prependedCount:J.prefixItems.length,onLoad:J.loadOlder},outline:a.jsx(pB,{entries:Ue,turnOffset:J.outlineOffset,version:J.version,scrollRef:pt,running:J.taskState!=="idle",fit:wt})})}),a.jsx("div",{className:"shrink-0 border-t border-gray-200 bg-white px-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] pt-3 md:pb-3 dark:border-gray-800 dark:bg-gray-950",children:a.jsxs("div",{className:"mx-auto max-w-3xl",children:[J.goal&&a.jsx(NP,{goal:J.goal}),br]})})]}):w?a.jsx("div",{className:"space-y-3 p-6",children:a.jsx(on,{className:"h-5 w-1/2"})}):a.jsx(Fa,{title:d.chat.noSessions,action:a.jsx(ge,{onClick:ls,children:d.nav.newChat})})},ne?.sessionId??"empty")}),Tn.view&&a.jsx(B2,{view:Tn.view,open:Tn.open,animateEntrance:Tn.animateEntrance,renderPanel:Mn,panelBadges:{agents:Ar},terminalSupported:wa})]}),Vr.view&&a.jsx(B2,{view:Vr.view,open:Vr.open,animateEntrance:Vr.animateEntrance,renderPanel:Mn,panelBadges:{agents:Ar},terminalSupported:wa}),a.jsx(Yt,{open:L,title:d.project.noCredentialTitle,onClose:()=>F(!1),footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:()=>F(!1),children:d.project.later}),a.jsx(ge,{variant:"primary",onClick:()=>{F(!1),e("/models")},children:d.project.goToModels})]}),children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.project.noCredentialBody})}),a.jsxs(ln,{open:A?.phase==="ask",title:d.chat.thinkingSwitchTitle,tone:"primary",confirmLabel:d.chat.thinkingSwitchCompactFirst,confirmDisabled:J.taskState!=="idle",onConfirm:os,secondaryLabel:d.chat.thinkingSwitchConfirm,onSecondary:()=>{A!==null&&fn(A.level),Q(null)},onClose:()=>Q(null),children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.chat.thinkingSwitchBody(W0(d.chat.thinkingLevelNames,A?.level)??A?.level??"")}),J.taskState!=="idle"&&a.jsx("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:d.chat.thinkingSwitchBusyHint})]})]})}function wq({sessionId:e,onClose:t,onChanged:n}){const s=kM(e,{poll:!0,...n?{onChanged:n}:{},onLoadFailed:t});return a.jsx(Yt,{open:!0,title:d.messaging.dialogTitle,onClose:t,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:t,children:d.common.close}),a.jsx(ge,{variant:"primary",disabled:s.busy||s.form===null,onClick:()=>{s.save()},children:s.busy?d.common.saving:d.common.save})]}),children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(wM,{b:s}),s.form!==null&&a.jsx(SM,{channel:s.form.channel})]})})}const mx=/^[a-z][a-z0-9_]{1,63}$/,q2=/^[a-z][a-z0-9_]{1,31}$/,Sq=/^[a-z0-9_]+$/,jq=64;function Cq(e){const t=[];return y.Children.forEach(e,n=>{if(!y.isValidElement(n)||n.type!=="option")return;const s=n.props;t.push({value:s.value!==void 0?String(s.value):"",label:s.children??"",...s.disabled?{disabled:!0}:{}})}),t}const Nq=`flex w-full items-center gap-2 text-left ${Uf} disabled:cursor-not-allowed disabled:opacity-60`,Tq={base:"text-base",sm:"text-xs"};function Ss({label:e,hint:t,error:n,required:s,size:o="base",className:c,children:u,value:f,onChange:p,disabled:h,"aria-label":x}){const g=Cq(u),v=String(f??""),w=g.find(E=>E.value===v),S=y.useId(),[C,N]=y.useState(!1),{triggerRef:T,panelRef:_,position:R}=$f({open:C,onClose:()=>N(!1),estimatedHeight:g.length*36+8}),D=E=>{N(!1),p?.({target:{value:E}}),T.current?.focus()},z=a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:T,type:"button",disabled:h,"aria-haspopup":"listbox","aria-expanded":C,...x!==void 0?{"aria-label":x}:{},"aria-required":s||void 0,"aria-invalid":n?!0:void 0,"aria-describedby":n?S:void 0,onClick:()=>N(E=>!E),className:`${Nq} ${Pf[o]} ${n?zf:""} ${c??""}`,children:[a.jsx("span",{className:"min-w-0 flex-1 truncate",children:w?.label??g[0]?.label??""}),a.jsx(ns,{className:"text-gray-400"})]}),C&&R&&ss.createPortal(a.jsx("div",{ref:_,role:"listbox",className:"anim-pop fixed z-[60] max-h-60 overflow-y-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",style:{left:R.left,width:R.triggerWidth,top:R.topPx,bottom:R.bottomPx},children:g.map((E,L)=>a.jsxs("button",{type:"button",role:"option","aria-selected":E.value===v,disabled:E.disabled,onClick:()=>D(E.value),className:`flex items-center ${ny} ${Tq[o]} disabled:opacity-50 ${E.value===v?"bg-gray-100 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:[a.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.label}),E.value===v&&a.jsx(qu,{className:"text-gray-500 dark:text-gray-400"})]},`${E.value}-${L}`))}),document.body)]});return a.jsx(Vu,{label:e,hint:t,error:n,errorId:S,required:s,children:z})}const Mq=["always-ask","read-only","allow-all","deny-all"];function Eq({open:e,onClose:t,onCreated:n}){const{user:s}=mn(),o=s&&!s.isAdmin?`${s.userId}-`:"",[c,u]=y.useState(""),[f,p]=y.useState(""),[h,x]=y.useState(void 0),[g,v]=y.useState(!1);y.useEffect(()=>{e&&(u(""),p(""),x(void 0))},[e]);const w=async()=>{const S=o+c.trim();if(!c.trim()){x(d.common.requiredField);return}if(!(o?Sq.test(c.trim())&&S.length<=jq:mx.test(S))){x(o?d.project.idPrefixHint:d.project.idHint);return}v(!0),x(void 0);try{const N=await bE({projectId:S,...f.trim()?{name:f.trim()}:{}});n(N.project.projectId)}catch(N){x(Ae(N))}finally{v(!1)}};return a.jsx(Yt,{open:e,title:d.project.createTitle,onClose:t,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:t,children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:g,onClick:()=>{w()},children:d.common.create})]}),children:a.jsxs("div",{className:"space-y-3",children:[o?a.jsxs("div",{children:[a.jsx(Yn,{required:!0,children:d.project.id}),a.jsxs("div",{className:"flex items-stretch",children:[a.jsx("span",{className:"flex shrink-0 items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-100 px-2 font-mono text-xs text-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400",children:o}),a.jsx(at,{size:"sm",className:"rounded-l-none",value:c,invalid:!!h,onChange:S=>{u(S.target.value),x(void 0)},autoFocus:!0})]}),h?a.jsx(ga,{children:h}):a.jsx(wo,{children:d.project.idPrefixHint})]}):a.jsx(at,{label:d.project.id,required:!0,size:"sm",value:c,error:h,onChange:S=>{u(S.target.value),x(void 0)},hint:d.project.idHint,autoFocus:!0}),a.jsx(at,{label:d.project.displayName,hint:d.project.displayNameHint,size:"sm",value:f,onChange:S=>p(S.target.value)})]})})}const Aq={general:If,members:Bx,defaults:"M4 21v-7m0-4V3m8 18v-9m0-4V3m8 18v-5m0-4V3M1 14h6m2-6h6m2 8h6",security:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"};function _q({d:e}){return a.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"shrink-0",children:a.jsx("path",{d:e})})}function xl({title:e,description:t,children:n}){return a.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm",children:e}),t!==void 0&&a.jsx("p",{className:"mt-0.5 text-xs text-gray-400",children:t})]}),n!==void 0&&a.jsx("div",{className:"flex shrink-0 items-center gap-2",children:n})]})}function Rq({open:e,onClose:t}){const{desktopMode:n}=mn(),{currentProject:s}=en(),[o,c]=y.useState("general");y.useEffect(()=>{e&&c("general")},[e]);const u=s?.projectId,f=s?.role==="owner";if(!s||!u)return null;const p=[{key:"general",label:d.project.settingsTabGeneral},...n?[]:[{key:"members",label:d.project.settingsTabMembers}],{key:"defaults",label:d.project.settingsTabDefaults},{key:"security",label:d.project.settingsTabSecurity,info:d.project.commandPolicyInfo}],h=p.find(x=>x.key===o)??p[0];return a.jsx(Yt,{open:e,title:d.project.settingsTitle,onClose:t,widthClass:"sm:max-w-3xl",children:a.jsxs("div",{className:"flex flex-col gap-3 sm:min-h-[26rem] sm:flex-row sm:gap-0",children:[a.jsx("nav",{"aria-label":d.project.settingsTitle,className:"flex shrink-0 gap-1 overflow-x-auto sm:w-44 sm:flex-col sm:overflow-x-visible sm:border-r sm:border-gray-100 sm:pr-3 dark:sm:border-gray-800",children:p.map(x=>a.jsxs("button",{type:"button","aria-current":h.key===x.key?"page":void 0,onClick:()=>c(x.key),className:`flex shrink-0 items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors duration-150 ${h.key===x.key?"bg-gray-100 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-600 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-800/60"}`,children:[a.jsx(_q,{d:Aq[x.key]}),a.jsx("span",{className:"truncate",children:x.label})]},x.key))}),a.jsxs("section",{className:"min-w-0 flex-1 sm:pl-5",children:[a.jsxs("h3",{className:"flex items-center gap-1.5 text-base font-semibold",children:[h.label,h.info!==void 0&&a.jsx(ba,{label:h.label,children:h.info})]}),a.jsxs("div",{className:"mt-2",children:[h.key==="general"&&a.jsx(Iq,{projectId:u,isOwner:f,onClose:t}),h.key==="members"&&a.jsx(Lq,{projectId:u,isOwner:f}),h.key==="defaults"&&a.jsx(Oq,{projectId:u,isOwner:f}),h.key==="security"&&a.jsx($q,{projectId:u,isOwner:f})]})]})]})})}function Iq({projectId:e,isOwner:t,onClose:n}){const{currentProject:s,setCurrentProjectId:o,projects:c,reloadProjects:u}=en(),f=s?wu(s):"",[p,h]=y.useState(f),[x,g]=y.useState(!1),[v,w]=y.useState(void 0),[S,C]=y.useState(!1),N=async()=>{const _=p.trim();if(!(!_||_===f||x)){g(!0),w(void 0);try{await vE(e,{name:_}),await u()}catch(R){w(Ae(R))}finally{g(!1)}}},T=async()=>{try{await kE(e),n();const _=c.find(R=>R.projectId!==e);await u(),_&&o(_.projectId)}catch(_){Be(Ae(_))}};return a.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[a.jsx(xl,{title:d.project.displayName,children:t?a.jsxs("div",{className:"flex flex-col items-end gap-1",children:[a.jsxs("div",{className:"flex items-stretch gap-2",children:[a.jsx(at,{size:"sm",className:"w-44",value:p,invalid:!!v,maxLength:100,onChange:_=>{h(_.target.value),v&&w(void 0)},onKeyDown:_=>{_.key==="Enter"&&N()}}),a.jsx(ge,{size:"sm",disabled:x||!p.trim()||p.trim()===f,onClick:()=>{N()},children:d.common.save})]}),v!==void 0&&a.jsx(ga,{children:v})]}):a.jsx("span",{className:"text-sm",children:f})}),a.jsx(xl,{title:d.project.projectIdLabel,children:a.jsx("span",{className:"font-mono text-xs text-gray-400",children:e})}),t&&(e==="default_project"?a.jsx(xl,{title:d.project.deleteProject,description:d.project.deleteDefaultForbidden}):c.length<=1?a.jsx(xl,{title:d.project.deleteProject,description:d.project.deleteLastForbidden}):a.jsx(xl,{title:d.project.deleteProject,description:d.project.deleteProjectDesc,children:a.jsx(ge,{size:"sm",variant:"danger",onClick:()=>C(!0),children:d.common.delete})})),a.jsx(ln,{open:S,title:d.project.deleteProject,onClose:()=>C(!1),onConfirm:()=>{T()},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.project.deleteConfirm})})]})}function Lq({projectId:e,isOwner:t}){const{user:n}=mn(),[s,o]=y.useState(null),[c,u]=y.useState(""),[f,p]=y.useState(null);y.useEffect(()=>{let g=!1;return o(null),p(null),mg(e).then(v=>{g||o(v.members)}).catch(v=>{g||p(Ae(v))}),()=>{g=!0}},[e]);const h=async()=>{if(c.trim())try{await wE(e,{userId:c.trim()}),u("");const g=await mg(e);o(g.members)}catch(g){Be(Ae(g))}},x=async g=>{try{await SE(e,g);const v=await mg(e);o(v.members)}catch(v){Be(Ae(v))}};return f?a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:f}):s===null?a.jsx("p",{className:"text-xs text-gray-400",children:d.common.loading}):a.jsx("div",{className:"overflow-x-auto rounded-md border border-gray-200 dark:border-gray-800",children:a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-gray-100 bg-gray-50 text-left text-gray-500 dark:border-gray-800 dark:bg-gray-900/60 dark:text-gray-400",children:[a.jsx("th",{className:"whitespace-nowrap px-2.5 py-1.5 font-medium",children:d.common.username}),a.jsx("th",{className:"whitespace-nowrap px-2.5 py-1.5 font-medium",children:d.common.role}),a.jsx("th",{className:"w-20 whitespace-nowrap px-2.5 py-1.5 text-right font-medium",children:d.common.actions})]})}),a.jsxs("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[s.map(g=>a.jsxs("tr",{children:[a.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:g.userId}),a.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:a.jsx(On,{tone:"gray",children:g.role})}),a.jsx("td",{className:"whitespace-nowrap px-2.5 py-1 text-right",children:t&&g.role!=="owner"&&g.userId!==n?.userId&&a.jsx(ge,{size:"sm",variant:"ghost",onClick:()=>{x(g.userId)},children:d.project.removeMember})})]},g.userId)),t&&a.jsxs("tr",{children:[a.jsx("td",{className:"px-2.5 py-1.5",children:a.jsx(at,{placeholder:d.common.username,size:"sm",value:c,onChange:g=>u(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()}})}),a.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:a.jsx(On,{tone:"gray",children:"member"})}),a.jsx("td",{className:"whitespace-nowrap px-2.5 py-1 text-right",children:a.jsx(ge,{size:"sm",disabled:!c.trim(),onClick:()=>{h()},children:d.project.addMember})})]})]})]})})}function Oq({projectId:e,isOwner:t}){const{user:n}=mn(),{agents:s}=en(),[o,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=y.useState(null),[x,g]=y.useState(!1),[v,w]=y.useState(""),[S,C]=y.useState(""),[N,T]=y.useState(""),[_,R]=y.useState(""),[D,z]=y.useState(null);y.useEffect(()=>{let B=!1;return Qj(e).then(Y=>{B||(c(Y),w(Y.agentId??""),C(Y.workspace??""),T(Y.approvalMode??""),R(Y.thinkingLevel??""))}).catch(Y=>{B||h(Ae(Y))}),Ml(e).then(Y=>{B||(f(Y),z(Y.defaultModel??null))}).catch(Y=>{B||h(Ae(Y))}),()=>{B=!0}},[e]);const E=o!==null&&(v!==(o.agentId??"")||S.trim()!==(o.workspace??"")||N!==(o.approvalMode??"")||_!==(o.thinkingLevel??"")),L=u!==null&&D!==null&&!zt(u.defaultModel,D),F=async()=>{if(x||!E&&!L)return;g(!0);let B=null;try{if(E){const Y={...v?{agentId:v}:{},...S.trim()?{workspace:S.trim()}:{},...N?{approvalMode:N}:{},..._?{thinkingLevel:_}:{}},q=await jE(e,Y);c(q),n&&dH(n.userId,e),B={projectId:e,defaults:q}}if(L&&D){const Y=await ME(e,{provider:D.provider,modelId:D.modelId});f(q=>q&&{...q,defaultModel:Y.defaultModel}),n&&iM(n.userId,e),B={...B??{projectId:e},defaultModel:Y.defaultModel}}B&&yt(d.common.saved)}catch(Y){Be(Ae(Y))}finally{B&&xH(B),g(!1)}},V=o?.agentId?(()=>{const B=s.find(Y=>Y.agentId===o.agentId);return B?_n(B):o.agentId})():d.project.chatDefaultsNotSet,P=u?.models.find(B=>zt(B,u.defaultModel));return a.jsxs("div",{children:[a.jsxs("p",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-gray-500",children:[d.project.chatDefaultsTitle,a.jsx(ba,{label:d.project.chatDefaultsTitle,children:d.project.chatDefaultsHint})]}),p?a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:p}):o===null||u===null?a.jsx("p",{className:"text-xs text-gray-400",children:d.common.loading}):t?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[a.jsxs(Ss,{label:d.project.chatDefaultsAgent,size:"sm",value:v,onChange:B=>w(B.target.value),children:[a.jsx("option",{value:"",children:d.project.chatDefaultsNotSet}),s.map(B=>a.jsx("option",{value:B.agentId,children:_n(B)},B.agentId))]}),a.jsxs(Ss,{label:d.chat.approvalMode,size:"sm",value:N,onChange:B=>T(B.target.value),children:[a.jsx("option",{value:"",children:d.project.chatDefaultsApprovalNotSet}),Mq.map(B=>a.jsx("option",{value:B,children:d.chat.approvalModeNames[B]??B},B))]}),a.jsxs(Ss,{label:d.chat.thinkingLevel,size:"sm",value:_,onChange:B=>R(B.target.value),children:[a.jsx("option",{value:"",children:d.project.chatDefaultsThinkingNotSet}),ST.map(B=>a.jsx("option",{value:B,children:d.chat.thinkingLevelNames[B]??B},B))]}),a.jsxs("div",{children:[a.jsxs("span",{className:"mb-1 flex items-center gap-1",children:[a.jsx(Yn,{block:!1,children:d.chat.model}),a.jsx(ba,{label:d.chat.model,children:d.project.chatDefaultsModelHint})]}),u.models.length>0?a.jsx(a.Fragment,{children:a.jsx(Ay,{models:u.models,value:D,defaultModel:u.defaultModel,onChange:z,disabled:x,variant:"form"})}):a.jsx("p",{className:"text-xs text-gray-400",children:d.models.empty})]}),a.jsxs("div",{className:"sm:col-span-2",children:[a.jsx(Yn,{children:d.chat.workspace}),a.jsx(sd,{projectId:e,workspace:S,onChange:C,variant:"form"}),a.jsx(wo,{children:d.chat.workspaceHintShort})]})]}),a.jsx("div",{className:"mt-3 flex justify-end",children:a.jsx(ge,{size:"sm",disabled:x||!E&&!L,onClick:()=>{F()},children:d.common.save})})]}):a.jsx("div",{className:"space-y-1 text-sm",children:[[d.project.chatDefaultsAgent,V],[d.chat.workspace,o.workspace??d.chat.workspaceAuto],[d.chat.approvalMode,o.approvalMode?d.chat.approvalModeNames[o.approvalMode]??o.approvalMode:d.project.chatDefaultsApprovalNotSet],[d.chat.thinkingLevel,o.thinkingLevel?d.chat.thinkingLevelNames[o.thinkingLevel]??o.thinkingLevel:d.project.chatDefaultsThinkingNotSet],[d.chat.model,P?P.displayName??P.modelId:d.project.chatDefaultsNotSet]].map(([B,Y])=>a.jsxs("div",{className:"flex items-baseline gap-2",children:[a.jsx("span",{className:"w-24 shrink-0 text-xs text-gray-500",children:B}),a.jsx("span",{className:"min-w-0 flex-1 break-all",children:Y})]},B))})]})}function Dq(e,t){return e.name===t.name&&e.pattern===t.pattern&&(e.description??"")===(t.description??"")&&e.enabled===t.enabled}function V2({initial:e,onApply:t,onCancel:n}){const[s,o]=y.useState(e?.name??""),[c,u]=y.useState(e?.pattern??""),[f,p]=y.useState(e?.description??""),[h,x]=y.useState(void 0),g=()=>{const v=s.trim(),w=c.trim();if(!v||!w)return;try{new RegExp(w)}catch{x(d.project.commandPolicyInvalidPattern);return}const S=f.trim();t({name:v,pattern:w,...S!==""?{description:S}:{},enabled:e?.enabled??!0})};return a.jsxs("div",{className:"space-y-2 py-3",children:[a.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[a.jsx("div",{className:"sm:w-40",children:a.jsx(at,{size:"sm",label:d.project.commandPolicyRuleName,required:!0,value:s,maxLength:64,autoFocus:!0,onChange:v=>o(v.target.value)})}),a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx(at,{size:"sm",className:"font-mono",label:d.project.commandPolicyRulePattern,required:!0,value:c,maxLength:512,...h!==void 0?{error:h}:{},onChange:v=>{u(v.target.value),h&&x(void 0)},onKeyDown:v=>{v.key==="Enter"&&g()}})})]}),a.jsx(at,{size:"sm",label:d.project.commandPolicyRuleDesc,value:f,maxLength:300,onChange:v=>p(v.target.value)}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(ge,{size:"sm",variant:"ghost",onClick:n,children:d.common.cancel}),a.jsx(ge,{size:"sm",disabled:!s.trim()||!c.trim(),onClick:g,children:d.project.commandPolicyApplyRule})]})]})}function $q({projectId:e,isOwner:t}){const[n,s]=y.useState(null),[o,c]=y.useState(null),[u,f]=y.useState(!1),[p,h]=y.useState(!0),[x,g]=y.useState([]),[v,w]=y.useState(null);y.useEffect(()=>{let N=!1;return s(null),c(null),w(null),CE(e).then(T=>{N||(s(T),h(T.enabled),g(T.rules))}).catch(T=>{N||c(Ae(T))}),()=>{N=!0}},[e]);const S=n!==null&&(p!==n.enabled||x.length!==n.rules.length||x.some((N,T)=>!Dq(N,n.rules[T]))),C=async()=>{if(!(u||!S)){f(!0);try{const N=await NE(e,{enabled:p,rules:x});s(N),h(N.enabled),g(N.rules),yt(d.common.saved)}catch(N){Be(Ae(N))}finally{f(!1)}}};return a.jsx("div",{children:o!==null?a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:o}):n===null?a.jsx("p",{className:"text-xs text-gray-400",children:d.common.loading}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:a.jsx(xl,{title:d.project.commandPolicyEnable,description:d.project.commandPolicyEnableDesc,children:t?a.jsx(js,{checked:p,onChange:h,disabled:u}):a.jsx("span",{className:"text-xs text-gray-400",children:p?d.project.commandPolicyOn:d.project.commandPolicyOff})})}),a.jsxs("div",{className:p?"":"opacity-50",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-gray-100 py-1.5 dark:border-gray-800/60",children:[a.jsxs("p",{className:"text-xs font-medium text-gray-500",children:[d.project.commandPolicyRules," ·"," ",a.jsx("span",{className:"font-semibold",children:x.length})]}),t&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ge,{size:"sm",variant:"ghost",disabled:u||!p||v!==null,onClick:()=>g(n.defaultRules.map(N=>({...N}))),children:d.project.commandPolicyRestore}),a.jsx(ge,{size:"sm",variant:"ghost",disabled:u||!p||v!==null,onClick:()=>w("new"),children:d.project.commandPolicyAddRule})]})]}),a.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[v==="new"&&a.jsx(V2,{initial:null,onApply:N=>{g([N,...x]),w(null)},onCancel:()=>w(null)}),x.map((N,T)=>v===T?a.jsx(V2,{initial:N,onApply:_=>{g(x.map((R,D)=>D===T?_:R)),w(null)},onCancel:()=>w(null)},`edit-${T}`):a.jsxs("div",{className:`flex items-center gap-3 py-2.5 ${N.enabled?"":"opacity-60"}`,children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm font-medium",children:N.name}),N.description!==void 0&&a.jsx("p",{className:"mt-0.5 text-xs text-gray-400",children:N.description}),a.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-gray-400",title:N.pattern,children:N.pattern})]}),t?a.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[a.jsx(js,{checked:N.enabled,disabled:u||!p,onChange:_=>g(x.map((R,D)=>D===T?{...R,enabled:_}:R))}),a.jsx(ge,{size:"sm",variant:"ghost",disabled:u||!p||v!==null,onClick:()=>w(T),children:d.project.commandPolicyEditRule}),a.jsx(ge,{size:"sm",variant:"ghost",disabled:u||!p||v!==null,onClick:()=>g(x.filter((_,R)=>R!==T)),children:d.common.delete})]}):a.jsx("span",{className:"shrink-0 text-xs text-gray-400",children:N.enabled?d.project.commandPolicyOn:d.project.commandPolicyOff})]},`${N.name}-${T}`)),x.length===0&&v!=="new"&&a.jsx("p",{className:"py-3 text-xs text-gray-400",children:d.project.commandPolicyEmpty})]})]}),t&&a.jsx("div",{className:"mt-2 flex justify-end border-t border-gray-100 pt-3 dark:border-gray-800/60",children:a.jsx(ge,{size:"sm",disabled:u||!S||v!==null,onClick:()=>{C()},children:d.common.save})})]})})}function Uq({status:e,checkPending:t,menuItemClass:n,onInstallRequest:s}){const o=FC(e,t),c=o.action==="none",u=o.labelKind==="checking"?d.update.checking:o.labelKind==="downloading"?d.update.clientDownloading(o.version,o.percent):o.labelKind==="install"?d.update.clientRestartToInstall(o.version):d.update.clientCheckNow,f=o.labelKind==="unsupported"?o.unsupportedReason==="linux-not-appimage"?d.update.clientUnsupportedNonAppImage:d.update.clientUnsupportedDev:null,p=a.jsxs("button",{type:"button",disabled:c,onClick:()=>{o.action==="install"?s():o.action==="check"&&dI()},className:`${n} flex items-center justify-between gap-2 disabled:cursor-default disabled:opacity-60`,children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.busy&&a.jsx("span",{"aria-hidden":!0,className:"inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-[1.5px] border-current border-t-transparent opacity-70"}),!o.busy&&o.labelKind==="install"&&a.jsx("span",{"aria-hidden":!0,className:"h-2 w-2 shrink-0 rounded-full bg-[var(--accent-bg)]"}),a.jsx("span",{className:"min-w-0 truncate",children:u})]}),o.appVersion!==null&&a.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:`v${o.appVersion}`})]});return f!==null?a.jsx("span",{className:"block",title:f,children:p}):p}function Pq({version:e,newVersion:t,checking:n,menuItemClass:s,onCheck:o,onOpenDialog:c}){const u=t!==null,f=n?d.update.checking:u?d.update.newVersion(t):d.update.checkNow;return a.jsxs("button",{type:"button",disabled:n,onClick:u?c:o,className:`${s} flex items-center justify-between gap-2 disabled:cursor-default disabled:opacity-60`,children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n&&a.jsx("span",{"aria-hidden":!0,className:"inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-[1.5px] border-current border-t-transparent opacity-70"}),!n&&u&&a.jsx("span",{"aria-hidden":!0,className:"h-2 w-2 shrink-0 rounded-full bg-[var(--accent-bg)]"}),a.jsx("span",{className:"min-w-0 truncate",children:f})]}),e!==null&&a.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:`v${e}`})]})}function zq({open:e,onClose:t,latestVersion:n,releaseUrl:s=null,canUpdate:o,onRunFinished:c}){const[u,f]=y.useState("confirm"),[p,h]=y.useState(null);y.useEffect(()=>{e&&(f("confirm"),h(null))},[e]);const x=()=>{u==="done"&&c?.(),t()},g=async()=>{f("running");try{h(await $A())}catch(w){h({status:"failed",output:Ae(w),needsRestart:!1})}f("done")},v=p===null?null:p.status==="updated"?{text:d.update.updated,className:sn.success}:p.status==="unsupported"?{text:d.update.unsupported,className:sn.attention}:{text:d.update.failed,className:sn.danger};return a.jsx(Yt,{open:e,title:o?d.update.updateNow:n!==null?d.update.newVersion(n):d.update.releaseNotes,onClose:u==="running"?()=>{}:x,footer:u==="done"||!o?a.jsx(ge,{onClick:x,children:d.common.close}):a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:x,disabled:u==="running",children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:u==="running",onClick:()=>{g()},children:u==="running"?d.update.updating:d.update.updateNow})]}),children:u==="done"&&p!==null&&v!==null?a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:`text-sm font-medium ${v.className}`,children:v.text}),p.status==="updated"&&a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:d.update.restartHint}),p.output!==""&&a.jsx("pre",{className:"max-h-56 overflow-auto rounded-md bg-gray-100 p-3 text-xs leading-relaxed whitespace-pre-wrap text-gray-700 dark:bg-gray-800 dark:text-gray-300",children:oT(p.output)})]}):a.jsxs("div",{className:"space-y-2",children:[n!==null&&a.jsx("p",{className:"text-sm font-medium",children:d.update.newVersion(n)}),s!==null&&a.jsx("p",{children:a.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:d.update.releaseNotes})}),a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:o?d.update.confirmBody:d.update.adminOnly}),u==="running"&&a.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:d.update.updating})]})})}function Bq(e){return!(e.desktopMode&&e.sessionVia==="desktop")}const Hq=[{key:"general",group:"personal",visible:()=>!0},{key:"appearance",group:"personal",visible:()=>!0},{key:"account",group:"personal",visible:e=>Bq(e)},{key:"proxy",group:"server",visible:e=>e.isAdmin},{key:"uploads",group:"server",visible:e=>e.isAdmin},{key:"users",group:"server",visible:e=>e.isAdmin&&!e.desktopMode}];function Fq(e){return Hq.filter(t=>t.visible(e)).map(({key:t,group:n})=>({key:t,group:n}))}function qq(e){const t=[];for(const n of e)t.includes(n.group)||t.push(n.group);return t}function Vq(e,t){return t.some(n=>n.key===e)?e:t[0]?.key??null}const Gq=e=>`flex w-full items-center gap-2 whitespace-nowrap rounded-md px-2.5 py-1.5 text-sm transition-colors duration-150 ${e?"bg-gray-200/70 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"}`;function Kq({open:e,onClose:t,title:n,groups:s,active:o,onSelect:c,children:u}){const f=s.length>1,p=s.flatMap(x=>x.items).find(x=>x.key===o),h=p?.label??n;return a.jsx(Yt,{open:e,onClose:t,title:n,headerless:!0,bare:!0,widthClass:"sm:max-w-3xl",children:a.jsxs("div",{className:"flex h-[min(40rem,85vh)] flex-col sm:flex-row",children:[a.jsx("nav",{"aria-label":n,className:"flex shrink-0 gap-1 overflow-x-auto border-b border-gray-100 p-2 sm:w-44 sm:flex-col sm:overflow-x-visible sm:overflow-y-auto sm:border-b-0 sm:border-r sm:p-3 dark:border-gray-800",children:s.map(x=>a.jsxs("div",{className:"contents sm:mt-3 sm:block sm:first:mt-0",children:[f&&x.label!==void 0&&a.jsx("p",{className:"hidden px-2.5 pb-1 text-[11px] font-medium uppercase tracking-wide text-gray-400 sm:block dark:text-gray-500",children:x.label}),x.items.map(g=>a.jsxs("button",{type:"button",className:Gq(g.key===o),"aria-current":g.key===o?"page":void 0,onClick:()=>c(g.key),children:[g.icon!==void 0&&a.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-gray-400 dark:text-gray-500",children:g.icon}),a.jsx("span",{className:"min-w-0 truncate",children:g.label})]},g.key))]},x.key))}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-4 pt-4 sm:px-6 sm:pt-5",children:[a.jsxs("h2",{className:`flex min-w-0 items-center ${Ro.row} text-lg font-semibold`,children:[h,p?.info!==void 0&&a.jsx(ba,{label:h,children:p.info})]}),a.jsx(Rf,{onClose:t})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-4 pt-3 sm:px-6 sm:pb-6",children:u})]})]})})}function _i({label:e,hint:t,info:n,children:s}){return a.jsxs("div",{className:"flex items-center justify-between gap-4 py-3.5 first:pt-0 last:pb-0",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("p",{className:`flex items-center ${Ro.row} text-sm font-medium`,children:[e,n!==void 0&&a.jsx(ba,{label:e,children:n})]}),t!==void 0&&a.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:t})]}),a.jsx("div",{className:"shrink-0",children:s})]})}function Wq({value:e,onChange:t}){return a.jsx("div",{className:"flex items-center gap-1.5",children:cE.map(n=>a.jsx("button",{type:"button",title:d.settings.accentNames[n.value],"aria-label":d.settings.accentNames[n.value],"aria-pressed":e===n.value,onClick:()=>t(n.value),className:`h-5 w-5 rounded-full border transition-transform duration-150 hover:scale-110 ${e===n.value?"border-gray-500 ring-2 ring-gray-400/50 dark:border-gray-300":"border-transparent"}`,style:{backgroundColor:n.color}},n.value))})}const Yq=14*1024*1024;function Xq(){const{projects:e,currentProject:t}=en(),{reload:n}=Ii(),[s,o]=y.useState(""),[c,u]=y.useState(""),[f,p]=y.useState([]),[h,x]=y.useState(!1),g=s!==""?s:t?.projectId??e[0]?.projectId??"",v=f.some(N=>N.agentId===c)?c:(f.find(N=>N.agentId==="default_agent")??f[0])?.agentId??"";y.useEffect(()=>{if(g==="")return;let N=!1;return aC(g).then(T=>{N||p(T.agents)}).catch(()=>{N||p([])}),()=>{N=!0}},[g]);const w=h||v==="",S=async N=>{if(!(g===""||v==="")){x(!0);try{await bA(g,v,{dataBase64:N});const T=e.find(R=>R.projectId===g),_=`${T?wu(T):g} · ${f.find(R=>R.agentId===v)?.name??v}`;g===t?.projectId&&await n(),yt(d.settings.importTraceDone(_))}catch(T){Be(Ae(T))}finally{x(!1)}}},C=N=>{const T=N.target.files?.[0];if(N.target.value="",!T||v==="")return;if(T.size>Yq){Be(d.settings.importTraceTooLarge);return}const _=new FileReader;_.onload=()=>{const R=_.result;S(R.slice(R.indexOf(",")+1))},_.onerror=()=>Be(d.common.unknownError),_.readAsDataURL(T)};return a.jsx(_i,{label:d.settings.importTrace,info:d.settings.importTraceInfo,children:a.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[a.jsx("div",{className:"w-32",children:a.jsx(Ss,{size:"sm",value:g,disabled:h,onChange:N=>{o(N.target.value),u("")},"aria-label":d.settings.importTraceProject,children:e.map(N=>a.jsx("option",{value:N.projectId,children:wu(N)},N.projectId))})}),a.jsx("div",{className:"w-32",children:a.jsx(Ss,{size:"sm",value:v,disabled:w,onChange:N=>u(N.target.value),"aria-label":d.settings.importTraceAgent,children:f.map(N=>a.jsx("option",{value:N.agentId,children:_n(N)},N.agentId))})}),a.jsxs("label",{className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-md border border-gray-300 px-3 py-1 text-sm font-medium transition-colors duration-150 dark:border-gray-700 ${w?"pointer-events-none opacity-60":"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[a.jsx(Xl,{accept:".jsonl",disabled:w,onChange:C}),a.jsx(YC,{size:14}),h?d.settings.importTraceRunning:d.settings.importTracePick]})]})})}function Qq(){const{lang:e,setLang:t}=Dr(),{currency:n,setCurrency:s}=as(),o=[{value:"en",label:d.settings.langEn},{value:"zh",label:d.settings.langZh},{value:"system",label:d.settings.followSystem}],c=[{value:"USD",label:d.models.currencyUsd},{value:"CNY",label:d.models.currencyCny}];return a.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[a.jsx(_i,{label:d.settings.language,info:d.settings.languageInfo,children:a.jsx(ws,{options:o,value:e,onChange:t})}),a.jsx(_i,{label:d.models.currency,info:d.settings.currencyInfo,children:a.jsx(ws,{options:c,value:n,onChange:s,cols:2})}),a.jsx(Xq,{})]})}function Zq(){const{mode:e,setMode:t,fontScale:n,setFontScale:s,accent:o,setAccent:c,terminalMode:u,setTerminalMode:f}=as(),p=[{value:"light",label:d.settings.themeLight},{value:"dark",label:d.settings.themeDark},{value:"system",label:d.settings.followSystem}],h=[{value:"app",label:d.settings.followAppTheme},{value:"light",label:d.settings.themeLight},{value:"dark",label:d.settings.themeDark}],x=[{value:"sm",label:d.settings.fontSmall},{value:"md",label:d.settings.fontMedium},{value:"lg",label:d.settings.fontLarge}];return a.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[a.jsx(_i,{label:d.settings.theme,info:d.settings.themeInfo,children:a.jsx(ws,{options:p,value:e,onChange:t})}),a.jsx(_i,{label:d.settings.terminalTheme,info:d.settings.terminalThemeInfo,children:a.jsx(ws,{options:h,value:u,onChange:f})}),a.jsx(_i,{label:d.settings.fontSize,info:d.settings.fontSizeInfo,children:a.jsx(ws,{options:x,value:n,onChange:s})}),a.jsx(_i,{label:d.settings.accent,info:d.settings.accentInfo,children:a.jsx(Wq,{value:o,onChange:c})})]})}function _M({open:e,onClose:t}){const{refresh:n,sessionVia:s}=mn(),o=s==="desktop",[c,u]=y.useState(""),[f,p]=y.useState(""),[h,x]=y.useState(""),[g,v]=y.useState({}),[w,S]=y.useState(!1),C=()=>v(T=>T.old||T.new||T.confirm?{}:T);y.useEffect(()=>{e&&(u(""),p(""),x(""),v({}))},[e]);const N=async()=>{const T={};if(!o&&!c&&(T.old=d.common.requiredField),f||(T.new=d.common.requiredField),h||(T.confirm=d.common.requiredField),!T.confirm&&f!==h&&(T.confirm=d.account.passwordMismatch),T.old||T.new||T.confirm){v(T);return}S(!0),v({});try{await fE(o?{newPassword:f}:{oldPassword:c,newPassword:f}),await n(),t()}catch(_){_ instanceof xr&&_.code==="invalid_password"?v({new:Ae(_)}):v({old:Ae(_)})}finally{S(!1)}};return a.jsx(Yt,{open:e,title:d.account.changePassword,onClose:t,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:t,disabled:w,children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:w,onClick:()=>{N()},children:d.common.save})]}),children:a.jsxs("div",{className:"space-y-3",children:[!o&&a.jsx(ts,{label:d.account.oldPassword,required:!0,size:"sm",value:c,onChange:T=>{u(T.target.value),C()},error:g.old,autoComplete:"current-password",info:d.account.oldPasswordHint,infoLabel:d.account.oldPassword,autoFocus:!0}),a.jsx(ts,{label:d.account.newPassword,required:!0,size:"sm",value:f,onChange:T=>{p(T.target.value),C()},error:g.new,autoComplete:"new-password",hint:d.auth.passwordHint,autoFocus:o}),a.jsx(ts,{label:d.account.confirmPassword,required:!0,size:"sm",value:h,onChange:T=>{x(T.target.value),C()},error:g.confirm,autoComplete:"new-password"})]})})}function Jq(){const[e,t]=y.useState(!1);return a.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[a.jsx(_i,{label:d.account.changePassword,info:d.settings.changePasswordInfo,children:a.jsx(ge,{variant:"secondary",onClick:()=>t(!0),children:d.account.changePassword})}),a.jsx(_M,{open:e,onClose:()=>t(!1)})]})}function RM({actions:e,children:t}){return a.jsxs("section",{children:[a.jsx("div",{className:"space-y-4",children:t}),e!==void 0&&a.jsx("div",{className:"mt-5 flex justify-end gap-2 border-t border-gray-100 pt-4 dark:border-gray-800/60",children:e})]})}function eV(){const[e,t]=y.useState(null),[n,s]=y.useState(!0),[o,c]=y.useState(!0),[u,f]=y.useState(""),[p,h]=y.useState(null),[x,g]=y.useState(!1),v=C=>{t(C),s(C.proxyForApp),c(C.proxyForAgent),f(C.proxyUrl??"")};y.useEffect(()=>{let C=!1;return Yj().then(N=>{C||v(N.settings)}).catch(N=>{C||Be(Ae(N))}),()=>{C=!0}},[]);const w=async()=>{if(e===null||x)return;if(n===e.proxyForApp&&o===e.proxyForAgent&&u.trim()===(e.proxyUrl??"")){wr(d.common.noChangesToSave);return}g(!0),h(null);try{const N=await Xj({proxyForApp:n,proxyForAgent:o,proxyUrl:u});v(N.settings),yt(d.common.saved)}catch(N){N instanceof xr&&N.code==="invalid_proxy_url"?h(Ae(N)):Be(Ae(N))}finally{g(!1)}},S=e!==null;return a.jsxs(RM,{actions:a.jsx(ge,{variant:"primary",disabled:!S||x,onClick:()=>{w()},children:d.common.save}),children:[a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("span",{className:"text-sm font-medium",children:d.settings.proxyForApp}),a.jsx(js,{checked:n,onChange:s,disabled:!S})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsx("span",{className:"text-sm font-medium",children:d.settings.proxyForAgent}),a.jsx(js,{checked:o,onChange:c,disabled:!S})]}),a.jsx(at,{label:d.settings.proxyAddress,size:"sm",value:u,placeholder:d.settings.proxyAddressPlaceholder,disabled:!S,...p!==null?{error:p}:{},onChange:C=>{f(C.target.value),p!==null&&h(null)}})]})}function tV(){const{uploadLimits:e,refresh:t}=mn(),[n,s]=y.useState(null),[o,c]=y.useState(""),[u,f]=y.useState(""),[p,h]=y.useState(null),[x,g]=y.useState(!1),v=C=>{s(C),c(String(C.attachmentMaxMb)),f(String(C.attachmentTotalMb))};y.useEffect(()=>{let C=!1;return Yj().then(N=>{C||v(N.settings)}).catch(N=>{C||Be(Ae(N))}),()=>{C=!0}},[]);const w=async()=>{if(n===null||x)return;const C=Number(o.trim()),N=Number(u.trim()),T=o.trim()===""||!Number.isInteger(C),_=u.trim()===""||!Number.isInteger(N);if(T||_){h({text:d.errors.byCode.invalid_attachment_limit,max:T,total:_});return}if(C===n.attachmentMaxMb&&N===n.attachmentTotalMb){wr(d.common.noChangesToSave);return}g(!0),h(null);try{const R=await Xj({attachmentMaxMb:C,attachmentTotalMb:N});v(R.settings),await t().catch(()=>{}),yt(d.common.saved)}catch(R){R instanceof xr&&R.code==="invalid_attachment_limit"?h({text:Ae(R),max:!0,total:!0}):Be(Ae(R))}finally{g(!1)}},S=n!==null;return a.jsxs(RM,{actions:a.jsx(ge,{variant:"primary",disabled:!S||x,onClick:()=>{w()},children:d.common.save}),children:[a.jsx(at,{label:d.settings.attachmentMaxMb,required:!0,size:"sm",type:"number",inputMode:"numeric",min:e.attachmentLimitMinMb,max:e.attachmentLimitMaxMb,hint:d.settings.attachmentMaxMbHint(e.attachmentLimitMinMb,e.attachmentLimitMaxMb),value:o,disabled:!S,...p?.max===!0?{error:p.text}:{},onChange:C=>{c(C.target.value),p!==null&&h(null)}}),a.jsx(at,{label:d.settings.attachmentTotalMb,required:!0,size:"sm",type:"number",inputMode:"numeric",min:e.attachmentLimitMinMb,max:e.attachmentLimitMaxMb,hint:d.settings.attachmentTotalMbHint(e.attachmentLimitMinMb,e.attachmentLimitMaxMb),value:u,disabled:!S,...p?.total===!0?p.max?{invalid:!0}:{error:p.text}:{},onChange:C=>{f(C.target.value),p!==null&&h(null)}})]})}function nV(){const{user:e,desktopMode:t}=mn(),[n,s]=y.useState(null),[o,c]=y.useState(null),[u,f]=y.useState(!1),[p,h]=y.useState(null),[x,g]=y.useState(null),v=y.useCallback(async()=>{try{s((await pE()).users),c(null)}catch(w){c(Ae(w))}},[]);return y.useEffect(()=>{e?.isAdmin&&!t&&v()},[e?.isAdmin,t,v]),e&&(!e.isAdmin||t)?null:a.jsxs("div",{children:[a.jsx("div",{className:"mb-4 flex justify-end",children:a.jsx(ge,{variant:"primary",onClick:()=>f(!0),children:d.admin.createUser})}),n===null?a.jsx("p",{className:"text-sm text-gray-400",children:d.common.loading}):a.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-gray-100 bg-gray-50 text-left text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900/60 dark:text-gray-400",children:[a.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:d.common.username}),a.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:d.common.role}),a.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:d.common.created}),a.jsx("th",{className:"whitespace-nowrap px-3 py-2 text-right font-medium",children:d.common.actions})]})}),a.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:n.map(w=>a.jsxs("tr",{children:[a.jsxs("td",{className:"whitespace-nowrap px-3 py-2 font-medium",children:[w.userId,w.passwordIsInitial&&a.jsx("span",{className:"ml-2 align-middle",children:a.jsx(On,{tone:"gray",children:d.admin.initialPasswordFlag})})]}),a.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:a.jsx(On,{tone:"gray",children:w.isAdmin?d.admin.roleAdmin:d.admin.roleUser})}),a.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-gray-500 dark:text-gray-400",children:Jr(w.createdAt)}),a.jsxs("td",{className:"whitespace-nowrap px-3 py-1.5 text-right",children:[a.jsx(ge,{size:"sm",variant:"ghost",onClick:()=>h(w),children:d.admin.resetPassword}),!w.isAdmin&&a.jsx(ge,{size:"sm",variant:"ghost",onClick:()=>g(w),children:d.common.delete})]})]},w.userId))})]})}),o&&a.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:o}),a.jsx(rV,{open:u,onClose:()=>f(!1),onDone:()=>{f(!1),v()}}),a.jsx(aV,{user:p,onClose:()=>h(null)}),a.jsx(sV,{user:x,onClose:()=>g(null),onDone:()=>{g(null),v()}})]})}function rV({open:e,onClose:t,onDone:n}){const[s,o]=y.useState(""),[c,u]=y.useState(""),[f,p]=y.useState({}),[h,x]=y.useState(!1),g=()=>p(w=>w.userId||w.password?{}:w);y.useEffect(()=>{e&&(o(""),u(""),p({}))},[e]);const v=async()=>{const w=s.trim(),S={};if(w?q2.test(w)||(S.userId=d.auth.usernameHint):S.userId=d.common.requiredField,c||(S.password=d.common.requiredField),S.userId||S.password){p(S);return}x(!0),p({});try{await hE({userId:w,password:c}),n()}catch(C){C instanceof xr&&C.code==="invalid_password"?p({password:Ae(C)}):p({userId:Ae(C)})}finally{x(!1)}};return a.jsx(Yt,{open:e,title:d.admin.createUser,onClose:t,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:t,disabled:h,children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:h,onClick:()=>{v()},children:d.common.create})]}),children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(at,{label:d.common.username,required:!0,size:"sm",value:s,onChange:w=>{o(w.target.value),g()},error:f.userId,hint:d.auth.usernameHint,autoFocus:!0}),a.jsx(ts,{label:d.admin.initialPassword,required:!0,size:"sm",value:c,onChange:w=>{u(w.target.value),g()},error:f.password,autoComplete:"new-password",hint:d.auth.passwordHint}),q2.test(s.trim())&&a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:d.admin.defaultProjectNote(`${s.trim()}-default_project`)})]})})}function aV({user:e,onClose:t}){const[n,s]=y.useState(""),[o,c]=y.useState(void 0),[u,f]=y.useState(!1);y.useEffect(()=>{e&&(s(""),c(void 0))},[e]);const p=async()=>{if(e){if(!n){c(d.common.requiredField);return}f(!0),c(void 0);try{await gE(e.userId,{password:n}),t()}catch(h){c(Ae(h))}finally{f(!1)}}};return a.jsx(Yt,{open:e!==null,title:e?d.admin.resetPasswordTitle(e.userId):"",onClose:t,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:t,disabled:u,children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:u,onClick:()=>{p()},children:d.common.save})]}),children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(ts,{label:d.admin.initialPassword,required:!0,size:"sm",value:n,onChange:h=>{s(h.target.value),c(void 0)},error:o,autoComplete:"new-password",hint:d.auth.passwordHint,autoFocus:!0}),a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:d.admin.resetPasswordNote})]})})}function sV({user:e,onClose:t,onDone:n}){const[s,o]=y.useState(!1),[c,u]=y.useState(null),[f,p]=y.useState(!1);y.useEffect(()=>{e&&(o(!1),u(null))},[e]);const h=async()=>{if(e){p(!0),u(null);try{await xE(e.userId),n()}catch(x){u(Ae(x))}finally{p(!1)}}};return a.jsx(Yt,{open:e!==null,title:e?d.admin.deleteUserTitle(e.userId):"",onClose:t,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:t,disabled:f,children:d.common.cancel}),s?a.jsx(ge,{variant:"danger",disabled:f,onClick:()=>{h()},children:d.common.confirm}):a.jsx(ge,{variant:"danger",onClick:()=>o(!0),children:d.common.delete})]}),children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:e?d.admin.deleteUserConfirm(e.userId):""}),c&&a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:c})]})})}const iV={general:If,appearance:"M12 17a5 5 0 1 0 0-10 5 5 0 0 0 0 10zM12 2v2m0 16v2M4.9 4.9l1.4 1.4m11.4 11.4l1.4 1.4M2 12h2m16 0h2M4.9 19.1l1.4-1.4m11.4-11.4l1.4-1.4",account:"M20 21a8 8 0 0 0-16 0M12 13a5 5 0 1 0 0-10 5 5 0 0 0 0 10z",proxy:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM3.6 9h16.8M3.6 15h16.8M12 3a15 15 0 0 0 0 18M12 3a15 15 0 0 1 0 18",uploads:"M12 15V4m0 0L7 9m5-5l5 5M4 20h16",users:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"};function oV({open:e,onClose:t}){const{user:n,desktopMode:s,sessionVia:o,uploadLimits:c}=mn(),u=Fq({isAdmin:n?.isAdmin===!0,desktopMode:s,sessionVia:o}),[f,p]=y.useState(null);y.useEffect(()=>{e&&p(null)},[e]);const h=Vq(f,u);if(h===null)return null;const x={general:d.settings.generalTitle,appearance:d.settings.appearanceTitle,account:d.settings.accountTitle,proxy:d.settings.proxyTitle,uploads:d.settings.uploadLimitsTitle,users:d.admin.users},g={personal:d.settings.groupPersonal,server:d.settings.groupServer},v={proxy:d.settings.proxyInfo,uploads:d.settings.uploadLimitsInfo(c.attachmentMaxCount,c.imageMaxMb)},w=qq(u).map(S=>({key:S,label:g[S],items:u.filter(C=>C.group===S).map(C=>({key:C.key,label:x[C.key],icon:a.jsx(vn,{d:iV[C.key],size:16}),...v[C.key]!==void 0?{info:v[C.key]}:{}}))}));return a.jsxs(Kq,{open:e,onClose:t,title:d.settings.systemSettings,groups:w,active:h,onSelect:p,children:[h==="general"&&a.jsx(Qq,{}),h==="appearance"&&a.jsx(Zq,{}),h==="account"&&a.jsx(Jq,{}),h==="proxy"&&a.jsx(eV,{}),h==="uploads"&&a.jsx(tV,{}),h==="users"&&a.jsx(nV,{})]})}const Jm="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z";function lV({size:e=16}){return a.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:[a.jsx("circle",{cx:"5",cy:"12",r:"2"}),a.jsx("circle",{cx:"12",cy:"12",r:"2"}),a.jsx("circle",{cx:"19",cy:"12",r:"2"})]})}const G2="M21 21l-4.35-4.35M17 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0z",cV="M21 5h-7M10 5H3M21 12h-9M8 12H3M21 19h-5M12 19H3M14 2v6M8 9v6M16 16v6",uV="M18 6L6 18M6 6l12 12",dV="application/x-penguin-session-id",IM="application/x-penguin-group-key",K2=e=>e.dataTransfer.types.includes(IM),W2="(hover: hover) and (pointer: fine)";function Y2({base:e,size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("g",{transform:"translate(-1 -1) scale(0.82)",children:a.jsx("path",{d:e})}),a.jsx("path",{d:"M18.5 15.5v6M15.5 18.5h6",strokeWidth:"2"})]})}const Zc="block w-full px-3.5 py-2 text-left text-sm transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800",Jc=e=>`flex h-6 w-6 shrink-0 items-center justify-center rounded-md transition-colors duration-150 ${e?"bg-gray-200/70 text-gray-700 dark:bg-gray-800 dark:text-gray-200":"text-gray-400 hover:bg-gray-200/50 hover:text-gray-700 dark:text-gray-500 dark:hover:bg-gray-800/70 dark:hover:text-gray-300"}`,X2="px-2.5 pb-0.5 pt-1.5 text-[11px] font-medium text-gray-400 dark:text-gray-500",mV=e=>`penguin.sidebarCollapsedGroups.${e}`,fV=e=>`penguin.sidebarPinnedGroups.${e}`;function Om(e){if(!e)return new Set;try{const t=JSON.parse(localStorage.getItem(e)??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function Q2(e,t){if(e)try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}const Dm=(e,t)=>`${t}\0${e}`,Jg="\0drafts";function pV({activity:e}){return e===null?a.jsx("span",{"aria-hidden":"true",className:"block h-3 w-3 shrink-0"}):a.jsx(vN,{activity:e})}function Z2({onNavigate:e,onCollapse:t}){const n=yr(),{user:s,logout:o,desktopMode:c,sessionVia:u}=mn(),{locale:f}=Dr(),{projects:p,currentProject:h,setCurrentProjectId:x,reloadProjects:g,agents:v,currentAgent:w,setCurrentAgentId:S}=en(),{sessions:C,byAgent:N,countsByAgent:T,workspaceCountsByAgent:_,isLoadedFor:R,hasMoreFor:D,loadMoreFor:z,loading:E,remove:L,replace:F}=Ii(),P=Mx("/chat/:sessionId")?.params.sessionId??null,[B,Y]=y.useState(!1),[q,K]=y.useState(!1),[H,$]=y.useState(!1),[X,le]=y.useState(!1),[ie,I]=y.useState(!1),A=HC({desktopMode:c,sessionVia:u}),Q=VC(A,q),[j,U]=y.useState(!1),{version:ee,update:re}=Px(q),ke=zx(),be=GC(re),[ye,Se]=y.useState(!1),[Me,ze]=y.useState(!1),De=h?.projectId??null,ct=VI(De),bt=De===null?null:mV(De),he=De===null?null:fV(De),[ne,oe]=y.useState(YI),[J,ht]=y.useState(bg),[ve,Xe]=y.useState(()=>Om(bt)),[Ge,He]=y.useState(()=>Om(he)),[Pe,W]=y.useState(()=>dw(De)),[me,Ue]=y.useState(s6),[pe,$e]=y.useState(()=>vg(De,bg())),[nt,gt]=y.useState(()=>kg(De,bg())),[Ke,dt]=y.useState(()=>fw(De)),[pt,wt]=y.useState(null),[st,Bt]=y.useState(""),[Sn,Dn]=y.useState(null),[Vt,ar]=y.useState(!1),[zn,Xt]=y.useState(""),[Cn,lr]=y.useState(!1),[Mt,Pr]=y.useState(()=>window.matchMedia(W2).matches);y.useEffect(()=>{const G=window.matchMedia(W2),Ce=Ze=>Pr(Ze.matches);return G.addEventListener("change",Ce),()=>G.removeEventListener("change",Ce)},[]);const[Bn,Nr]=y.useState(null),[Tr,Te]=y.useState(null),[Ie,ut]=y.useState(null),[St,gn]=y.useState(null);y.useEffect(()=>{Xe(Om(bt)),He(Om(he)),W(dw(De)),$e(vg(De,J)),gt(kg(De,J)),dt(fw(De)),Mr(0),cr(new Map)},[bt,he,De]);const[Nn,Hn]=y.useState(new Set),[Dt,Rn]=y.useState(new Set),[zr,cr]=y.useState(new Map),[Js,Mr]=y.useState(0),[ta,Br]=y.useState(null),[is,Hr]=y.useState(!1),[fn,Fr]=y.useState(null),qr=pH(s?.userId??null,De),[pn,na]=y.useState(null),[Jn,Er]=y.useState(""),[ur,os]=y.useState(!1),[ls,ra]=y.useState(null),[cs,ka]=y.useState(null),Ar=G=>{NI(G),ht(G),$e(vg(De,G)),gt(kg(De,G)),Mr(0),cr(new Map)},er=()=>{const G=!ne;XI(G),oe(G)},Tn=y.useMemo(()=>a6(PR(C),Ke),[C,Ke]),Vr=y.useMemo(()=>UR(_),[_]),wa=y.useMemo(()=>gw(v,G=>G.agentId,{pinned:Ge,order:J==="agent"?nt:[]}),[v,Ge,nt,J]),Mn=y.useMemo(()=>gw(Tn,G=>G.key,{pinned:Ge,order:J==="workspace"?nt:[]}),[Tn,Ge,nt,J]),Gr=y.useMemo(()=>wa.map(G=>G.agentId),[wa]),En=y.useMemo(()=>Mn.map(G=>G.key),[Mn]),us=G=>J==="agent"?G.agentId:J==="time"?zc:vo(G.workspace),hn=G=>{if(Ct)return;const Ce=new Set(ve);Ce.has(G)?Ce.delete(G):Ce.add(G),Xe(Ce),Q2(bt,Ce)},Sa=G=>{const Ce=new Set(Ge);Ce.has(G)?Ce.delete(G):Ce.add(G),He(Ce),Q2(he,Ce)},Ts=G=>{const Ce=QI(Pe,G);W(Ce),mw(De,Ce)},Ga=G=>{i6(G),Ue(G)},Ct=zn.trim()!=="",ds=J==="agent"?wa.length:J==="workspace"?Mn.length:0,ja=DC(ds),br=$C(Js,ds),Ca=G=>Ct?G:aw(G,br),de=()=>!Ct&&ja>1?a.jsx(EI,{page:br,pageCount:ja,onChange:Mr}):null,Re=me==="manual"&&Mt?"manual":"recent",Qe=G=>Ct?G.filter(Ce=>$R(Ce,zn)):G,mt=J==="time"?gg(Qe(C)):null,Et=mt===null?[]:qR(mt.active,Date.now()),Pt=VR(T),Wt=G=>[...T].filter(([,Ce])=>Ce[G]>0).map(([Ce])=>Ce),Ka=Wt("active").filter(G=>D(G,"active")),_r=G=>({active:G,subagent:[],schedule:[],archived:[]}),Rr=()=>{ar(!1),Xt("")},Ir=(G,Ce,Ze)=>{if(!Bn)return;const it=Yx(G,Bn.id,Ce,Ze);if(it===G)return;const tt=l6(pe,it);$e(tt),pw(De,J,tt)},Ui=(G,Ce,Ze)=>{if(Ie===null)return;const it=m6(nt,G,Ie,Ce,Ze);it!==nt&&(gt(it),d6(De,J,it))},ae=(G,Ce)=>{if(!Mt||Ct||!Xx(J))return{header:{},dropEdge:null};const Ze=Ie,it=Ze!==null&&Ze!==G&&Ge.has(Ze)===Ge.has(G),tt=Je=>{const ft=Je.currentTarget.getBoundingClientRect();return Je.clientY-ft.top>ft.height/2};return{header:{draggable:!0,onDragStart:Je=>{Je.dataTransfer.setData(IM,G),Je.dataTransfer.effectAllowed="move",ut(G)},onDragEnd:()=>{ut(null),gn(null)},onDragOver:Je=>{if(!it||!K2(Je))return;Je.preventDefault(),Je.dataTransfer.dropEffect="move";const ft=tt(Je);gn(An=>An?.key===G&&An.after===ft?An:{key:G,after:ft})},onDragLeave:Je=>{const ft=Je.relatedTarget;ft instanceof Node&&Je.currentTarget.contains(ft)||gn(An=>An?.key===G?null:An)},onDrop:Je=>{!it||Ze===null||!K2(Je)||(Je.preventDefault(),Ui(Ce,G,tt(Je)),ut(null),gn(null))}},dropEdge:it&&St?.key===G?St.after?"below":"above":null}},_e=Ct?qr.filter(G=>sx(G).toLowerCase().includes(zn.trim().toLowerCase())):qr,et=_e.length>0||(J==="agent"?wa.some(G=>Qe(N.get(G.agentId)??[]).length>0):J==="time"?mt!==null&&Object.values(mt).some(G=>G.length>0):Mn.some(G=>Qe(G.sessions).length>0)),qe=(G,Ce)=>`${Ce}\0${G}`,vt=G=>J==="workspace"?G:void 0,xn=(G,Ce,Ze)=>{const it=qe(G,Ce);Rn(tt=>new Set(tt).add(it)),z(Ze,Ce,vt(G)).finally(()=>{Rn(tt=>{const Je=new Set(tt);return Je.delete(it),Je})})},tr=(G,Ce,Ze)=>{if(Ct)return;const it=Dm(G,Ce),tt=!Nn.has(it);if(Hn(Je=>{const ft=new Set(Je);return tt?ft.add(it):ft.delete(it),ft}),tt){const Je=vt(G),ft=Ze.filter(An=>!R(An,Ce,Je));ft.length>0&&z(ft,Ce,Je)}},Pi=y.useRef(null);y.useEffect(()=>{if(!P)return;const G=C.find(ft=>ft.sessionId===P);if(!G)return;const Ce=ha(G);if(Ce==="active"||Ce==="archived")return;const Ze=`${J}\0${P}`;if(Pi.current===Ze)return;Pi.current=Ze;const it=J==="agent"?G.agentId:J==="time"?zc:vo(G.workspace),tt=Dm(it,Ce);Hn(ft=>ft.has(tt)?ft:new Set(ft).add(tt));const Je=J==="workspace"?it:void 0;R(G.agentId,Ce,Je)||z([G.agentId],Ce,Je)},[P,C,J,R,z]),y.useEffect(()=>{if(!(J!=="workspace"||Ct))for(const G of aw(Mn,br)){const Ce=Vr.get(G.key),Ze=Ce?.totals.active??0;if(G.sessions.filter(ft=>ha(ft)==="active").length>=Math.min(bs,Ze))continue;const Je=[...new Set([...Ce?.agents.active??[],...G.sessions.map(ft=>ft.agentId)])].filter(ft=>!R(ft,"active",G.key));Je.length>0&&z(Je,"active",G.key)}},[J,Ct,Mn,br,Vr,R,z]);const ei=async()=>{if(!Me){ze(!0);try{const G=fI(await iw());G.kind==="disabled"?wr(d.update.checkDisabled):G.kind==="failed"?Be(d.update.checkFailed):G.kind==="found"?yt(d.update.foundNew(G.latestVersion)):yt(d.update.upToDate)}catch(G){Be(Ae(G))}finally{ze(!1)}}},id=async G=>{!G.archived&&G.sessionId===P&&Hn(Ce=>new Set(Ce).add(Dm(us(G),"archived")));try{const Ce=await tf(G.sessionId,{archived:!G.archived});F(Ce.session)}catch{}},zi=async()=>{if(!pn)return;const G=Jn.trim();if(G){os(!0),ra(null);try{const Ce=await tf(pn.sessionId,{title:G});F(Ce.session),na(null)}catch(Ce){ra(Ae(Ce))}finally{os(!1)}}},Lo=async()=>{if(!ta)return;Hr(!0);const G=ta;try{await nf(G.sessionId),L(G.sessionId),s&&Du(aM(s.userId,G.sessionId));const Ce=ZI(Pe,G.sessionId);Ce!==Pe&&(W(Ce),mw(De,Ce)),GI(De,G.sessionId);const Ze=c6(pe,G.sessionId);if(Ze!==pe&&($e(Ze),pw(De,J,Ze)),Br(null),P===G.sessionId){const it=(N.get(G.agentId)??[]).filter(tt=>{const Je=ha(tt);return tt.sessionId!==G.sessionId&&(Je==="active"||Je==="schedule")});n(it[0]?`/chat/${it[0].sessionId}`:"/chat")}}catch(Ce){Be(Ae(Ce))}finally{Hr(!1)}},Oo=G=>{n(G),e?.()},nr=(G,Ce)=>{s&&De&&Yl(s.userId,De),G&&S(G);const Ze={...G?{agentId:G}:{},...Ce!==void 0?{workspace:Ce}:{}};n(`/chat/${ya}`,Object.keys(Ze).length>0?{state:Ze}:void 0),e?.()},Ms=()=>{fn&&(s&&De&&lM(s.userId,De,fn.id),P===fn.id&&n(`/chat/${ya}`),Fr(null))},Bi=(v.find(G=>G.agentId==="default_agent")??v[0])?.agentId,Hi=w?.agentId??Bi,Do=CI(J),ms=Do==="agent"?d.agent.create:Do==="chat"?d.chat.newSessionMenu:d.chat.newWorkspaceEntity,Fi=G=>{G!==Ke&&(dt(G),e6(De,G))},qi=G=>{const Ce=t6(Ke,G);if(Ce===Ke)return;Fi(Ce);const Ze=vo(G),it=Mn.findIndex(tt=>tt.key===Ze);Mr(OR(it>=0?it:Mn.length))},$o=y.useMemo(()=>new Set(Ke.map(G=>G.path)),[Ke]),od=G=>{Bt(Ke.find(Ce=>Ce.path===G)?.alias??""),wt({path:G})},ld=()=>{pt&&(Fi(n6(Ke,pt.path,st)),wt(null))},sp=()=>{Sn&&(Fi(r6(Ke,Sn.path)),Dn(null))},ip=G=>{Gx(De,G.sessionId,G.lastActiveAt),S(G.agentId),Oo(`/chat/${G.sessionId}`)},Ql=y.useMemo(()=>new Map(v.map(G=>[G.agentId,_n(G)])),[v]),cd=(G,Ce,Ze,it=!1)=>a.jsx("ul",{className:"space-y-0.5",children:G.map(tt=>{const Je=Ze!==void 0&&Bn?.scope===Ze.scope?Bn:null,ft=Je!==null&&Je.id!==tt.sessionId&&Pe.has(Je.id)===Pe.has(tt.sessionId),An=Ze===void 0?{}:{draggable:!0,onDragStart:Ht=>{Ht.dataTransfer.setData(dV,tt.sessionId),Ht.dataTransfer.effectAllowed="move",Nr({scope:Ze.scope,id:tt.sessionId})},onDragEnd:()=>{Nr(null),Te(null)},onDragOver:Ht=>{if(!Je||!ft)return;Ht.preventDefault();const dr=Ht.currentTarget.getBoundingClientRect(),ti=Ht.clientY-dr.top>dr.height/2;Te(Na=>Na?.id===tt.sessionId&&Na.after===ti?Na:{id:tt.sessionId,after:ti})},onDragLeave:()=>Te(Ht=>Ht?.id===tt.sessionId?null:Ht),onDrop:Ht=>{if(!Je||!ft)return;Ht.preventDefault();const dr=Ht.currentTarget.getBoundingClientRect(),ti=Ht.clientY-dr.top>dr.height/2,Na=Ze.fullRows.filter(Vi=>Pe.has(Vi.sessionId)===Pe.has(Je.id)).map(Vi=>Vi.sessionId);Ir(Na,tt.sessionId,ti),Nr(null),Te(null)},dropEdge:ft&&Tr?.id===tt.sessionId?Tr.after?"below":"above":null};return a.jsx(gV,{s:tt,active:tt.sessionId===P,activity:KI(tt,ct,P),pinned:Pe.has(tt.sessionId),canPin:it,lastActive:UI(tt.lastActiveAt,f),...Ce?{agentHint:Ql.get(tt.agentId)??tt.agentId}:{},...An,onOpen:ip,onTogglePin:Ht=>Ts(Ht.sessionId),onRename:Ht=>{ra(null),Er(Ht.title??""),na(Ht)},onMessaging:Ht=>ka(Ht),onDelete:Ht=>Br(Ht),onToggleArchive:Ht=>{id(Ht)}},tt.sessionId)})}),ud=(G,Ce,Ze,it,tt,Je)=>{const ft=Ze[Ce];if(Ct&&ft.length===0)return null;const An=Ct?ft.length:Math.max(Je?.[Ce]??0,ft.length);if(An===0)return null;const Ht=!Ct&&ft.length<An&&tt.some(dr=>D(dr,Ce,vt(G)));return a.jsx(AI,{label:d.chat.folderGroups[Ce](An),open:Ct||Nn.has(Dm(G,Ce)),onToggle:()=>tr(G,Ce,tt),more:Ht,moreLabel:d.chat.expandRestSessions(Math.max(An-ft.length,0)),pending:Dt.has(qe(G,Ce)),onMore:()=>xn(G,Ce,tt),children:cd(ft,it)},Ce)},op=(G,Ce,Ze)=>{const it=(zr.get(G)??bs)+bs;cr(tt=>{const Je=new Map(tt);return Je.set(G,it),Je}),Ce.length>0&&Ze<it&&xn(G,"active",Ce)},lp=G=>{cr(Ce=>{if(!Ce.has(G))return Ce;const Ze=new Map(Ce);return Ze.delete(G),Ze})},Zl=(G,Ce,Ze,it,tt)=>{const Je=zr.get(G)??bs,ft=o6(Ce.active,Ta=>Ta.sessionId,{pinned:Pe,sortMode:Re,order:pe,recencyOf:Ta=>Ta.lastActiveAt}),An=Ct?ft:ft.slice(0,Je),Ht=Re==="manual"&&!Ct?{scope:G,fullRows:ft}:void 0,dr=tt("active"),ti=dr.length>0&&!dr.some(Ta=>D(Ta,"active",vt(G))),Na=Ct?0:DR({shown:An.length,loaded:Ce.active.length,total:it?.active??0,fullyLoaded:ti}),Vi=!Ct&&Je>bs&&Ce.active.length>bs,dd=rf.map(Ta=>ud(G,Ta,Ce,Ze,tt(Ta),it)),up=Ce.active.length===0&&dd.every(Ta=>Ta===null),dp=Dt.has(qe(G,"active"));return a.jsxs(a.Fragment,{children:[up?a.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400 dark:text-gray-600",children:d.chat.noSessions}):cd(An,Ze,Ht,!0),Na>0&&a.jsx(Km,{label:d.chat.expandRestSessions(Na),ariaLabel:d.chat.expandRestSessions(Na),pending:dp,onClick:()=>op(G,dr,Ce.active.length),className:"mt-0.5"}),Vi&&a.jsx(Km,{label:d.chat.showLess,ariaLabel:d.chat.showLess,onClick:()=>lp(G),...Na>0?{}:{className:"mt-0.5"}}),dd]})},Jl=mt===null?[]:rf.map(G=>ud(zc,G,mt,!0,Wt(G),Pt)),cp=WI.map(G=>({to:`/${G}`,label:d.nav[G],icon:vs[G]}));return a.jsxs("div",{className:"flex h-full w-full flex-col",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-2 pt-2",children:[t&&a.jsx("button",{type:"button",title:d.nav.collapseSidebar,"aria-label":d.nav.collapseSidebar,onClick:t,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(vn,{d:"M15 6l-6 6 6 6M4 4v16",size:18})}),a.jsxs(Qn,{open:B,setOpen:Y,className:"min-w-0 flex-1",menuClass:"left-0 right-0 top-full mt-1 origin-top",button:a.jsxs("button",{type:"button",onClick:()=>Y(!B),className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-base font-semibold transition-colors duration-150 hover:bg-gray-200/70 dark:hover:bg-gray-800",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:h?wu(h):d.common.loading}),a.jsx("span",{className:"text-gray-400",children:a.jsx(ns,{})})]}),children:[p.map(G=>a.jsxs("button",{type:"button",onClick:()=>{x(G.projectId),Y(!1)},className:`flex w-full items-center justify-between gap-2 px-3.5 py-2 text-left text-sm transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800 ${G.projectId===h?.projectId?"font-semibold":""}`,children:[a.jsx("span",{className:"truncate",children:wu(G)}),a.jsx(On,{tone:"gray",children:G.role})]},G.projectId)),a.jsxs("div",{className:"mt-1.5 border-t border-gray-100 pt-1.5 dark:border-gray-800",children:[a.jsxs("button",{type:"button",className:Zc,onClick:()=>{Y(!1),$(!0)},children:["+ ",d.project.create]}),h&&a.jsx("button",{type:"button",className:Zc,onClick:()=>{Y(!1),le(!0)},children:d.project.settings})]})]})]}),a.jsx("div",{className:"shrink-0 px-2 pb-2 pt-2",children:a.jsxs("button",{type:"button",onClick:()=>nr(Bi),className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors duration-150 ${P===ya?"bg-gray-200/70 text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-600 hover:bg-gray-200/50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"}`,children:[a.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:a.jsx(vn,{d:Jm})}),d.chat.newSessionMenu]})}),a.jsxs("div",{className:"relative min-h-0 flex-1 overflow-y-auto px-2 pb-2",children:[a.jsxs("nav",{className:"space-y-0.5",children:[a.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${ne?"grid-rows-[0fr]":"grid-rows-[1fr]"}`,children:a.jsx("div",{className:"overflow-hidden",inert:ne,children:a.jsx("div",{className:`space-y-0.5 transition-opacity duration-200 ${ne?"opacity-0":"opacity-100"}`,children:cp.map(G=>{const Ce=G.to==="/agents"?ke.kernelNote:null;return a.jsxs(Lx,{to:G.to,onClick:()=>e?.(),...Ce!==null?{title:Ce,"aria-label":`${G.label} · ${Ce}`}:{},className:({isActive:Ze})=>`relative flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm transition-colors duration-150 ${Ze?"bg-gray-200/70 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-600 hover:bg-gray-200/50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"}`,children:[a.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:a.jsx(vn,{d:G.icon})}),G.label,Ce!==null&&a.jsx(Mo,{size:"inline",position:"right-2.5 top-1/2 -translate-y-1/2"})]},G.to)})})})}),a.jsx("button",{type:"button",onClick:er,"aria-expanded":!ne,"aria-label":ne?d.nav.expandGroup:d.nav.collapseGroup,title:ne?d.nav.expandGroup:d.nav.collapseGroup,className:"flex h-4 w-full items-center justify-center rounded-md bg-gray-200/70 text-gray-400 transition-colors duration-150 hover:bg-gray-300/60 hover:text-gray-700 dark:bg-gray-800/70 dark:text-gray-500 dark:hover:bg-gray-700 dark:hover:text-gray-300",children:a.jsx(ns,{size:12,className:`transition-transform duration-200 ${ne?"":"rotate-180"}`})})]}),a.jsxs("div",{className:`mt-3 grid items-center px-1 pt-2 transition-[grid-template-columns] duration-200 ease-out ${Vt?"grid-cols-[0fr_1fr]":"grid-cols-[1fr_1fr]"}`,children:[a.jsx("span",{className:`min-w-0 overflow-hidden whitespace-nowrap px-1 text-[11px] font-semibold uppercase tracking-wide text-gray-400 transition-opacity duration-200 dark:text-gray-500 ${Vt?"opacity-0":"opacity-100"}`,children:d.chat.sessionList}),a.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-0.5",children:[Vt?a.jsxs("div",{className:"flex h-6 min-w-0 flex-1 items-center gap-1 rounded-md border border-gray-300 bg-white px-1.5 transition-colors duration-150 focus-within:border-gray-400 dark:border-gray-700 dark:bg-gray-900 dark:focus-within:border-gray-500",children:[a.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-gray-400 dark:text-gray-500",children:a.jsx(vn,{d:G2,size:12})}),a.jsx("input",{autoFocus:!0,value:zn,placeholder:d.chat.searchSessionsPlaceholder,"aria-label":d.chat.searchSessions,...Gu,onChange:G=>Xt(G.target.value),onKeyDown:G=>{G.key==="Escape"&&(G.stopPropagation(),Rr())},className:"min-w-0 flex-1 bg-transparent text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:text-gray-200 dark:placeholder:text-gray-500"}),a.jsx("button",{type:"button",title:d.chat.searchClear,"aria-label":d.chat.searchClear,onClick:Rr,className:"flex h-4 w-4 shrink-0 items-center justify-center text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-300",children:a.jsx(vn,{d:uV,size:11})})]}):a.jsx("button",{type:"button",title:d.chat.searchSessions,"aria-label":d.chat.searchSessions,onClick:()=>ar(!0),className:Jc(!1),children:a.jsx(vn,{d:G2,size:14})}),a.jsxs(Qn,{open:Cn,setOpen:lr,portal:{direction:"down",align:"right"},menuClass:"w-40",button:a.jsx("button",{type:"button",title:d.chat.listSettings,"aria-label":d.chat.listSettings,"aria-haspopup":"menu","aria-expanded":Cn,onClick:()=>lr(!Cn),className:Jc(Cn),children:a.jsx(vn,{d:cV,size:14})}),children:[a.jsx("p",{className:X2,children:d.chat.groupModeSection}),a.jsx(eu,{icon:xm.workspace,label:d.chat.groupByWorkspace,checked:J==="workspace",onSelect:()=>{Ar("workspace"),lr(!1)}}),a.jsx(eu,{icon:xm.agent,label:d.chat.groupByAgent,checked:J==="agent",onSelect:()=>{Ar("agent"),lr(!1)}}),a.jsx(eu,{icon:xm.time,label:d.chat.groupByTime,checked:J==="time",onSelect:()=>{Ar("time"),lr(!1)}}),a.jsx("div",{className:"my-1 border-t border-gray-100 dark:border-gray-800"}),a.jsx("p",{className:X2,children:d.chat.sortModeSection}),Mt&&a.jsx(eu,{icon:lw.manual,label:d.chat.sortManual,checked:me==="manual",onSelect:()=>{Ga("manual"),lr(!1)}}),a.jsx(eu,{icon:lw.recent,label:d.chat.sortRecent,checked:me==="recent",onSelect:()=>{Ga("recent"),lr(!1)}})]}),Do==="agent"?a.jsx("button",{type:"button",title:ms,"aria-label":ms,onClick:()=>{n("/agents",{state:{create:!0}}),e?.()},className:Jc(!1),children:a.jsx(Y2,{base:vs.agents})}):Do==="chat"?a.jsx("button",{type:"button",title:ms,"aria-label":ms,onClick:()=>nr(),className:Jc(!1),children:a.jsx(vn,{d:Jm,size:Ye.iconButton})}):a.jsx(sd,{projectId:De??"",workspace:"",onChange:qi,trigger:(G,Ce)=>a.jsx("button",{type:"button",title:ms,"aria-label":ms,"aria-expanded":G,onClick:Ce,className:Jc(G),children:a.jsx(Y2,{base:El})})},De??"no-project")]})]}),_e.length>0&&a.jsxs("div",{className:"pt-2.5",children:[a.jsx(ym,{open:Ct||!ve.has(Jg),onToggle:()=>hn(Jg),icon:a.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:a.jsx(vn,{d:Jm,size:Ye.groupHeaderGlyph})}),label:d.chat.draftGroup,uppercase:!0,count:_e.length}),(Ct||!ve.has(Jg))&&a.jsx("ul",{className:"space-y-0.5",children:_e.map(G=>a.jsx(hV,{entry:G,active:G.id===P,onOpen:()=>Oo(`/chat/${G.id}`),onDelete:()=>Fr(G)},G.id))})]}),J==="agent"?E&&v.length===0?a.jsx(Sr,{rows:5}):Ca(wa).map(G=>{const Ce=Qe(N.get(G.agentId)??[]);if(Ct&&Ce.length===0)return null;const Ze=gg(Ce),it=!Ct&&ve.has(G.agentId),tt=Ge.has(G.agentId),Je=ae(G.agentId,Gr);return a.jsxs(J2,{dropEdge:Je.dropEdge,children:[a.jsx(ym,{...Je.header,open:!it,onToggle:()=>hn(G.agentId),icon:a.jsx(Ha,{id:G.agentId,name:_n(G),size:18,className:"shrink-0 rounded"}),label:_n(G),uppercase:!0,actions:a.jsxs(a.Fragment,{children:[a.jsx(ej,{pinned:tt,onToggle:()=>Sa(G.agentId)}),a.jsx("button",{type:"button",title:d.chat.newSessionMenu,"aria-label":d.chat.newSessionMenu,onClick:()=>nr(G.agentId),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(vn,{d:"M12 5v14M5 12h14",size:Ye.groupHeaderAction})}),a.jsx("button",{type:"button",title:d.agent.settings,onClick:()=>Oo(`/agents/${G.agentId}`),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(vn,{d:If,size:Ye.groupHeaderAction})})]})}),it?null:Zl(G.agentId,Ze,!1,T.get(G.agentId),()=>[G.agentId])]},G.agentId)}):null,J==="agent"?de():null,J!=="workspace"?null:E&&C.length===0?a.jsx(Sr,{rows:5}):Mn.length===0&&!Ct?a.jsx("p",{className:"px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600",children:d.chat.noSessions}):Ca(Mn).map(G=>{const Ce=Qe(G.sessions);if(Ct&&Ce.length===0)return null;const Ze=gg(Ce),it=!Ct&&ve.has(G.key),tt=Ge.has(G.key),Je=ae(G.key,En),ft=Vr.get(G.key),An=[...new Set(G.sessions.map(dr=>dr.agentId))],Ht=dr=>[...new Set([...ft?.agents[dr]??[],...An])];return a.jsxs(J2,{dropEdge:Je.dropEdge,children:[a.jsx(ym,{...Je.header,open:!it,onToggle:()=>hn(G.key),icon:a.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:a.jsx(vn,{d:it?El:kI,size:Ye.groupHeaderGlyph})}),label:G.temp?d.chat.tempWorkspaces:G.label,count:Ct?Ze.active.length:Math.max(ft?.totals.active??0,Ze.active.length),...G.fullPath!==null?{title:G.fullPath}:{},actions:a.jsxs(a.Fragment,{children:[a.jsx(ej,{pinned:tt,onToggle:()=>Sa(G.key)}),a.jsx("button",{type:"button",title:d.chat.newSessionInWorkspace,"aria-label":d.chat.newSessionInWorkspace,onClick:()=>nr(Hi,G.fullPath??""),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-500 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(vn,{d:"M12 5v14M5 12h14",size:Ye.groupHeaderAction})}),$o.has(G.key)&&a.jsx(xV,{onRename:()=>od(G.key),onDelete:()=>Dn({path:G.key,label:G.label})})]})}),it?null:Zl(G.key,Ze,!0,ft?.totals,Ht)]},G.key)}),J==="workspace"?de():null,J!=="time"||mt===null?null:E&&C.length===0?a.jsx(Sr,{rows:5}):a.jsxs(a.Fragment,{children:[Et.map(G=>{const Ce=!Ct&&ve.has(G.key);return a.jsxs("div",{className:"pt-2.5",children:[a.jsx(ym,{open:!Ce,onToggle:()=>hn(G.key),icon:a.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:a.jsx(vn,{d:xm.time,size:Ye.groupHeaderGlyph})}),label:d.chat.timeGroups[G.bucket],uppercase:!0,count:G.sessions.length}),Ce?null:Zl(G.key,_r(G.sessions),!0,void 0,()=>[])]},G.key)}),Et.length===0&&!Ct&&Jl.every(G=>G===null)&&a.jsx("p",{className:"px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600",children:d.chat.noSessions}),!Ct&&mt.active.length<Pt.active&&Ka.length>0&&a.jsx(Km,{label:d.chat.loadMoreSessions,ariaLabel:d.chat.loadMoreSessions,pending:Dt.has(qe(zc,"active")),onClick:()=>xn(zc,"active",Ka),className:"mt-1"}),a.jsx("div",{className:"pt-2.5",children:Jl})]}),Ct&&!et&&a.jsx("p",{className:"px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600",children:d.chat.searchNoMatches})]}),a.jsx("div",{className:"shrink-0 border-t border-gray-200 p-2 dark:border-gray-800",children:a.jsx(Qn,{open:q,setOpen:K,menuClass:"bottom-full left-0 right-0 mb-1 origin-bottom",button:a.jsxs("button",{type:"button",onClick:()=>K(!q),...ke.softwareNote!==null?{title:ke.softwareNote,"aria-label":`${s?.userId??""} · ${ke.softwareNote}`}:{},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors duration-150 hover:bg-gray-200/70 dark:hover:bg-gray-800",children:[a.jsxs("span",{className:"relative flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-gray-900 text-xs font-bold text-white dark:bg-gray-200 dark:text-gray-900",children:[(s?.userId??"?").slice(0,1).toUpperCase(),ke.software!==null&&a.jsx(Mo,{})]}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:s?.userId}),s?.isAdmin&&a.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:d.auth.admin})]}),children:a.jsxs("div",{className:"py-1",children:[a.jsx("button",{type:"button",className:Zc,onClick:()=>{K(!1),I(!0)},children:d.settings.systemSettings}),!c&&a.jsx(Pq,{version:ee?.version??null,newVersion:be,checking:Me,menuItemClass:Zc,onCheck:()=>{ei()},onOpenDialog:()=>{K(!1),Se(!0)}}),A&&a.jsx(Uq,{status:Q.status,checkPending:Q.checkPending,menuItemClass:Zc,onInstallRequest:()=>{K(!1),U(!0)}}),!c&&a.jsx("button",{type:"button",className:"block w-full px-3.5 py-2 text-left text-sm text-red-600 transition-colors duration-150 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40",onClick:()=>{K(!1),o().then(()=>n("/login"))},children:d.auth.logout})]})})}),a.jsx(oV,{open:ie,onClose:()=>I(!1)}),a.jsx(zq,{open:ye,onClose:()=>Se(!1),latestVersion:be,releaseUrl:re?.releaseUrl??null,canUpdate:s?.isAdmin===!0,onRunFinished:()=>{iw().catch(()=>{})}}),a.jsx(ln,{open:j,title:d.update.clientInstallConfirmTitle,onClose:()=>U(!1),onConfirm:()=>{U(!1),mI()},confirmLabel:d.update.clientInstallConfirmAction,tone:"primary",children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.update.clientInstallConfirmBody})}),a.jsx(Eq,{open:H,onClose:()=>$(!1),onCreated:G=>{$(!1),g().then(()=>x(G))}}),h&&a.jsx(Rq,{open:X,onClose:()=>le(!1)}),a.jsx(Yt,{open:pn!==null,title:d.chat.renameSession,onClose:()=>ur?void 0:na(null),footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:()=>na(null),disabled:ur,children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:ur||!Jn.trim(),onClick:()=>{zi()},children:d.common.save})]}),children:a.jsx(at,{label:d.chat.renameSessionLabel,value:Jn,error:ls??void 0,autoFocus:!0,maxLength:120,onChange:G=>{Er(G.target.value),ls&&ra(null)},onKeyDown:G=>{G.key==="Enter"&&Jn.trim()&&!ur&&zi()}})}),cs&&a.jsx(wq,{sessionId:cs.sessionId,onClose:()=>ka(null),onChanged:(G,Ce)=>{const Ze=C.find(tt=>tt.sessionId===G);if(!Ze)return;const it={...Ze};Ce!==null?it.messagingChannel=Ce:delete it.messagingChannel,F(it)}}),a.jsx(Yt,{open:pt!==null,title:d.chat.renameWorkspace,onClose:()=>wt(null),footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:()=>wt(null),children:d.common.cancel}),a.jsx(ge,{variant:"primary",onClick:ld,children:d.common.save})]}),children:a.jsx(at,{label:d.chat.renameWorkspaceLabel,hint:d.chat.renameWorkspaceHint,value:st,placeholder:pt?$x(pt.path):"",autoFocus:!0,maxLength:80,onChange:G=>Bt(G.target.value),onKeyDown:G=>{G.key==="Enter"&&!G.nativeEvent.isComposing&&ld()}})}),a.jsx(ln,{open:ta!==null,title:d.chat.deleteSession,confirmLabel:d.common.delete,busy:is,onClose:()=>is?void 0:Br(null),onConfirm:()=>{Lo()},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:ta?d.chat.deleteSessionConfirm(ta.title??d.chat.defaultSessionTitle):""})}),a.jsx(ln,{open:Sn!==null,title:d.chat.deleteWorkspace,confirmLabel:d.common.delete,onClose:()=>Dn(null),onConfirm:sp,children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:Sn?d.chat.deleteWorkspaceConfirm(Sn.label):""})}),a.jsx(ln,{open:fn!==null,title:d.chat.deleteDraft,confirmLabel:d.common.delete,onClose:()=>Fr(null),onConfirm:Ms,children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:fn?d.chat.deleteDraftConfirm(sx(fn)||d.chat.draftUntitled):""})})]})}function hV({entry:e,active:t,onOpen:n,onDelete:s}){const o=sx(e)||d.chat.draftUntitled;return a.jsx("li",{children:a.jsxs("div",{"data-title-reveal":!0,className:`group flex items-center rounded-md pr-1 transition-colors duration-150 ${t?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[a.jsx("button",{type:"button",onClick:n,className:"flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left",children:a.jsx(Of,{scrollReveal:!0,text:o,className:`min-w-0 flex-1 text-sm ${t?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`})}),a.jsx("div",{className:"flex shrink-0 items-center",children:a.jsx("button",{type:"button",title:d.chat.deleteDraft,"aria-label":d.chat.deleteDraft,onClick:s,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded text-gray-400 opacity-0 transition-all duration-150 hover:bg-gray-300/60 hover:text-red-600 focus-visible:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-red-400",children:a.jsx(vn,{d:"M4 6h16M9 6V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V6M6 6v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V6M10 10.5v6M14 10.5v6",size:14})})})]})})}function J2({dropEdge:e,children:t}){return a.jsxs("div",{className:"relative pt-2.5",children:[e!==null&&a.jsx("div",{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-1 z-10 h-0.5 rounded-full bg-[var(--accent-bg)] ${e==="above"?"top-1":"-bottom-1"}`}),t]})}function ej({pinned:e,onToggle:t}){return a.jsx("button",{type:"button",title:e?d.nav.unpinGroup:d.nav.pinGroup,"aria-label":d.nav.pinGroup,"aria-pressed":e,onClick:t,className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-all duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200 ${e?"text-gray-500 dark:text-gray-400":"text-gray-400 opacity-0 focus-visible:opacity-100 group-hover/header:opacity-100 dark:text-gray-500"}`,children:a.jsx(vn,{d:Qx,size:Ye.groupHeaderAction})})}function gV({s:e,active:t,activity:n,pinned:s,canPin:o=!1,lastActive:c,agentHint:u,draggable:f=!1,dropEdge:p=null,onDragStart:h,onDragEnd:x,onDragOver:g,onDragLeave:v,onDrop:w,onOpen:S,onTogglePin:C,onRename:N,onMessaging:T,onDelete:_,onToggleArchive:R}){const D=w6(),z=F=>{D.close(),{pin:C,rename:N,messaging:T,archive:R,delete:_}[F](e)},E=F=>{D.returnFocus()?.focus(),z(F)},L={archived:e.archived,pinned:s};return a.jsxs("li",{className:"relative",...f?{draggable:!0,onDragStart:h,onDragEnd:x,onDragOver:g,onDragLeave:v,onDrop:w}:{},children:[p!==null&&a.jsx("div",{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-1 z-10 h-0.5 rounded-full bg-[var(--accent-bg)] ${p==="above"?"-top-px":"-bottom-px"}`}),a.jsxs("div",{"data-title-reveal":!0,ref:D.rowRef,...D.rowProps,className:`group flex select-none items-center rounded-md pr-1 transition-colors duration-150 ${f?"cursor-grab ":""}${t?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[a.jsxs("button",{type:"button","data-testid":"session-row","data-session-id":e.sessionId,onClick:()=>{D.consumeLongPressClick()||S(e)},className:"flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left",children:[u!==void 0&&a.jsxs("span",{title:u,className:"flex shrink-0 items-center",children:[a.jsx(Ha,{id:e.agentId,name:u,size:14,className:"rounded"}),a.jsx("span",{className:"sr-only",children:u})]}),a.jsx(Of,{scrollReveal:!0,text:e.title??d.chat.defaultSessionTitle,className:`min-w-0 flex-1 text-sm ${t?"font-medium text-gray-900 dark:text-gray-100":e.archived?"text-gray-400 dark:text-gray-500":"text-gray-700 dark:text-gray-300"}`}),s&&o&&a.jsxs("span",{title:d.chat.pinnedSession,className:"shrink-0 text-gray-400 dark:text-gray-500",children:[a.jsx(vn,{d:Qx,size:12}),a.jsx("span",{className:"sr-only",children:d.chat.pinnedSession})]}),e.messagingChannel!==void 0&&a.jsxs("span",{title:d.messaging.enabledIndicator[e.messagingChannel],className:"shrink-0 text-gray-400 dark:text-gray-500",children:[a.jsx(vn,{d:II,size:12}),a.jsx("span",{className:"sr-only",children:d.messaging.enabledIndicator[e.messagingChannel]})]}),a.jsx(pV,{activity:n}),e.pendingApprovalCount>0&&a.jsx("span",{title:d.chat.pendingApprovals(e.pendingApprovalCount),children:a.jsx(On,{tone:"amber",children:e.pendingApprovalCount})})]}),a.jsxs("div",{className:"relative flex h-6 min-w-12 shrink-0 items-center justify-end",children:[a.jsx("div",{className:"peer absolute right-0 top-1/2 flex -translate-y-1/2 items-center",children:a.jsx(E6,{actions:N6,state:L,onRun:z,onMore:D.openAt})}),c!==""&&a.jsx("span",{"aria-hidden":!0,className:"pointer-events-none px-1 text-[11px] text-gray-400 transition-opacity duration-150 group-hover:opacity-0 peer-focus-within:opacity-0 dark:text-gray-500",children:c})]}),a.jsx(Qn,{open:D.open,setOpen:D.setOpen,portal:{direction:"down",align:"left"},anchorRect:D.anchor,returnFocus:D.returnFocus,className:"contents",menuClass:"w-36",button:null,children:a.jsx(M6,{actions:T6(o),state:L,onRun:E})})]})]})}function xV({onRename:e,onDelete:t}){const[n,s]=y.useState(!1),o=c=>()=>{s(!1),c()};return a.jsxs(Qn,{open:n,setOpen:s,portal:{direction:"down",align:"right"},menuClass:"w-32",className:"shrink-0",button:a.jsx("button",{type:"button",title:d.chat.workspaceMenu,"aria-label":d.chat.workspaceMenu,"aria-haspopup":"menu","aria-expanded":n,onClick:()=>s(!n),className:"flex h-7 w-7 shrink-0 items-center justify-center text-gray-500 transition-colors duration-150 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100",children:a.jsx(lV,{size:16})}),children:[a.jsxs("button",{type:"button",className:ey,onClick:o(e),children:[ty(Zx),d.chat.renameWorkspace]}),a.jsxs("button",{type:"button",className:gN,onClick:o(t),children:[a.jsx("span",{className:"shrink-0",children:a.jsx(vn,{d:Jx,size:13})}),d.chat.deleteWorkspace]})]})}function eu({icon:e,label:t,checked:n,onSelect:s}){return a.jsxs("button",{type:"button","aria-pressed":n,onClick:s,className:`${ey} justify-between`,children:[a.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[ty(e),a.jsx("span",{className:"truncate",children:t})]}),n&&a.jsx(qu,{className:"shrink-0 text-gray-500 dark:text-gray-400"})]})}const yV="M8 10h8M8 14h5M21 12a9 9 0 1 1-4.2-7.6L21 4v5h-5",e0=e=>`relative flex h-8 w-8 items-center justify-center rounded-md transition-colors duration-150 ${e?"bg-gray-200/70 text-gray-900 dark:bg-gray-800 dark:text-gray-100":"text-gray-500 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200"}`;function bV({onExpand:e}){const{user:t}=mn(),n=yr(),{agents:s,currentProject:o,setCurrentAgentId:c}=en(),{sessions:u,loading:f}=Ii(),p=zx(),h=Mx("/chat/:sessionId")?.params.sessionId??null,x=h!==null&&h!==ya,g=y.useMemo(()=>PC(u),[u]),v=()=>{g&&(c(g.agentId),n(`/chat/${g.sessionId}`))},w=()=>{t&&o&&Yl(t.userId,o.projectId);const C=(s.find(N=>N.agentId==="default_agent")??s[0])?.agentId;C&&c(C),n(`/chat/${ya}`,C?{state:{agentId:C}}:void 0)},S=[{to:"/agents",label:d.nav.agents,icon:vs.agents},{to:"/skills",label:d.nav.skills,icon:vs.skills},{to:"/models",label:d.nav.models,icon:vs.models},{to:"/usage",label:d.nav.usage,icon:vs.usage},{to:"/benchmark",label:d.nav.benchmark,icon:vs.benchmark}];return a.jsxs("div",{className:"flex h-full flex-col items-center gap-1 py-2.5",children:[a.jsx("button",{type:"button",title:d.nav.expandSidebar,"aria-label":d.nav.expandSidebar,onClick:e,className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-200/70 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:a.jsx(Oe,{d:"M9 6l6 6-6 6M20 4v16",size:18})}),a.jsxs("nav",{className:"no-scrollbar mt-1 flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto",children:[a.jsx("button",{type:"button",title:d.nav.lastConversation,"aria-label":d.nav.lastConversation,disabled:!g&&!f,onClick:v,className:g||f?e0(x):"flex h-8 w-8 cursor-not-allowed items-center justify-center rounded-md text-gray-300 dark:text-gray-700",children:a.jsx(Oe,{d:yV,size:18})}),a.jsx("button",{type:"button",title:d.chat.newSessionMenu,"aria-label":d.chat.newSessionMenu,onClick:w,className:e0(h===ya),children:a.jsx(Oe,{d:Jm,size:18})}),S.map(C=>{const N=C.to==="/agents"?p.kernelNote:null;return a.jsxs(Lx,{to:C.to,title:N!==null?`${C.label} · ${N}`:C.label,"aria-label":N!==null?`${C.label} · ${N}`:C.label,className:({isActive:T})=>e0(T),children:[a.jsx(Oe,{d:C.icon,size:18}),N!==null&&a.jsx(Mo,{})]},C.to)})]}),a.jsxs("button",{type:"button",title:[t?.userId??"",d.nav.expandSidebar].concat(p.softwareNote!==null?[p.softwareNote]:[]).join(" · "),"aria-label":p.softwareNote!==null?`${t?.userId??""} · ${p.softwareNote}`:t?.userId??d.auth.admin,onClick:e,className:"relative mt-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gray-900 text-xs font-bold text-white dark:bg-gray-200 dark:text-gray-900",children:[(t?.userId??"?").slice(0,1).toUpperCase(),p.software!==null&&a.jsx(Mo,{})]})]})}function vV(){const{user:e,desktopMode:t}=mn(),n=Mx("/chat/:sessionId")?.params.sessionId??null;y.useLayoutEffect(()=>{SB(n)},[n]),vI();const s=zx(!0),[o,c]=y.useState(!1),[u,f]=y.useState(!1),[p,h]=y.useState(null),x=!!e?.passwordIsInitial&&!t;y.useEffect(()=>{if(!x)return;let C=!1;return Sx().then(N=>{C||h(N.prefs.initialPasswordBannerDismissed===!0)}).catch(()=>{C||h(!1)}),()=>{C=!0}},[x]);const g=()=>{h(!0),Nf({initialPasswordBannerDismissed:!0}).catch(()=>{})},[v,w]=y.useState(()=>localStorage.getItem("penguin.sidebarCollapsed")==="1"),S=()=>w(C=>{const N=!C;return localStorage.setItem("penguin.sidebarCollapsed",N?"1":"0"),N});return a.jsxs("div",{className:"flex h-full",children:[a.jsx("aside",{className:`hidden shrink-0 border-r border-gray-200 bg-gray-50 md:block dark:border-gray-800 dark:bg-gray-900 ${v?"w-12":"w-64 lg:w-72"}`,children:v?a.jsx(bV,{onExpand:S}):a.jsx(Z2,{onCollapse:S})}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-gray-200 bg-white px-2 md:hidden dark:border-gray-800 dark:bg-gray-950",children:[a.jsxs("button",{type:"button","aria-label":s.note!==null?`${d.chat.sessionList} · ${s.note}`:d.chat.sessionList,...s.note!==null?{title:s.note}:{},onClick:()=>c(!0),className:"relative flex h-9 w-9 items-center justify-center rounded-md text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:[a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"})}),s.any&&a.jsx(Mo,{})]}),a.jsx("span",{className:"text-sm font-semibold",children:d.appName})]}),x&&p===!1&&a.jsxs("div",{className:`relative flex shrink-0 items-center justify-center gap-3 border-b px-8 py-1.5 text-xs ${Df.attention}`,children:[a.jsx("span",{children:d.account.initialPasswordBanner}),a.jsx("button",{type:"button",className:"shrink-0 font-medium underline underline-offset-2 hover:text-amber-950 dark:hover:text-amber-100",onClick:()=>f(!0),children:d.account.changeNow}),a.jsx("button",{type:"button","aria-label":d.common.close,title:d.common.close,onClick:g,className:"absolute inset-y-0.5 right-1.5 flex items-center rounded-md px-1 text-amber-500 transition-colors duration-150 hover:text-amber-950 dark:text-amber-400/70 dark:hover:text-amber-100",children:a.jsx(Hl,{size:12})})]}),a.jsx("main",{className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:a.jsx(V_,{})}),a.jsx(OF,{})]}),a.jsx(_M,{open:u,onClose:()=>f(!1)}),a.jsx(QC,{open:o,side:"left",title:d.appName,onClose:()=>c(!1),children:a.jsx("div",{className:"h-full bg-gray-50 dark:bg-gray-900",children:a.jsx(Z2,{onNavigate:()=>c(!1)})})})]})}const Xy=1440,Qy=900,fx=3,kV=3,tj=Xy/fx,nj=Qy/kV,$m=28,Um=14;function wV(e){return()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function SV(e,t){return e.x1-Um<=t.x2&&e.x2+Um>=t.x1&&e.y1-Um<=t.y2&&e.y2+Um>=t.y1}function jV(e,t,n,s){return{x1:Math.min(e,n),y1:Math.min(t,s),x2:Math.max(e,n),y2:Math.max(t,s)}}const CV=[{cell:0,edge:"left"},{cell:1,edge:"top"},{cell:2,edge:"right"},{cell:3,edge:"left"},{cell:5,edge:"right"},{cell:6,edge:"bottom"},{cell:7,edge:"bottom"},{cell:8,edge:"right"}];function NV(){const e=wV(12696599),t=[];for(const{cell:n,edge:s}of CV){const o=n%fx*tj+$m,c=Math.floor(n/fx)*nj+$m,u=o+tj-2*$m,f=c+nj-2*$m,p=[],h=(R,D,z,E)=>{const L=z[0]>0?u-R:z[0]<0?R-o:z[1]>0?f-D:D-c;for(let F=Math.min(60+e()*150,L);F>=40;F/=2){const V=Math.round(R+z[0]*F),P=Math.round(D+z[1]*F),B=jV(R,D,V,P);if(p.every((Y,q)=>E.has(q)||!SV(B,Y)))return p.push(B),[V,P]}return null},x=(R,D,z)=>(z-R)*(.35+e()*.3)>R-D?1:-1,g=(R,D,z,E,L,F,V)=>{let[P,B]=[R,D],Y=z;const q=[`M${Math.round(P)},${Math.round(B)}`],K=[];for(let H=0;H<E;H+=1){const $=H===0?V:new Set([p.length-1]),X=h(P,B,Y,$);if(!X)break;[P,B]=X,q.push(`L${P},${B}`),K.push([P,B]),Y=Y[0]!==0?[0,x(B,c,f)]:[x(P,o,u),0]}return K.length>=2&&t.push({d:q.join(" "),end:K[K.length-1],dur:L,delay:F}),K},v=.15+e()*.7,w=s==="left"?0:s==="right"?Xy:Math.round(o+(u-o)*v),S=s==="top"?0:s==="bottom"?Qy:Math.round(c+(f-c)*v),C=s==="left"?[1,0]:s==="right"?[-1,0]:s==="top"?[0,1]:[0,-1],N=12+e()*8,T=e()*3.2,_=g(w,S,C,3+Math.floor(e()*3),N,T,new Set);if(n%2===0&&_.length>=3){const[R,D]=_[1],[z,E]=_[2],L=[-Math.sign(z-R),-Math.sign(E-D)];g(R,D,L,2,N,T+1.4,new Set([1,2]))}}return t}const TV=NV();function MV(){return a.jsx("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full text-slate-500/25 dark:text-cyan-300/15",viewBox:`0 0 ${Xy} ${Qy}`,preserveAspectRatio:"xMidYMid slice",fill:"none",children:TV.map((e,t)=>a.jsxs("g",{style:{"--trace-dur":`${e.dur.toFixed(1)}s`},children:[a.jsx("path",{d:e.d,pathLength:1,stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",className:"login-trace",style:{animationDelay:`${e.delay.toFixed(1)}s`}}),a.jsx("circle",{cx:e.end[0],cy:e.end[1],r:"3",fill:"currentColor",className:"login-via",style:{animationDelay:`${e.delay.toFixed(1)}s`}})]},t))})}function EV(){Li(d.auth.login);const{login:e}=mn(),{mode:t,setMode:n}=as(),{lang:s,setLang:o}=Dr(),c=yr(),[u,f]=y.useState(""),[p,h]=y.useState(""),[x,g]=y.useState({}),[v,w]=y.useState(!1),S=()=>g(_=>_.userId||_.password||_.form?{}:_),C=async()=>{const _={};if(u.trim()||(_.userId=d.common.requiredField),p||(_.password=d.common.requiredField),_.userId||_.password){g(_);return}w(!0),g({});try{await e(u.trim(),p),c("/chat",{replace:!0})}catch(R){g({form:Ae(R)})}finally{w(!1)}},N=[{value:"light",label:d.settings.themeLight},{value:"dark",label:d.settings.themeDark},{value:"system",label:d.settings.followSystem}],T=[{value:"en",label:d.settings.langEn},{value:"zh",label:d.settings.langZh},{value:"system",label:d.settings.followSystem}];return a.jsxs("div",{className:"relative flex min-h-full items-center justify-center overflow-hidden p-4",children:[a.jsx(MV,{}),a.jsxs("div",{className:"absolute right-4 top-4 flex flex-col items-end gap-1.5 sm:flex-row sm:items-center sm:gap-2",children:[a.jsx("div",{"aria-label":d.settings.language,children:a.jsx(ws,{options:T,value:s,onChange:o})}),a.jsx("div",{"aria-label":d.settings.theme,children:a.jsx(ws,{options:N,value:t,onChange:n})})]}),a.jsxs("div",{className:"anim-rise relative w-full max-w-sm",children:[a.jsx(OT,{className:"mx-auto mb-3 h-16 w-16 rounded-2xl"}),a.jsx("h1",{className:"mb-6 text-center text-3xl font-semibold tracking-tight",children:d.appName}),a.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-800 dark:bg-gray-900",children:[a.jsxs("form",{className:"space-y-4",onSubmit:_=>{_.preventDefault(),C()},children:[a.jsx(at,{label:d.common.username,required:!0,value:u,onChange:_=>{f(_.target.value),S()},error:x.userId,autoComplete:"username",autoFocus:!0}),a.jsx(ts,{label:d.auth.password,required:!0,value:p,onChange:_=>{h(_.target.value),S()},error:x.password,autoComplete:"current-password"}),x.form&&a.jsx("p",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900 dark:bg-red-950/50 dark:text-red-300",children:x.form}),a.jsx(ge,{type:"submit",variant:"primary",className:"w-full justify-center py-2.5 text-sm font-semibold",disabled:v,children:d.auth.login})]}),a.jsx("p",{className:"mt-4 text-center text-xs text-gray-400 dark:text-gray-500",children:d.auth.defaultAdminNote}),a.jsx("p",{className:"mt-1.5 text-center text-xs text-gray-400 dark:text-gray-500",children:d.auth.forgotAdminNote})]})]})]})}const tu=100,Ni=30,Da=2;function AV({data:e,label:t,className:n=""}){const s=Math.max(1,...e),o=e.length>1?(tu-2*Da)/(e.length-1):0,c=e.map((h,x)=>[Da+x*o,Ni-Da-h/s*(Ni-2*Da)]),u=`${Da},${Ni-Da} ${tu-Da},${Ni-Da}`,f=c.length>1?c.map(([h,x])=>`${h},${x}`).join(" "):u,p=c.length>1?`${f} ${tu-Da},${Ni-Da} ${Da},${Ni-Da}`:null;return a.jsxs("svg",{width:tu,height:Ni,viewBox:`0 0 ${tu} ${Ni}`,role:"img","aria-label":t,className:`text-emerald-600 dark:text-emerald-500 ${n}`,children:[a.jsx("title",{children:t}),p!==null&&a.jsx("polygon",{points:p,fill:"currentColor",fillOpacity:"0.12"}),a.jsx("polyline",{points:f,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const px="inline-flex cursor-pointer items-center justify-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1 text-xs font-medium text-gray-800 transition-colors duration-150 hover:bg-gray-50 focus-within:ring-2 focus-within:ring-gray-400/30 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",LM=".tar.gz,.tgz,.gz,application/gzip,application/x-gzip";function OM(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const o=s.result;t(o.slice(o.indexOf(",")+1))},s.onerror=()=>n(s.error??new Error("File read failed.")),s.readAsDataURL(e)})}function _V(e){return e.replace(/\.(tar\.gz|tgz|gz)$/i,"").replace(/-v\d+$/,"")}const RV=new Set(["default_agent"]),Gs={newChat:"M12 5v14M5 12h14",trash:"M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m3 0l-1 13a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L6 7m4 4v6m4-6v6",sessions:"M8 10h8M8 14h5M21 12a9 9 0 1 1-4-7.5",vaultKeys:"M15.5 7.5l3 3L22 7l-3-3M21 2l-9.6 9.6M13 15.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z",schedules:"M12 21a7 7 0 1 0 0-14 7 7 0 0 0 0 14zm0-10v3l2 1.5M5 3L2.5 5.5M19 3l2.5 2.5",skills:"M12 6.5C10.5 5 8 4.5 4 5v12c4-.5 6.5 0 8 1.5 1.5-1.5 4-2 8-1.5V5c-4-.5-6.5 0-8 1.5zm0 0V18",usage:"M4 20V10m6 10V4m6 16v-7m4 7H2",memory:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18ZM12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18ZM15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"},nu="inline-flex shrink-0 cursor-pointer items-center gap-1 tabular-nums transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200";function IV(){const e=yr();Li(d.nav.agents);const{locale:t}=Dr(),{user:n}=mn(),{currentProject:s,agents:o,agentsLoading:c,reloadAgents:u,setCurrentAgentId:f}=en(),[p,h]=y.useState(!1),[x,g]=y.useState(""),[v,w]=y.useState(""),[S,C]=y.useState(""),[N,T]=y.useState(void 0),[_,R]=y.useState(!1),[D,z]=y.useState(null),[E,L]=y.useState(null),F=y.useRef(!1),[V,P]=y.useState([]),[B,Y]=y.useState(!1),[q,K]=y.useState(""),[H,$]=y.useState(null),[X,le]=y.useState(null),[ie,I]=y.useState([]),[A,Q]=y.useState(!1),[j,U]=y.useState(null),ee=()=>{g(""),w(""),C(""),T(void 0),P([]),Y(!1),K(""),$(null),le(null),I([]),Q(!1),U(null),h(!0)},re=oe=>{const J=oe.target.files?.[0];if(oe.target.value="",!!J&&(U(J),P([]),K(""),I([]),!x.trim())){const ht=_V(J.name);mx.test(ht)&&g(ht)}};y.useEffect(()=>{!p||D!==null||F.current||(F.current=!0,L(null),oC().then(oe=>z(oe.groups.flatMap(J=>J.skills))).catch(oe=>{F.current=!1,L(Ae(oe))}))},[p,D]);const ke=$r(),be=ke.state?.create===!0;y.useEffect(()=>{be&&(ee(),e(ke.pathname,{replace:!0}))},[be]);const[ye,Se]=y.useState(null),[Me,ze]=y.useState(null),De=s?.projectId;y.useEffect(()=>{if(!p||!q||!De){$(null),le(null);return}let oe=!1;return $(null),le(null),KE(De,q).then(J=>{oe||$(J.skills)}).catch(J=>{oe||($(null),le(Ae(J)))}),()=>{oe=!0}},[p,De,q]),y.useEffect(()=>{if(H===null){I(J=>J.length===0?J:[]);return}const oe=new Set(H.map(J=>J.name));I(J=>{const ht=J.filter(ve=>oe.has(ve));return ht.length===J.length?J:ht})},[H]);const ct=async()=>{if(!De)return;const oe=x.trim();if(!oe){T(d.common.requiredField);return}if(!mx.test(oe)){T(d.agent.idHint);return}R(!0),T(void 0);try{const J={agentId:oe};v.trim()&&(J.name=v.trim()),S.trim()&&(J.description=S.trim()),j!==null?J.dataBase64=await OM(j):(V.length>0&&(J.skills=V),q&&ie.length>0&&(J.skillsDirectory=q,J.directorySkills=ie));const ht=await FE(De,J);h(!1),await u(),f(ht.agent.agentId),e(`/agents/${ht.agent.agentId}`)}catch(J){T(Ae(J))}finally{R(!1)}},bt=oe=>{n&&De&&Yl(n.userId,De),f(oe),e(`/chat/${ya}`,{state:{agentId:oe}})},he=(oe,J)=>{f(oe),e(`/agents/${oe}?tab=${J}`)},ne=async()=>{if(!(!De||!ye)){R(!0),ze(null);try{await kA(De,ye.agentId),Se(null),await u()}catch(oe){ze(Ae(oe))}finally{R(!1)}}};return a.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:[a.jsxs("div",{className:"mx-auto max-w-5xl",children:[a.jsxs("div",{className:"mb-4 flex items-center justify-between gap-2",children:[a.jsx("h1",{className:"text-xl font-semibold",children:d.agent.listTitle}),a.jsx(ge,{variant:"primary",onClick:ee,children:d.agent.create})]}),c?a.jsx("div",{className:"space-y-3",children:Array.from({length:4},(oe,J)=>a.jsxs(SN,{className:"flex flex-wrap items-center gap-x-6 gap-y-2 px-5 py-4",children:[a.jsxs("div",{className:"min-w-[14rem] flex-1",children:[a.jsx(on,{className:"h-[18px] w-40"}),a.jsx(on,{className:"mt-1.5 h-4 w-2/3"}),a.jsx(on,{className:"mt-1.5 h-4 w-48"})]}),a.jsx(on,{className:"hidden h-9 w-40 md:block"}),a.jsx(on,{className:"h-8 w-52"})]},J))}):o.length===0?a.jsx(Fa,{title:d.common.none}):a.jsx("div",{className:"space-y-3",children:o.map(oe=>{const J=RV.has(oe.agentId);return a.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2 rounded-md border border-gray-200 bg-white px-5 py-4 dark:border-gray-800 dark:bg-gray-900",children:[a.jsxs("div",{className:"min-w-[14rem] flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ha,{id:oe.agentId,name:_n(oe),size:18,className:"shrink-0 rounded"}),a.jsx("span",{className:"min-w-0 truncate text-base font-bold",children:_n(oe)}),a.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 md:inline dark:text-gray-500",children:oe.agentId}),a.jsxs(On,{tone:"gray",children:["v",oe.version]}),oe.kernelOutdated&&a.jsx(OI,{onClick:()=>he(oe.agentId,"overview"),children:d.agent.kernelUpdateNeeded})]}),a.jsx("p",{className:"mt-1.5 min-h-4 truncate text-xs text-gray-500 dark:text-gray-400",children:oe.description??""}),a.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",title:d.agent.sessionCount(oe.sessionCount),children:[a.jsx(Oe,{d:Gs.sessions,size:Ye.inlineGlyph}),oe.sessionCount]}),a.jsxs("button",{type:"button",className:nu,title:d.agent.toolCount(oe.toolCount),"aria-label":d.agent.toolCount(oe.toolCount),onClick:()=>he(oe.agentId,"tools"),children:[a.jsx(Oe,{d:Xn.toolCalls,size:Ye.inlineGlyph}),oe.toolCount]}),a.jsxs("button",{type:"button",className:nu,title:d.skills.skillCount(oe.skillCount),"aria-label":d.skills.skillCount(oe.skillCount),onClick:()=>he(oe.agentId,"skills"),children:[a.jsx(Oe,{d:Gs.skills,size:Ye.inlineGlyph}),oe.skillCount]}),a.jsxs("button",{type:"button",className:nu,title:d.agent.memoryCount(oe.memoryCount),"aria-label":d.agent.memoryCount(oe.memoryCount),onClick:()=>he(oe.agentId,"memory"),children:[a.jsx(Oe,{d:Gs.memory,size:Ye.inlineGlyph}),oe.memoryCount]}),a.jsxs("button",{type:"button",className:nu,title:d.agent.vaultKeyCount(oe.vaultKeyCount),"aria-label":d.agent.vaultKeyCount(oe.vaultKeyCount),onClick:()=>he(oe.agentId,"vault"),children:[a.jsx(Oe,{d:Gs.vaultKeys,size:Ye.inlineGlyph}),oe.vaultKeyCount]}),a.jsxs("button",{type:"button",className:nu,title:d.agent.scheduleCount(oe.scheduleCount),"aria-label":d.agent.scheduleCount(oe.scheduleCount),onClick:()=>he(oe.agentId,"schedules"),children:[a.jsx(Oe,{d:Gs.schedules,size:Ye.inlineGlyph}),oe.scheduleCount]}),a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",title:`${d.agent.updatedAt} ${oe.updatedAt?Jr(oe.updatedAt):"—"}`,children:[a.jsx(Oe,{d:Xn.elapsed,size:Ye.inlineGlyph}),oe.updatedAt?$I(oe.updatedAt,t):"—"]})]})]}),a.jsx(AV,{data:oe.sessionActivity,label:d.agent.activity(oe.sessionActivity.length||30),className:"hidden shrink-0 md:block"}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsxs(ge,{size:"sm",variant:"primary",onClick:()=>bt(oe.agentId),children:[a.jsx(Oe,{d:Gs.newChat}),d.chat.newSessionMenu]}),a.jsxs(ge,{size:"sm",onClick:()=>{f(oe.agentId),e(`/agents/${oe.agentId}`)},children:[a.jsx(Oe,{d:If}),d.common.settings]}),a.jsx(ge,{size:"icon",title:d.nav.usage,"aria-label":d.nav.usage,onClick:()=>e(`/usage?agentId=${encodeURIComponent(oe.agentId)}`),children:a.jsx(Oe,{d:Gs.usage,size:15,className:"text-gray-600 dark:text-gray-300"})}),J?a.jsx("span",{role:"img",title:d.agent.builtinUndeletable,"aria-label":d.agent.builtinUndeletable,className:"inline-flex cursor-not-allowed items-center justify-center rounded-md border border-transparent p-1.5 text-gray-300 dark:text-gray-600",children:a.jsx(Oe,{d:Gs.trash,size:15})}):a.jsx(ge,{size:"icon",variant:"danger",title:d.agent.deleteAgent,"aria-label":d.agent.deleteAgent,onClick:()=>Se({agentId:oe.agentId,name:_n(oe)}),children:a.jsx(Oe,{d:Gs.trash,size:15})})]})]},oe.agentId)})})]}),a.jsx(Yt,{open:p,title:d.agent.createTitle,onClose:()=>h(!1),footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:()=>h(!1),children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:_,onClick:()=>{ct()},children:d.common.create})]}),children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(at,{label:d.agent.id,required:!0,size:"sm",value:x,onChange:oe=>{g(oe.target.value),T(void 0)},error:N,hint:d.agent.idHint,autoFocus:!0}),a.jsx(at,{label:d.common.name,size:"sm",value:v,onChange:oe=>w(oe.target.value),hint:d.agent.nameHint}),a.jsx(ir,{label:d.agent.description,size:"sm",rows:3,value:S,onChange:oe=>C(oe.target.value)}),a.jsxs("div",{children:[a.jsx(Yn,{children:d.agent.createSnapshot}),j===null?a.jsxs("label",{className:`${px} ${_?"pointer-events-none opacity-60":""}`,children:[a.jsx(Xl,{accept:LM,disabled:_,onChange:re}),d.agent.createSnapshotPick]}):a.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[a.jsx("span",{className:"min-w-0 truncate rounded-md border border-gray-300 bg-gray-50 px-2.5 py-1 font-mono text-xs dark:border-gray-700 dark:bg-gray-900",children:j.name}),a.jsx("button",{type:"button",title:d.agent.createSnapshotClear,"aria-label":d.agent.createSnapshotClear,disabled:_,onClick:()=>U(null),className:"shrink-0 rounded-md p-1 text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:hover:text-gray-300",children:a.jsx(Hl,{size:12})})]}),a.jsx(wo,{children:j===null?d.agent.createSnapshotHint:d.agent.createSnapshotSkillsOff})]}),j===null&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx(Yn,{children:d.agent.createSkills}),a.jsx(Ru,{open:B,setOpen:Y,label:V.length===0?d.agent.createSkillsPlaceholder:d.agent.createSkillsPicked(V.length),muted:V.length===0,title:d.agent.createSkills,ariaLabel:d.agent.createSkills,disabled:_,menuClass:"w-[26rem]",children:a.jsx(q0,{skills:D??[],selected:V,onToggle:oe=>P(J=>V0(J,oe)),onSelectAll:oe=>P(J=>LS(J,oe)),onSelectNone:oe=>P(J=>OS(J,oe)),emptyHint:D===null?d.common.loading:d.agent.createSkillsEmpty})}),E?a.jsx(ga,{children:E}):a.jsx(wo,{children:d.agent.createSkillsHint})]}),a.jsxs("div",{children:[a.jsx(Yn,{children:d.agent.createDirSkills}),a.jsx(sd,{projectId:De??"",workspace:q,onChange:K,variant:"form",fieldLabel:d.agent.createDirSkills,emptyLabel:d.agent.createDirSkillsPick,menuHint:d.agent.createDirSkillsHint,clearLabel:d.agent.createDirSkillsClear}),q&&H!==null&&H.length>0&&a.jsx("div",{className:"mt-2",children:a.jsx(Ru,{open:A,setOpen:Q,label:ie.length===0?d.agent.createSkillsPlaceholder:d.agent.createSkillsPicked(ie.length),muted:ie.length===0,title:d.agent.createDirSkills,ariaLabel:d.agent.createDirSkills,disabled:_,menuClass:"w-[26rem]",children:a.jsx(q0,{skills:H,selected:ie,onToggle:oe=>I(J=>V0(J,oe)),onSelectAll:oe=>I(J=>LS(J,oe)),onSelectNone:oe=>I(J=>OS(J,oe)),emptyHint:d.agent.createDirSkillsEmpty})})}),X?a.jsx(ga,{children:X}):a.jsx(wo,{children:q?H===null?d.common.loading:H.length===0?d.agent.createDirSkillsEmpty:d.agent.createDirSkillsFound(H.length):d.agent.createDirSkillsHint})]})]})]})}),a.jsxs(ln,{open:ye!==null,title:d.agent.deleteAgent,busy:_,onClose:()=>{Se(null),ze(null)},onConfirm:()=>{ne()},children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:ye?d.agent.deleteConfirm(ye.name):""}),Me&&a.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:Me})]})]})}function LV({items:e,active:t,onChange:n}){return a.jsx("div",{role:"tablist",className:"flex max-w-full gap-1 overflow-x-auto overflow-y-hidden border-b border-gray-200 dark:border-gray-800",children:e.map(s=>{const o=s.badge??null;return a.jsxs("button",{type:"button",role:"tab","aria-selected":s.key===t,...o!==null?{title:o,"aria-label":`${s.label} · ${o}`}:{},onClick:()=>n(s.key),className:`relative -mb-px whitespace-nowrap border-b-2 px-3 py-2 text-sm transition-colors duration-150 ${s.key===t?"border-gray-900 font-semibold text-gray-900 dark:border-gray-100 dark:text-gray-100":"border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-800 dark:text-gray-400 dark:hover:border-gray-700 dark:hover:text-gray-200"}`,children:[s.label,o!==null&&a.jsx(Mo,{size:"inline",position:"right-1 top-1"})]},s.key)})})}const OV=288,DV={base:"text-base",sm:"text-xs"},$V={base:"text-xs",sm:"text-[11px]"};function Sf({options:e,value:t,onChange:n,placeholder:s,mono:o,label:c,error:u,required:f,fullWidth:p,size:h="base","aria-label":x}){const[g,v]=y.useState(!1),{triggerRef:w,panelRef:S,position:C}=$f({open:g,onClose:()=>v(!1),estimatedHeight:e.length*48+16,panelWidth:OV}),N=t!=null?e.find(R=>R.value===t):void 0,T=y.useId(),_=a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:w,type:"button","aria-label":x,"aria-haspopup":"listbox","aria-expanded":g,"aria-required":f||void 0,"aria-invalid":u?!0:void 0,"aria-describedby":u?T:void 0,onClick:()=>v(R=>!R),className:`flex items-center gap-2 ${Uf} ${Pf[h]} ${u?zf:""}`+(p?" w-full justify-between":""),children:[a.jsx("span",{className:`min-w-0 truncate ${o?"font-mono":""}`,children:N?.triggerLabel??s??"—"}),a.jsx(ns,{className:"text-gray-400"})]}),g&&C&&ss.createPortal(a.jsx("div",{ref:S,role:"listbox",style:{position:"fixed",top:C.topPx,bottom:C.bottomPx,left:C.left,minWidth:C.triggerWidth},className:"anim-pop z-[60] max-h-[70vh] w-72 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:e.map(R=>a.jsxs("button",{type:"button",role:"option","aria-selected":R.value===t,onClick:()=>{n(R.value),v(!1)},className:`block ${ny} hover:bg-gray-100 dark:hover:bg-gray-800 ${R.value===t?"bg-gray-100 dark:bg-gray-800":""}`,children:[a.jsxs("span",{className:"flex items-center justify-between gap-2",children:[a.jsx("span",{className:`${DV[h]} ${R.value===t?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:R.label}),R.value===t&&a.jsx(qu,{className:"text-gray-500 dark:text-gray-400"})]}),a.jsx("span",{className:`mt-0.5 block ${$V[h]} text-gray-500 dark:text-gray-400`,children:R.description})]},R.value))}),document.body)]});return a.jsx(Vu,{label:c,error:u,errorId:T,required:f,children:_})}const UV=/^(www\.)?(github|gitlab|gitee|bitbucket)\.(com|org)$/i;function PV(e){const t=e.trim();if(/^git@[\w.-]+:/.test(t)||/\.git$/i.test(t))return"repoUrl";if(/^https?:\/\//i.test(t)){try{if(UV.test(new URL(t).hostname))return"repoUrl"}catch{}return"webUrl"}return/^(\/|~\/|\.{1,2}\/|[A-Za-z]:[\\/]|\\\\)/.test(t)?"localPath":/^[A-Za-z@][\w@./-]*\s+\S/.test(t)?"command":"reference"}function t0(e){return`${d.skills.importPromptLead[PV(e)](e)}
181
- ${d.skills.importPromptTail}`}function zV(e,t,n,s){const o=e.current;if(o&&(o.focus(),document.execCommand?.("insertText",!1,s)))return;const c=o?o.selectionStart:t.length,u=o?o.selectionEnd:t.length;n(t.slice(0,c)+s+t.slice(u)),requestAnimationFrame(()=>{if(!o)return;o.focus();const f=c+s.length;o.setSelectionRange(f,f)})}function Zy({agentId:e,feature:t,strings:n,canEdit:s,onConfigChanged:o}){const{currentProject:c}=en(),u=c?.projectId??null,[f,p]=y.useState(null),[h,x]=y.useState(""),[g,v]=y.useState(!1),w=y.useRef(null),{requestSave:S,element:C}=ql(),N=y.useCallback(V=>{const P=V[t];p(P),x(P.prompt)},[t]),T=V=>t==="skills"?{config:{skills:V}}:t==="vault"?{config:{vault:V}}:{config:{schedules:V}},_=async V=>{if(u){v(!0);try{const P=await To(u,e,T({enabled:V}));N(P.config),yt(d.common.saved),o?.()}catch(P){Be(Ae(P))}finally{v(!1)}}},R=async()=>{if(!u)return;const V=t==="skills"?$E:t==="vault"?DE:UE;try{const P=await V(u,e);p(P),x(P.prompt),yt(d.common.saved),o?.()}catch(P){Be(Ae(P))}},D=()=>S(()=>{u&&To(u,e,T({prompt:h})).then(V=>{N(V.config),yt(d.common.saved),o?.()}).catch(V=>Be(Ae(V)))}),z=f!==null&&a.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-gray-200 px-4 py-3 dark:border-gray-800",children:[a.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:n.enable}),a.jsx(js,{checked:f.enabled,onChange:V=>{_(V)},disabled:g||!s})]}),E=f?.legacySectionPresent===!0,L=f!==null&&!f.templateHasPlaceholder&&a.jsxs("div",{className:`flex items-center justify-between gap-4 rounded-lg border px-4 py-3 ${Df.attention}`,children:[a.jsx("p",{className:"text-xs",children:E?n.legacyTemplate??n.templateMissing:n.templateMissing}),s&&a.jsx(ge,{size:"sm",className:"shrink-0",onClick:()=>{R()},children:E?n.migrate??n.insertPlaceholder:n.insertPlaceholder})]}),F=f!==null&&a.jsxs("section",{className:"space-y-2.5 rounded-lg border border-gray-200 p-3.5 dark:border-gray-800",children:[a.jsxs("h3",{className:"flex items-center gap-1.5 text-sm font-semibold text-gray-800 dark:text-gray-200",children:[n.promptSection,a.jsx(ba,{label:n.promptSection,children:n.promptSectionHint})]}),a.jsx(ir,{ref:w,label:n.promptLabel,mono:!0,size:"sm",rows:12,readOnly:!s,value:h,onChange:V=>x(V.target.value)}),a.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:d.agent.placeholdersTitle}),a.jsx("ul",{className:"space-y-1",children:n.promptPlaceholders.map(([V,P])=>a.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[a.jsx("button",{type:"button",disabled:!s,onClick:()=>zV(w,h,x,V),title:d.memory.insertToken,className:"shrink-0 rounded border border-gray-200 bg-white px-1.5 py-0.5 font-mono font-semibold text-gray-800 transition-colors duration-150 hover:border-gray-400 hover:bg-gray-100 disabled:pointer-events-none dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:border-gray-500 dark:hover:bg-gray-700",children:V}),a.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:P})]},V))})]}),s&&a.jsx("div",{className:"flex justify-end",children:a.jsx(ge,{size:"sm",variant:"primary",onClick:D,children:d.common.save})}),C]});return{applyConfig:N,toggleCard:z,alertStrip:L,promptSection:F}}const BV="inline-flex cursor-pointer items-center justify-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1 text-xs font-medium text-gray-800 transition-colors duration-150 hover:bg-gray-50 focus-within:ring-2 focus-within:ring-gray-400/30 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",HV="M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m3 0l-1 13a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L6 7m4 4v6m4-6v6";function FV({agentId:e,onConfigChanged:t}){const n=yr(),{locale:s}=Dr(),o=mn().user?.userId??null,{currentProject:c,agents:u,setCurrentAgentId:f,reloadAgents:p}=en(),h=c?.projectId??null,{applyConfig:x,toggleCard:g,alertStrip:v,promptSection:w}=Zy({agentId:e,feature:"skills",strings:d.skills.injection,canEdit:!0,onConfigChanged:t}),[S,C]=y.useState(null),[N,T]=y.useState(null),[_,R]=y.useState(!1),[D,z]=y.useState(null),[E,L]=y.useState(!1),[F,V]=y.useState(""),[P,B]=y.useState(!1),[Y,q]=y.useState(null),[K,H]=y.useState(null),$=y.useCallback(async()=>{if(!(!h||!e)){C(null),T(null);try{const[ye,Se]=await Promise.all([Bu(h,e),Ao(h,e)]);C(ye.skills),x(Se.config)}catch(ye){T(Ae(ye))}}},[h,e,x]);y.useEffect(()=>{$()},[$]);const X=u.find(ye=>ye.agentId===e),le=X?_n(X):e,ie=async ye=>{if(h)try{const Se=await fetch(EA(h,e,ye));if(!Se.ok){const ct=await Se.json().catch(()=>null);throw new xr(Se.status,ct?.error?.code??"unknown",ct?.error?.message??d.common.unknownError)}const Me=/filename\*=UTF-8''([^;]+)/i.exec(Se.headers.get("content-disposition")??"")?.[1],ze=URL.createObjectURL(await Se.blob()),De=document.createElement("a");De.href=ze,De.download=Me?decodeURIComponent(Me):`${ye}.zip`,document.body.appendChild(De),De.click(),De.remove(),URL.revokeObjectURL(ze)}catch(Se){Be(Ae(Se))}},I=async()=>{if(!(!h||D===null)){R(!0);try{await lC(h,e,D),yt(d.skills.uninstalledToast(D,le)),await $(),p()}catch(ye){Be(Ae(ye))}finally{R(!1),z(null)}}},A=()=>{V(""),q(null),H(null),L(!0)},Q=F.trim(),j=t0(Q||d.skills.importSourceToken),U=lf(),ee=()=>{if(o&&h&&Q){Yl(o,h);const ye=ks(o,h);Qs(ye,{...$i(ye),agentId:e,text:t0(Q),skills:[],handoffAgentId:void 0})}f(e),n(`/chat/${ya}`,{state:{agentId:e}})},re=async(ye,Se,Me)=>{if(h){B(!0),q(null);try{await MA(h,e,{dataBase64:ye,...Me?{overwrite:!0}:{}}),H(null),L(!1),yt(d.skills.importDoneToast),await $(),p()}catch(ze){if(ze instanceof xr&&ze.status===409&&ze.code==="skill_exists"){const De=/:\s*([A-Za-z0-9_-]+)$/.exec(ze.message)?.[1]??Se;H({dataBase64:ye,name:De})}else H(null),q(Ae(ze))}finally{B(!1)}}},ke=ye=>{const Se=ye.target.files?.[0];if(ye.target.value="",!Se)return;q(null);const Me=Se.name.replace(/\.zip$/i,""),ze=new FileReader;ze.onload=()=>{const De=ze.result;re(De.slice(De.indexOf(",")+1),Me,!1)},ze.onerror=()=>q(d.common.unknownError),ze.readAsDataURL(Se)},be=ye=>[`v${ye.version}`,ye.updated?Al(ye.updated,s):null].filter(Se=>Se!==null).join(" · ");return h?a.jsxs("div",{className:"space-y-4",children:[a.jsx(Co,{label:d.agent.tabSkills,children:d.skills.agentTabDesc}),g,v,a.jsx("div",{className:"flex justify-end",children:a.jsx(ge,{size:"sm",variant:"primary",disabled:S===null,onClick:A,children:d.skills.importSkill})}),S===null?a.jsx(Sr,{rows:4}):S.length===0?a.jsx(Ff,{children:d.skills.agentTabEmpty}):a.jsx("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:S.map(ye=>a.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 px-3 py-2.5 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[a.jsx("span",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${hT(ye.name)}`,children:a.jsx(Yf,{icon:ye.icon,size:20})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate font-mono text-[13px] font-semibold",title:ye.name,children:ye.name}),a.jsx("p",{className:"mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400",title:ye.description,children:Wl(s,ye)})]}),a.jsx("span",{className:"hidden shrink-0 text-[11px] text-gray-400 sm:block dark:text-gray-500",title:be(ye),children:be(ye)}),a.jsx(ge,{size:"icon",title:d.skills.exportSkill,"aria-label":`${d.skills.exportSkill} ${ye.name}`,disabled:_,onClick:()=>{ie(ye.name)},children:a.jsx(Hx,{size:14,className:"text-gray-600 dark:text-gray-300"})}),a.jsx(ge,{size:"icon",variant:"danger",title:d.skills.uninstall,"aria-label":`${d.skills.uninstall} ${ye.name}`,disabled:_,onClick:()=>z(ye.name),children:a.jsx(Oe,{d:HV,size:14})})]},ye.name))}),w,a.jsx(Yt,{open:E,title:d.skills.importSkill,onClose:()=>L(!1),widthClass:"sm:max-w-lg",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("section",{children:[a.jsx("p",{className:"text-sm font-medium",children:d.skills.importChatTitle}),a.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:d.skills.importChatWhy}),a.jsxs("div",{className:"mt-2.5 space-y-2.5",children:[a.jsx(at,{size:"sm",label:d.skills.importSourceLabel,hint:d.skills.importSourceHint,value:F,onChange:ye=>V(ye.target.value),placeholder:d.skills.importSourcePlaceholder,autoComplete:"off"}),a.jsx(ir,{label:d.skills.importPromptLabel,size:"sm",rows:5,readOnly:!0,value:j,className:"text-gray-600 dark:text-gray-300"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(ge,{size:"sm",disabled:Q==="",onClick:()=>U.flash(t0(Q)),children:[a.jsx(cf,{copied:U.copied,size:12}),d.skills.importCopyPrompt]}),a.jsx(uf,{copied:U.copied}),a.jsx(ge,{size:"sm",variant:"primary",onClick:ee,children:d.skills.importOpenChat})]})]})]}),a.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[a.jsx("p",{className:"text-sm font-medium",children:d.skills.importUploadTitle}),a.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:d.skills.importUploadDesc}),a.jsxs("label",{className:`${BV} mt-2.5 ${P?"pointer-events-none opacity-60":""}`,children:[a.jsx(Xl,{accept:".zip",disabled:P,onChange:ke}),P?d.skills.importUploading:d.skills.importUploadAction]}),Y&&a.jsx("p",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:Y})]})]})}),a.jsx(ln,{open:K!==null,title:d.skills.importOverwriteTitle,confirmLabel:d.skills.importOverwriteAction,busy:P,onClose:()=>H(null),onConfirm:()=>{K!==null&&re(K.dataBase64,K.name,!0)},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:K!==null?d.skills.importOverwriteBody(K.name):""})}),a.jsx(ln,{open:D!==null,title:D!==null?d.skills.uninstallConfirmTitle(D):"",busy:_,onClose:()=>z(null),onConfirm:()=>{I()},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:D!==null?d.skills.uninstallConfirmBody(D,le):""})}),N&&a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:N})]}):null}const hx={damping:1,response:.35},rj={damping:.8,response:.3};function qV(e,t,n,s,o){const c=2*Math.PI/s.response,u=c*c,f=2*s.damping*c;let p=e,h=t,x=Math.min(o,64);for(;x>0;){const g=Math.min(x,8)/1e3,v=-u*(p-n)-f*h;h+=v*g,p+=h*g,x-=8}return[p,h]}function aj(e,t,n){return Math.abs(e-n)<.5&&Math.abs(t)<5}function VV(e,t){let n=e,s=0,o=e,c=hx,u,f=0,p=0;const h=()=>{f&&cancelAnimationFrame(f),f=0,p=0,u=void 0},x=g=>{const v=p?g-p:16;if(p=g,[n,s]=qV(n,s,o,c,v),aj(n,s,o)){n=o,s=0,f=0,p=0,t(n);const w=u;u=void 0,w?.();return}t(n),f=requestAnimationFrame(x)};return{get value(){return n},get velocity(){return s},animateTo(g,v,w){if(o=g,c=v,w?.velocity!==void 0&&(s=w.velocity),u=w?.onSettle,aj(n,s,o)){n=o,s=0,t(n);const S=u;u=void 0,S?.();return}f||(f=requestAnimationFrame(x))},stop(){return h(),[n,s]},set(g){h(),n=g,s=0,t(n)},dispose:h}}function GV(e,t=.998){return e/1e3*t/(1-t)}function KV(e,t,n=.55){return e*t*n/(t+n*Math.abs(e))}function WV(e,t){let n=t[0];for(const s of t)Math.abs(s-e)<Math.abs(n-e)&&(n=s);return n}const YV=.92,XV=.6;function QV(){const[e,t]=y.useState(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches);return y.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function ZV({open:e,snap:t,onSnapChange:n,onClose:s,title:o,children:c}){const[u,f]=y.useState(e),p=y.useRef(null),h=y.useRef(null),x=y.useRef(null),g=y.useRef(0),v=y.useRef(!1),w=y.useRef(!1),S=y.useRef(null),C=y.useRef([]),N=y.useRef({pointerY:0,sheetY:0}),T=y.useRef(e);T.current=e;const _=y.useRef(null),R=QV(),D=y.useCallback(B=>{const Y=g.current||1;p.current&&(p.current.style.transform=`translate3d(0, ${B}px, 0)`),h.current&&(h.current.style.opacity=String(Math.min(1,Math.max(0,1-B/Y))))},[]),z=y.useCallback(B=>{const Y=g.current;return B==="full"?0:Y*(1-XV/YV)},[]);y.useEffect(()=>{e&&f(!0)},[e]),y.useLayoutEffect(()=>{if(!u)return;const B=p.current;B&&(g.current=B.offsetHeight,x.current||(x.current=VV(g.current,D),x.current.set(g.current)))},[u,D]),y.useEffect(()=>{if(!u)return;const B=x.current;if(B)if(e){if(w.current=!1,v.current)return;const Y=z(t);if(S.current!==null&&Math.abs(S.current-Y)<1)return;if(S.current=Y,R){B.set(Y);return}B.animateTo(Y,hx)}else{if(w.current=!0,S.current=g.current,R){f(!1);return}B.animateTo(g.current,hx,{onSettle:()=>f(!1)})}},[u,e,t,R,z]),y.useEffect(()=>{u||(x.current?.dispose(),x.current=null,S.current=null,v.current=!1,w.current=!1)},[u]),y.useEffect(()=>()=>x.current?.dispose(),[]),y.useEffect(()=>{if(!u)return;const B=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=B}},[u]),y.useEffect(()=>{if(!u||!e)return;const B=Y=>{Y.key==="Escape"&&s()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[u,e,s]),y.useEffect(()=>{if(u)return _.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>_.current?.focus()},[u]),y.useEffect(()=>{if(!u)return;const B=()=>{const Y=p.current;if(!Y||(g.current=Y.offsetHeight,v.current||w.current))return;const q=z(t);S.current=q,x.current?.set(q)};return window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[u,t,z]);const E=B=>{if(w.current)return;const Y=x.current;if(!Y)return;B.currentTarget.setPointerCapture(B.pointerId);const[q]=Y.stop();v.current=!0,N.current={pointerY:B.clientY,sheetY:q},C.current=[{y:B.clientY,t:performance.now()}]},L=B=>{if(!v.current)return;const Y=x.current;if(!Y)return;const q=N.current.sheetY+(B.clientY-N.current.pointerY),K=g.current,H=q<0?-KV(-q,K):Math.min(q,K);Y.set(H);const $=performance.now(),X=C.current;for(X.push({y:B.clientY,t:$});X.length>2&&$-X[0].t>100;)X.shift()},F=B=>{v.current=!1;const Y=x.current;if(!Y)return;const q=g.current,K=z("half"),H=T.current?Y.value+GV(B):q,$=WV(H,[0,K,q]);if(S.current=$,$===q){if(w.current=!0,R){f(!1),s();return}Y.animateTo(q,rj,{velocity:B,onSettle:()=>{f(!1),s()}});return}Y.animateTo($,rj,{velocity:B});const X=$===0?"full":"half";X!==t&&n?.(X)},V=()=>{if(!v.current)return;const B=C.current,Y=B[B.length-1],q=B[0],K=Y&&q?Y.t-q.t:0;F(K>0?(Y.y-q.y)/K*1e3:0)},P=()=>{v.current&&F(0)};return u?a.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":o,children:[a.jsx("div",{ref:h,className:`absolute inset-0 bg-black/45 ${R?"anim-fade":""}`,style:{opacity:0},onPointerDown:()=>s()}),a.jsxs("div",{ref:p,className:`absolute inset-x-0 bottom-0 flex h-[92dvh] flex-col overflow-hidden rounded-t-2xl border-t border-gray-200 bg-white shadow-2xl dark:border-gray-800 dark:bg-gray-900 ${R?"anim-fade":""}`,style:{transform:"translate3d(0, 100%, 0)"},children:[a.jsxs("div",{className:"shrink-0 cursor-grab touch-none select-none active:cursor-grabbing",onPointerDown:E,onPointerMove:L,onPointerUp:V,onPointerCancel:P,onLostPointerCapture:P,children:[a.jsx("div",{className:"mx-auto mt-2 h-1 w-9 rounded-full bg-gray-300 dark:bg-gray-600"}),a.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 pt-1.5",children:[a.jsx("span",{className:"text-base font-semibold",children:o??""}),a.jsx(Rf,{onClose:s,onPointerDown:B=>B.stopPropagation()})]})]}),a.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain pb-[env(safe-area-inset-bottom)]",children:c})]})]}):null}function JV(e,t=""){const n=`${d.memory.editPromptLead(e)}
182
- ${d.memory.editPromptTail}`,s=t.trim();return s.length>0?`${n}${s}`:n}function eG(e,t){return`${d.memory.addPromptLead[e]}
183
- ${t.trim()}`}const tG="penguin-memory-scope",nG=1;class yl extends Error{constructor(t){super(t),this.name="MemoryDocumentError"}}function rG(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.content=="string"}function aG(e){let t;try{t=JSON.parse(e)}catch{throw new yl(d.memory.importInvalidFile)}if(t===null||typeof t!="object"||Array.isArray(t))throw new yl(d.memory.importInvalidFile);const n=t;if(n.format!==tG||n.version!==nG)throw new yl(d.memory.importInvalidFile);if(!Array.isArray(n.files)||!n.files.every(rG))throw new yl(d.memory.importInvalidFile);if(n.files.length===0&&typeof n.index!="string")throw new yl(d.memory.importEmptyFile);return n}function sG(e,t,n){const s=new Set(t.names),o=new Set(e.files.map(g=>g.name)),c=e.files.filter(g=>s.has(g.name)).map(g=>g.name),u=e.files.filter(g=>!s.has(g.name)).map(g=>g.name),f=n==="skip"?[]:c,p=n==="skip"?c:[],h=n==="replace"?[...s].filter(g=>!o.has(g)):[],x=n==="replace"&&t.hasIndex&&e.index!==null;return{added:u,overwritten:f,skipped:p,removed:h,replacesIndex:x,destroys:f.length>0||h.length>0||x}}function iG(e){const t=new Date(e);if(Number.isNaN(t.getTime()))return null;const n=s=>String(s).padStart(2,"0");return`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}-${n(t.getHours())}${n(t.getMinutes())}`}function oG(e,t,n){const s=iG(n);return s===null?`${e}-${t}-memory.json`:`${e}-${t}-memory-${s}.json`}const sj="(min-width: 1024px)",lG="M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z",cG="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z",uG="M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m3 0l-1 13a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L6 7m4 4v6m4-6v6",dG="M12 5v14M5 12h14",mG="inline-flex cursor-pointer items-center justify-center gap-1 rounded-md border border-transparent px-2.5 py-1 text-xs font-medium text-gray-600 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-900 focus-within:ring-2 focus-within:ring-gray-400/30 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",fG=(e,t,n)=>`penguin.memoryCollapsed.${e}.${t}.${n}`;function ij(e){if(!e)return new Set;try{const t=JSON.parse(localStorage.getItem(e)??"[]");return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function oj(e,t){if(e)try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function pG({agentId:e,onConfigChanged:t}){const n=yr(),{locale:s}=Dr(),o=mn().user?.userId??null,{currentProject:c,setCurrentAgentId:u,reloadAgents:f}=en(),p=c?.projectId??null,h=c?.role==="owner",[x,g]=y.useState(!0),[v,w]=y.useState(!0),[S,C]=y.useState(""),[N,T]=y.useState(null),[_,R]=y.useState(null),[D,z]=y.useState(!1),E=o&&p?fG(o,p,e):null,[L,F]=y.useState(()=>ij(E)),[V,P]=y.useState(""),[B,Y]=y.useState(""),q=y.useRef(null),K=y.useRef(null),[H,$]=y.useState("main"),{requestSave:X,element:le}=ql(),[ie,I]=y.useState(!1),[A,Q]=y.useState(null),[j,U]=y.useState(null),[ee,re]=y.useState(""),[ke,be]=y.useState(null),[ye,Se]=y.useState(""),[Me,ze]=y.useState(null),[De,ct]=y.useState("skip"),[bt,he]=y.useState(null),[ne,oe]=y.useState(!1),[J,ht]=y.useState(null),[ve,Xe]=y.useState(()=>window.matchMedia(sj).matches),[Ge,He]=y.useState("half");y.useEffect(()=>{const Te=window.matchMedia(sj),Ie=ut=>Xe(ut.matches);return Te.addEventListener("change",Ie),()=>Te.removeEventListener("change",Ie)},[]),y.useEffect(()=>{F(ij(E))},[E]);const Pe=Te=>{const Ie=new Set(L);Ie.delete(Te)||Ie.add(Te),oj(E,Ie),F(Ie)},W=y.useCallback(async()=>{if(!(!p||!e)){T(null),R(null);try{const[Te,Ie]=await Promise.all([eC(p,e),Ao(p,e)]);P(Ie.config.memory.prompt),Y(Ie.config.memory.workspacePrompt),g(Te.enabled),w(Te.templateHasMemory),C(Te.memoryDir);const ut=new Set(Te.scopes.map(St=>St.scopeKey));F(St=>{const gn=new Set([...St].filter(Nn=>ut.has(Nn)));return gn.size===St.size?St:(oj(E,gn),gn)}),T(await Promise.all(Te.scopes.map(async St=>{try{return{scope:St,files:(await tC(p,e,St.scopeKey)).files}}catch{return{scope:St,files:[]}}})))}catch(Te){R(Ae(Te))}}},[p,e,E]);y.useEffect(()=>{W()},[W]);const me=async Te=>{if(p){z(!0);try{const Ie=await To(p,e,{config:{memory:{enabled:Te}}});g(Ie.config.memory.enabled),yt(d.common.saved),t?.()}catch(Ie){Be(Ae(Ie))}finally{z(!1)}}},Ue=async()=>{if(p)try{const Te=await PE(p,e);w(Te.templateHasMemory),yt(d.memory.insertPlaceholderDone),t?.()}catch(Te){Be(Ae(Te))}},pe=(Te,Ie,ut,St)=>{const gn=Te.current;if(gn&&(gn.focus(),document.execCommand?.("insertText",!1,St)))return;const Nn=gn?gn.selectionStart:Ie.length,Hn=gn?gn.selectionEnd:Ie.length;ut(Ie.slice(0,Nn)+St+Ie.slice(Hn)),requestAnimationFrame(()=>{if(!gn)return;gn.focus();const Dt=Nn+St.length;gn.setSelectionRange(Dt,Dt)})},$e=()=>X(()=>{p&&To(p,e,{config:{memory:{prompt:V,workspacePrompt:B}}}).then(Te=>{P(Te.config.memory.prompt),Y(Te.config.memory.workspacePrompt),yt(d.common.saved),t?.()}).catch(Te=>Be(Ae(Te)))}),nt=async(Te,Ie)=>{if(p)try{const ut=await nC(p,e,Te.scopeKey,Ie.name);He("half"),Q({scope:Te,file:ut.file,content:ut.content}),I(!0)}catch(ut){Be(Ae(ut))}},gt=(Te,Ie)=>`${S}/${Te.scopeKey}/${Ie.name}`,Ke=(Te,Ie)=>{I(!1),re(""),U({scope:Te,file:Ie})},dt=j?JV(j.file.title,ee):"",pt=lf(),wt=(Te,Ie)=>{if(!o||!p)return;const ut=ks(o,p);Qs(ut,{...$i(ut),agentId:e,text:Te,...Ie!==void 0?{workspace:Ie}:{},skills:[],handoffAgentId:void 0}),u(e),n(`/chat/${ya}`,{state:{agentId:e,...Ie!==void 0?{workspace:Ie}:{}}})},st=()=>{j&&wt(dt,j.scope.workspacePath)},Bt=Te=>{Se(""),be(Te)},Sn=ke?eG(ke.kind,ye):"",Dn=lf(),Vt=()=>{ke&&wt(Sn,ke.workspacePath)},ar=async Te=>{if(p)try{const Ie=await BE(p,e,Te.scopeKey),ut=URL.createObjectURL(new Blob([JSON.stringify(Ie,null,2)],{type:"application/json"})),St=document.createElement("a");St.href=ut,St.download=oG(e,Te.scopeKey,Ie.exportedAt),document.body.appendChild(St),St.click(),St.remove(),URL.revokeObjectURL(ut)}catch(Ie){Be(Ae(Ie))}},zn=async(Te,Ie)=>{const ut=Ie.target.files?.[0];if(Ie.target.value="",!!ut)try{const St=aG(await ut.text());ct("skip"),ze({scope:Te,fileName:ut.name,doc:St})}catch(St){Be(St instanceof yl?St.message:d.memory.importInvalidFile)}},Xt=async Te=>{if(!(!p||!Me)){oe(!0);try{const Ie=await HE(p,e,Me.scope.scopeKey,{mode:De,confirm:Te,payload:Me.doc}),ut=Ie.added.length+Ie.overwritten.length+Ie.removed.length;yt(ut===0?d.memory.importNothingNew:d.memory.importDone(Ie.added.length,Ie.overwritten.length,Ie.removed.length)),he(null),ze(null),await W(),f()}catch(Ie){Be(Ae(Ie))}finally{oe(!1)}}},Cn=()=>{if(!Me)return;const Te=N?.find(ut=>ut.scope.scopeKey===Me.scope.scopeKey),Ie=sG(Me.doc,{names:Te?.files.map(ut=>ut.name)??[],hasIndex:Me.scope.hasIndex},De);Ie.destroys?he(Ie):Xt(!1)},lr=async()=>{if(!p||!J)return;const Te=J;ht(null);try{await zE(p,e,Te.scope.scopeKey,Te.file.name),yt(d.memory.deleteDone),A&&A.file.name===Te.file.name&&I(!1),await W(),f()}catch(Ie){Be(Ae(Ie))}};if(_)return a.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:_});const Mt=Te=>Te.kind==="user"?d.memory.userScope:Te.workspacePath?.split(/[\\/]/).filter(Boolean).at(-1)??Te.scopeKey,Pr=(Te,Ie)=>a.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[a.jsx(ge,{size:"icon",title:d.memory.view,"aria-label":`${d.memory.view} ${Ie.title}`,onClick:()=>{nt(Te,Ie)},children:a.jsx(Oe,{d:lG,size:14,className:"text-gray-600 dark:text-gray-300"})}),a.jsx(ge,{size:"icon",title:d.memory.edit,"aria-label":`${d.memory.edit} ${Ie.title}`,onClick:()=>Ke(Te,Ie),children:a.jsx(Oe,{d:cG,size:14,className:"text-gray-600 dark:text-gray-300"})}),a.jsx(ge,{size:"icon",variant:"danger",title:d.memory.delete,"aria-label":`${d.memory.delete} ${Ie.title}`,onClick:()=>ht({scope:Te,file:Ie}),children:a.jsx(Oe,{d:uG,size:14})})]}),Bn=(Te,Ie)=>a.jsxs("li",{className:"flex items-center gap-3 px-3.5 py-2.5",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate font-mono text-[13px] font-medium text-gray-800 dark:text-gray-200",children:Ie.title}),Ie.description&&a.jsx("p",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:Ie.description})]}),a.jsx("span",{className:"shrink-0 text-xs tabular-nums text-gray-400 dark:text-gray-500",children:Ie.updatedAt??Al(Ie.modifiedAt,s)}),Pr(Te,Ie)]},Ie.name),Nr=A&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:A.file.updatedAt??Al(A.file.modifiedAt,s)}),A.file.description&&a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:A.file.description}),a.jsx("div",{className:"md-body border-t border-gray-100 pt-3 text-sm dark:border-gray-800",children:a.jsx(ed,{text:Y5(A.content)})})]}),Tr=A&&a.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-gray-200 px-4 py-3 dark:border-gray-800",children:[a.jsx(ge,{size:"sm",onClick:()=>Ke(A.scope,A.file),children:d.memory.edit}),a.jsx(ge,{size:"sm",variant:"danger",onClick:()=>ht(A),children:d.memory.delete})]});return a.jsxs("div",{className:"space-y-5",children:[a.jsx(Co,{label:d.agent.tabMemory,children:d.memory.desc}),a.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-gray-200 px-4 py-3 dark:border-gray-800",children:[a.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:d.memory.enable}),a.jsx(js,{checked:x,onChange:Te=>{me(Te)},disabled:D})]}),!v&&a.jsxs("div",{className:`flex items-center justify-between gap-4 rounded-lg border px-4 py-3 ${Df.attention}`,children:[a.jsx("p",{className:"text-xs",children:d.memory.templateMissing}),a.jsx(ge,{size:"sm",onClick:()=>{Ue()},children:d.memory.insertPlaceholder})]}),N===null?a.jsx(Sr,{rows:4}):a.jsx("div",{className:x?"space-y-5":"space-y-5 opacity-60",children:N.map(({scope:Te,files:Ie})=>{const ut=!L.has(Te.scopeKey);return a.jsxs("section",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800",children:[a.jsxs("div",{className:"@container flex items-center gap-2 bg-gray-50 pr-2 transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60",children:[a.jsxs("button",{type:"button","aria-expanded":ut,onClick:()=>Pe(Te.scopeKey),className:"flex min-w-0 flex-1 items-center gap-2.5 px-3.5 py-2.5 text-left",children:[a.jsx("span",{className:"min-w-0 truncate text-sm font-semibold text-gray-800 dark:text-gray-200",children:Mt(Te)}),Te.kind==="workspace"&&Te.workspacePath!==void 0&&a.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-gray-400 dark:text-gray-500",children:Te.workspacePath}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx("span",{className:"shrink-0 whitespace-nowrap text-xs text-gray-400 dark:text-gray-500",children:d.memory.itemCount(Ie.length)})]}),a.jsx("span",{className:"shrink-0",children:a.jsxs(ge,{size:"sm",variant:"ghost",title:d.memory.exportScopeHint,"aria-label":d.memory.exportScopeLabel(Mt(Te)),onClick:()=>{ar(Te)},children:[a.jsx(Hx,{size:13}),a.jsx("span",{className:"hidden @md:inline",children:d.memory.exportScope})]})}),h&&a.jsxs("label",{className:`${mG} shrink-0`,title:d.memory.importScopeHint,"aria-label":d.memory.importScopeLabel(Mt(Te)),children:[a.jsx(Xl,{accept:".json,application/json",onChange:St=>{zn(Te,St)}}),a.jsx(YC,{size:13}),a.jsx("span",{className:"hidden @md:inline",children:d.memory.importScope})]}),a.jsx("span",{className:"shrink-0",children:a.jsxs(ge,{size:"sm",variant:"ghost",title:d.memory.add,"aria-label":d.memory.addScopeLabel(Mt(Te)),onClick:()=>Bt(Te),children:[a.jsx(Oe,{d:dG,size:13}),a.jsx("span",{className:"hidden @md:inline",children:d.memory.add})]})}),a.jsx("button",{type:"button","aria-expanded":ut,"aria-label":Mt(Te),onClick:()=>Pe(Te.scopeKey),className:"shrink-0 p-1.5",children:a.jsx(Zn,{open:ut,className:"text-gray-400"})})]}),a.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${ut?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:a.jsx("div",{className:"overflow-hidden",inert:!ut,children:Ie.length===0?a.jsx("p",{className:"px-4 py-4 text-center text-xs text-gray-400 dark:text-gray-500",children:Te.kind==="user"?d.memory.emptyUserScope:d.memory.emptyScope}):a.jsx("ul",{className:"divide-y divide-gray-100 border-t border-gray-200 dark:divide-gray-800 dark:border-gray-800",children:Ie.map(St=>Bn(Te,St))})})})]},Te.scopeKey)})}),a.jsxs("section",{className:"space-y-2.5 rounded-lg border border-gray-200 p-3.5 dark:border-gray-800",children:[a.jsxs("h3",{className:"flex items-center gap-1.5 text-sm font-semibold text-gray-800 dark:text-gray-200",children:[d.memory.promptSection,a.jsx(ba,{label:d.memory.promptSection,children:d.memory.promptSectionHint})]}),a.jsx(ir,{ref:q,label:d.memory.promptLabel,mono:!0,size:"sm",rows:12,value:V,onFocus:()=>$("main"),onChange:Te=>P(Te.target.value)}),a.jsx(ir,{ref:K,label:d.memory.workspacePromptLabel,mono:!0,size:"sm",rows:6,value:B,onFocus:()=>$("workspace"),onChange:Te=>Y(Te.target.value)}),a.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:d.agent.placeholdersTitle}),a.jsx("ul",{className:"space-y-1",children:d.memory.promptPlaceholders.map(([Te,Ie])=>a.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[a.jsx("button",{type:"button",onClick:()=>H==="main"?pe(q,V,P,Te):pe(K,B,Y,Te),title:d.memory.insertToken,className:"shrink-0 rounded border border-gray-200 bg-white px-1.5 py-0.5 font-mono font-semibold text-gray-800 transition-colors duration-150 hover:border-gray-400 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:border-gray-500 dark:hover:bg-gray-700",children:Te}),a.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:Ie})]},Te))})]}),a.jsx("div",{className:"flex justify-end",children:a.jsx(ge,{size:"sm",variant:"primary",onClick:$e,children:d.common.save})})]}),le,ve?a.jsx(QC,{open:ie,side:"right",title:A?.file.title??"",onClose:()=>I(!1),widthClass:"max-w-lg",children:A&&a.jsxs("div",{className:"flex h-full flex-col",children:[a.jsx("div",{className:"flex-1 space-y-3 overflow-y-auto px-4 py-3",children:Nr}),Tr]})}):a.jsx(ZV,{open:ie,snap:Ge,onSnapChange:He,title:A?.file.title??"",onClose:()=>I(!1),children:A&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"space-y-3 px-4 py-3",children:Nr}),Tr]})}),a.jsx(Yt,{open:j!==null,title:d.memory.editTitle,onClose:()=>U(null),widthClass:"sm:max-w-lg",children:j&&a.jsxs("div",{className:"space-y-2.5",children:[a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.memory.editWhy}),a.jsx("p",{className:"break-all font-mono text-[11px] text-gray-400 dark:text-gray-500",children:gt(j.scope,j.file)}),a.jsx(ir,{label:d.memory.editRequirementLabel,size:"sm",rows:2,value:ee,onChange:Te=>re(Te.target.value),placeholder:d.memory.editRequirementPlaceholder}),a.jsx(ir,{label:d.memory.editPromptLabel,size:"sm",rows:6,readOnly:!0,value:dt,className:"text-gray-600 dark:text-gray-300"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(ge,{size:"sm",onClick:()=>pt.flash(dt),children:[a.jsx(cf,{copied:pt.copied,size:12}),d.memory.editCopyPrompt]}),a.jsx(uf,{copied:pt.copied}),a.jsx(ge,{size:"sm",variant:"primary",onClick:st,children:d.memory.editOpenChat})]})]})}),a.jsx(Yt,{open:ke!==null,title:d.memory.addTitle,onClose:()=>be(null),widthClass:"sm:max-w-lg",children:ke&&a.jsxs("div",{className:"space-y-2.5",children:[a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.memory.addWhy}),a.jsx("p",{className:"break-all font-mono text-[11px] text-gray-400 dark:text-gray-500",children:`${S}/${ke.scopeKey}`}),a.jsx(ir,{label:d.memory.addContentLabel,required:!0,size:"sm",rows:4,value:ye,onChange:Te=>Se(Te.target.value),placeholder:d.memory.addContentPlaceholder}),a.jsx(ir,{label:d.memory.editPromptLabel,size:"sm",rows:6,readOnly:!0,value:Sn,className:"text-gray-600 dark:text-gray-300"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(ge,{size:"sm",disabled:ye.trim()==="",onClick:()=>Dn.flash(Sn),children:[a.jsx(cf,{copied:Dn.copied,size:12}),d.memory.editCopyPrompt]}),a.jsx(uf,{copied:Dn.copied}),a.jsx(ge,{size:"sm",variant:"primary",disabled:ye.trim()==="",onClick:Vt,children:d.memory.editOpenChat})]})]})}),a.jsx(Yt,{open:Me!==null,title:d.memory.importTitle,onClose:()=>ze(null),widthClass:"sm:max-w-lg",children:Me&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.memory.importWhy}),a.jsx("p",{className:"break-all font-mono text-[11px] text-gray-500 dark:text-gray-400",children:d.memory.importFile(Me.fileName,Me.doc.files.length)}),a.jsxs("fieldset",{className:"space-y-2",children:[a.jsx("legend",{className:"mb-1 text-xs font-medium text-gray-500 dark:text-gray-400",children:d.memory.importModeLabel}),[["skip",d.memory.importModeSkip,d.memory.importModeSkipHint],["overwrite",d.memory.importModeOverwrite,d.memory.importModeOverwriteHint],["replace",d.memory.importModeReplace,d.memory.importModeReplaceHint]].map(([Te,Ie,ut])=>a.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-sm",children:[a.jsx("input",{type:"radio",name:"memory-import-mode",className:"mt-1 shrink-0",checked:De===Te,onChange:()=>ct(Te)}),a.jsxs("span",{className:"min-w-0",children:[a.jsx("span",{className:"text-gray-800 dark:text-gray-200",children:Ie}),a.jsx("span",{className:"block text-xs text-gray-500 dark:text-gray-400",children:ut})]})]},Te))]}),a.jsx("div",{className:"flex justify-end",children:a.jsx(ge,{size:"sm",variant:"primary",disabled:ne,onClick:Cn,children:d.memory.importAction})})]})}),a.jsx(ln,{open:bt!==null,tone:"danger",title:d.memory.importConfirmTitle,confirmLabel:d.memory.importAction,busy:ne,onClose:()=>he(null),onConfirm:()=>{Xt(!0)},children:a.jsxs("div",{className:"space-y-1.5 text-sm text-gray-700 dark:text-gray-300",children:[bt&&bt.overwritten.length>0&&a.jsx("p",{className:"break-words",children:d.memory.importWillOverwrite(bt.overwritten)}),bt&&bt.removed.length>0&&a.jsx("p",{className:"break-words",children:d.memory.importWillRemove(bt.removed)}),bt?.replacesIndex&&a.jsx("p",{children:d.memory.importWillReplaceIndex}),a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.memory.importIrreversible})]})}),a.jsx(ln,{open:J!==null,tone:"danger",title:d.memory.deleteTitle,confirmLabel:d.memory.delete,onClose:()=>ht(null),onConfirm:()=>{lr()},children:a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:J?d.memory.deleteConfirm(J.file.title):""})})]})}function hG(e){return{prompt:d.agent.tabPrompt,runtime:d.agent.tabRuntime,tools:d.agent.tabTools,skills:d.agent.tabSkills,memory:d.agent.tabMemory,vault:d.agent.tabVault,schedules:d.agent.tabSchedules}[e]??e}const gG=/^[A-Za-z_][A-Za-z0-9_]*$/;function xG({agentId:e,onConfigChanged:t}){const{currentProject:n,reloadAgents:s}=en(),o=n?.projectId??null,c=n?.role==="owner",{applyConfig:u,toggleCard:f,alertStrip:p,promptSection:h}=Zy({agentId:e,feature:"vault",strings:d.vault.injection,canEdit:c,onConfigChanged:t}),[x,g]=y.useState(null),[v,w]=y.useState(null),[S,C]=y.useState(!1),[N,T]=y.useState(!1),[_,R]=y.useState(""),[D,z]=y.useState(""),[E,L]=y.useState({}),F=()=>L(ie=>ie.key||ie.value?{}:ie),[V,P]=y.useState(null),[B,Y]=y.useState(null),q=y.useCallback(async()=>{if(!(!o||!e)){g(null),w(null);try{const[ie,I]=await Promise.all([LE(o,e),Ao(o,e)]);g(ie.entries),u(I.config)}catch(ie){w(Ae(ie))}}},[o,e,u]);y.useEffect(()=>{q()},[q]);const K=async ie=>{if(!o||!e)return d.common.unknownError;C(!0);try{const I=await OE(o,e,ie);return g(I.entries),yt(d.common.saved),s(),null}catch(I){return Ae(I)}finally{C(!1)}},H=ie=>(x??[]).filter(I=>I.key!==ie).map(I=>({key:I.key})),$=()=>{R(""),z(""),L({}),T(!0)},X=async()=>{const ie=_.trim(),I={};if(ie?gG.test(ie)||(I.key=d.vault.keyInvalid):I.key=d.common.requiredField,D||(I.value=d.vault.valueRequired),I.key||I.value){L(I);return}if(L({}),B!==ie&&(x??[]).some(Q=>Q.key===ie)){Y(ie);return}Y(null);const A=await K({entries:[...H(ie),{key:ie,value:D}]});if(A!==null){L({key:A});return}T(!1)},le=async()=>{if(V===null)return;const ie=await K({entries:H(V)});ie!==null&&Be(ie),P(null)};return o?a.jsxs("div",{className:"space-y-4",children:[a.jsxs(Co,{label:d.agent.tabVault,children:[d.vault.desc,!c&&a.jsx("span",{className:"mt-1.5 block",children:d.vault.readOnlyHint})]}),f,p,x===null?a.jsx(Sr,{rows:4}):x.length===0?a.jsx(Ff,{children:d.vault.empty}):a.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:a.jsxs("table",{className:"w-full min-w-[420px] text-left text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("th",{className:"px-3 py-2.5",children:d.vault.key}),a.jsx("th",{className:"px-3 py-2.5",children:d.vault.valueMasked}),a.jsx("th",{className:"px-3 py-2.5"})]})}),a.jsx("tbody",{children:x.map(ie=>a.jsxs("tr",{className:"border-b border-gray-100 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[a.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:ie.key}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:ie.valueMasked}),a.jsx("td",{className:"px-3 py-2 text-right",children:c&&a.jsx(ge,{size:"sm",variant:"ghost",disabled:S,onClick:()=>P(ie.key),children:d.vault.remove})})]},ie.key))})]})}),c&&x!==null&&a.jsx(ge,{size:"sm",variant:"primary",disabled:S,onClick:$,children:d.vault.add}),h,a.jsx(Yt,{open:N,title:d.vault.addTitle,onClose:()=>T(!1),footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:()=>T(!1),children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:S,onClick:()=>{X()},children:d.vault.add})]}),children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(at,{size:"sm",label:d.vault.key,required:!0,hint:d.vault.keyHint,error:E.key,value:_,onChange:ie=>{R(ie.target.value),F()},className:"font-mono",placeholder:"OPENAI_API_KEY",autoComplete:"off"}),a.jsx(ts,{size:"sm",label:d.vault.value,required:!0,error:E.value,value:D,onChange:ie=>{z(ie.target.value),F()},className:"font-mono",autoComplete:"off",onKeyDown:ie=>{ie.key==="Enter"&&!S&&X()}})]})}),a.jsx(ln,{open:B!==null,title:d.vault.overwriteTitle,tone:"primary",confirmLabel:d.common.save,busy:S,onClose:()=>Y(null),onConfirm:()=>{X()},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:B!==null?d.vault.overwriteConfirm(B):""})}),a.jsx(ln,{open:V!==null,title:d.vault.deleteTitle,busy:S,onClose:()=>P(null),onConfirm:()=>{le()},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:V!==null?d.vault.deleteConfirm(V):""})}),v&&a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:v})]}):null}const yG={active:"green",disabled:"gray",expired:"amber",done:"brand",missed:"amber",invalid:"red"};function lj(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=s=>s<10?`0${s}`:`${s}`;return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}const cj=e=>e.modelId&&e.provider?{provider:e.provider,modelId:e.modelId}:null,bG={editing:null,name:"",prompt:"",enabled:!0,startAt:"",endAt:"",period:"",target:"new",sessionId:"",workspace:"",model:null};function vG(e,t){const n=t.trim().toLowerCase();return n?e.filter(s=>s.sessionId.toLowerCase().includes(n)||(s.title??"").toLowerCase().includes(n)):e}function kG({projectId:e,agentId:t,value:n,onChange:s}){const[o,c]=y.useState(!1),[u,f]=y.useState(""),[p,h]=y.useState(null);y.useEffect(()=>{if(!o||p!==null)return;let v=!1;return c0(e,t).then(w=>{v||h(w.sessions)}).catch(()=>{v||h([])}),()=>{v=!0}},[o,p,e,t]);const x=p?.find(v=>v.sessionId===n)??null,g=x?x.title??d.chat.defaultSessionTitle:n||d.schedule.chooseSession;return a.jsx(Ru,{open:o,setOpen:c,label:g,muted:!n,title:n?`${d.schedule.sessionId}:${n}`:d.schedule.chooseSession,ariaLabel:d.schedule.chooseSession,ariaHaspopup:"listbox",menuClass:"w-80 origin-top-left",children:p===null?a.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:d.common.loading}):p.length===0?a.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:d.schedule.sessionEmpty}):a.jsx(Ey,{items:vG(p,u),itemKey:v=>v.sessionId,isCurrent:v=>v.sessionId===n,query:u,onQueryChange:f,searchPlaceholder:d.schedule.sessionSearch,emptyText:d.schedule.sessionNoMatch,onPick:v=>{s(v.sessionId),c(!1)},renderRow:v=>a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-800 dark:text-gray-200",children:v.title??d.chat.defaultSessionTitle}),a.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400 dark:text-gray-500",children:v.sessionId.slice(-6)})]})})})}function wG({agentId:e,onConfigChanged:t}){const{currentProject:n,reloadAgents:s}=en(),o=n?.projectId??null,c=n?.role==="owner",{applyConfig:u,toggleCard:f,alertStrip:p,promptSection:h}=Zy({agentId:e,feature:"schedules",strings:d.schedule.injection,canEdit:c,onConfigChanged:t}),[x,g]=y.useState(null),[v,w]=y.useState(null),[S,C]=y.useState(!1),[N,T]=y.useState(null),[_,R]=y.useState(null),[D,z]=y.useState({}),[E,L]=y.useState(null),[F,V]=y.useState(null),[P,B]=y.useState([]),[Y,q]=y.useState(null),K=y.useCallback(async()=>{if(!(!o||!e)){g(null),w(null);try{const[j,U]=await Promise.all([CA(o,e),Ao(o,e)]);g(j),u(U.config)}catch(j){w(Ae(j))}}},[o,e,u]);y.useEffect(()=>{K()},[K]),y.useEffect(()=>{!o||!c||Ml(o).then(j=>{B(j.models),q(j.defaultModel??null)}).catch(()=>{B([]),q(null)})},[o,c]);const H=j=>{z(U=>U.name||U.prompt||U.startAt||U.sessionId?{}:U),L(U=>U&&null),T(U=>U===null?U:{...U,...j})},$=j=>{z({}),L(null),T(j),R(j)},X=async()=>{if(!o||N===null)return;L(null);const j=N.editing??N.name.trim(),U={};if(j||(U.name=d.common.requiredField),N.prompt.trim()||(U.prompt=d.common.requiredField),N.startAt||(U.startAt=d.common.requiredField),N.target==="session"&&!N.sessionId.trim()&&(U.sessionId=d.common.requiredField),U.name||U.prompt||U.startAt||U.sessionId){z(U);return}if(z({}),N.editing!==null&&JSON.stringify(N)===JSON.stringify(_)){wr(d.common.noChangesToSave);return}const ee={prompt:N.prompt,enabled:N.enabled,startAt:new Date(N.startAt).toISOString(),...N.period.trim()?{period:N.period.trim()}:{},...N.endAt?{endAt:new Date(N.endAt).toISOString()}:{},...N.target==="session"&&N.sessionId.trim()?{sessionId:N.sessionId.trim()}:{},...N.target==="new"&&N.workspace.trim()?{workspace:N.workspace.trim()}:{},...N.target==="new"&&N.model&&!zt(Y,N.model)?{modelId:N.model.modelId,provider:N.model.provider}:{}};C(!0);try{N.editing!==null?await G1(o,e,N.editing,ee):await NA(o,e,{name:j,...ee}),T(null),yt(d.common.saved),await K(),s()}catch(re){L(Ae(re))}finally{C(!1)}},le=async j=>{if(!o)return;C(!0);const U=cj(j);try{await G1(o,e,j.name,{prompt:j.prompt,enabled:!j.enabled,startAt:j.startAt,...j.period!==void 0?{period:j.period}:{},...j.endAt!==void 0?{endAt:j.endAt}:{},...j.sessionId!==void 0?{sessionId:j.sessionId}:{},...j.workspace!==void 0?{workspace:j.workspace}:{},...U?{modelId:U.modelId,provider:U.provider}:{}}),yt(d.common.saved),await K()}catch(ee){Be(Ae(ee))}finally{C(!1)}},ie=j=>{$({editing:j.name,name:j.name,prompt:j.prompt,enabled:j.enabled,startAt:lj(j.startAt),endAt:lj(j.endAt),period:j.period??"",target:j.sessionId?"session":"new",sessionId:j.sessionId??"",workspace:j.workspace??"",model:cj(j)??Y})},I=async()=>{if(!(!o||F===null)){C(!0);try{await TA(o,e,F),N?.editing===F&&T(null),await K(),s()}catch(j){Be(Ae(j))}finally{C(!1),V(null)}}};if(!o)return null;const A=x?.schedules??[],Q=x?.invalidFiles??[];return a.jsxs("div",{className:"space-y-4",children:[a.jsxs(Co,{label:d.agent.tabSchedules,children:[d.schedule.desc,!c&&a.jsx("span",{className:"mt-1.5 block",children:d.schedule.readOnlyHint})]}),f,p,x===null?a.jsx(Sr,{rows:4}):A.length===0?a.jsx(Ff,{children:d.schedule.empty}):a.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:a.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:d.common.name}),a.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:d.schedule.colStatus}),a.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:d.schedule.colPeriod}),a.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:d.schedule.colTarget}),a.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:d.schedule.colFireTimes}),a.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:d.schedule.colQueued}),c&&a.jsx("th",{className:"px-3 py-2.5"})]})}),a.jsx("tbody",{children:A.map(j=>a.jsxs("tr",{className:"border-b border-gray-100 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[a.jsx("td",{className:"max-w-40 truncate px-3 py-2 font-mono text-xs",title:j.name,children:j.name}),a.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:a.jsx("span",{title:j.invalidReason,children:a.jsx(On,{tone:yG[j.status],children:d.schedule.statusNames[j.status]??j.status})})}),a.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:j.period!==void 0?a.jsx("span",{className:"font-mono",children:j.period}):d.schedule.once}),a.jsx("td",{className:"max-w-36 truncate px-3 py-2 text-xs text-gray-500 dark:text-gray-400",title:j.sessionId,children:j.sessionId!==void 0?a.jsx("span",{className:"font-mono",children:j.sessionId}):d.schedule.newSession}),a.jsxs("td",{className:"whitespace-nowrap px-3 py-2 text-xs",children:[a.jsx("span",{className:"block text-gray-600 dark:text-gray-300",children:j.nextFireAt?Jr(j.nextFireAt):"—"}),a.jsx("span",{className:"block text-gray-400 dark:text-gray-500",children:j.lastFiredAt?Jr(j.lastFiredAt):"—"})]}),a.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:j.queued&&a.jsx(On,{tone:"brand",children:d.schedule.queued})}),c&&a.jsxs("td",{className:"whitespace-nowrap px-3 py-2 text-right",children:[a.jsx(ge,{size:"sm",variant:"ghost",disabled:S,onClick:()=>{le(j)},children:j.enabled?d.schedule.disable:d.schedule.enable}),a.jsx(ge,{size:"sm",variant:"ghost",disabled:S,onClick:()=>ie(j),children:d.common.edit}),a.jsx(ge,{size:"sm",variant:"ghost",disabled:S,onClick:()=>V(j.name),children:d.common.delete})]})]},j.name))})]})}),Q.length>0&&a.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400",children:[a.jsx("p",{className:"font-medium",children:d.schedule.invalidFiles}),a.jsx("ul",{className:"mt-0.5 space-y-0.5 font-mono",children:Q.map(j=>a.jsxs("li",{children:[j.name,": ",j.error]},j.name))})]}),c&&x!==null&&a.jsx(ge,{size:"sm",variant:"primary",disabled:S,onClick:()=>$({...bG,model:Y}),children:d.schedule.addTitle}),h,a.jsx(Yt,{open:N!==null,title:N?.editing!=null?d.schedule.editTitle(N.editing):d.schedule.addTitle,onClose:()=>T(null),widthClass:"sm:max-w-lg",footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:()=>T(null),children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:S,onClick:()=>{X()},children:N?.editing!=null?d.common.save:d.common.create})]}),children:N!==null&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[a.jsx(at,{size:"sm",label:d.common.name,required:!0,hint:d.schedule.nameHint,error:D.name,value:N.name,disabled:N.editing!==null,onChange:j=>H({name:j.target.value}),className:"font-mono",placeholder:"daily_report",autoComplete:"off"}),a.jsx(at,{size:"sm",label:d.schedule.period,value:N.period,onChange:j=>H({period:j.target.value}),className:"font-mono",placeholder:d.schedule.periodPlaceholder,autoComplete:"off"}),a.jsx(at,{size:"sm",label:d.schedule.startAt,required:!0,type:"datetime-local",error:D.startAt,value:N.startAt,onChange:j=>H({startAt:j.target.value}),className:"font-mono"}),a.jsx(at,{size:"sm",label:d.schedule.endAt,type:"datetime-local",value:N.endAt,onChange:j=>H({endAt:j.target.value}),className:"font-mono"}),a.jsxs(Ss,{size:"sm",label:d.schedule.target,value:N.target,onChange:j=>H({target:j.target.value}),children:[a.jsx("option",{value:"new",children:d.schedule.targetNew}),a.jsx("option",{value:"session",children:d.schedule.targetSession})]}),N.target==="session"?a.jsxs("div",{children:[a.jsx(Yn,{required:!0,children:d.schedule.sessionId}),o&&a.jsx(kG,{projectId:o,agentId:e,value:N.sessionId,onChange:j=>H({sessionId:j})}),D.sessionId&&a.jsx(ga,{children:D.sessionId})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx(Yn,{children:d.schedule.model}),P.length>0?a.jsx(Ay,{models:P,value:N.model,...Y?{defaultModel:Y}:{},onChange:j=>H({model:j}),disabled:S,variant:"form"}):a.jsx("p",{className:"text-xs text-gray-400",children:d.schedule.modelDefault})]}),a.jsxs("div",{children:[a.jsx(Yn,{children:d.schedule.workspace}),a.jsx(sd,{projectId:o??"",workspace:N.workspace,onChange:j=>H({workspace:j}),variant:"form"}),a.jsx(wo,{children:d.chat.workspaceHintShort})]})]})]}),a.jsx(ir,{label:d.schedule.prompt,required:!0,size:"sm",rows:4,error:D.prompt,value:N.prompt,onChange:j=>H({prompt:j.target.value})}),a.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-600 dark:text-gray-300",children:[a.jsx("input",{type:"checkbox",checked:N.enabled,onChange:j=>H({enabled:j.target.checked})}),d.schedule.enabled]}),E&&a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:E})]})}),a.jsx(ln,{open:F!==null,title:d.schedule.deleteTitle,busy:S,onClose:()=>V(null),onConfirm:()=>{I()},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:F!==null?d.schedule.deleteConfirm(F):""})}),v&&a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:v})]})}const Jy="auto",SG=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,No={connectTimeoutMs:1e4,timeoutMs:12e4,maxOutputLength:16e3},jG=new Set(["transport","command","args","env","cwd","url","headers","connectTimeoutMs","timeoutMs","maxOutputLength","permission"]);function CG(){return{name:"",transport:"http",command:"",argsText:"",envText:"",cwd:"",url:"",headersText:"",connectTimeoutMs:String(No.connectTimeoutMs),timeoutMs:String(No.timeoutMs),maxOutputLength:String(No.maxOutputLength),permission:Jy,extras:{}}}function uj(e,t){return e===null||typeof e!="object"?"":Object.entries(e).map(([n,s])=>`${n}${t}${String(s)}`).join(`
184
- `)}function DM(e){const t=e.config;return t.transport==="http"||t.transport==="sse"||t.transport==="stdio"?t.transport:typeof t.url=="string"?"http":"stdio"}function $M(e){const t=e.config.permission;return t==="r"||t==="rw"||t==="auto"?t:Jy}function NG(e){const t=e.config,n=DM(e),s={};for(const[o,c]of Object.entries(t))jG.has(o)||(s[o]=c);return{name:e.name,transport:n,command:typeof t.command=="string"?t.command:"",argsText:Array.isArray(t.args)?t.args.map(o=>String(o)).join(`
185
- `):"",envText:uj(t.env,"="),cwd:typeof t.cwd=="string"?t.cwd:"",url:typeof t.url=="string"?t.url:"",headersText:uj(t.headers,": "),connectTimeoutMs:String(typeof t.connectTimeoutMs=="number"?t.connectTimeoutMs:No.connectTimeoutMs),timeoutMs:String(typeof t.timeoutMs=="number"?t.timeoutMs:No.timeoutMs),maxOutputLength:String(typeof t.maxOutputLength=="number"?t.maxOutputLength:No.maxOutputLength),permission:$M(e),extras:s}}function dj(e,t){const n={},s=e.split(`
186
- `);for(const[o,c]of s.entries()){const u=c.trim();if(u==="")continue;const f=u.indexOf(t),p=f>=0?u.slice(0,f).trim():"";if(f<0||p==="")return{ok:!1,line:o+1};n[p]=u.slice(f+1).trim()}return{ok:!0,map:n}}function TG(e){const t=e.trim();if(t==="")return{ok:!0,value:void 0};const n=Number(t);return!Number.isInteger(n)||n<=0?{ok:!1,error:{code:"number"}}:{ok:!0,value:n}}function mj(e){const t={},n=e.name.trim();n===""?t.name={code:"required"}:SG.test(n)||(t.name={code:"name_charset"});const s={...e.extras,transport:e.transport};if(e.transport==="stdio"){const o=e.command.trim();o===""?t.command={code:"required"}:s.command=o;const c=e.argsText.split(`
187
- `).map(p=>p.trim()).filter(p=>p!=="");c.length>0&&(s.args=c);const u=dj(e.envText,"=");u.ok?Object.keys(u.map).length>0&&(s.env=u.map):t.env={code:"kv_line",line:u.line};const f=e.cwd.trim();f!==""&&(s.cwd=f)}else{const o=e.url.trim();if(o==="")t.url={code:"required"};else try{const u=new URL(o);u.protocol!=="http:"&&u.protocol!=="https:"?t.url={code:"url_invalid"}:s.url=o}catch{t.url={code:"url_invalid"}}const c=dj(e.headersText,":");c.ok?Object.keys(c.map).length>0&&(s.headers=c.map):t.headers={code:"kv_line",line:c.line}}for(const o of["connectTimeoutMs","timeoutMs","maxOutputLength"]){const c=TG(e[o]);c.ok?c.value!==void 0&&c.value!==No[o]&&(s[o]=c.value):t[o]=c.error}return e.permission!==Jy&&(s.permission=e.permission),Object.keys(t).length>0?{ok:!1,errors:t}:{ok:!0,server:{name:n,config:s}}}function Ti(e){if(e)switch(e.code){case"required":return d.common.requiredField;case"name_charset":return d.agent.mcpNameInvalid;case"url_invalid":return d.agent.mcpUrlInvalid;case"kv_line":return d.agent.mcpLineInvalid(e.line??1);case"number":return d.agent.mcpNumberInvalid;case"duplicate":return d.agent.mcpDuplicateName}}function MG(e){const t=e.config;if(typeof t.url=="string")return t.url;const n=typeof t.command=="string"?t.command:"",s=Array.isArray(t.args)?t.args.map(o=>String(o)).join(" "):"";return s?`${n} ${s}`:n}function EG({result:e}){return e===void 0?null:e==="pending"?a.jsx("span",{className:"text-[11px] whitespace-nowrap text-gray-400",children:d.agent.mcpTestPending}):e.ok?a.jsx("span",{className:`text-[11px] font-medium whitespace-nowrap ${sn.success}`,children:d.agent.mcpTestBadge(e.tools?.length??0,e.latencyMs)}):a.jsx("span",{title:e.error,className:`text-[11px] font-medium whitespace-nowrap ${sn.danger}`,children:d.agent.mcpTestBadgeFail})}function AG({agentId:e,initial:t}){const{currentProject:n}=en(),s=n?.projectId??null,[o,c]=y.useState(t),[u,f]=y.useState(!1),[p,h]=y.useState(null),[x,g]=y.useState(null),[v,w]=y.useState({}),[S,C]=y.useState(null),[N,T]=y.useState(null),[_,R]=y.useState(!1),[D,z]=y.useState(!1),[E,L]=y.useState(!1),[F,V]=y.useState(new Map),P=[{value:"http",label:"http"},{value:"stdio",label:"stdio"},{value:"sse",label:"sse"}],B={http:d.agent.mcpTransportHttp,stdio:d.agent.mcpTransportStdio,sse:d.agent.mcpTransportSse},Y=[{value:"auto",triggerLabel:d.agent.mcpPermissionAuto,label:d.agent.mcpPermissionAutoLabel,description:d.agent.mcpPermissionAutoDescription},{value:"r",triggerLabel:"r",label:d.agent.permissionReadLabel,description:d.agent.mcpPermissionReadDescription},{value:"rw",triggerLabel:"rw",label:d.agent.permissionReadWriteLabel,description:d.agent.mcpPermissionReadWriteDescription}],q=async U=>{if(!s||!e)return d.common.unknownError;f(!0);try{const ee=await To(s,e,{config:{mcpServers:U}});return c(ee.config.mcpServers),yt(d.common.saved),null}catch(ee){return Ae(ee)}finally{f(!1)}},K=()=>{h(CG()),g(null),w({}),C(null)},H=U=>{const ee=o[U];ee&&(h(NG(ee)),g(U),w({}),C(null))},$=()=>{h(null),g(null)},X=U=>{h(ee=>ee&&{...ee,...U}),w({}),C(null)},le=async()=>{if(!p||!s)return;const U=mj(p);if(!U.ok){w(U.errors);return}R(!0);try{const ee=await F1(s,e,U.server);ee.ok?yt(d.agent.mcpTestOk(ee.tools?.length??0,ee.latencyMs)):Be(d.agent.mcpTestFail(ee.error??d.common.unknownError))}catch(ee){Be(d.agent.mcpTestFail(Ae(ee)))}finally{R(!1)}},ie=async()=>{if(s){L(!0);try{for(const U of o){V(re=>new Map(re).set(U.name,"pending"));let ee;try{ee=await F1(s,e,U)}catch(re){ee={ok:!1,error:Ae(re)}}V(re=>new Map(re).set(U.name,ee))}}finally{L(!1)}}},I=async()=>{if(!p)return;const U=mj(p);if(!U.ok){w(U.errors);return}if(o.some((be,ye)=>ye!==x&&be.name===U.server.name)){w({name:{code:"duplicate"}});return}const re=x===null?[...o,U.server]:o.map((be,ye)=>ye===x?U.server:be),ke=await q(re);if(ke!==null){C(ke);return}$()},A=async()=>{if(N===null)return;const U=await q(o.filter((ee,re)=>re!==N));U!==null&&Be(U),T(null)};if(!s)return null;const Q=p!==null&&(p.transport==="stdio"?p.command.trim()!=="":p.url.trim()!==""),j=F.size>0;return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("p",{className:"flex items-center gap-1.5 text-xs font-medium text-gray-500",children:[d.agent.mcpServers,a.jsx(ba,{label:d.agent.mcpServers,children:d.agent.mcpDesc})]}),o.length===0?a.jsx(Ff,{children:d.agent.mcpEmpty}):a.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:a.jsxs("table",{className:"w-full min-w-[520px] text-left text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("th",{className:"px-3 py-2.5",children:d.agent.mcpName}),a.jsx("th",{className:"px-3 py-2.5",children:d.agent.mcpTransport}),a.jsx("th",{className:"px-3 py-2.5",children:d.agent.mcpPermission}),a.jsx("th",{className:"px-3 py-2.5",children:d.agent.mcpTarget}),j&&a.jsx("th",{className:"px-3 py-2.5"}),a.jsx("th",{className:"px-3 py-1 text-right font-normal whitespace-nowrap",children:a.jsx(ge,{size:"sm",variant:"ghost",disabled:u||E,onClick:()=>z(!0),children:E?d.agent.mcpTestPending:d.agent.mcpTest})})]})}),a.jsx("tbody",{children:o.map((U,ee)=>a.jsxs("tr",{className:"border-b border-gray-100 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[a.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:U.name}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:DM(U)}),a.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:$M(U)}),a.jsx("td",{className:"max-w-[360px] truncate px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:MG(U)}),j&&a.jsx("td",{className:"px-3 py-2 text-right",children:a.jsx(EG,{result:F.get(U.name)})}),a.jsxs("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[a.jsx(ge,{size:"sm",variant:"ghost",disabled:u,onClick:()=>H(ee),children:d.common.edit}),a.jsx(ge,{size:"sm",variant:"ghost",disabled:u,onClick:()=>T(ee),children:d.agent.mcpRemove})]})]},U.name))})]})}),a.jsx(ge,{size:"sm",variant:"primary",disabled:u,onClick:K,children:d.agent.mcpAdd}),a.jsx(Yt,{open:p!==null,title:x===null?d.agent.mcpAdd:d.agent.mcpEditTitle,onClose:$,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:$,children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:u,onClick:()=>{I()},children:d.common.save})]}),children:p&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(ws,{options:P,value:p.transport,onChange:U=>X({transport:U})}),a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:B[p.transport]})]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:a.jsx(ge,{size:"sm",disabled:_||u||!Q,onClick:()=>{le()},children:_?d.agent.mcpTesting:d.agent.mcpTest})}),a.jsx(at,{size:"sm",label:d.agent.mcpName,required:!0,hint:d.agent.mcpNameHint,error:Ti(v.name),value:p.name,onChange:U=>X({name:U.target.value}),className:"font-mono",placeholder:"filesystem",autoComplete:"off"}),p.transport==="stdio"?a.jsxs(a.Fragment,{children:[a.jsx(at,{size:"sm",label:d.agent.mcpCommand,required:!0,error:Ti(v.command),value:p.command,onChange:U=>X({command:U.target.value}),className:"font-mono",placeholder:"npx",autoComplete:"off"}),a.jsx(ir,{size:"sm",mono:!0,label:d.agent.mcpArgs,hint:d.agent.mcpArgsHint,rows:3,value:p.argsText,onChange:U=>X({argsText:U.target.value}),placeholder:`-y
188
- @modelcontextprotocol/server-filesystem
189
- .`}),a.jsx(ir,{size:"sm",mono:!0,label:d.agent.mcpEnv,hint:d.agent.mcpEnvHint,error:Ti(v.env),rows:2,value:p.envText,onChange:U=>X({envText:U.target.value}),placeholder:"API_TOKEN=..."}),a.jsx(at,{size:"sm",label:d.agent.mcpCwd,hint:d.agent.mcpCwdHint,value:p.cwd,onChange:U=>X({cwd:U.target.value}),className:"font-mono",autoComplete:"off"})]}):a.jsxs(a.Fragment,{children:[a.jsx(at,{size:"sm",label:d.agent.mcpUrl,required:!0,error:Ti(v.url),value:p.url,onChange:U=>X({url:U.target.value}),className:"font-mono",placeholder:"https://example.com/mcp",autoComplete:"off"}),a.jsx(ir,{size:"sm",mono:!0,label:d.agent.mcpHeaders,hint:d.agent.mcpHeadersHint,error:Ti(v.headers),rows:2,value:p.headersText,onChange:U=>X({headersText:U.target.value}),placeholder:"Authorization: Bearer ..."})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(Sf,{mono:!0,size:"sm",fullWidth:!0,label:d.agent.mcpPermission,options:Y,value:p.permission,onChange:U=>X({permission:U})}),a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:d.agent.mcpPermissionHint})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[a.jsx(at,{size:"sm",label:d.agent.mcpConnectTimeout,error:Ti(v.connectTimeoutMs),value:p.connectTimeoutMs,inputMode:"numeric",onChange:U=>X({connectTimeoutMs:U.target.value}),className:"font-mono",autoComplete:"off"}),a.jsx(at,{size:"sm",label:d.agent.toolTimeout,error:Ti(v.timeoutMs),value:p.timeoutMs,inputMode:"numeric",onChange:U=>X({timeoutMs:U.target.value}),className:"font-mono",autoComplete:"off"}),a.jsx(at,{size:"sm",label:d.agent.toolMaxOutput,error:Ti(v.maxOutputLength),value:p.maxOutputLength,inputMode:"numeric",onChange:U=>X({maxOutputLength:U.target.value}),className:"font-mono",autoComplete:"off"})]}),a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:d.agent.mcpBudgetsHint}),S&&a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:S})]})}),a.jsx(Yt,{open:D,title:d.agent.mcpTest,onClose:()=>z(!1),footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:()=>z(!1),children:d.common.cancel}),a.jsx(ge,{variant:"primary",onClick:()=>{z(!1),ie()},children:d.agent.mcpTestAllStart})]}),children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.agent.mcpTestAllConfirm(o.length)})}),a.jsx(ln,{open:N!==null,title:d.agent.mcpDeleteTitle,busy:u,onClose:()=>T(null),onConfirm:()=>{A()},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:N!==null?d.agent.mcpDeleteConfirm(o[N]?.name??""):""})})]})}function _G(e){return e.filter(([t])=>t!=="").map(([t,n])=>({value:t,triggerLabel:t,label:t,description:n}))}function ru(e){const t=e.trim();if(!t)return;const n=Number(t);return Number.isFinite(n)?n:void 0}function go(e){return e===void 0?"":String(e)}function RG(e,t,n){return t.some(s=>s.key===e)?e:n}function IG(){const e=[{key:"overview",label:d.agent.tabOverview},{key:"prompt",label:d.agent.tabPrompt},{key:"runtime",label:d.agent.tabRuntime},{key:"tools",label:d.agent.tabTools},{key:"skills",label:d.agent.tabSkills},{key:"memory",label:d.agent.tabMemory},{key:"vault",label:d.agent.tabVault},{key:"schedules",label:d.agent.tabSchedules}],t=yr(),s=MC().agentId??"";Li(d.agent.settings);const{currentProject:o,reloadAgents:c}=en(),u=o?.projectId??null,[f,p]=y.useState(null),[h,x]=Ox(),[g,v]=y.useState(()=>RG(h.get("tab"),e,"overview")),w=y.useCallback(E=>{v(E),x(L=>{const F=new URLSearchParams(L);return F.set("tab",E),F},{replace:!0})},[x]),[S,C]=y.useState(null),N=y.useCallback(E=>{!u||!s||(E?.keepStale||p(null),C(null),Ao(u,s).then(p).catch(L=>C(Ae(L))))},[u,s]);y.useEffect(()=>{N()},[N]);const T=y.useCallback(()=>N({keepStale:!0}),[N]),_=y.useCallback(E=>{yt(d.agent.importDone(E)),N(),c()},[N,c]),R=y.useCallback(()=>{yt(d.agent.resetConfigDone),N(),c()},[N,c]),D=y.useCallback(()=>{N({keepStale:!0}),c()},[N,c]),z=y.useCallback(async E=>{if(!(!u||!s))try{const L=await To(u,s,E);p(L),yt(d.common.saved),(E.config?.name!==void 0||E.config?.description!==void 0||E.config?.toolsBuiltin!==void 0)&&c()}catch(L){Be(Ae(L))}},[u,s,c]);return u?S&&!f?a.jsx("p",{className:"p-6 text-sm text-red-600 dark:text-red-400",children:S}):f?a.jsx("div",{className:"no-scrollbar relative h-full overflow-y-auto p-4 md:p-6",children:a.jsxs("div",{className:"mx-auto max-w-3xl",children:[a.jsxs(ge,{variant:"ghost",size:"sm",onClick:()=>t("/agents"),className:"-ml-2 mb-3 text-gray-500 dark:text-gray-400",children:[a.jsx(Oe,{d:"M15 18l-6-6 6-6M9 12h12",size:Ye.rowLead}),d.agent.backToList]}),a.jsx("h1",{className:"mb-1 text-xl font-semibold",children:f.config.name??s}),a.jsx("p",{className:"mb-4 font-mono text-xs text-gray-400",children:s}),a.jsx(LV,{items:e.map(E=>E.key==="overview"&&f.config.kernelOutdated?{...E,badge:d.agent.kernelOutdatedHint}:E),active:g,onChange:w}),a.jsxs("div",{className:"py-4",children:[g==="overview"&&a.jsx(OG,{data:f,agentId:s,onSave:z,onImported:_,onConfigReset:R,onKernelUpdated:D}),g==="prompt"&&a.jsx(DG,{data:f,onSave:z}),g==="memory"&&a.jsx(pG,{agentId:s,onConfigChanged:T}),g==="runtime"&&a.jsx($G,{data:f,onSave:z}),g==="tools"&&a.jsxs("div",{className:"space-y-8",children:[a.jsx(UG,{data:f,onSave:z}),a.jsx(AG,{agentId:s,initial:f.config.mcpServers})]}),g==="skills"&&a.jsx(FV,{agentId:s,onConfigChanged:T}),g==="vault"&&a.jsx(xG,{agentId:s,onConfigChanged:T}),g==="schedules"&&a.jsx(wG,{agentId:s,onConfigChanged:T})]})]})}):a.jsxs("div",{className:"space-y-3 p-6",children:[a.jsx(on,{className:"h-6 w-64"}),a.jsx(on,{className:"h-32 w-full"})]}):null}const LG="M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10";function OG({data:e,agentId:t,onSave:n,onImported:s,onConfigReset:o,onKernelUpdated:c}){const{currentProject:u}=en(),f=u?.projectId??null,p=u?.role==="owner",[h,x]=y.useState(e.config.name??""),[g,v]=y.useState(e.config.description??""),[w,S]=y.useState(!1),[C,N]=y.useState(null),[T,_]=y.useState(null),[R,D]=y.useState(!1),[z,E]=y.useState(!1),[L,F]=y.useState(!1),[V,P]=y.useState(!1),[B,Y]=y.useState(null),{requestSave:q,element:K}=ql(),H=async()=>{if(f){E(!0);try{await qE(f,t),D(!1),o()}catch(I){Be(Ae(I))}finally{E(!1)}}},$=async()=>{if(f){P(!0);try{const I=await VE(f,t);F(!1),Y(I),yt(d.agent.kernelUpdateDone(I.kernelVersion,I.advanced.length)),c()}catch(I){Be(Ae(I))}finally{P(!1)}}},X=()=>{const I={};if(h.trim()!==(e.config.name??"")&&(I.name=h.trim()),g.trim()!==(e.config.description??"")&&(I.description=g.trim()),Object.keys(I).length===0){wr(d.common.noChangesToSave);return}q(()=>{n({config:I})})},le=async(I,A)=>{if(f){S(!0),N(null);try{const Q=await OA(f,t,{dataBase64:I,...A?{confirm:!0}:{}});_(null),s(Q.version)}catch(Q){Q instanceof xr&&Q.status===409&&Q.code==="version_conflict"?_(I):(_(null),N(Ae(Q)))}finally{S(!1)}}},ie=I=>{const A=I.target.files?.[0];I.target.value="",A&&(N(null),OM(A).then(Q=>{le(Q,!1)},()=>N(d.common.unknownError)))};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(at,{size:"sm",label:d.common.name,value:h,onChange:I=>x(I.target.value)}),a.jsx(ir,{label:d.agent.description,size:"sm",rows:3,value:g,onChange:I=>v(I.target.value)}),a.jsx(ge,{size:"sm",variant:"primary",onClick:X,children:d.common.save}),K,a.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[a.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-medium",children:[d.agent.stateTitle,a.jsx(ba,{label:d.agent.stateTitle,children:d.agent.transferDesc})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[f&&a.jsx("a",{href:LA(f,t),download:!0,className:px,children:d.agent.exportSnapshot}),p&&a.jsxs("label",{className:`${px} ${w?"pointer-events-none opacity-60":""}`,children:[a.jsx(Xl,{accept:LM,disabled:w,onChange:ie}),w?d.agent.importing:d.agent.importSnapshot]})]})]}),a.jsxs("div",{className:"mt-3 space-y-2.5",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.agent.stateVersion}),a.jsxs("p",{className:"mt-0.5 font-mono text-sm font-semibold",children:["v",e.config.version]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:d.agent.stateDir}),a.jsxs("div",{className:"flex items-start gap-1.5",children:[a.jsx("span",{title:e.stateDir,className:"min-w-0 flex-1 break-all font-mono text-xs leading-5",children:e.stateDir}),a.jsx(Wu,{text:e.stateDir,label:d.agent.copyStateDir,className:PN})]})]})]}),C&&a.jsx("p",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:C})]}),a.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[a.jsx("p",{className:"text-sm font-medium",children:d.agent.kernelTitle}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsxs(ge,{size:"sm",className:"relative",disabled:V||!e.config.kernelOutdated,onClick:()=>F(!0),children:[d.agent.kernelUpdateAction,e.config.kernelOutdated&&a.jsxs(a.Fragment,{children:[a.jsx(Mo,{size:"inline",position:"right-0.5 top-0.5 -translate-y-1/2 translate-x-1/2"}),a.jsxs("span",{className:"sr-only",children:[" · ",d.agent.kernelOutdatedHint]})]})]}),a.jsx(ge,{size:"sm",variant:"danger",disabled:z,onClick:()=>D(!0),children:d.agent.resetConfigAction})]})]}),a.jsx("p",{className:"mt-2.5 flex flex-wrap items-baseline gap-x-1.5 gap-y-0.5 text-sm",children:e.config.kernelOutdated?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.agent.kernelCurrent}),a.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelVersion??d.agent.kernelLegacy}),a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",d.agent.kernelLatest]}),a.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelLatest}),a.jsx("span",{role:"img",title:d.agent.kernelOutdatedHint,"aria-label":d.agent.kernelOutdatedHint,className:"self-center text-gray-500 dark:text-gray-400",children:a.jsx(Oe,{d:LG,size:12})})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelVersion}),a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",d.agent.kernelUpToDate]})]})}),B!==null&&B.kept.length>0&&a.jsxs("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:[d.agent.kernelUpdateKeptIntro,B.kept.map(hG).join(d.agent.kernelListSeparator)]})]}),a.jsx(ln,{open:T!==null,title:d.agent.importConflictTitle,busy:w,onClose:()=>_(null),onConfirm:()=>{T!==null&&le(T,!0)},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.agent.importConflictBody})}),a.jsx(ln,{open:L,title:d.agent.kernelUpdateTitle,busy:V,tone:"primary",onClose:()=>F(!1),onConfirm:()=>{$()},confirmLabel:d.agent.kernelUpdateAction,children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.agent.kernelUpdateConfirmBody})}),a.jsx(ln,{open:R,title:d.agent.resetConfigTitle,busy:z,onClose:()=>D(!1),onConfirm:()=>{H()},confirmLabel:d.agent.resetConfigAction,children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.agent.resetConfigConfirmBody})})]})}function DG({data:e,onSave:t}){const[n,s]=y.useState(e.agentsMd),[o,c]=y.useState(e.config.systemPrompt),u=y.useRef(null),{requestSave:f,element:p}=ql(),h=()=>{const g={};if(n!==e.agentsMd&&(g.agentsMd=n),o!==e.config.systemPrompt&&(g.config={systemPrompt:o}),g.agentsMd===void 0&&g.config===void 0){wr(d.common.noChangesToSave);return}f(()=>{t(g)})},x=g=>{const v=u.current;if(v&&(v.focus(),document.execCommand?.("insertText",!1,g)))return;const w=v?v.selectionStart:o.length,S=v?v.selectionEnd:o.length;c(o.slice(0,w)+g+o.slice(S)),requestAnimationFrame(()=>{if(!v)return;v.focus();const C=w+g.length;v.setSelectionRange(C,C)})};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(ir,{label:d.agent.agentsMd,mono:!0,size:"sm",rows:14,value:n,onChange:g=>s(g.target.value)}),a.jsx(ir,{ref:u,label:d.agent.systemPrompt,mono:!0,size:"sm",rows:12,value:o,onChange:g=>c(g.target.value)}),a.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:d.agent.placeholdersTitle}),a.jsx("ul",{className:"space-y-1",children:d.agent.placeholders.map(([g,v])=>a.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[a.jsx("button",{type:"button",onClick:()=>x(g),title:d.agent.insertPlaceholder,className:"shrink-0 rounded border border-gray-200 bg-white px-1.5 py-0.5 font-mono font-semibold text-gray-800 transition-colors duration-150 hover:border-gray-400 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:border-gray-500 dark:hover:bg-gray-700",children:g}),a.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:v})]},g))})]}),a.jsx(ge,{size:"sm",variant:"primary",onClick:h,children:d.common.save}),p]})}function $G({data:e,onSave:t}){const n=e.config,[s,o]=y.useState(go(n.maxTurns)),[c,u]=y.useState(go(n.model?.maxTokens)),[f,p]=y.useState(n.model?.thinkingLevel??""),[h,x]=y.useState(go(n.model?.timeoutMs)),[g,v]=y.useState(go(n.compaction?.maxContextLength)),[w,S]=y.useState(go(n.compaction?.maxSessionTurns)),[C,N]=y.useState(n.compaction?.mode??""),[T,_]=y.useState(n.compaction?.prompt??""),[R,D]=y.useState({}),z=()=>D(B=>B.maxTurns||B.timeoutMs?{}:B),{requestSave:E,element:L}=ql(),F=()=>{D({});const B={},Y=ru(s);if(Y!==void 0&&Y!==n.maxTurns){if(Y<=0&&Y!==-1){D({maxTurns:d.agent.maxTurnsInvalid});return}B.maxTurns=Y}const q={},K=ru(c);K!==void 0&&K!==n.model?.maxTokens&&(q.maxTokens=K),f&&f!==(n.model?.thinkingLevel??"")&&(q.thinkingLevel=f);const H=ru(h);if(H!==void 0&&H!==n.model?.timeoutMs){if(H<=0&&H!==-1){D({timeoutMs:d.agent.timeoutInvalid});return}q.timeoutMs=H}Object.keys(q).length>0&&(B.model=q);const $={},X=ru(g);X!==void 0&&X!==n.compaction?.maxContextLength&&($.maxContextLength=X);const le=ru(w);if(le!==void 0&&le!==n.compaction?.maxSessionTurns&&($.maxSessionTurns=le),C&&C!==(n.compaction?.mode??"")&&($.mode=C),T!==(n.compaction?.prompt??"")&&($.prompt=T),Object.keys($).length>0&&(B.compaction=$),Object.keys(B).length===0){wr(d.common.noChangesToSave);return}E(()=>{t({config:B})})},V=mz(d.agent.thinkingLevelOptions,d.agent.thinkingLevelNoneKept,n.model?.thinkingLevel),P=_G(d.agent.compactionModeOptions);return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("div",{className:"p-3",children:a.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[a.jsx(at,{label:d.agent.maxTurns,size:"sm",value:s,error:R.maxTurns,onChange:B=>{o(B.target.value),z()},inputMode:"numeric",className:"font-mono"}),a.jsx(at,{label:d.agent.maxTokens,size:"sm",value:c,onChange:B=>u(B.target.value),inputMode:"numeric",className:"font-mono"}),a.jsx(Sf,{label:d.agent.thinkingLevel,fullWidth:!0,size:"sm",placeholder:d.agent.defaultValue,value:f,onChange:p,options:V}),a.jsx(at,{label:d.agent.timeoutMs,info:d.agent.timeoutMsHint,infoLabel:d.agent.timeoutMs,size:"sm",value:h,error:R.timeoutMs,onChange:B=>{x(B.target.value),z()},inputMode:"numeric",className:"font-mono"})]})}),a.jsx("div",{className:"border-t border-b border-gray-200 bg-gray-50/80 px-3 py-2 text-xs font-semibold text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:d.agent.compaction}),a.jsx("div",{className:"p-3",children:a.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:[a.jsx(at,{label:d.agent.maxContextLength,info:d.agent.maxContextLengthHint,infoLabel:d.agent.maxContextLength,size:"sm",value:g,onChange:B=>v(B.target.value),inputMode:"numeric",className:"font-mono"}),a.jsx(at,{label:d.agent.maxSessionTurns,info:d.agent.maxSessionTurnsHint,infoLabel:d.agent.maxSessionTurns,size:"sm",value:w,onChange:B=>S(B.target.value),inputMode:"numeric",className:"font-mono"}),a.jsx(Sf,{label:d.agent.compactionMode,fullWidth:!0,size:"sm",placeholder:d.agent.defaultValue,value:C,onChange:N,options:P})]})}),a.jsx("div",{className:"border-t border-b border-gray-200 bg-gray-50/80 px-3 py-2 text-xs font-semibold text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:d.agent.compactionPrompt}),a.jsx("div",{className:"p-3",children:a.jsx(ir,{"aria-label":d.agent.compactionPrompt,mono:!0,size:"sm",rows:4,value:T,onChange:B=>_(B.target.value)})})]}),a.jsx(ge,{size:"sm",variant:"primary",onClick:F,children:d.common.save}),L]})}function UG({data:e,onSave:t}){const n=[{value:"r",triggerLabel:"r",label:d.agent.permissionReadLabel,description:d.agent.permissionReadDescription},{value:"rw",triggerLabel:"rw",label:d.agent.permissionReadWriteLabel,description:d.agent.permissionReadWriteDescription}],[s,o]=y.useState(()=>e.config.toolsBuiltin.map(v=>({base:{...v},timeoutMs:go(v.timeoutMs),maxOutputLength:go(v.maxOutputLength)}))),[c,u]=y.useState({}),{requestSave:f,element:p}=ql(),h=(v,w)=>{o(S=>S.map((C,N)=>N===v?{...C,...w}:C)),u(S=>{const C=`${v}-timeoutMs`,N=`${v}-maxOutputLength`;if(!S[C]&&!S[N])return S;const T={...S};return delete T[C],delete T[N],T})},x=()=>{const v={},w=[];for(const[N,T]of s.entries()){const _={...T.base};delete _.timeoutMs,delete _.maxOutputLength;const R=T.timeoutMs.trim();if(R){const E=Number(R);!Number.isInteger(E)||E<=0&&E!==-1?v[`${N}-timeoutMs`]=d.agent.toolFieldInvalid(T.base.name,"timeoutMs"):_.timeoutMs=E}const D=T.maxOutputLength.trim();if(D){const E=Number(D);!Number.isInteger(E)||E<=0&&E!==-1?v[`${N}-maxOutputLength`]=d.agent.toolFieldInvalid(T.base.name,"maxOutputLength"):_.maxOutputLength=E}const z=e.config.toolsBuiltin[N];_.call_description===!0&&z?.call_description===void 0&&delete _.call_description,w.push(_)}if(Object.keys(v).length>0){u(v);return}u({});const S=e.config.toolsBuiltin;if(!(w.length!==S.length||w.some((N,T)=>{const _=S[T];return N.permission!==_.permission||N.timeoutMs!==_.timeoutMs||N.maxOutputLength!==_.maxOutputLength||N.call_description!==_.call_description}))){wr(d.common.noChangesToSave);return}f(()=>{t({config:{toolsBuiltin:w}})})},g=v=>{const w=v.parameters?.properties;return w!=null&&w.description!==void 0};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:a.jsxs("table",{className:"w-full min-w-[640px] text-left text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("th",{className:"px-3 py-2",children:d.common.name}),a.jsx("th",{className:"px-3 py-2",children:d.agent.toolPermission}),a.jsx("th",{className:"px-3 py-2",children:d.agent.toolTimeout}),a.jsx("th",{className:"px-3 py-2",children:d.agent.toolMaxOutput}),a.jsx("th",{className:"px-3 py-2",children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[d.agent.toolCallDescription,a.jsx(ba,{label:d.agent.toolCallDescription,children:d.agent.callDescriptionHint})]})})]})}),a.jsx("tbody",{children:s.map((v,w)=>a.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800/60",children:[a.jsx("td",{className:"px-3 py-2 align-top font-mono text-xs",children:v.base.name}),a.jsx("td",{className:"px-3 py-2 align-top",children:a.jsx(Sf,{mono:!0,size:"sm","aria-label":d.agent.toolPermission,placeholder:d.agent.defaultValue,options:n,value:v.base.permission,onChange:S=>h(w,{base:{...v.base,permission:S}})})}),a.jsx("td",{className:"px-3 py-2 align-top",children:a.jsx(at,{size:"sm",value:v.timeoutMs,error:c[`${w}-timeoutMs`],inputMode:"numeric",className:"font-mono",onChange:S=>h(w,{timeoutMs:S.target.value})})}),a.jsx("td",{className:"px-3 py-2 align-top",children:a.jsx(at,{size:"sm",value:v.maxOutputLength,error:c[`${w}-maxOutputLength`],inputMode:"numeric",className:"font-mono",onChange:S=>h(w,{maxOutputLength:S.target.value})})}),a.jsx("td",{className:"px-3 py-2 align-top",children:g(v.base)?a.jsx(js,{checked:v.base.call_description!==!1,onChange:S=>h(w,{base:{...v.base,call_description:S}}),"aria-label":`${v.base.name} ${d.agent.toolCallDescription}`}):a.jsx("span",{className:"text-xs text-gray-300 dark:text-gray-600",children:"—"})})]},v.base.name))})]})}),a.jsx(ge,{size:"sm",variant:"primary",onClick:x,children:d.common.save}),p]})}const PG="M22 2 11 13M22 2 15 22 11 13 2 9 22 2",zG="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3",BG="M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10";function HG(e,t,n,s){return e.filter(o=>{const c=t.get(o)?.get(n);return c!==void 0&&c<s})}function FG(){Li(d.nav.skills);const e=yr(),{locale:t}=Dr(),n=mn().user?.userId??null,{currentProject:s,agents:o,currentAgent:c,setCurrentAgentId:u}=en(),f=s?.projectId??null,[p,h]=y.useState(null),[x,g]=y.useState(null),[v,w]=y.useState(new Map),[S,C]=y.useState(new Set);y.useEffect(()=>{let E=!1;return g(null),oC().then(L=>{E||h(L.groups)}).catch(L=>{E||g(Ae(L))}),()=>{E=!0}},[]);const N=o.map(E=>E.agentId).join(",");y.useEffect(()=>{if(w(new Map),!f||N==="")return;let E=!1;const L=N.split(",");return Promise.all(L.map(async F=>{try{const V=await Bu(f,F);return[F,new Map(V.skills.map(P=>[P.name,P.version]))]}catch{return[F,new Map]}})).then(F=>{E||w(V=>{const P=new Map(F);for(const[B,Y]of V)P.set(B,Y);return P})}),()=>{E=!0}},[f,N]);const T=(E,L,F)=>w(V=>{const P=new Map(V),B=new Map(P.get(E)??[]);return F!==void 0?B.set(L,F):B.delete(L),P.set(E,B),P}),_=(E,L)=>w(F=>new Map(F).set(E,new Map(L.map(V=>[V.name,V.version])))),R=async(E,L,F,V)=>{if(!f)return;const P=v.get(E)?.get(L);T(E,L,F?V:void 0);const B=o.find(q=>q.agentId===E),Y=B?_n(B):E;try{if(F){const q=await K1(f,E,[L]);_(E,q.skills),yt(d.skills.installedToast(L,Y))}else await lC(f,E,L),yt(d.skills.uninstalledToast(L,Y))}catch(q){if(!F&&q instanceof xr&&q.status===404)return;T(E,L,P),Be(Ae(q))}},D=async(E,L)=>{if(!f||L.length===0)return;const V=(await Promise.allSettled(L.map(async P=>{const B=await K1(f,P,[E]);_(P,B.skills)}))).find(P=>P.status==="rejected");V?Be(Ae(V.reason)):yt(d.skills.updatedToast(E,L.length))},z=E=>{const L=c?.agentId;if(L){if(n&&f){Yl(n,f);const F=ks(n,f);Qs(F,{...$i(F),agentId:L,text:d.skills.quickInvokeText(E),skills:[E],handoffAgentId:void 0})}u(L),e(`/chat/${ya}`,{state:{agentId:L}})}};return a.jsx("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:a.jsxs("div",{className:"mx-auto max-w-5xl",children:[a.jsxs("h1",{className:"flex items-center gap-1.5 text-xl font-semibold",children:[d.skills.pageTitle,a.jsx(ba,{label:d.skills.pageTitle,children:d.skills.pageDesc})]}),x?a.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[a.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:x}),a.jsx(ge,{size:"sm",onClick:()=>window.location.reload(),children:d.common.retry})]}):p===null?a.jsx("div",{className:"mt-6 grid grid-cols-1 gap-2.5 sm:grid-cols-2",children:Array.from({length:4},(E,L)=>a.jsxs(SN,{className:"p-4",children:[a.jsx(on,{className:"h-4 w-32"}),a.jsx(on,{className:"mt-2 h-4 w-3/4"}),a.jsx(on,{className:"mt-3 h-6 w-36"})]},L))}):a.jsx("div",{className:"mt-6 space-y-3",children:p.map(E=>{const L=!S.has(E.id);return a.jsxs("section",{className:"overflow-hidden rounded-md bg-white dark:bg-gray-900",children:[a.jsxs("button",{type:"button","aria-expanded":L,onClick:()=>C(F=>{const V=new Set(F);return V.has(E.id)?V.delete(E.id):V.add(E.id),V}),className:"flex w-full items-center gap-2.5 bg-gray-50 px-3 py-2.5 text-left transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60",children:[a.jsx("span",{className:"min-w-0 truncate text-sm font-semibold",children:_P(t,E.title,E.titleZh)}),a.jsx("span",{className:"shrink-0 whitespace-nowrap font-mono text-xs text-gray-400",children:d.skills.skillCount(E.skills.length)}),a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx(Zn,{open:L,className:"text-gray-400"})]}),a.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${L?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:a.jsx("div",{className:"overflow-hidden",inert:!L,children:a.jsx("div",{className:`grid grid-cols-1 gap-2.5 p-2.5 transition-opacity duration-200 sm:grid-cols-2 ${L?"opacity-100":"opacity-0"}`,children:E.skills.map(F=>a.jsx(qG,{skill:F,installed:v,onQuickInvoke:z,onToggleInstall:R,onUpdateOutdated:D},F.name))})})})]},E.id)})})]})})}function qG({skill:e,installed:t,onQuickInvoke:n,onToggleInstall:s,onUpdateOutdated:o}){const{locale:c}=Dr(),{agents:u,currentAgent:f}=en(),[p,h]=y.useState(!1),[x,g]=y.useState(null),[v,w]=y.useState(!1),[S,C]=y.useState(null),N=async()=>{x&&(w(!0),await o(e.name,x),w(!1),g(null))},T=S!==null?u.find(V=>V.agentId===S):void 0,_=T?_n(T):void 0;let R=0;for(const V of t.values())V.has(e.name)&&(R+=1);const D=HG(u.map(V=>V.agentId),t,e.name,e.version),z=f!==null&&(t.get(f.agentId)?.has(e.name)??!1),E=Wl(c,e),L=e.description,F=[`v${e.version}`,e.updated?Al(e.updated,c):null,d.skills.usedByAgents(R)].filter(V=>V!==null).join(" · ");return a.jsxs("div",{className:"flex h-full items-center gap-3 rounded-md p-4 transition-colors hover:bg-gray-100/70 dark:hover:bg-gray-800/60",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${hT(e.name)}`,children:a.jsx(Yf,{icon:e.icon,size:20})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate font-mono text-[13px] font-semibold",title:e.name,children:e.name}),a.jsx("p",{className:"mt-0.5 truncate text-xs leading-5 text-gray-500 dark:text-gray-400",title:L,children:E})]})]}),a.jsx("p",{className:"mt-2.5 truncate text-[11px] text-gray-400 dark:text-gray-500",title:F,children:F})]}),a.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-1.5",children:[D.length>0&&a.jsx(ge,{size:"sm",variant:"secondary",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${d.skills.updateOutdated(D.length)} ${e.name}`,title:d.skills.updateOutdated(D.length),onClick:()=>g(D),children:a.jsx(Oe,{d:BG,size:Ye.iconButton})}),a.jsx(ge,{size:"sm",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${d.skills.quickInvoke} ${e.name}`,title:z?d.skills.quickInvoke:d.skills.quickInvokeNeedsInstall,disabled:!z,onClick:()=>n(e.name),children:a.jsx(Oe,{d:PG,size:Ye.iconButton})}),a.jsx(ge,{size:"sm",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${d.skills.manageInstall} ${e.name}`,title:d.skills.manageInstall,onClick:()=>h(!0),children:a.jsx(Oe,{d:zG,size:Ye.iconButton})})]}),p&&a.jsx(Yt,{open:!0,title:d.skills.manageInstallTitle(e.name),onClose:()=>h(!1),children:a.jsxs("div",{className:"space-y-0.5",children:[u.length===0&&a.jsx("p",{className:"py-1.5 text-xs text-gray-400",children:d.common.loading}),u.map(V=>a.jsx(VG,{agentId:V.agentId,name:_n(V),installed:t.get(V.agentId)?.has(e.name)??!1,outdated:D.includes(V.agentId),onToggle:P=>{P?s(V.agentId,e.name,!0,e.version):C(V.agentId)},onUpdate:()=>g([V.agentId])},V.agentId))]})}),x&&a.jsx(ln,{open:!0,title:d.skills.updateConfirmTitle(e.name),tone:"primary",confirmLabel:d.skills.updateAction,busy:v,onClose:()=>g(null),onConfirm:()=>{N()},children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.skills.updateConfirmWarning(e.name)}),a.jsx("ul",{className:"divide-y divide-gray-100 overflow-hidden rounded-md border border-gray-200 dark:divide-gray-800 dark:border-gray-800",children:x.map(V=>{const P=t.get(V)?.get(e.name),B=u.find(Y=>Y.agentId===V);return a.jsxs("li",{className:"flex items-center justify-between gap-3 px-3 py-1.5 text-xs",children:[a.jsx("span",{className:"min-w-0 truncate",children:B?_n(B):V}),a.jsxs("span",{className:"shrink-0 font-mono text-gray-500 dark:text-gray-400",children:["v",P??"?"," → v",e.version]})]},V)})})]})}),S!==null&&a.jsx(ln,{open:!0,title:d.skills.uninstallConfirmTitle(e.name),confirmLabel:d.skills.uninstall,onClose:()=>C(null),onConfirm:()=>{const V=S;C(null),s(V,e.name,!1,e.version)},children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.skills.uninstallConfirmBody(e.name,_??S)})})]})}function VG({agentId:e,name:t,installed:n,outdated:s,onToggle:o,onUpdate:c}){return a.jsxs("div",{className:"flex items-center gap-2 rounded-md px-1.5 py-1.5 transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800/60",children:[a.jsx(Ha,{id:e,name:t,size:22,className:"shrink-0 rounded"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",title:e,children:t}),n&&s&&a.jsx(ge,{size:"sm",variant:"secondary",className:"shrink-0","aria-label":`${d.skills.updateAction} ${e}`,onClick:c,children:d.skills.updateAction}),n?a.jsxs(ge,{size:"sm",variant:"ghost",className:"group shrink-0","aria-label":`${d.skills.uninstall} ${e}`,onClick:()=>o(!1),children:[a.jsx("span",{className:"group-hover:hidden",children:d.skills.installed}),a.jsx("span",{className:"hidden text-red-600 group-hover:inline dark:text-red-400",children:d.skills.uninstall})]}):a.jsx(ge,{size:"sm",className:"shrink-0","aria-label":`${d.skills.install} ${e}`,onClick:()=>o(!0),children:d.skills.install})]})}function eb(e,t){const n=t.trim().toLowerCase();if(n.includes("ant-messages"))return"/v1/messages";if(n.includes("openai-responses"))return"/responses";if(n.includes("openai"))return"/chat/completions";if(n.includes("claude"))return"/v1/messages";if(n.includes("gemini"))return"/v1beta/models";if(n.includes("gpt")||n.includes("minimax")||n.includes("deepseek"))return"/responses";if(n!=="")return"/chat/completions";switch(e){case"anthropic":return"/v1/messages";case"openai":return"/responses";case"minimax":return"/responses";case"deepseek":return"/responses";case"google":return"/v1beta/models";default:return"/chat/completions"}}const UM=["openai-responses","ant-messages","openai-chat"],tb="openai-chat";function PM(e){const t=e.trim().toLowerCase();return t===""||t==="openai"||UM.includes(t)}function zM(e){const t=e.trim().toLowerCase();return t===""?null:t==="openai-responses"||t==="ant-messages"?t:"openai-chat"}function BM(e){let t=0;for(const n of e)t+=n.codePointAt(0)>11903?2:1;return t}function gx(e){try{const t=new URL(e.trim());return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function zu(e){return e==="custom"||Ws(e)===void 0}function HM(e,t){const n=t.trim();return n!==""||!zu(e)?n:tb}function GG(e,t,n){return e==="save"&&zu(t)&&n.trim()===""}function KG(e,t){const n=t.trim();return n!==""?n:zu(e)?tb:void 0}function FM({value:e,path:t,detecting:n,tone:s,onPick:o}){const[c,u]=y.useState(!1),f=e===null?d.models.protocolUnset:d.models.protocolNames[e]??e;return a.jsx(Qn,{open:c,setOpen:u,className:"flex",menuClass:"w-72 max-w-[calc(100vw-2rem)] origin-top-right",portal:{direction:"down",align:"right"},button:a.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-label":`${d.models.protocol}: ${f}`,title:d.models.protocolTriggerTitle(f),onClick:()=>u(p=>!p),className:"flex items-center gap-1 rounded px-1 py-0.5 font-mono text-xs transition-colors duration-150 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-400/30 dark:hover:bg-gray-800 "+(s==="warn"?`${sn.attention} hover:text-amber-700 dark:hover:text-amber-300`:"text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"),children:[a.jsx("span",{className:"truncate",children:t}),n?a.jsx("span",{"aria-hidden":!0,className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border border-current border-t-transparent"}):a.jsx(ns,{size:10})]}),children:a.jsx("div",{role:"menu",children:UM.map(p=>{const h=p===e;return a.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":h,onClick:()=>{u(!1),o(p)},className:`block ${ny} hover:bg-gray-100 dark:hover:bg-gray-800 ${h?"bg-gray-100 dark:bg-gray-800":""}`,children:[a.jsxs("span",{className:"flex items-center justify-between gap-2",children:[a.jsx("span",{className:`min-w-0 truncate text-xs ${h?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:d.models.protocolNames[p]??p}),h&&a.jsx(qu,{className:"text-gray-500 dark:text-gray-400"})]}),a.jsx("span",{className:"mt-0.5 block font-mono text-[11px] text-gray-500 dark:text-gray-500",children:eb("custom",p)})]},p)})})})}function n0(){return new Set(["deepseek"])}function WG(e,t,n){return n||e.has(t)}function YG(e,t){const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}const qM=e=>`penguin.modelsExpandedGroups.${e}`;function XG(e){return JSON.stringify([...e])}function QG(e){if(e===null)return null;try{const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):null}catch{return null}}function fj(e,t=localStorage){if(e===null)return n0();try{return QG(t.getItem(qM(e)))??n0()}catch{return n0()}}function pj(e,t,n=localStorage){if(e!==null)try{n.setItem(qM(e),XG(t))}catch{}}function VM(e){return{vision:e.vision!==!1,contextWindow:e.context_window!==void 0?String(e.context_window):"",clientType:e.client_type??"",cacheRead:e.pricing?String(e.pricing.cache_read):"",cacheWrite:e.pricing?String(e.pricing.cache_write):"",output:e.pricing?String(e.pricing.output):"",baseUrl:e.base_url??""}}function ZG(e){return{provider:e.provider,modelId:e.model_id,original:null,...VM(e),maxTokens:"",fastMode:!1,originalBaseUrl:"",apiKeyInput:"",clearApiKey:!1}}function JG(e,t=tz()){const n=(f,p)=>`${f}\0${p}`,s=new Map(e.map((f,p)=>[n(f.provider,f.modelId),p])),o=[...e];let c=0,u=0;for(const f of t){const p=s.get(n(f.provider,f.model_id));if(p===void 0){o.push(ZG(f)),c+=1;continue}const h=o[p],x=VM(f);Object.keys(x).some(v=>h[v]!==x[v])&&(o[p]={...h,...x},u+=1)}return{rows:o,added:c,updated:u}}const eK=200,tK=/[\u0000-\u001f\u007f]/;function nK(e){if(typeof e!="string")return null;const t=e.trim();return t===""||t.length>eK||tK.test(t)?null:t}function rK(e,t,n){return{provider:e,modelId:t,original:null,vision:!1,contextWindow:"",maxTokens:"",fastMode:!1,clientType:n.clientType,cacheRead:"",cacheWrite:"",output:"",baseUrl:n.baseUrl,originalBaseUrl:"",apiKeyInput:n.apiKey,clearApiKey:!1}}function aK(e,t,n,s){const o=(p,h)=>`${p}\0${h}`,c=new Set(e.map(p=>o(p.provider,p.modelId))),u=[];let f=0;for(const p of n){const h=nK(p);if(h===null){f+=1;continue}const x=o(t,h);if(c.has(x)){f+=1;continue}c.add(x),u.push(rK(t,h,s))}return{rows:u,added:u.length,skipped:f}}function sK(e){return e<1e3?"green":e<=3e3?"yellow":"red"}function iK(e){return e>=40?"green":e>=15?"yellow":"red"}const GM={USD:"$",CNY:"¥"};function hj(e){return Number.isFinite(e)?String(Math.round(e*1e6)/1e6):"0"}function xx(e){return Number.isFinite(e)?String(Math.round(e*1e4)/1e4):"0"}function r0(e,t){const n=Number(e||"0"),s=t==="CNY"?n*wx:n;return`${GM[t]}${xx(s)}`}function pl(e,t){const n=e.trim();if(!n)return"";const s=Number(n);return Number.isFinite(s)?xx(t==="CNY"?s*wx:s):n}function a0(e,t){const n=e.trim();if(!n)return"";const s=Number(n);return Number.isFinite(s)?hj(t==="CNY"?s/wx:s):n}const oK="M12 5v14M5 12h14",lK="M4 7h16M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m3 0l-1 13a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L6 7m4 4v6m4-6v6",cK="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4",KM="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3",WM="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4M10 17l5-5-5-5M15 12H3",uK="M12 14l3.5-3.5M20.49 17A10 10 0 1 0 3.5 17",dK="M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM12 7v5l3.5 2",mK="M13 2 3 14h9l-1 8 10-12h-9l1-8Z",gj={green:sn.success,yellow:sn.attention,red:sn.danger},xj=(e,t)=>`${e}\0${t}`,s0=128e3;function yj(e){return e.replace(/[^\d]/g,"")}function fK(e){const t=e.replace(/[^\d.]/g,""),n=t.indexOf(".");return n===-1?t:t.slice(0,n+1)+t.slice(n+1).replace(/\./g,"")}function bj(e,t){return e!=="custom"||t.trim()!==""&&PM(t)?t:"openai-chat"}function $a(e){return{provider:e.provider,modelId:e.modelId}}function pK(e){const{editing:t,ref:n,action:s,defaultModel:o,visionModel:c}=e,u=t===null,f=!u&&!zt(t,n)?t:null,p=h=>zt(h,f)?n:h;return{defaultModel:s==="setDefault"||u&&!o?n:p(o),visionModel:s==="setVisionModel"?n:p(c)}}function hK(e){return e.original!==null&&G0(e.original.provider,e.original.modelId)!==void 0}function gK(e){return e.clearApiKey?Ol({...e,credential:void 0}):e.apiKeyInput.trim()!==""||Ol(e)}function xK(e){return gK(e)?e.credential?.apiKeyMasked&&!e.clearApiKey?e.credential.apiKeyMasked:e.apiKeyInput.trim()!==""?d.models.keyConfigured:e.envKeyMasked??d.models.keyConfigured:d.models.noKey}function vj(e){const t={provider:e.provider,modelId:e.modelId,original:{provider:e.provider,modelId:e.modelId},vision:e.vision!==!1,contextWindow:e.contextWindow!==void 0?String(e.contextWindow):"",maxTokens:e.maxTokens!==void 0?String(e.maxTokens):"",fastMode:e.fastMode===!0,clientType:e.clientType??"",cacheRead:e.pricing?String(e.pricing.cacheRead):"",cacheWrite:e.pricing?String(e.pricing.cacheWrite):"",output:e.pricing?String(e.pricing.output):"",baseUrl:e.credential?.baseUrl??"",originalBaseUrl:e.credential?.baseUrl??"",apiKeyInput:"",clearApiKey:!1};return e.displayName!==void 0&&(t.displayName=e.displayName),e.envKey!==void 0&&(t.envKey=e.envKey),e.envKeyMasked!==void 0&&(t.envKeyMasked=e.envKeyMasked),e.credential&&(t.credential=e.credential),t}function yK(e){const t=new Set;for(const n of e)n.envKeyMasked!==void 0&&n.envKey!==void 0&&t.add(n.envKey);return t}function bK(e){const t=ez(e.modelId.trim(),HM(e.provider,e.clientType)||void 0,e.baseUrl.trim()||void 0);return{protocol:t,show:t!==void 0||e.fastMode}}function vK(e){const t=e.vision&&e.fastMode;return{show:e.vision||e.fastMode,cellClass:t?void 0:"col-span-2"}}function kK(e){const t={provider:e.provider,modelId:e.modelId};e.original&&!zt(e.original,$a(e))&&(t.renamedFrom=e.original),e.displayName?.trim()&&(t.displayName=e.displayName.trim());const n=Number(e.contextWindow.trim());e.contextWindow.trim()&&Number.isFinite(n)&&(t.contextWindow=n);const s=HM(e.provider,e.clientType);s&&(t.clientType=s),e.vision||(t.vision=!1);const o=Number(e.maxTokens.trim());e.maxTokens.trim()&&Number.isFinite(o)&&o>0&&(t.maxTokens=o),e.fastMode&&(t.fastMode=!0);const c=Number(e.cacheRead.trim()),u=Number(e.cacheWrite.trim()),f=Number(e.output.trim());e.cacheRead.trim()&&e.cacheWrite.trim()&&e.output.trim()&&Number.isFinite(c)&&Number.isFinite(u)&&Number.isFinite(f)&&(t.pricing={cacheRead:c,cacheWrite:u,output:f}),e.apiKeyInput.trim()&&(t.apiKey=e.apiKeyInput.trim()),e.clearApiKey&&(t.clearApiKey=!0);const p=e.baseUrl.trim();return p!==e.originalBaseUrl&&(t.baseUrl=p||null),t}const YM="application/x-penguin-model-group",kj=e=>e.dataTransfer.types.includes(YM),wj="(hover: hover) and (pointer: fine)";function wK(){Li(d.models.title);const{currentProject:e}=en(),t=e?.projectId??null,n=e?.role==="owner",s=mn().user?.userId??null,[o,c]=y.useState(new Map),[u,f]=y.useState(null),[p,h]=y.useState(null),[x,g]=y.useState(null),[v,w]=y.useState(void 0),[S,C]=y.useState(void 0),[N,T]=y.useState(null),[_,R]=y.useState(null),[D,z]=y.useState(""),[E,L]=y.useState(()=>fj(t));y.useEffect(()=>{L(fj(t))},[t]);const[F,V]=y.useState(()=>K0(t));y.useEffect(()=>{V(K0(t))},[t]);const[P,B]=y.useState(()=>window.matchMedia(wj).matches);y.useEffect(()=>{const ve=window.matchMedia(wj),Xe=Ge=>B(Ge.matches);return ve.addEventListener("change",Xe),()=>ve.removeEventListener("change",Xe)},[]);const[Y,q]=y.useState(null),[K,H]=y.useState(null),[$,X]=y.useState(null),[le,ie]=y.useState(null),[I,A]=y.useState(null),[Q,j]=y.useState(!1),[U,ee]=y.useState(null),[re,ke]=y.useState(!1),{currency:be}=as(),ye=y.useCallback(async()=>{if(t){g(null),ee(null),c(new Map);try{const ve=await Ml(t);g(ve.models.map(vj)),w(ve.defaultModel),C(ve.visionModel)}catch(ve){ee(Ae(ve))}}},[t]);y.useEffect(()=>{ye()},[ye]);const Se=async(ve,Xe,Ge,He)=>{if(!t)return!1;ke(!0);const Pe=Ge&&ve.some(W=>zt($a(W),Ge)&&W.vision)?Ge:void 0;try{const W={models:ve.map(kK)};Xe&&(W.defaultModel=Xe),Pe&&(W.visionModel=Pe);const me=await TE(t,W);return g(me.models.map(vj)),w(me.defaultModel),C(me.visionModel),s&&me.defaultModel&&!zt(me.defaultModel,v)&&iM(s,t),yt(He??d.common.saved),!0}catch(W){return g(ve),Xe!==void 0&&w(Xe),Pe!==void 0&&C(Pe),Be(Ae(W)),!1}finally{ke(!1)}},Me=y.useMemo(()=>x?vT(x,D,F):[],[x,D,F]),ze=y.useMemo(()=>sz(x??[]),[x]),De=y.useMemo(()=>yK(x??[]),[x]),ct=D.trim()!=="",bt=async()=>{if(!x)return;const ve=JG(x);if(ve.added===0&&ve.updated===0){wr(d.models.syncUpToDate);return}await Se(ve.rows,v,S,d.models.syncDone(ve.added,ve.updated))},he=async ve=>{if(!t||!x)return;const Xe=x.filter(Ge=>Ge.provider===ve);h(ve);try{for(const Ge of Xe){const He=xj(Ge.provider,Ge.modelId);c(Pe=>new Map(Pe).set(He,"pending"));try{const Pe=await Zj(t,{provider:Ge.provider,modelId:Ge.modelId,speed:!0});c(W=>new Map(W).set(He,Pe))}catch(Pe){c(W=>new Map(W).set(He,{ok:!1,message:Ae(Pe)}))}}}finally{h(null)}},ne=async(ve,Xe,Ge,He)=>{if(!t)return!1;const Pe=x;if(!await Se(ve,v,S,d.models.groupImported(Ge,He)))return g(Pe),!1;if(!E.has(Xe)){const me=new Set(E);me.add(Xe),L(me),pj(t,me)}return j(!1),!0},oe=N!==null?x?.find(ve=>zt($a(ve),N)):void 0;if(!t)return null;const J=ve=>{if(ct)return;const Xe=YG(E,ve);L(Xe),pj(t,Xe)},ht=ve=>{if(!P||ct)return{header:{},dropEdge:null};const Xe=Y,Ge=Pe=>{const W=Pe.currentTarget.getBoundingClientRect();return Pe.clientY-W.top>W.height/2},He=Xe!==null&&Xe!==ve;return{header:{draggable:!0,onDragStart:Pe=>{Pe.target===Pe.currentTarget&&(Pe.dataTransfer.setData(YM,ve),Pe.dataTransfer.effectAllowed="move",q(ve))},onDragEnd:()=>{q(null),H(null)},onDragOver:Pe=>{if(!He||!kj(Pe))return;Pe.preventDefault(),Pe.dataTransfer.dropEffect="move";const W=Ge(Pe);H(me=>me?.key===ve&&me.after===W?me:{key:ve,after:W})},onDragLeave:Pe=>{const W=Pe.relatedTarget;W instanceof Node&&Pe.currentTarget.contains(W)||H(me=>me?.key===ve?null:me)},onDrop:Pe=>{if(!He||Xe===null||!kj(Pe))return;Pe.preventDefault();const W=az(F,ze,Xe,ve,Ge(Pe));W!==F&&(V(W),nz(t,W)),q(null),H(null)}},dropEdge:He&&K?.key===ve?K.after?"below":"above":null}};return a.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:[a.jsxs("div",{className:"mx-auto max-w-5xl",children:[a.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[a.jsxs("h1",{className:"flex items-center gap-1.5 text-xl font-semibold",children:[d.models.title,!n&&a.jsx(ba,{label:d.models.title,children:d.models.readOnlyHint})]}),a.jsxs("div",{className:"flex min-w-0 max-w-full grow items-center gap-2 sm:grow-0",children:[a.jsx("div",{className:"min-w-0 flex-1 sm:w-56 sm:flex-none",children:a.jsx(at,{size:"sm",value:D,onChange:ve=>z(ve.target.value),placeholder:d.models.searchPlaceholder})}),n&&a.jsx(ge,{size:"sm",onClick:()=>{bt()},disabled:re||x===null,title:d.models.syncCatalogHint,children:d.models.syncCatalog})]})]}),x===null?a.jsx(Sr,{rows:4}):x.length===0?a.jsx(Fa,{title:d.models.empty,action:n&&a.jsx(ge,{onClick:()=>R("custom"),children:d.models.addCustom})}):Me.length===0?a.jsx(Fa,{title:d.models.noSearchResults}):a.jsxs("div",{className:"space-y-3",children:[Me.map(ve=>{const Xe=WG(E,ve.provider.id,ct),Ge=ht(ve.provider.id);return a.jsxs("div",{className:"relative",children:[Ge.dropEdge!==null&&a.jsx("div",{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 z-10 h-0.5 rounded-full bg-[var(--accent-bg)] ${Ge.dropEdge==="above"?"-top-1.5":"-bottom-1.5"}`}),a.jsxs("section",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[a.jsxs("div",{...Ge.header,className:`@container flex items-center gap-2 bg-gray-50 pr-2 transition-colors duration-150 hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60${P&&!ct?" cursor-grab":""}`,children:[a.jsxs("button",{type:"button","aria-expanded":Xe,onClick:()=>J(ve.provider.id),className:"flex min-w-0 flex-1 items-center gap-2.5 px-3 py-2.5 text-left",children:[a.jsx(jo,{provider:ve.provider.id,className:"h-5 w-5 shrink-0 text-gray-700 dark:text-gray-300"}),a.jsx("span",{className:"min-w-0 truncate text-sm font-semibold",children:ve.provider.label}),a.jsx("span",{className:"shrink-0 whitespace-nowrap font-mono text-xs text-gray-400",children:d.models.modelCount(ve.rows.length)})]}),n&&a.jsxs(ge,{size:"sm",variant:"ghost",className:"shrink-0",disabled:re,"aria-label":`${d.models.addToGroup} ${ve.provider.label}`,title:d.models.addToGroup,onClick:()=>R(ve.provider.id),children:[a.jsx(Oe,{d:oK,size:13}),a.jsx("span",{className:"hidden @3xl:inline",children:d.models.addToGroup})]}),n&&ve.provider.oauth&&a.jsxs(ge,{size:"sm",variant:"ghost",className:"shrink-0",disabled:re,"aria-label":`${d.models.oauthKey} ${ve.provider.label}`,title:d.models.oauthKey,onClick:()=>ie(ve.provider.id),children:[a.jsx(Oe,{d:WM,size:13}),a.jsx("span",{className:"hidden @3xl:inline",children:d.models.oauthKey})]}),n&&ve.provider.id!=="custom"&&a.jsxs(ge,{size:"sm",variant:"ghost",className:"shrink-0",disabled:re,"aria-label":`${d.models.groupApiKey} ${ve.provider.label}`,title:d.models.groupApiKey,onClick:()=>X(ve.provider.id),children:[a.jsx(Oe,{d:cK,size:13}),a.jsx("span",{className:"hidden @3xl:inline",children:d.models.groupApiKey})]}),n&&a.jsxs(ge,{size:"sm",variant:"ghost",className:"shrink-0",disabled:re||p!==null,"aria-label":`${d.models.speedTest} ${ve.provider.label}`,title:p===ve.provider.id?d.models.speedPending:d.models.speedTest,onClick:()=>f(ve.provider.id),children:[a.jsx(Oe,{d:uK,size:13}),a.jsx("span",{className:"hidden @3xl:inline",children:p===ve.provider.id?d.models.speedPending:d.models.speedTest})]}),n&&!es.some(He=>He.id===ve.provider.id)&&a.jsxs(ge,{size:"sm",variant:"ghost",className:"shrink-0",disabled:re,"aria-label":`${d.models.deleteGroup} ${ve.provider.label}`,title:d.models.deleteGroup,onClick:()=>A(ve.provider.id),children:[a.jsx(Oe,{d:lK,size:13}),a.jsx("span",{className:"hidden @3xl:inline",children:d.models.deleteGroup})]}),ve.provider.apiKeyUrl&&a.jsxs("a",{href:ve.provider.apiKeyUrl,target:"_blank",rel:"noreferrer noopener","aria-label":`${d.models.getApiKey} ${ve.provider.label}`,title:d.models.getApiKey,className:"inline-flex shrink-0 items-center whitespace-nowrap p-1 text-xs text-brand-600 underline-offset-2 hover:underline @4xl:p-0 dark:text-brand-300",children:[a.jsx(Oe,{d:KM,size:13,className:"@4xl:hidden"}),a.jsxs("span",{className:"hidden @4xl:inline",children:[d.models.getApiKey," ↗"]})]}),a.jsx("button",{type:"button","aria-expanded":Xe,"aria-label":ve.provider.label,onClick:()=>J(ve.provider.id),className:"shrink-0 p-1.5",children:a.jsx(Zn,{open:Xe,className:"text-gray-400"})})]}),a.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${Xe?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:a.jsx("div",{className:"overflow-hidden",inert:!Xe,children:a.jsx("div",{className:`grid grid-cols-1 gap-2 border-t border-gray-200 p-2.5 transition-opacity duration-200 sm:grid-cols-2 lg:grid-cols-3 dark:border-gray-800 ${Xe?"opacity-100":"opacity-0"}`,children:ve.rows.length===0?a.jsx("p",{className:"col-span-full py-1 text-center text-xs text-gray-400 dark:text-gray-500",children:d.models.groupEmptyHint}):ve.rows.map(He=>a.jsx(jK,{row:He,currency:be,isDefault:zt($a(He),v),isVisionModel:zt($a(He),S),speed:o.get(xj(He.provider,He.modelId)),onOpen:()=>T($a(He))},`${He.provider}:${He.modelId}`))})})})]})]},ve.provider.id)}),n&&D.trim()===""&&a.jsxs("button",{type:"button",onClick:()=>j(!0),className:"w-full rounded-md border border-dashed border-gray-300 px-3 py-2.5 text-sm text-gray-500 transition-colors hover:border-gray-400 hover:text-gray-700 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-600 dark:hover:text-gray-200",children:["+ ",d.models.addGroup]})]}),U&&a.jsx("p",{className:"mt-3 text-xs text-red-600 dark:text-red-400",children:U})]}),x&&$&&a.jsx(MK,{provider:es.find(ve=>ve.id===$)??Qm($),count:x.filter(ve=>ve.provider===$).length,detectedEnvKeys:De,onClose:()=>X(null),onSubmit:ve=>{const Xe=$;X(null);const Ge=x.filter(Pe=>Pe.provider===Xe);if(Ge.length===0)return;const He=x.map(Pe=>Pe.provider===Xe?{...Pe,apiKeyInput:ve,clearApiKey:!1}:Pe);Se(He,v,S,d.models.groupKeyApplied(Ge.length))}}),x&&t&&le!==null&&a.jsx(AK,{projectId:t,provider:es.find(ve=>ve.id===le)??Qm(le),count:x.filter(ve=>ve.provider===le).length,onClose:()=>ie(null),onApplied:ve=>{ie(null),yt(d.models.oauthApplied(ve)),ye()}}),x&&I!==null&&a.jsx(ln,{open:!0,title:d.models.deleteGroupTitle,tone:"danger",onClose:()=>A(null),onConfirm:()=>{const ve=I;A(null);const Xe=x.filter(Ge=>Ge.provider===ve);Xe.length!==0&&Se(x.filter(Ge=>Ge.provider!==ve),v?.provider===ve?void 0:v,S?.provider===ve?void 0:S,d.models.groupDeleted(Xe.length))},children:a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:d.models.deleteGroupConfirm(Qm(I).label,x.filter(ve=>ve.provider===I).length)})}),u!==null&&a.jsxs(Yt,{open:!0,title:d.models.speedTestTitle,onClose:()=>f(null),children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:d.models.speedTestConfirm(x?.filter(ve=>ve.provider===u).length??0)}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(ge,{onClick:()=>f(null),children:d.common.cancel}),a.jsx(ge,{variant:"primary",onClick:()=>{const ve=u;f(null),ve&&he(ve)},children:d.models.speedTestStart})]})]}),x&&Q&&a.jsx(SK,{projectId:t,rows:x,onClose:()=>j(!1),onManual:ve=>{j(!1),R(ve)},onImport:ne}),x&&(_!==null||oe)&&a.jsx(TK,{projectId:t,row:_!==null?null:oe??null,addProvider:_??"custom",existingRefs:x.map($a),detectedEnvKeys:De,currency:be,canEdit:n,isDefault:oe!==void 0&&zt($a(oe),v),isVisionModel:oe!==void 0&&zt($a(oe),S),onClose:()=>{T(null),R(null)},onSubmit:(ve,Xe)=>{const Ge=_!==null;if(T(null),R(null),Xe==="remove"){const W=ve.original;Se(x.filter(me=>!zt($a(me),W)),zt(W,v)?void 0:v,zt(W,S)?void 0:S);return}const He=Ge?[...x,ve]:x.map(W=>zt($a(W),N)?ve:W),Pe=pK({editing:Ge?null:N,ref:$a(ve),action:Xe,defaultModel:v,visionModel:S});Se(He,Pe.defaultModel,Pe.visionModel)}})]})}function SK({projectId:e,rows:t,onClose:n,onManual:s,onImport:o}){const[c,u]=y.useState(""),[f,p]=y.useState(null),[h,x]=y.useState("create"),[g,v]=y.useState(""),[w,S]=y.useState(""),[C,N]=y.useState(null),[T,_]=y.useState(!1),[R,D]=y.useState(!1),[z,E]=y.useState(null),[L,F]=y.useState(null),V=y.useRef(0),P=()=>{const X=c.trim();return/^[a-z0-9][a-z0-9_-]{0,31}$/.test(X)?es.some(le=>le.id===X)||t.some(le=>le.provider===X)?(p(d.models.groupNameExists),null):X:(p(d.models.groupNameInvalid),null)},B=()=>{const X=P();X&&s(X)},Y=async()=>{const X=w.trim();if(F(null),!gx(X)){F(d.models.groupImportNeedUrl);return}const le=++V.current;_(!0),D(!1);try{const ie=g.trim(),I=await Jj(e,{baseUrl:X,...ie?{apiKey:ie}:{}});if(le!==V.current)return;const A=I.detected!==void 0?zM(I.detected):null;A!==null?(N(A),yt(d.models.detectedProtocol(d.models.protocolNames[A]??A))):(D(!0),F(d.models.detectFailedBody))}catch(ie){if(le!==V.current)return;D(!0),F(Ae(ie))}finally{le===V.current&&_(!1)}},q=X=>{V.current++,_(!1),D(!1),F(null),N(X)},K=async()=>{const X=P();if(!X||C===null)return;const le=w.trim();if(!gx(le)){F(d.models.groupImportNeedUrl);return}F(null),E(d.models.groupImportListing);try{const ie=g.trim(),I=await EE(e,{baseUrl:le,clientType:C,...ie?{apiKey:ie}:{}});if(!I.ok||!I.models){F(I.unsupported?d.models.groupImportUnsupported:I.message??d.models.groupImportFailed);return}const A=aK(t,X,I.models,{baseUrl:le,clientType:C,apiKey:ie});if(A.added===0){F(d.models.groupImportEmpty);return}E(d.models.groupImportSaving(A.added)),await o([...t,...A.rows],X,A.added,A.skipped)}catch(ie){F(Ae(ie))}finally{E(null)}},H=z!==null,$=C===null?d.models.protocolUnset:eb(c.trim(),C);return a.jsx(Yt,{open:!0,title:d.models.addGroupTitle,onClose:()=>!H&&n(),widthClass:"sm:max-w-sm",footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{disabled:H,onClick:n,children:d.common.cancel}),h==="create"?a.jsx(ge,{variant:"primary",onClick:B,children:d.common.confirm}):C!==null&&a.jsx(ge,{variant:"primary",disabled:H,onClick:()=>{K()},children:d.models.groupImportAll})]}),children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"block",children:[a.jsx(at,{size:"sm",label:d.models.groupNameLabel,info:d.models.addGroupDesc,infoLabel:d.models.groupNameLabel,required:!0,value:c,invalid:!!f,onChange:X=>{u(X.target.value),p(null)},onKeyDown:X=>{X.key==="Enter"&&h==="create"&&B()},placeholder:d.models.groupNameHint,className:"font-mono",autoFocus:!0}),f&&a.jsx(ga,{children:f})]}),a.jsx(ws,{cols:2,options:[{value:"create",label:d.models.groupModeCreate},{value:"import",label:d.models.groupModeImport}],value:h,onChange:x}),h==="import"&&a.jsxs(a.Fragment,{children:[a.jsx(ts,{size:"sm",label:d.models.apiKey,value:g,onChange:X=>{v(X.target.value),F(null)},className:"font-mono",autoComplete:"off",placeholder:d.models.groupImportKeyHint}),a.jsxs("div",{className:"block",children:[a.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[a.jsx(Yn,{required:!0,block:!1,children:d.models.baseUrl}),a.jsxs("button",{type:"button",disabled:T||H,onClick:()=>{Y()},title:d.models.detectProtocolHint,className:"flex shrink-0 items-center gap-1 text-xs text-brand-600 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:text-gray-400 disabled:no-underline dark:text-brand-300 dark:disabled:text-gray-500",children:[T&&a.jsx("span",{"aria-hidden":!0,className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border border-current border-t-transparent"}),T?d.models.detecting:d.models.detectProtocol]})]}),a.jsxs("div",{className:"relative",children:[a.jsx(at,{size:"sm","aria-label":d.models.baseUrl,required:!0,value:w,disabled:H,onChange:X=>{V.current++,_(!1),D(!1),F(null),S(X.target.value)},className:"font-mono",style:{paddingRight:`calc(${BM($)}ch + 2.25rem)`},title:d.models.baseUrlSuffixTitle,placeholder:"https://…"}),a.jsx("div",{className:"absolute inset-y-0 right-1 flex items-center",children:a.jsx(FM,{value:C,path:$,detecting:T,tone:R?"warn":null,onPick:q})})]})]}),z!==null&&a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:z})]}),L&&a.jsx(ga,{children:L})]})})}function jK({row:e,currency:t,isDefault:n,isVisionModel:s,speed:o,onOpen:c}){const u=e.cacheRead||e.cacheWrite||e.output,f=[e.contextWindow?It(Number(e.contextWindow)):null,u?`${r0(e.cacheRead,t)} / ${r0(e.cacheWrite,t)} / ${r0(e.output,t)}`:null,xK(e)].filter(h=>h!==null),p=o==="pending"?a.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:d.models.speedPending}):o?o.ok?a.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] font-medium",children:[o.ttftMs!==void 0&&a.jsxs("span",{className:`flex items-center gap-0.5 ${gj[sK(o.ttftMs)]}`,title:d.models.ttftTitle,children:[a.jsx(Oe,{d:dK,size:11}),Math.round(o.ttftMs),"ms"]}),o.tps!==void 0&&a.jsxs("span",{className:`flex items-center gap-0.5 ${gj[iK(o.tps)]}`,title:d.models.tpsTitle,children:[a.jsx(Oe,{d:mK,size:11}),o.tps," tok/s"]})]}):a.jsx("span",{className:"shrink-0 text-[11px] font-medium text-red-600 dark:text-red-400",title:o.message,children:d.models.speedFailed}):null;return a.jsxs("button",{type:"button",onClick:c,className:"flex w-full flex-col gap-0.5 rounded-md border border-gray-200 px-3 py-2.5 text-left transition-colors duration-150 hover:border-gray-300 hover:bg-gray-50 dark:border-gray-800 dark:hover:border-gray-700 dark:hover:bg-gray-800/40",children:[a.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx("span",{className:"text-sm font-medium",children:e.displayName??e.modelId}),n&&a.jsx(On,{tone:"brand",children:d.models.default}),kT(e)&&a.jsx(On,{tone:"yellow",children:d.models.freeBadge}),e.vision&&a.jsx(On,{tone:"green",children:d.models.visionBadge}),s&&a.jsx(On,{tone:"amber",children:d.models.visionModelBadge}),e.fastMode&&a.jsx(On,{tone:"amber",children:d.models.fastModeBadge})]}),e.displayName!==void 0&&a.jsx("span",{className:"truncate font-mono text-[11px] text-gray-500 dark:text-gray-400",children:e.modelId}),a.jsxs("span",{className:"flex w-full items-center gap-1.5",children:[a.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-gray-400 dark:text-gray-500",children:f.join(" · ")}),p]})]})}const CK={save:()=>d.models.confirmSaveTitle,setDefault:()=>d.models.confirmDefaultTitle,setVisionModel:()=>d.models.confirmVisionModelTitle,remove:()=>d.models.confirmDeleteTitle},NK={save:e=>d.models.confirmSave(e),setDefault:e=>d.models.confirmDefault(e),setVisionModel:e=>d.models.confirmVisionModel(e),remove:e=>d.models.confirmDelete(e)};function TK({projectId:e,row:t,addProvider:n,existingRefs:s,detectedEnvKeys:o,currency:c,canEdit:u,isDefault:f,isVisionModel:p,onClose:h,onSubmit:x}){const[g,v]=y.useState(()=>{if(t)return{...t,cacheRead:pl(t.cacheRead,c),cacheWrite:pl(t.cacheWrite,c),output:pl(t.output,c)};const W=Ws(n),me=W!==void 0&&W.id!=="custom"&&W.gatewayBaseUrl===void 0;return{provider:n,modelId:"",original:null,vision:!zu(n),contextWindow:"",maxTokens:"",fastMode:!1,clientType:me||zu(n)?"":"openai-chat",cacheRead:"",cacheWrite:"",output:"",baseUrl:W?.gatewayBaseUrl??"",originalBaseUrl:"",apiKeyInput:"",clearApiKey:!1}}),[w,S]=y.useState({}),[C,N]=y.useState(!1),[T,_]=y.useState(null),[R,D]=y.useState(!1),[z,E]=y.useState(!1),[L,F]=y.useState(!1),V=y.useRef(0),P=y.useRef(null),[B,Y]=y.useState(!1),q=y.useRef(null),K=t===null,H=t!==null&&hK(t),{protocol:$,show:X}=bK(g),le=!H,{show:ie,cellClass:I}=vK({vision:le,fastMode:X}),A=W=>{v(me=>({...me,...W})),S(me=>{const Ue={...me};for(const pe of Object.keys(W))delete Ue[pe];return Ue})},Q=async()=>{N(!0);try{const W=g.apiKeyInput.trim(),me=g.baseUrl.trim(),Ue={provider:g.provider,modelId:g.modelId.trim(),baseUrl:me||null};W?Ue.apiKey=W:g.clearApiKey&&(Ue.clearApiKey=!0),g.clientType.trim()&&(Ue.clientType=g.clientType.trim()),Ue.fastMode=g.fastMode;const pe=await Zj(e,Ue);pe.ok?yt(d.models.testOk(pe.latencyMs??0)):Be(d.models.testFailed(pe.message??""))}catch(W){Be(d.models.testFailed(Ae(W)))}finally{N(!1)}},j=async W=>{const me=()=>{F(!0),W==="save"?wr(d.models.detectFellBack):Be(d.models.detectFailedBody)},Ue=g.baseUrl.trim();if(!gx(Ue))return me(),null;const pe=++V.current;E(!0),F(!1);try{const $e={baseUrl:Ue},nt=g.apiKeyInput.trim();nt?$e.apiKey=nt:g.clearApiKey&&($e.clearApiKey=!0);const gt=g.modelId.trim();gt&&($e.provider=g.provider,$e.modelId=gt);const Ke=await Jj(e,$e);return pe!==V.current?null:Ke.detected?(A({clientType:Ke.detected}),Ke.detected):(me(),null)}catch{return pe===V.current&&me(),null}finally{pe===V.current&&E(!1)}},U=W=>{if(P.current)return P.current;const me=j(W).finally(()=>{P.current=null});return P.current=me,me},ee=async()=>{const W=await U("manual");W!==null&&yt(d.models.detectedProtocol(d.models.protocolNames[W]??W))},re=async()=>{if(q.current)return;const W=g.modelId.trim();if(!W){Be(d.models.detectVisionNeedsId);return}Y(!0);const me=(async()=>{try{const Ue={provider:g.provider,modelId:W},pe=g.apiKeyInput.trim();pe?Ue.apiKey=pe:g.clearApiKey&&(Ue.clearApiKey=!0);const $e=g.baseUrl.trim();Ue.baseUrl=$e||null,g.clientType.trim()&&(Ue.clientType=g.clientType.trim());const nt=await AE(e,Ue);nt.outcome==="supported"?(A({vision:!0}),yt(d.models.detectVisionOk)):nt.outcome==="unsupported"?(A({vision:!1}),wr(d.models.detectVisionNo)):Be(d.models.detectFailedBody)}catch{Be(d.models.detectFailedBody)}finally{Y(!1)}})();q.current=me.finally(()=>{q.current=null}),await q.current},ke=W=>{V.current++,E(!1),F(!1),A({clientType:W})},be=g.clientType.trim().toLowerCase().includes("openai")||g.provider==="custom"||Ws(g.provider)===void 0,ye=!H&&be,Se=g.provider==="custom"||Ws(g.provider)===void 0,Me=Se&&PM(g.clientType)&&!H,ze=Me&&u,De=eb(g.provider,g.clientType),ct=zM(g.clientType),bt=ze&&ct===null?d.models.protocolUnset:De,he=()=>{const W=g.modelId.trim(),me={provider:g.provider,modelId:W},Ue=g.baseUrl.trim(),pe={};W?!zt(me,g.original)&&s.some(dt=>zt(dt,me))&&(pe.modelId=d.models.modelIdExists):pe.modelId=d.common.requiredField,ye&&!Ue&&(pe.baseUrl=d.models.baseUrlRequired);const $e=[["cacheRead",g.cacheRead.trim()],["cacheWrite",g.cacheWrite.trim()],["output",g.output.trim()]],nt=$e.filter(([,dt])=>dt!=="").length;for(const[dt,pt]of $e)pt===""&&nt>0?pe[dt]=d.models.pricingAllOrNone:pt!==""&&!Number.isFinite(Number(pt))&&(pe[dt]=d.models.pricingInvalid);const gt=g.contextWindow.trim();gt&&!Number.isFinite(Number(gt))&&(pe.contextWindow=d.models.contextWindowInvalid);const Ke=g.maxTokens.trim();return Ke&&!(Number.isInteger(Number(Ke))&&Number(Ke)>0)&&(pe.maxTokens=d.models.maxTokensInvalid),Object.keys(pe).length>0?(S(pe),null):(S({}),{...g,modelId:W,contextWindow:!H&&!gt?String(s0):g.contextWindow,cacheRead:a0(g.cacheRead,c),cacheWrite:a0(g.cacheWrite,c),output:a0(g.output,c)})},ne=async W=>{const me=he();if(me){if(GG(W,me.provider,me.clientType)){const Ue=await U("save");x({...me,clientType:Ue??tb},W);return}x(me,W)}},oe=Ws(g.provider),J=JP(g.modelId.trim(),KG(g.provider,g.clientType))?.envKey,ht=oe!==void 0&&oe.id!=="custom"&&oe.gatewayBaseUrl===void 0,ve=ht&&!g.clientType.trim()&&g.modelId.trim()!==""&&J===void 0,Xe=a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"block",children:[a.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[a.jsx(Yn,{required:!0,block:!1,children:d.models.modelId}),a.jsx("span",{className:"flex shrink-0 items-baseline gap-2.5",children:oe?.modelsUrl&&a.jsxs("a",{href:oe.modelsUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[d.models.getModelIds," ↗"]})})]}),a.jsx(at,{size:"sm",required:!0,value:g.modelId,disabled:!u,invalid:!!w.modelId,onChange:W=>A({modelId:W.target.value}),className:"font-mono",autoFocus:K,placeholder:d.models.modelIdHint}),w.modelId&&a.jsx(ga,{children:w.modelId})]}),ve&&a.jsxs("div",{role:"alert",className:`flex items-center justify-between gap-3 rounded-md border px-2.5 py-2 text-xs ${Df.attention}`,children:[a.jsx("span",{children:d.models.autoRouteNone}),a.jsx(ge,{size:"sm",className:"shrink-0",onClick:()=>A({provider:"custom",clientType:bj("custom",g.clientType)}),children:d.models.useCustomGroup})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(at,{size:"sm",label:d.models.displayName,value:g.displayName??"",disabled:!u,onChange:W=>A({displayName:W.target.value}),placeholder:d.models.displayNameHint}),a.jsxs(Ss,{size:"sm",label:d.models.providerGroup,value:g.provider,disabled:!u,onChange:W=>{const me=W.target.value;A({provider:me,clientType:bj(me,g.clientType)})},children:[es.map(W=>a.jsx("option",{value:W.id,children:W.label},W.id)),[...new Set(s.map(W=>W.provider).concat(g.provider))].filter(W=>!es.some(me=>me.id===W)).sort().map(W=>a.jsx("option",{value:W,children:W},W))]})]})]}),Ge=!g.credential?.apiKeyMasked&&J!==void 0&&o.has(J)?J:void 0,He=g.credential?.apiKeyMasked?d.models.apiKeyKeepHint:Ge!==void 0?d.models.apiKeyEnvHint(Ge):void 0,Pe=Ge!==void 0&&Ge===oe?.envKey?d.models.providerEnvNotes[g.provider]:void 0;return a.jsxs(Yt,{open:!0,title:K?ht?d.models.addTitleVendor:Se?d.models.addTitleCustom:d.models.addTitle:d.models.editTitle,onClose:h,widthClass:"sm:max-w-lg",footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:h,children:d.common.cancel}),u&&a.jsx(ge,{variant:"primary",disabled:z,onClick:()=>{if(!he())return;if(K||t===null){ne("save");return}const W={...t,cacheRead:pl(t.cacheRead,c),cacheWrite:pl(t.cacheWrite,c),output:pl(t.output,c)};if(JSON.stringify(g)===JSON.stringify(W)){wr(d.common.noChangesToSave);return}_("save")},children:z?d.models.detecting:d.common.confirm})]}),children:[a.jsxs("div",{className:"space-y-3",children:[!K&&a.jsxs("div",{className:"flex items-center gap-2.5 rounded-md bg-gray-50 px-3 py-2 dark:bg-gray-800/60",children:[a.jsx(jo,{provider:g.provider,className:"h-6 w-6 shrink-0 text-gray-700 dark:text-gray-300"}),a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[a.jsxs("span",{className:"flex flex-wrap items-center gap-1.5 text-sm font-medium",children:[g.displayName??g.modelId,f&&a.jsx(On,{tone:"brand",children:d.models.default}),g.vision&&a.jsx(On,{tone:"green",children:d.models.visionBadge}),p&&a.jsx(On,{tone:"amber",children:d.models.visionModelBadge})]}),g.displayName!==void 0&&a.jsx("span",{className:"truncate font-mono text-xs text-gray-500 dark:text-gray-400",children:g.modelId})]}),t&&$S(t.provider,t.modelId)&&a.jsxs("a",{href:$S(t.provider,t.modelId),target:"_blank",rel:"noreferrer noopener",className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1 text-xs font-medium text-gray-800 transition-colors duration-150 hover:bg-gray-50 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800",children:[d.models.homepage,a.jsx(Oe,{d:KM})]})]}),K&&a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:ht&&oe?d.models.vendorProtocolHint(oe.label):Se?d.models.addProtocolHintDetect:d.models.addProtocolHint}),Xe]}),u&&a.jsx("div",{className:"space-y-1.5",children:a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(ge,{size:"sm",disabled:C||!g.modelId.trim(),onClick:()=>{Q()},children:C?d.models.testing:d.models.testConnection}),!K&&!f&&a.jsx(ge,{size:"sm",onClick:()=>_("setDefault"),children:d.models.setDefault}),!K&&g.vision&&!p&&a.jsx(ge,{size:"sm",title:d.models.visionModelHint,onClick:()=>_("setVisionModel"),children:d.models.setVisionModel}),!K&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"min-w-0 flex-1"}),a.jsx(ge,{size:"sm",variant:"danger",onClick:()=>_("remove"),children:d.models.remove})]})]})}),a.jsxs("div",{className:"block",children:[a.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[a.jsx(Yn,{block:!1,children:d.models.apiKey}),oe?.apiKeyUrl&&a.jsxs("a",{href:oe.apiKeyUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[d.models.getApiKey," ↗"]})]}),a.jsx(ts,{size:"sm","aria-label":d.models.apiKey,value:g.apiKeyInput,disabled:!u,onChange:W=>A({apiKeyInput:W.target.value,clearApiKey:!1}),className:"font-mono",autoComplete:"off",autoFocus:!K,placeholder:He})]}),Pe&&a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:Pe}),g.credential?.apiKeyMasked&&!g.apiKeyInput&&a.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"font-mono",children:g.credential.apiKeyMasked}),g.credential.createdAt&&a.jsxs("span",{className:"text-gray-400",children:[d.common.created," ",Jr(g.credential.createdAt)]}),u&&a.jsxs("label",{className:"flex items-center gap-1.5",children:[a.jsx("input",{type:"checkbox",checked:g.clearApiKey,onChange:W=>A({clearApiKey:W.target.checked})}),d.models.clearApiKey]})]}),!g.credential?.apiKeyMasked&&g.envKeyMasked!==void 0&&!g.apiKeyInput&&a.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"font-mono",children:g.envKeyMasked}),a.jsx("span",{className:"text-gray-400",children:d.models.readFromEnv})]}),a.jsxs("div",{className:"block",children:[ze?a.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[a.jsx(Yn,{required:ye,block:!1,children:d.models.baseUrl}),a.jsxs("button",{type:"button",disabled:z,onClick:()=>{ee()},title:d.models.detectProtocolHint,className:"flex shrink-0 items-center gap-1 text-xs text-brand-600 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:text-gray-400 disabled:no-underline dark:text-brand-300 dark:disabled:text-gray-500",children:[z&&a.jsx("span",{"aria-hidden":!0,className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border border-current border-t-transparent"}),z?d.models.detecting:d.models.detectProtocol]})]}):a.jsx(Yn,{required:ye,children:d.models.baseUrl}),a.jsxs("div",{className:"relative",children:[a.jsx(at,{size:"sm","aria-label":d.models.baseUrl,required:ye,value:g.baseUrl,disabled:!u,invalid:!!w.baseUrl,onChange:W=>{F(!1),A({baseUrl:W.target.value})},className:"font-mono",style:{paddingRight:`calc(${BM(bt)}ch + ${ze?"2.25rem":"1.25rem"})`},title:d.models.baseUrlSuffixTitle,placeholder:H?d.models.baseUrlHint:"https://…"}),ze?a.jsx("div",{className:"absolute inset-y-0 right-1 flex items-center",children:a.jsx(FM,{value:ct,path:bt,detecting:z,tone:L?"warn":null,onPick:ke})}):a.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center font-mono text-xs text-gray-400",children:De})]}),w.baseUrl&&a.jsx(ga,{children:w.baseUrl})]}),a.jsxs("div",{className:"grid grid-cols-2 items-start gap-2",children:[a.jsxs("label",{className:"block",children:[a.jsx(Yn,{children:d.models.contextWindow}),a.jsxs("span",{className:"relative block",children:[a.jsx(at,{size:"sm",value:g.contextWindow,inputMode:"numeric",disabled:!u,invalid:!!w.contextWindow,onChange:W=>A({contextWindow:yj(W.target.value)}),className:"pr-12 font-mono",title:H?d.models.contextWindowHint:d.models.contextWindowDefaultHint(s0),placeholder:H?d.models.contextWindowHint:d.models.contextWindowDefaultHint(s0)}),a.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:d.models.tokenUnit})]}),w.contextWindow&&a.jsx(ga,{children:w.contextWindow})]}),a.jsxs("label",{className:"block",children:[a.jsx(Yn,{children:d.models.maxTokens}),a.jsxs("span",{className:"relative block",children:[a.jsx(at,{size:"sm",value:g.maxTokens,inputMode:"numeric",disabled:!u,invalid:!!w.maxTokens,onChange:W=>A({maxTokens:yj(W.target.value)}),className:"pr-12 font-mono",title:d.models.maxTokensTitle,placeholder:d.models.maxTokensHint}),a.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:d.models.tokenUnit})]}),w.maxTokens&&a.jsx(ga,{children:w.maxTokens})]})]}),a.jsx("div",{className:"grid grid-cols-3 items-start gap-2",children:[["cacheRead",d.models.priceCacheRead,g.cacheRead],["cacheWrite",d.models.priceCacheWrite,g.cacheWrite],["output",d.models.priceOutput,g.output]].map(([W,me,Ue])=>a.jsxs("label",{className:"block",children:[a.jsx(Yn,{children:me}),a.jsxs("span",{className:"relative block",children:[a.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-2 flex items-center text-xs text-gray-400",children:GM[c]}),a.jsx(at,{size:"sm",value:Ue,inputMode:"decimal",disabled:!u,invalid:!!w[W],onChange:pe=>A({[W]:fK(pe.target.value)}),className:"pl-4 pr-11 text-right font-mono"}),a.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:d.models.priceUnitShort})]}),w[W]&&a.jsx(ga,{children:w[W]})]},W))}),!K&&Xe,!K&&!H&&!Me&&g.clientType&&ZP(g.clientType)!=="openai-chat"&&a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:d.models.clientTypeLocked(g.clientType)}),ie&&a.jsxs("div",{className:"grid grid-cols-2 items-start gap-2",children:[le&&a.jsxs("div",{className:I,children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[a.jsxs("label",{className:`inline-flex items-center gap-2 ${u?"cursor-pointer":"cursor-not-allowed"}`,children:[a.jsx("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:d.models.vision}),a.jsx(js,{checked:g.vision,disabled:!u,onChange:W=>A({vision:W}),"aria-label":d.models.vision})]}),u&&a.jsxs("button",{type:"button",disabled:B,onClick:()=>{re()},title:d.models.detectVisionHint,className:"flex shrink-0 items-center gap-1 text-xs text-brand-600 underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:text-gray-400 disabled:no-underline dark:text-brand-300 dark:disabled:text-gray-500",children:[B&&a.jsx("span",{"aria-hidden":!0,className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border border-current border-t-transparent"}),B?d.models.detectingVision:d.models.detectVision]})]}),!g.vision&&a.jsx("p",{className:"mt-1 text-xs text-gray-400 dark:text-gray-500",children:d.models.visionOffProxyHint})]}),X&&a.jsxs("div",{className:I,children:[a.jsxs("label",{className:`inline-flex items-center gap-2 ${u?"cursor-pointer":"cursor-not-allowed"}`,title:d.models.fastModeHint,children:[a.jsx("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:d.models.fastMode}),a.jsx(js,{checked:g.fastMode,disabled:!u,onChange:W=>{W?D(!0):A({fastMode:!1})},"aria-label":d.models.fastMode})]}),g.fastMode&&a.jsx("p",{className:"mt-1 text-xs text-gray-400 dark:text-gray-500",children:d.models.fastModeHint}),g.fastMode&&$===void 0&&a.jsx("p",{className:`mt-1 text-xs ${sn.attention}`,children:d.models.fastModeUnsupported})]})]})]}),R&&a.jsxs(ln,{open:!0,title:d.models.fastModeConfirmTitle,tone:"danger",onClose:()=>D(!1),onConfirm:()=>{D(!1),A({fastMode:!0})},children:[a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:d.models.fastModeConfirmBody}),$==="anthropic"&&a.jsx("p",{className:"mt-2 text-sm text-gray-700 dark:text-gray-300",children:d.models.fastModeConfirmPreview})]}),T&&a.jsx(ln,{open:!0,title:CK[T](),tone:T==="remove"?"danger":"primary",onClose:()=>_(null),onConfirm:()=>{const W=T;_(null),ne(W)},children:a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:NK[T](g.displayName??g.modelId)})})]})}function MK({provider:e,count:t,detectedEnvKeys:n,onClose:s,onSubmit:o}){const[c,u]=y.useState("");return a.jsx(Yt,{open:!0,title:d.models.groupApiKeyTitle(e.label),onClose:s,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:s,children:d.common.cancel}),a.jsx(ge,{variant:"primary",disabled:!c.trim(),onClick:()=>o(c.trim()),children:d.common.confirm})]}),children:a.jsxs("div",{className:"space-y-2",children:[a.jsx(at,{size:"sm",label:d.models.apiKey,required:!0,type:"password",value:c,onChange:f=>u(f.target.value),className:"font-mono",autoComplete:"off",autoFocus:!0,placeholder:n.has(e.envKey)?d.models.apiKeyEnvHint(e.envKey):void 0}),a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:d.models.groupApiKeyHint(t)}),d.models.providerEnvNotes[e.id]&&a.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:d.models.providerEnvNotes[e.id]}),e.apiKeyUrl&&a.jsxs("a",{href:e.apiKeyUrl,target:"_blank",rel:"noreferrer noopener",className:"inline-block text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[d.models.getApiKey," ↗"]})]})})}const EK=2e3;function AK({projectId:e,provider:t,count:n,onClose:s,onApplied:o}){const[c,u]=y.useState(!1),[f,p]=y.useState("starting"),[h,x]=y.useState(null),[g,v]=y.useState(null),[w,S]=y.useState(""),[C,N]=y.useState(0),T=y.useRef(o);T.current=o,y.useEffect(()=>{let z=!1;return p("starting"),x(null),v(null),S(""),(async()=>{try{const E=await _E(e,{provider:t.id,mode:c?"manual":"callback"});if(z)return;x(E),p("ready")}catch(E){if(z)return;v(Ae(E)),p("failed")}})(),()=>{z=!0}},[e,t.id,c,C]),y.useEffect(()=>{if(f!=="waiting"||c||h===null)return;let z=!1;const E=async()=>{try{const F=await RE(e,h.flowId);if(z)return;if(F.status==="done"){T.current(n);return}F.status==="error"&&(v(F.error?d.models.oauthErrors[F.error]:d.models.oauthTimedOut),p("failed"))}catch{if(z)return;v(d.models.oauthTimedOut),p("failed")}},L=window.setInterval(()=>{E()},EK);return()=>{z=!0,window.clearInterval(L)}},[f,c,h,e,n]);const _=()=>{h!==null&&(window.open(h.authorizeUrl,"_blank","noopener,noreferrer"),c||p("waiting"))},R=async()=>{if(h!==null){p("waiting"),v(null);try{const z=await IE(e,h.flowId,w.trim());if(z.ok){T.current(z.applied??n);return}v(z.error?d.models.oauthErrors[z.error]:d.models.oauthTimedOut),p("failed")}catch(z){v(Ae(z)),p("failed")}}},D=f==="failed"?a.jsx(ge,{variant:"primary",onClick:()=>N(z=>z+1),children:d.models.oauthRetry}):c?a.jsx(ge,{variant:"primary",disabled:h===null||f==="waiting"||!w.trim(),onClick:()=>{R()},children:d.models.oauthSubmitCode}):a.jsx(ge,{variant:"primary",disabled:h===null,onClick:_,children:d.models.oauthAuthorize});return a.jsx(Yt,{open:!0,title:d.models.oauthTitle(t.label),onClose:s,footer:a.jsxs(a.Fragment,{children:[a.jsx(ge,{onClick:s,children:d.common.cancel}),D]}),children:a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:d.models.oauthIntro(t.label,n)}),c&&a.jsxs(a.Fragment,{children:[a.jsxs(ge,{variant:"ghost",disabled:h===null,onClick:_,children:[a.jsx(Oe,{d:WM,size:13}),d.models.oauthAuthorize]}),a.jsx(at,{size:"sm",label:d.models.oauthCodeLabel,hint:d.models.oauthManualHint,value:w,onChange:z=>S(z.target.value),className:"font-mono",autoComplete:"off"})]}),f==="waiting"&&!c&&a.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border border-current border-t-transparent"}),d.models.oauthWaiting]}),g!==null&&a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:g}),a.jsx("button",{type:"button",onClick:()=>u(z=>!z),className:"text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:c?d.models.oauthCallbackSwitch:d.models.oauthManualSwitch})]})})}const cu=200,yu=46,XM=8,xo=10,_K=22,jf=34;function nb(e,t,n,s=XM){return tp(e,0,t,n,s)}function tp(e,t,n,s,o=XM){const c=Math.max(0,s-yu-o),u=cu-xo-_K,f=e>0?c/e:c,p=n-t;return{n:e,min:t,max:n,w:s,padR:o,innerW:c,innerH:u,step:f,x:h=>yu+f*h+f/2,y:h=>xo+u*(1-(p>0?(h-t)/p:0))}}function rb(e,t){return t.map((n,s)=>`${s===0?"M":"L"}${e.x(s)},${e.y(n)}`).join(" ")}function RK(e,t){const n=t.length;if(n===0)return"";const s=e.y(0),o=[];for(let c=0;c<n;c++)o.push(`${c===0?"M":"L"}${e.x(c)},${e.y(t[c])}`);return o.push(`L${e.x(n-1)},${s}`),o.push(`L${e.x(0)},${s}`),o.push("Z"),o.join(" ")}const Sj=e=>Math.round(e*100)/100;function IK(e){const t=[];let n=[];return e.forEach((s,o)=>{if(s===null){n.length>0&&t.push(n),n=[];return}n.push({index:o,value:s})}),n.length>0&&t.push(n),t}function LK(e,t){return t.map((n,s)=>`${s===0?"M":"L"}${Sj(e.x(n.index))},${Sj(e.y(n.value))}`).join(" ")}function OK(e){return e<=0?[]:e===1?[0]:e===2?[0,1]:[0,Math.floor((e-1)/2),e-1]}const DK=40;function QM(e,t){if(e<=0)return[];const n=t>0?Math.max(1,Math.ceil(DK/t)):e,s=[];for(let o=0;o<e;o+=n)s.push(o);return s}const Pm=12;function $K(e,t,n,s,o){let c=e+Pm;c+n>o.right&&(c=e-Pm-n);let u=t+Pm;return u+s>o.bottom&&(u=t-Pm-s),{left:Math.max(o.left,Math.min(c,o.right-n)),top:Math.max(0,Math.min(u,o.bottom-s))}}const UK=25,PK=8;function ZM(e){return Math.max(1,Math.min(UK,Math.floor(e*.6)))}function zK(e,t,n){const s=e.length;if(s===0)return[];if(t<=s*n)return e.map(()=>t/s);const o=new Set;for(;;){const c=t-o.size*n,u=e.reduce((h,x,g)=>o.has(g)?h:h+x,0),f=h=>u>0?e[h]/u*c:c/(s-o.size),p=e.findIndex((h,x)=>!o.has(x)&&f(x)<n);if(p<0)return e.map((h,x)=>o.has(x)?n:f(x));o.add(p)}}function JM(e,t){const n=t.map((p,h)=>({index:h,value:p})).filter(p=>p.value>0);if(n.length===0)return[];const s=[];let o=0;for(const p of n){const h=e.y(o);o+=p.value;const x=e.y(o);s.push({y:x,h:h-x})}const c=e.y(0),u=zK(s.map(p=>p.h),c-e.y(o),PK);let f=c;return n.map((p,h)=>{const x=u[h],g={index:p.index,value:p.value,y:s[h].y,h:s[h].h,hitY:f-x,hitH:x};return f-=x,g})}const jj=["output","cacheWrite","cacheRead"];function BK(e,t){return JM(e,jj.map(n=>t[n])).map(n=>({...n,key:jj[n.index]}))}const Cj=10,ab=2,HK=8;function e4({geom:e,values:t,onEnter:n,onLeave:s}){return t.map((o,c)=>a.jsx("rect",{x:e.x(c)-e.step/2,y:e.y(o)-Cj/2,width:e.step,height:Cj,fill:"transparent",className:"cursor-pointer",onMouseEnter:()=>n(c),onMouseLeave:s},c))}function np(){const e=y.useRef(null),[t,n]=y.useState(0);return y.useLayoutEffect(()=>{const s=e.current;if(!s)return;const o=()=>n(Math.floor(s.getBoundingClientRect().width));o();const c=new ResizeObserver(o);return c.observe(s),()=>c.disconnect()},[]),[e,t]}function rp({geom:e,fmtY:t,dates:n,hover:s,onHover:o,bubble:c,hitLayer:u,labels:f,fmtX:p,yTicks:h,rightAxis:x,hoverLine:g=!0,axisBreaks:v,children:w}){const{x:S,y:C,w:N,innerH:T,step:_,min:R,max:D}=e,z=h??[0,.25,.5,.75,1].map(K=>R+(D-R)*K),E=f??OK(n.length),L=y.useRef(null),F=y.useRef(null),V=y.useRef(null),P=y.useRef(null),B=y.useRef(0),Y=()=>{const K=V.current,H=F.current,$=L.current,X=P.current;if(!K||!H||!$||!X)return;const le=H.getBoundingClientRect(),ie=$K(X.cx-le.left,X.cy-le.top,K.offsetWidth,K.offsetHeight,{left:$.scrollLeft,right:$.scrollLeft+$.clientWidth,bottom:cu});K.style.left=`${ie.left}px`,K.style.top=`${ie.top}px`,K.style.visibility="visible"},q=()=>{B.current||(B.current=requestAnimationFrame(()=>{B.current=0,Y()}))};return y.useEffect(()=>()=>cancelAnimationFrame(B.current),[]),y.useLayoutEffect(Y,[c,s]),a.jsxs("div",{ref:L,className:"relative overflow-x-auto",children:[a.jsxs("svg",{ref:F,viewBox:`0 0 ${N} ${cu}`,width:N,height:cu,className:"text-gray-600 dark:text-gray-400",role:"img",onMouseLeave:()=>{o(null),P.current=null},onMouseMove:K=>{P.current={cx:K.clientX,cy:K.clientY},q()},children:[z.map((K,H)=>a.jsxs("g",{children:[a.jsx("line",{x1:yu,x2:N-e.padR,y1:C(K),y2:C(K),className:"stroke-gray-200 dark:stroke-gray-800",strokeWidth:1}),a.jsx("text",{x:yu-6,y:C(K)+3,textAnchor:"end",className:"fill-gray-400 dark:fill-gray-500",fontSize:9,children:t(K)})]},H)),x?.ticks.map(K=>a.jsx("text",{x:N-e.padR+6,y:x.y(K)+3,textAnchor:"start",className:"fill-gray-400 dark:fill-gray-500",fontSize:9,children:x.fmt(K)},`r${K}`)),g&&s!==null&&n[s]&&a.jsx("line",{x1:S(s),x2:S(s),y1:xo,y2:xo+T,className:"stroke-gray-300 dark:stroke-gray-700",strokeWidth:1}),w,_>=HK&&v?.map(K=>K+1<e.n?a.jsx("g",{className:"pointer-events-none stroke-gray-400 dark:stroke-gray-500",strokeWidth:1,children:[-2,2].map(H=>{const $=(S(K)+S(K+1))/2+H/2;return a.jsx("line",{x1:$-2,y1:xo+T+3,x2:$+2,y2:xo+T-3},H)})},`break-${K}`):null),E.map(K=>{const H=n[K];return H?a.jsx("text",{x:S(K),y:cu-6,textAnchor:"middle",className:"fill-gray-400 dark:fill-gray-500",fontSize:9,children:(p??($=>$.slice(5)))(H)},K):null}),u??n.map((K,H)=>a.jsx("rect",{x:yu+_*H,y:xo,width:_,height:T,fill:"transparent",className:"cursor-crosshair",onMouseEnter:()=>o(H)},`hit-${H}`))]}),c&&s!==null&&n[s]&&a.jsx("div",{ref:V,className:"pointer-events-none absolute rounded border border-gray-200 bg-white px-2 py-1 text-xs whitespace-nowrap shadow-sm dark:border-gray-700 dark:bg-gray-900",style:{left:0,top:0,visibility:"hidden"},children:c(s)})]})}const FK={"7d":7,"30d":30,"90d":90};function Cf(e){const t=n=>n<10?`0${n}`:`${n}`;return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function i0(e,t){const n=new Date(t);return n.setDate(n.getDate()-(FK[e]-1)),{from:Cf(n),to:Cf(t)}}function qK(e,t){const n=new Date(t.getTime()-(e==="1h"?36e5:864e5));return{fromTs:n.toISOString(),toTs:t.toISOString(),from:Cf(n),to:Cf(t)}}function VK(e,t){const n=Date.parse(`${t}T00:00:00Z`)-Date.parse(`${e}T00:00:00Z`);return!Number.isFinite(n)||n<0?1:Math.round(n/864e5)+1}function GK(e){return e<=92?"day":e<=190?"week":"month"}function KK(e,t){return e==="1h"?"minute":e==="1d"?"hour":e==="custom"?GK(t):"day"}function sb(e,t){return e==="minute"||e==="hour"?t.slice(11):e==="month"?t:t.slice(5)}function ib(e,t){return e==="minute"||e==="hour"?t.replace("T"," "):t}const WK=Y0.length;function YK(e,t,n=WK){const s=e.slice(0,n).map(c=>({...c})),o=e.slice(n);return o.length===0?s:o.length===1?[...s,{...o[0],other:!0}]:[...s,{...t4(o),label:t(o.length),other:!0}]}function t4(e){const t=e[0]?.requests.length??0,n=s=>Array.from({length:t},(o,c)=>e.reduce((u,f)=>u+(s(f)[c]??0),0));return{requests:n(s=>s.requests),completed:n(s=>s.completed),denominator:n(s=>s.denominator)}}function Nj(e){return e.denominator.map((t,n)=>t>0?(e.completed[n]??0)/t*100:null)}function XK(e){return e.map(t=>{const n=JC(t.cacheRead,t.cacheWrite);return n===null?null:n*100})}const QK=100;function n4(e){return e.map(t=>t??QK)}function ZK(e){const t=[],n=[],s=[];let o=!1;return e.forEach((c,u)=>{if(c.requests===0&&c.total===0){o=!0;return}o&&t.length>0&&s.push(t.length-1),o=!1,n.push(u),t.push(c)}),{points:t,kept:n,breaks:s}}function Tj(e,t){const n=s=>t.map(o=>s[o]??0);return{requests:n(e.requests),completed:n(e.completed),denominator:n(e.denominator)}}function ap({text:e}){return a.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:e??d.usage.empty})}function JK(e){return e==="cacheRead"?d.usage.colCacheRead:e==="cacheWrite"?d.usage.colCacheWrite:d.usage.colOutput}function eW(...e){return Math.max(4,Math.ceil(Math.max(0,...e)/4)*4)}function yx(e){return Lf(e==null?null:e/100)}function ef(e,t){return e.other?Xf:Ry(t)}function tW({entities:e,active:t,onHover:n}){return a.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-4 gap-y-1 text-[10px] text-gray-500 dark:text-gray-400",children:[e.map((s,o)=>a.jsxs("button",{type:"button",onMouseEnter:()=>n(o),onMouseLeave:()=>n(null),className:`flex min-w-0 items-center gap-1.5 transition-opacity duration-150 ${t!=null&&t!==o?"opacity-30":""}`,children:[a.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-[2px] ${ef(s,o).swatch}`}),a.jsx("span",{className:"max-w-40 truncate font-mono",children:s.label})]},`${s.label}:${o}`)),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:`inline-block h-0.5 w-3 shrink-0 rounded-sm ${Xf.swatch}`}),d.usage.legendSuccessRate]})]})}function Mj({series:e,entities:t,granularity:n,breaks:s}){const[o,c]=y.useState(null),[u,f]=y.useState(null),[p,h]=np(),x=YK(t,d.usage.legendOther);if(e.length===0||x.length===0)return a.jsx(ap,{});const g=t4(x),v=Nj(g),w=x.map(L=>Nj(L)),S=w.map(n4),C=nb(e.length,eW(...g.requests),h,jf),N=tp(e.length,0,100,h,jf),T=ZM(C.step),_=e.map(L=>L.bucket),R=e.map((L,F)=>JM(C,x.map(V=>V.requests[F]??0))),D=(L,F)=>u===null||u.entity===L&&(u.bucket===null||u.bucket===F),z=L=>u===null||u.entity===L,E=(L,F)=>D(L,F)?u===null&&o!==null&&o!==F?.35:1:.15;return a.jsx("div",{ref:p,children:h>0&&a.jsxs(a.Fragment,{children:[a.jsxs(rp,{geom:C,fmtY:L=>String(Math.round(L)),dates:_,fmtX:L=>sb(n,L),hover:o,onHover:L=>{L===null?(c(null),f(null)):c(L)},labels:QM(e.length,C.step),hoverLine:!1,axisBreaks:s,rightAxis:{y:N.y,ticks:[0,50,100],fmt:L=>`${L}%`},bubble:L=>a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-gray-400",children:ib(n,_[L])}),x.map((F,V)=>a.jsxs("p",{className:`flex items-center gap-1.5 font-mono ${u?.entity===V?"font-semibold":""}`,children:[a.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-[2px] ${ef(F,V).swatch}`}),a.jsx("span",{className:"max-w-32 truncate",children:F.label}),a.jsx("span",{className:"ml-auto min-w-8 pl-2 text-right tabular-nums",children:F.requests[L]??0}),a.jsx("span",{className:"min-w-10 pl-1.5 text-right tabular-nums",children:yx(w[V][L])})]},`${F.label}:${V}`)),x.length>1&&a.jsxs("p",{className:"flex items-center gap-1.5 font-mono text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:"inline-block h-2 w-2 shrink-0"}),a.jsx("span",{className:"max-w-32 truncate",children:d.usage.bucketTotal}),a.jsx("span",{className:"ml-auto min-w-8 pl-2 text-right tabular-nums",children:g.requests[L]??0}),a.jsx("span",{className:"min-w-10 pl-1.5 text-right tabular-nums",children:yx(v[L])})]})]}),hitLayer:[...e.map((L,F)=>a.jsx("rect",{x:C.x(F)-C.step/2,y:0,width:C.step,height:C.y(0),fill:"transparent",className:"cursor-crosshair",onMouseEnter:()=>{c(F),f(null)}},`col-${_[F]}`)),...e.map((L,F)=>R[F].map(V=>a.jsx("rect",{x:C.x(F)-T/2,y:V.hitY,width:T,height:V.hitH,fill:"transparent",className:"cursor-pointer",onMouseEnter:()=>{c(F),f({entity:V.index,bucket:F})}},`seg-${_[F]}-${V.index}`))),...x.map((L,F)=>a.jsx(e4,{geom:N,values:S[F],onEnter:V=>{c(V),f({entity:F,bucket:null})}},`line-${L.label}:${F}`))],children:[e.map((L,F)=>R[F].map(V=>a.jsx("rect",{x:C.x(F)-T/2,y:V.y,width:T,height:V.h,className:`${ef(x[V.index],V.index).text} transition-opacity duration-150`,fill:"currentColor",opacity:E(V.index,F)},`${_[F]}-${V.index}`))),x.map((L,F)=>a.jsx("path",{d:rb(N,S[F]),fill:"none",stroke:"currentColor",strokeWidth:ab,strokeDasharray:"4 3",className:`${ef(L,F).text} pointer-events-none transition-opacity duration-150`,opacity:z(F)?1:.15},`rate-${L.label}:${F}`))]}),a.jsx(tW,{entities:x,active:u?.bucket==null?u?.entity??null:null,onHover:L=>f(L===null?null:{entity:L,bucket:null})})]})})}const nW="text-amber-500 dark:text-amber-600",r4="bg-amber-500 dark:bg-amber-600";function rW({series:e,granularity:t,legend:n,breaks:s}){const[o,c]=y.useState(null),[u,f]=np();if(e.length===0||e.every(D=>D.total===0))return a.jsx(ap,{});const p=e.map(D=>D.cacheRead+D.cacheWrite+D.output),h=Math.max(1,...p),x=nb(e.length,h,f,jf),g=tp(e.length,0,100,f,jf),v=ZM(x.step),w=e.map(D=>D.bucket),S=e.map(D=>BK(x,D)),C=XK(e),N=n4(C),T=(D,z)=>o?.key!=null&&!(o.i===D&&o.key===z)||n!=null&&n!==z,_=n!=null&&n!=="hitRate"||o?.key!=null&&o.key!=="hitRate",R=(D,z,E,L)=>a.jsxs("p",{className:`flex items-center gap-1.5 font-mono ${L?"font-semibold":""}`,children:[D,z,a.jsx("span",{className:"ml-auto pl-2 tabular-nums",children:E})]},z);return a.jsx("div",{ref:u,children:f>0&&a.jsxs(rp,{geom:x,fmtY:D=>It(Math.round(D)),dates:w,fmtX:D=>sb(t,D),hover:o?.i??null,labels:QM(e.length,x.step),hoverLine:!1,rightAxis:{y:g.y,ticks:[0,50,100],fmt:D=>`${D}%`},axisBreaks:s,onHover:D=>{D===null&&c(null)},bubble:D=>{const z=e[D],E=o?.key??null,L=F=>a.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:F}});return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-gray-400",children:ib(t,z.bucket)}),["cacheRead","cacheWrite","output"].map(F=>R(L(Tl[F]),JK(F),It(z[F]),E===F)),R(a.jsx("span",{className:`inline-block h-0.5 w-2 shrink-0 rounded-sm ${r4}`}),d.usage.legendHitRate,yx(C[D]),E==="hitRate")]})},hitLayer:[...e.map((D,z)=>a.jsx("rect",{x:x.x(z)-x.step/2,y:0,width:x.step,height:x.y(0),fill:"transparent",className:"cursor-crosshair",onMouseEnter:()=>c({i:z,key:null})},`col-${D.bucket}`)),...e.map((D,z)=>S[z].map(E=>a.jsx("rect",{x:x.x(z)-v/2,y:E.hitY,width:v,height:E.hitH,fill:"transparent",className:"cursor-pointer",onMouseEnter:()=>c({i:z,key:E.key}),onMouseLeave:()=>c(L=>L?.i===z&&L.key===E.key?{i:z,key:null}:L)},`hit-${D.bucket}-${E.key}`))),a.jsx(e4,{geom:g,values:N,onEnter:D=>c({i:D,key:"hitRate"})},"hit-rate-line")],children:[e.map((D,z)=>S[z].map(E=>a.jsx("rect",{x:x.x(z)-v/2,y:E.y,width:v,height:E.h,fill:Tl[E.key],className:"transition-opacity duration-150",opacity:T(z,E.key)?.2:1},`${D.bucket}-${E.key}`))),a.jsxs("g",{className:`${nW} pointer-events-none transition-opacity duration-150`,opacity:_?.3:1,children:[a.jsx("path",{d:rb(g,N),fill:"none",stroke:"currentColor",strokeWidth:ab,strokeDasharray:"5 4"}),o!==null&&a.jsx("circle",{cx:g.x(o.i),cy:g.y(N[o.i]??0),r:2.5,className:"fill-current"})]})]})})}function aW({active:e,onHover:t}){const n=[["cacheRead",d.usage.colCacheRead],["cacheWrite",d.usage.colCacheWrite],["output",d.usage.colOutput]],s=o=>e!=null&&e!==o?"opacity-30":"";return a.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[n.map(([o,c])=>a.jsxs("button",{type:"button",onMouseEnter:()=>t?.(o),onMouseLeave:()=>t?.(null),className:`flex items-center gap-1 text-[10px] text-gray-500 transition-opacity duration-150 dark:text-gray-400 ${s(o)}`,children:[a.jsx("span",{className:"inline-block h-2 w-3 rounded-sm",style:{backgroundColor:Tl[o]}}),c]},o)),a.jsxs("button",{type:"button",onMouseEnter:()=>t?.("hitRate"),onMouseLeave:()=>t?.(null),className:`flex items-center gap-1 text-[10px] text-gray-500 transition-opacity duration-150 dark:text-gray-400 ${s("hitRate")}`,children:[a.jsx("span",{className:`inline-block h-0.5 w-3 rounded-sm ${r4}`}),d.usage.legendHitRate]})]})}const sW=8;function iW({series:e,granularity:t,currency:n="USD",breaks:s}){const[o,c]=y.useState(null),[u,f]=np();if(e.length===0)return a.jsx(ap,{});const p=e.map(w=>w.cost??0),h=Math.max(1e-9,...p),x=nb(e.length,h,f),g=e.map(w=>w.bucket),v=x.step>=sW;return a.jsx("div",{ref:u,children:f>0&&a.jsx(rp,{geom:x,fmtY:w=>rs(w,n),dates:g,fmtX:w=>sb(t,w),hover:o,onHover:c,axisBreaks:s,bubble:w=>{const S=e[w];return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-gray-400",children:ib(t,S.bucket)}),a.jsx("p",{className:"font-mono",children:rs(S.cost??0,n)})]})},children:a.jsxs("g",{children:[a.jsx("path",{d:RK(x,p),className:"fill-current",stroke:"none",opacity:o!==null?.06:.1}),a.jsx("path",{d:rb(x,p),fill:"none",stroke:"currentColor",strokeWidth:ab,opacity:o!==null?.35:1}),v&&e.map((w,S)=>a.jsx("circle",{cx:x.x(S),cy:x.y(p[S]??0),r:o===S?4:2.5,className:"fill-current",opacity:o!==null&&o!==S?.25:1},w.bucket)),!v&&o!==null&&a.jsx("circle",{cx:x.x(o),cy:x.y(p[o]??0),r:4,className:"fill-current"})]})})})}function oW(e){return e==="unexpected"?d.usage.errorsUnexpected:d.usage.errorsExpected}function lW(e){return e==="unexpected"?"unexpected":"expected"}const cW={environment:"env"};function Ej(e,t){return`[${cW[e]??e}] ${t}`}function zm({label:e,value:t,alert:n,muted:s}){const o=n?sn.danger:s?"text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100";return a.jsxs("div",{className:"flex items-baseline gap-1.5",children:[a.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e}),a.jsx("span",{className:`font-mono text-sm font-semibold tabular-nums ${o}`,children:t})]})}function Bm({children:e,className:t=""}){return a.jsx("th",{className:`py-1.5 pr-2 font-medium ${t}`,children:e})}function uW({errors:e,projectId:t,filters:n}){const{total:s,unexpected:o,topCode:c,recent:u}=e,f=Math.max(1,u.length),[p,h]=y.useState(0),[x,g]=y.useState(u),[v,w]=y.useState(s),[S,C]=y.useState(null),[N,T]=y.useState(!1);y.useEffect(()=>h(0),[u]),y.useEffect(()=>{if(p===0){g(u),w(s),C(null);return}let E=!1;return T(!0),C(null),vA(t,{offset:p*f,limit:f,...n}).then(L=>{E||(g(L.items),w(L.total))}).catch(L=>{E||C(Ae(L))}).finally(()=>{E||T(!1)}),()=>{E=!0}},[p,f,t,n,u,s]);const _=Math.max(1,Math.ceil(v/f)),[R,D]=y.useState(new Set);y.useEffect(()=>D(new Set),[x]);const z=E=>D(L=>{const F=new Set(L);return F.has(E)?F.delete(E):F.add(E),F});return a.jsxs("div",{children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1.5",children:[a.jsx(zm,{label:d.usage.errorsTotal,value:String(s)}),a.jsx(zm,{label:d.usage.errorsUnexpected,value:String(o),alert:o>0,muted:o===0}),a.jsx(zm,{label:d.usage.errorsExpected,value:String(s-o),muted:!0}),c&&a.jsx(zm,{label:d.usage.errorsTopCode,value:`${Ej(c.source,c.code)} ×${c.count}`})]}),x.length===0?a.jsx(ap,{text:d.usage.errorsEmpty}):a.jsx("div",{className:"mt-2.5 overflow-x-auto overflow-y-clip border-t border-gray-200 dark:border-gray-800",children:a.jsxs("table",{className:"w-full min-w-[720px] table-fixed text-xs",children:[a.jsx("thead",{className:"text-left text-gray-400 dark:text-gray-500",children:a.jsxs("tr",{children:[a.jsx(Bm,{className:"w-32",children:d.common.time}),a.jsx(Bm,{className:"w-72",children:d.usage.errorsColCode}),a.jsx(Bm,{className:"w-20",children:d.usage.errorsColKind}),a.jsx(Bm,{children:d.usage.errorsColMessage})]})}),a.jsx("tbody",{children:x.map((E,L)=>{const F=lW(E.kind);return a.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-800/60",children:[a.jsx("td",{className:"py-1.5 pr-2 align-top font-mono tabular-nums text-gray-400",children:Jr(E.ts)}),a.jsx("td",{className:"py-1.5 pr-2 align-top font-mono text-gray-500 dark:text-gray-400",children:a.jsx("span",{className:"block break-words",children:Ej(E.source,E.code)})}),a.jsx("td",{className:"py-1.5 pr-2 align-top",children:a.jsx(On,{tone:F==="unexpected"?"red":"gray",children:oW(F)})}),a.jsx("td",{className:"py-1.5 align-top text-gray-500 dark:text-gray-400",children:a.jsx("button",{type:"button",title:E.message,onClick:()=>z(L),className:`block w-full cursor-pointer text-left transition-colors hover:text-gray-700 dark:hover:text-gray-300 ${R.has(L)?"whitespace-pre-wrap break-words":"truncate"}`,children:E.message})})]},`${E.ts}-${L}`)})})]})}),(_>1||p>0)&&a.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 text-xs text-gray-500 dark:text-gray-400",children:[S!==null&&a.jsx("span",{className:"mr-auto text-rose-500",children:S}),a.jsx("span",{className:"tabular-nums",children:d.usage.errorsPageOf(p+1,_,v)}),a.jsx(Aj,{label:d.usage.errorsNewer,disabled:p===0||N,onClick:()=>h(E=>Math.max(0,E-1))}),a.jsx(Aj,{label:d.usage.errorsOlder,disabled:p+1>=_||N,onClick:()=>h(E=>E+1)})]})]})}function Aj({label:e,disabled:t,onClick:n}){return a.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded-md border border-gray-200 px-2 py-0.5 transition-colors duration-150 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:border-gray-800 dark:hover:bg-gray-800/60 dark:disabled:hover:bg-transparent",children:e})}function o0({label:e,value:t,muted:n,sup:s}){const o=n?"text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100";return a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsxs("span",{className:"shrink-0 text-xs text-gray-500 dark:text-gray-400",children:[e,s&&a.jsx("sup",{className:"ml-px",children:"*"})]}),a.jsx("span",{className:`min-w-0 truncate font-mono text-sm font-semibold tabular-nums ${o}`,children:t})]})}function l0({title:e,bucket:t,currency:n}){return a.jsxs("div",{className:"rounded-md border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("p",{className:"mb-1.5 text-xs font-medium text-gray-500 dark:text-gray-400",children:e}),a.jsxs("div",{className:"space-y-0.5",children:[a.jsx(o0,{label:d.usage.tokens,value:It(t.total)}),a.jsx(o0,{label:d.usage.requests,value:String(t.requests),muted:!0}),a.jsx(o0,{label:d.common.cost,value:rs(t.cost,n),sup:t.hasUncosted})]})]})}function au({title:e,extra:t,children:n}){return a.jsxs("div",{className:"rounded-md border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900",children:[a.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-x-2 gap-y-1",children:[a.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:e}),t]}),n]})}function dW(){Li(d.usage.title);const{currency:e}=as(),{currentProject:t}=en(),n=t?.projectId??null,[s]=Ox(),o=s.get("agentId"),[c,u]=y.useState(o??""),[f,p]=y.useState(null);y.useEffect(()=>{u(o??"")},[o]);const[h,x]=y.useState("7d"),[g,v]=y.useState(()=>i0("7d",new Date).from),[w,S]=y.useState(()=>i0("7d",new Date).to),C=($,X,le)=>{x($),v(X),S(le)},[N,T]=y.useState(null),[_,R]=y.useState(null),[D,z]=y.useState(null),E=y.useCallback(async()=>{if(n){R(null);try{const $=h==="1h"||h==="1d"?qK(h,new Date):{from:g,to:w},X=await iC(n,{...$,groupBy:"date",granularity:KK(h,VK(g,w)),...c?{agentId:c}:{},...f?{provider:f.provider,modelId:f.modelId}:{}});T(X)}catch($){R(Ae($))}}},[n,h,g,w,c,f?.provider,f?.modelId]);y.useEffect(()=>{T(null),E()},[E]);const L=y.useMemo(()=>({from:g,to:w,...c?{agentId:c}:{}}),[g,w,c]);if(!n)return null;const F=N?.models??[],V=f?F.findIndex($=>$.provider===f.provider&&$.modelId===f.modelId):-1,P=V>=0?String(V):"",B=N?.summary,Y=(B?.today.hasUncosted??!1)||(B?.last7d.hasUncosted??!1)||(B?.total.hasUncosted??!1),q=ZK(N?.series??[]),K=(N?.byAgentSeries??[]).map($=>({label:$.agentId,...Tj($,q.kept)})),H=(N?.byModelSeries??[]).map($=>({label:G0($.provider,$.modelId)?.displayName??$.modelId,...Tj($,q.kept)}));return a.jsx("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:a.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.jsx("h1",{className:"text-xl font-semibold",children:d.usage.title}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("div",{className:"w-32",children:a.jsxs(Ss,{size:"sm",value:c,onChange:$=>u($.target.value),children:[a.jsx("option",{value:"",children:d.usage.filterAllAgents}),c&&!(N?.agentIds??[]).includes(c)&&a.jsx("option",{value:c,children:c}),(N?.agentIds??[]).map($=>a.jsx("option",{value:$,children:$},$))]})}),a.jsx("div",{className:"w-32",children:a.jsxs(Ss,{size:"sm",value:P,onChange:$=>{const X=$.target.value;p(X===""?null:F[Number(X)]??null)},children:[a.jsx("option",{value:"",children:d.usage.filterAllModels}),F.map(($,X)=>a.jsx("option",{value:String(X),children:G0($.provider,$.modelId)?.displayName??$.modelId},`${$.provider}:${$.modelId}`))]})}),a.jsx("div",{className:"w-28",children:a.jsxs(Ss,{size:"sm",value:h,"aria-label":d.usage.rangeLabel,onChange:$=>{const X=$.target.value;if(X==="7d"||X==="30d"||X==="90d"){const le=i0(X,new Date);C(X,le.from,le.to)}else C(X,g,w)},children:[a.jsx("option",{value:"1h",children:d.usage.rangeHour}),a.jsx("option",{value:"1d",children:d.usage.rangeDay}),a.jsx("option",{value:"7d",children:d.usage.range7d}),a.jsx("option",{value:"30d",children:d.usage.range30d}),a.jsx("option",{value:"90d",children:d.usage.range90d}),a.jsx("option",{value:"custom",children:d.usage.rangeCustom})]})}),h==="custom"&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(at,{size:"sm",type:"date","aria-label":d.usage.from,value:g,onChange:$=>C("custom",$.target.value,w)}),a.jsx("span",{className:"shrink-0 text-gray-400","aria-hidden":!0,children:"–"}),a.jsx(at,{size:"sm",type:"date","aria-label":d.usage.to,value:w,onChange:$=>C("custom",g,$.target.value)})]})]})]}),N?a.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[a.jsx(l0,{title:d.usage.today,bucket:N.summary.today,currency:e}),a.jsx(l0,{title:d.usage.last7d,bucket:N.summary.last7d,currency:e}),a.jsx(l0,{title:d.usage.total,bucket:N.summary.total,currency:e})]}):a.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[a.jsx(on,{className:"h-24"}),a.jsx(on,{className:"h-24"}),a.jsx(on,{className:"h-24"})]}),N?a.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[a.jsx(au,{title:d.usage.chartRequestsByAgent,children:a.jsx(Mj,{series:q.points,entities:K,granularity:N.granularity,breaks:q.breaks})}),a.jsx(au,{title:d.usage.chartRequestsByModel,children:a.jsx(Mj,{series:q.points,entities:H,granularity:N.granularity,breaks:q.breaks})}),a.jsx(au,{title:d.usage.chartTokenTrend,extra:a.jsx(aW,{active:D,onHover:z}),children:a.jsx(rW,{series:q.points,granularity:N.granularity,legend:D,breaks:q.breaks})}),a.jsx(au,{title:d.usage.chartCostTrend,children:a.jsx(iW,{series:q.points,granularity:N.granularity,currency:e,breaks:q.breaks})})]}):a.jsx(on,{className:"h-64"}),N&&a.jsx(au,{title:d.usage.errors,children:a.jsx(uW,{errors:N.errors,projectId:n,filters:L})}),Y&&a.jsx("p",{className:"text-xs text-gray-400",children:d.usage.uncostedNote}),_&&a.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:_})]})})}function a4(e){return e.map(t=>typeof t.score=="number"&&Number.isFinite(t.score)?t.score:null)}const Hm=0,Fm=100,_j=10,mW=[1,2,2.5,5,10,20];function fW(e){const t=e.filter(x=>x!==null&&x>=Hm&&x<=Fm);if(t.length===0)return{min:Hm,max:Fm,ticks:[0,20,40,60,80,100]};const n=Math.min(...t),s=Math.max(...t),o=Math.max(Hm,n-_j),c=Math.min(Fm,s+_j),u=mW.find(x=>(c-o)/x<=5),f=Math.max(Hm,Math.floor(o/u)*u),p=Math.min(Fm,Math.ceil(c/u)*u),h=Array.from({length:Math.round((p-f)/u)+1},(x,g)=>f+g*u);return{min:f,max:p,ticks:h}}function pW(e){const t=new Map;e.forEach((s,o)=>{const c=s.modelId!==void 0&&s.modelId!=="",u=c?`${s.modelId}\0${s.thinkingLevel??""}`:"";let f=t.get(u);f||(f={key:u,...c&&s.modelId!==void 0?{modelId:s.modelId}:{},...c&&s.thinkingLevel!==void 0?{thinkingLevel:s.thinkingLevel}:{},indices:[]},t.set(u,f)),f.indices.push(o)});const n=[...t.values()];return[...n.filter(s=>s.key!==""),...n.filter(s=>s.key==="")]}function hW(e,t){const n=new Set(t.indices);return a4(e).map((s,o)=>n.has(o)?s:null)}const gW=new Set(["txt","md","json","js","mjs","cjs","ts","tsx","jsx","py","sh","bash","yaml","yml","toml","css","html","htm","csv","log","xml","ini","conf","sql","svg"]),xW=new Set(["png","jpg","jpeg","gif","webp"]),Rj=/^[a-z][a-z0-9+.-]*:/i,yW=64*1024;function s4(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():e.toLowerCase()}function Ij(e){return e.includes("/")?e.slice(0,e.lastIndexOf("/")):""}function Lj(e,t){const n=t.startsWith("/")||e===""?[]:e.split("/");for(const s of t.split("/"))s===""||s==="."||(s===".."?n.pop():n.push(s));return n.join("/")}function bW(e){const t=s4(e);return{json:"json",md:"markdown",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",sh:"shellscript",bash:"shellscript",yaml:"yaml",yml:"yaml",toml:"toml",css:"css",html:"html",htm:"html",xml:"xml",sql:"sql",svg:"xml"}[t]??"text"}function Oj({projectId:e,agentId:t,benchmarkId:n,caseSummary:s,material:o,label:c,hiddenLabel:u,defaultOpen:f=!1,autoPreviewReadme:p=!1,onPreview:h}){const[x,g]=y.useState(f),[v,w]=y.useState(""),[S,C]=y.useState(null),[N,T]=y.useState(null),_=y.useRef(!1);y.useEffect(()=>{if(!x)return;C(null),T(null);let z=!1;return RA(e,t,n,s.id,v,o).then(E=>{if(!z&&(C({base:v,res:E}),p&&v===""&&!_.current)){_.current=!0;const L=E.entries.find(F=>F.kind==="file"&&F.name.toLowerCase()==="readme.md");L&&h(o,L.name)}}).catch(E=>{z||T(Ae(E))}),()=>{z=!0}},[e,t,n,s.id,o,p,h,x,v]);const R=v===""?[]:v.split("/"),D=z=>{if(S===null)return;const E=Ym(S.base,z.name);if(z.kind==="dir"){w(E);return}h(o,E)};return a.jsxs("div",{className:"border-b border-gray-200 last:border-b-0 dark:border-gray-800",children:[a.jsxs("button",{type:"button","aria-expanded":x,onClick:()=>g(z=>!z),className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-800/60",children:[a.jsx("span",{className:"text-xs text-gray-400",children:x?"▾":"▸"}),a.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:c}),u&&a.jsx("span",{className:"shrink-0 rounded bg-gray-200/70 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:u})]}),x&&a.jsxs("div",{children:[R.length>0&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-t border-gray-100 px-5 py-1.5 dark:border-gray-800/70",children:[a.jsx("button",{type:"button",onClick:()=>w(""),className:"rounded px-1 py-0.5 text-xs text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",children:c}),R.map((z,E)=>a.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[a.jsx("span",{className:"text-gray-300 dark:text-gray-700",children:"/"}),a.jsx("button",{type:"button",onClick:()=>w(R.slice(0,E+1).join("/")),className:"max-w-24 truncate rounded px-1 py-0.5 text-xs text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-800",children:z})]},`${z}-${E}`))]}),N&&a.jsx("p",{className:"px-6 py-2 text-xs text-red-500",children:N}),!S&&!N&&a.jsx(Sr,{rows:3}),S?.res.entries.length===0&&a.jsx("p",{className:"px-6 py-2 text-xs text-gray-400",children:d.files.empty}),S?.res.entries.map(z=>a.jsxs("button",{type:"button",onClick:()=>D(z),className:"flex w-full items-center gap-2 border-t border-gray-100 px-6 py-2 text-left hover:bg-gray-100 dark:border-gray-800/70 dark:hover:bg-gray-800/60",children:[a.jsx("span",{className:"text-sm text-gray-400",children:z.kind==="dir"?"▸":"·"}),a.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:z.name}),z.kind==="file"&&a.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:ju(z.sizeBytes)})]},`${z.kind}/${z.name}`))]})]})}function vW({projectId:e,agentId:t,benchmarkId:n,caseSummary:s}){const[o,c]=y.useState(null),u=y.useRef(0),f=y.useCallback((v,w,S)=>IA(e,t,n,s.id,w,v,S),[e,t,n,s.id]),p=y.useCallback(async(v,w)=>{const S=++u.current,C=w.includes("/")?w.slice(w.lastIndexOf("/")+1):w,N=s4(C);if(xW.has(N)){c({material:v,path:w,name:C,kind:"image"});return}if(N==="pdf"){c({material:v,path:w,name:C,kind:"pdf"});return}const T=N==="md";if(!gW.has(N)){c({material:v,path:w,name:C,kind:"unsupported"});return}c({material:v,path:w,name:C,kind:T?"md":"text",loading:!0});try{const _=await fetch(f(v,w,{preview:!0}),{credentials:"same-origin"});if(!_.ok)throw new Error(String(_.status));const R=await _.text();if(S!==u.current)return;c({material:v,path:w,name:C,kind:T?"md":"text",content:R,truncated:_.headers.get("x-content-truncated")==="1"})}catch(_){if(S!==u.current)return;c({material:v,path:w,name:C,kind:T?"md":"text",error:Ae(_)})}},[f]),h=o?f(o.material,o.path,{download:!0}):null,x=o?.material==="rubric"?d.benchmark.rubric:d.benchmark.taskMaterials,g={img:({src:v,alt:w})=>a.jsx("img",{src:typeof v=="string"&&!Rj.test(v)?f(o?.material??"statement",Lj(Ij(o?.path??""),v)):v,alt:w??"",loading:"lazy",className:"max-w-full"}),a:({href:v,children:w})=>{if(typeof v!="string"||v.startsWith("#"))return a.jsx("a",{href:v,children:w});if(Rj.test(v))return a.jsx("a",{href:v,target:"_blank",rel:"noreferrer",children:w});const S=Lj(Ij(o?.path??""),v),C=o?.material??"statement";return a.jsx("a",{href:f(C,S),onClick:N=>{N.preventDefault(),p(C,S)},children:w})}};return a.jsxs("div",{className:"grid min-h-[58vh] grid-cols-1 overflow-hidden rounded-md border border-gray-200 md:grid-cols-[240px_minmax(0,1fr)] dark:border-gray-800",children:[a.jsx("aside",{className:"border-b border-gray-200 bg-gray-50/60 md:border-b-0 md:border-r dark:border-gray-800 dark:bg-gray-950/30",children:a.jsxs("div",{className:"max-h-44 overflow-y-auto md:max-h-[53vh]",children:[a.jsx(Oj,{projectId:e,agentId:t,benchmarkId:n,caseSummary:s,material:"statement",label:d.benchmark.taskMaterials,defaultOpen:!0,autoPreviewReadme:!0,onPreview:p}),a.jsx(Oj,{projectId:e,agentId:t,benchmarkId:n,caseSummary:s,material:"rubric",label:d.benchmark.rubric,hiddenLabel:d.benchmark.agentHidden,defaultOpen:!0,onPreview:p})]})}),a.jsxs("section",{className:"min-w-0",children:[a.jsxs("div",{className:"flex min-h-11 flex-wrap items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[a.jsx("div",{className:"min-w-0 flex-1",children:a.jsx("p",{className:"truncate font-mono text-xs text-gray-500",children:o?`${x} / ${o.path}`:s.id})}),h&&o&&a.jsx("a",{href:h,download:o.name,className:"rounded-md px-2.5 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800",children:d.files.download})]}),a.jsx("div",{className:"max-h-[52vh] min-h-[52vh] overflow-auto p-3",children:o?o.loading?a.jsx(Sr,{rows:8}):o.error?a.jsx("p",{className:"text-sm text-red-500",children:o.error}):o.kind==="image"?a.jsx("img",{src:f(o.material,o.path),alt:o.name,loading:"lazy",className:"max-w-full rounded-md border border-gray-200 dark:border-gray-800"}):o.kind==="pdf"?a.jsx("iframe",{src:f(o.material,o.path),title:o.name,className:"h-[50vh] w-full rounded-md border border-gray-200 dark:border-gray-800"}):o.kind==="md"?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"md-body text-sm text-gray-800 dark:text-gray-100",children:a.jsx(Zu,{remarkPlugins:Ju,components:g,children:o.content??""})}),o.truncated&&a.jsx("p",{className:"mt-2 text-xs text-gray-400",children:d.files.previewTruncated})]}):o.kind==="text"?a.jsxs(a.Fragment,{children:[a.jsx(Cy,{language:bW(o.name),code:o.content??"",highlight:(o.content?.length??0)<=yW}),o.truncated&&a.jsx("p",{className:"mt-2 text-xs text-gray-400",children:d.files.previewTruncated})]}):a.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:d.files.previewUnsupported}):a.jsx("p",{className:"text-sm text-gray-400",children:d.benchmark.caseFileUnavailable})})]})]})}function kW({projectId:e,agentId:t,name:n,defaultOpen:s,selection:o,onSelect:c}){const[u,f]=y.useState(s),[p,h]=y.useState(null),[x,g]=y.useState(null);return y.useEffect(()=>{!u||p||AA(e,t).then(v=>h(v.benchmarks)).catch(v=>g(Ae(v)))},[u,p,e,t]),a.jsxs("li",{className:"pt-2.5",children:[a.jsx("div",{className:"flex items-center px-1 pb-0.5",children:a.jsxs("button",{type:"button",onClick:()=>f(v=>!v),"aria-label":u?d.nav.collapseGroup:d.nav.expandGroup,className:"flex min-w-0 flex-1 items-center gap-1 rounded px-1 py-0.5 text-left transition-colors duration-150 hover:bg-gray-200/50 dark:hover:bg-gray-800/50",children:[a.jsx(Ha,{id:t,name:n,size:18,className:"shrink-0 rounded"}),a.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:n}),a.jsx(Zn,{open:u,size:12,className:"text-gray-400"}),a.jsx("span",{className:"min-w-0 flex-1"})]})}),u&&a.jsxs("div",{className:"anim-fade",children:[x&&a.jsx("p",{className:"px-2.5 py-1 text-xs text-red-500",children:x}),!p&&!x&&a.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400",children:d.common.loading}),p&&p.length===0&&a.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400 dark:text-gray-600",children:d.benchmark.emptyAgent}),a.jsx("ul",{className:"space-y-0.5",children:p?.map(v=>{const w=o?.agentId===t&&o.benchmark.id===v.id;return a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>c({agentId:t,benchmark:v}),className:`flex w-full items-center gap-1.5 rounded-md px-2.5 py-1.5 text-left transition-colors duration-150 ${w?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[a.jsx(Of,{text:v.title,className:`min-w-0 flex-1 text-sm ${w?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`}),a.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400",children:v.caseCount})]})},v.id)})})]})]})}function wW({evaluations:e,series:t}){const[n,s]=y.useState(null),[o,c]=np(),u=a4(e),f=fW(u),p=tp(e.length,f.min,f.max,c),h=e.map(x=>Jr(x.time));return a.jsx("div",{ref:o,children:c>0&&a.jsx(rp,{geom:p,fmtY:Su,dates:h,hover:n,onHover:s,yTicks:f.ticks,bubble:x=>{const g=e[x],v=u[x]??null;return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-gray-400",children:Jr(g.time)}),a.jsxs("p",{className:"font-mono",children:[v===null?"—":Su(v),g.version!==void 0&&a.jsxs("span",{className:"ml-1.5 text-gray-400",children:["v",g.version]})]}),a.jsxs("p",{className:"font-mono text-gray-400",children:[g.modelId," · ",g.thinkingLevel]})]})},children:t.map((x,g)=>{const v=IK(hW(e,x));return a.jsx("g",{className:(x.modelId?Ry(g):Xf).text,children:v.map((w,S)=>a.jsxs("g",{children:[w.length>1&&a.jsx("path",{d:LK(p,w),fill:"none",stroke:"currentColor",strokeWidth:2,opacity:n!==null?.35:1}),w.map(C=>a.jsx("circle",{cx:p.x(C.index),cy:p.y(C.value),r:n===C.index?4:2.5,className:"fill-current",opacity:n!==null&&n!==C.index?.25:1},C.index))]},S))},x.key===""?"unlabeled":x.key)})})})}function SW({evaluations:e}){const t=pW(e),n=s=>s.modelId?s.thinkingLevel?`${s.modelId} · ${s.thinkingLevel}`:s.modelId:d.benchmark.legendUnlabeled;return a.jsxs("div",{children:[a.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:d.benchmark.trendTitle(d.benchmark.colScore)}),t.length>=2&&a.jsx("div",{className:"mb-1.5 flex flex-wrap items-center gap-x-3 gap-y-1",children:t.map((s,o)=>a.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[a.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-sm ${(s.modelId?Ry(o):Xf).swatch}`}),a.jsx("span",{className:"font-mono",children:n(s)})]},s.key===""?"unlabeled":s.key))}),a.jsx(wW,{evaluations:e,series:t})]})}const uo="px-3 py-2";function jW({evaluation:e,caseTitles:t,onOpenCase:n,currency:s}){const[o,c]=y.useState(!1);return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{onClick:()=>c(u=>!u),className:"cursor-pointer border-b border-gray-100 transition-colors duration-150 last:border-b-0 hover:bg-gray-50 dark:border-gray-800/60 dark:hover:bg-gray-800/40",children:[a.jsx("td",{className:uo,children:a.jsxs("span",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx(Zn,{open:o,size:12,className:"text-gray-400"}),Jr(e.time)]})}),a.jsx("td",{className:`${uo} font-mono text-xs text-gray-500 dark:text-gray-400`,children:e.version!==void 0?`v${e.version}`:"—"}),a.jsx("td",{className:`${uo} max-w-40 truncate font-mono text-xs text-gray-500 dark:text-gray-400`,title:e.provider,children:e.modelId}),a.jsx("td",{className:`${uo} font-mono text-xs text-gray-500 dark:text-gray-400`,children:e.thinkingLevel}),a.jsx("td",{className:`${uo} font-mono text-xs font-semibold tabular-nums`,children:Su(e.score)}),a.jsx("td",{className:`${uo} font-mono text-xs tabular-nums text-gray-500 dark:text-gray-400`,children:rs(e.cost,s)}),a.jsx("td",{className:`${uo} font-mono text-xs tabular-nums text-gray-500 dark:text-gray-400`,children:e.durationMs!==void 0?Pn(e.durationMs):"—"})]}),o&&a.jsx("tr",{className:"border-b border-gray-100 last:border-b-0 dark:border-gray-800/60",children:a.jsxs("td",{colSpan:7,className:"bg-gray-50/80 px-3 py-2 dark:bg-gray-950/40",children:[(e.summaryTitle||e.summary)&&a.jsxs("div",{className:"mb-2",children:[e.summaryTitle?a.jsx("p",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:e.summaryTitle}):a.jsx("p",{className:"text-xs font-semibold text-gray-500",children:d.benchmark.summaryLabel}),e.summary&&a.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-xs text-gray-600 dark:text-gray-300",children:e.summary})]}),a.jsxs("table",{className:"w-full text-left",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-xs text-gray-500",children:[a.jsx("th",{className:"px-2 py-1 font-medium",children:d.benchmark.colCase}),a.jsx("th",{className:"px-2 py-1 font-medium",children:d.benchmark.colScore}),a.jsx("th",{className:"px-2 py-1 font-medium",children:d.common.cost}),a.jsx("th",{className:"px-2 py-1 font-medium",children:d.benchmark.colDuration}),a.jsx("th",{className:"px-2 py-1 font-medium",children:d.benchmark.colSession})]})}),a.jsx("tbody",{children:e.cases.map(u=>a.jsx(NW,{caseScore:u,title:t.get(u.case),onOpenCase:t.has(u.case)?n:void 0,currency:s},u.case))})]})]})})]})}function CW({sessionId:e}){return e?a.jsx("span",{className:"font-mono text-gray-600 dark:text-gray-300",title:e,children:e}):a.jsx("span",{className:"text-gray-400",children:"—"})}function NW({caseScore:e,title:t,onOpenCase:n,currency:s}){const[o,c]=y.useState(!1),u=e.runs;return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{onClick:()=>c(f=>!f),className:"cursor-pointer text-xs transition-colors duration-150 hover:bg-gray-100/70 dark:hover:bg-gray-800/40",children:[a.jsx("td",{className:"px-2 py-1",children:a.jsxs("span",{className:"flex items-start gap-1.5",children:[a.jsx(Zn,{open:o,size:12,className:"text-gray-400"}),a.jsxs("span",{className:"min-w-0",children:[n?a.jsx("button",{type:"button",className:"block text-left font-medium text-gray-800 hover:underline dark:text-gray-200",onClick:f=>{f.stopPropagation(),n(e.case)},children:t??e.case}):a.jsx("span",{className:"block font-medium text-gray-800 dark:text-gray-200",children:t??e.case}),t&&t!==e.case&&a.jsx("span",{className:"block font-mono text-[11px] text-gray-400",children:e.case})]})]})}),a.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:Su(e.score)}),a.jsx("td",{className:"px-2 py-1 font-mono tabular-nums text-gray-500 dark:text-gray-400",children:rs(e.cost,s)}),a.jsx("td",{className:"px-2 py-1 font-mono tabular-nums text-gray-500 dark:text-gray-400",children:e.durationMs!==void 0?Pn(e.durationMs):"—"}),a.jsx("td",{className:"px-2 py-1",children:a.jsx("span",{className:"text-gray-400",children:"—"})})]}),o&&u.map((f,p)=>a.jsxs("tr",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.jsxs("td",{className:"py-1 pl-7 pr-2 font-mono",children:[d.benchmark.colRun," #",p+1]}),a.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:Su(f.score)}),a.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:rs(f.cost,s)}),a.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:f.durationMs!==void 0?Pn(f.durationMs):"—"}),a.jsx("td",{className:"px-2 py-1",children:a.jsx(CW,{...f.sessionId?{sessionId:f.sessionId}:{}})})]},p))]})}function TW({cases:e,error:t,onOpenCase:n}){return a.jsxs("div",{children:[a.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:d.benchmark.cases}),a.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[t&&a.jsx("p",{className:"px-3 py-2 text-xs text-red-500",children:t}),!e&&!t&&a.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:d.common.loading}),e?.map(s=>a.jsxs("button",{type:"button",onClick:()=>n(s.id),className:"flex w-full items-center gap-3 border-b border-gray-100 px-3 py-2 text-left transition-colors last:border-b-0 hover:bg-gray-50 dark:border-gray-800/70 dark:hover:bg-gray-800/50",children:[a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block text-sm font-medium text-gray-800 dark:text-gray-200",children:s.title}),a.jsx("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:s.id})]}),a.jsx("span",{className:"shrink-0 rounded-md px-2.5 py-1 text-xs font-medium text-gray-600 dark:text-gray-300",children:d.benchmark.viewCase})]},s.id))]})]})}function MW(){Li(d.benchmark.title);const{currentProject:e,agents:t,agentsLoading:n}=en(),{currency:s}=as(),o=e?.projectId??null,[c]=Ox(),u=c.get("agentId"),[f,p]=y.useState(null),[h,x]=y.useState(null),[g,v]=y.useState(null),[w,S]=y.useState(null);if(y.useEffect(()=>{p(null)},[o]),y.useEffect(()=>{if(x(null),v(null),S(null),!o||!f)return;let R=!1;return _A(o,f.agentId,f.benchmark.id).then(D=>{R||x(D.cases)}).catch(D=>{R||v(Ae(D))}),()=>{R=!0}},[o,f]),!o)return null;const C=f?.benchmark??null,N=C?[...C.evaluations]:[],T=new Map(h?.map(R=>[R.id,R.title])??[]),_=h?.find(R=>R.id===w)??null;return a.jsxs("div",{className:"flex h-full flex-col md:flex-row",children:[a.jsxs("aside",{className:"max-h-52 shrink-0 overflow-y-auto border-b border-gray-200 bg-gray-50 px-1 py-2 md:max-h-none md:w-72 md:border-b-0 md:border-r dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("p",{className:"px-3 pb-1 text-xs font-bold uppercase tracking-wide text-gray-500",children:d.benchmark.title}),n?a.jsx(Sr,{rows:4}):a.jsx("ul",{children:t.map(R=>a.jsx(kW,{projectId:o,agentId:R.agentId,name:_n(R),defaultOpen:u===null||u===R.agentId,selection:f,onSelect:p},R.agentId))})]}),a.jsx("section",{className:"min-w-0 flex-1 overflow-y-auto p-3 md:p-4",children:f&&C?a.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[a.jsx("h1",{className:"min-w-0 truncate text-lg font-semibold",children:C.title}),a.jsx("span",{className:"text-xs text-gray-500",children:d.benchmark.caseCount(C.caseCount)})]}),C.description&&a.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:C.description})]}),a.jsx(TW,{cases:h,error:g,onOpenCase:S}),N.length===0?a.jsx(Fa,{title:d.benchmark.noEvaluations}):a.jsxs(a.Fragment,{children:[a.jsx(SW,{evaluations:N}),a.jsxs("div",{children:[a.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:d.benchmark.evaluations}),a.jsx("div",{className:"overflow-x-auto overflow-y-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:a.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-gray-200 bg-gray-50/80 text-xs text-gray-500 dark:border-gray-800 dark:bg-gray-900",children:[a.jsx("th",{className:"px-3 py-2.5",children:d.common.time}),a.jsx("th",{className:"px-3 py-2.5",children:d.benchmark.colVersion}),a.jsx("th",{className:"px-3 py-2.5",children:d.benchmark.colModel}),a.jsx("th",{className:"px-3 py-2.5",children:d.benchmark.colThinkingLevel}),a.jsx("th",{className:"px-3 py-2.5",children:d.benchmark.colScore}),a.jsx("th",{className:"px-3 py-2.5",children:d.common.cost}),a.jsx("th",{className:"px-3 py-2.5",children:d.benchmark.colDuration})]})}),a.jsx("tbody",{children:[...N].reverse().map((R,D)=>a.jsx(jW,{evaluation:R,caseTitles:T,onOpenCase:S,currency:s},D))})]})})]})]}),_&&a.jsx(Yt,{open:!0,title:_.title,widthClass:"sm:max-w-6xl",onClose:()=>S(null),children:a.jsx(vW,{projectId:o,agentId:f.agentId,benchmarkId:C.id,caseSummary:_})})]},`${f.agentId}/${C.id}`):a.jsx(Fa,{title:d.benchmark.selectBenchmark})})]})}const bx="penguin.terminal.page.id";function Dj(e){const t=new URLSearchParams(e),n=t.get("id"),s=t.get("cwd"),o=t.get("name");return{id:n&&n.trim()?n.trim():null,cwd:s&&s.trim()?s.trim():"~",name:o&&o.trim()?o.trim():null}}function EW(e){const t=new URL(location.href);t.searchParams.set("id",e),history.replaceState(null,"",t)}async function AW(e,t,n){if(e.id){const o=await vf(`/api/terminals/${e.id}`).catch(()=>null);if(o)return o}else{const o=localStorage.getItem(bx);if(o){const c=await vf(`/api/terminals/${o}`).catch(()=>null);if(c?.alive)return c}}return await Fy("/api/terminals",{method:"POST",body:JSON.stringify({cwd:e.cwd,cols:t,rows:n,...e.name!==null?{name:e.name}:{}})})}function _W(){const e=jM(),[t,n]=y.useState("connecting"),[s,o]=y.useState(""),[c,u]=y.useState(null),[f,p]=y.useState(0),h=y.useMemo(()=>Dj(window.location.search),[f]),x=y.useCallback(async(S,C)=>{const N=await AW(Dj(window.location.search),S,C);return localStorage.setItem(bx,N.id),EW(N.id),N},[f]),g=y.useCallback(()=>{localStorage.removeItem(bx);const S=new URL(location.href);S.searchParams.delete("id"),history.replaceState(null,"",S),n("connecting"),o(""),u(null),p(C=>C+1)},[]),v=y.useCallback((S,C)=>{n(S),o(C)},[]),w=t==="exited"&&s?`${d.terminal.status.exited} — ${d.terminal.exitedWithCode(s)}`:`${d.terminal.status[t]}${t==="error"&&s?` — ${s}`:""}`;return a.jsxs("div",{className:`flex h-screen w-screen flex-col ${e.surface}`,children:[a.jsxs("header",{className:`flex shrink-0 items-center gap-3 border-b px-4 py-2 text-xs ${e.border}`,children:[a.jsx("span",{className:"font-medium",children:d.terminal.title}),a.jsx("span",{className:e.muted,children:c?.cwd??h.cwd}),a.jsxs("span",{"data-testid":"terminal-status","data-status":t,className:t==="ready"?e.success:t==="connecting"?e.attention:e.danger,children:["● ",w]}),a.jsx("button",{type:"button","data-testid":"terminal-new-shell",onClick:g,className:`ml-auto rounded border px-2 py-1 ${e.outlineButton}`,children:d.terminal.newShell})]}),a.jsx(YT,{ensure:x,onStatus:v,onInfo:u,className:"min-h-0 flex-1 overflow-hidden px-2 py-1"},f)]})}function RW(){const{user:e}=mn();return e===void 0?null:e===null?a.jsx(ku,{to:"/login",replace:!0}):a.jsx(AR,{children:a.jsx(ZR,{children:a.jsx(vV,{})})})}function IW({children:e}){const{user:t}=mn();return t===void 0?null:t===null?a.jsx(ku,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:e})}function LW(){const{user:e}=mn();return e?a.jsx(ku,{to:"/chat",replace:!0}):a.jsx(EV,{})}function OW(){return a.jsx(bR,{children:a.jsxs(K_,{children:[a.jsx(da,{path:"/login",element:a.jsx(LW,{})}),a.jsx(da,{path:"/terminal",element:a.jsx(IW,{children:a.jsx(_W,{})})}),a.jsxs(da,{element:a.jsx(RW,{}),children:[a.jsx(da,{index:!0,element:a.jsx(ku,{to:"/chat",replace:!0})}),a.jsx(da,{path:"/chat/:sessionId?",element:a.jsx(kq,{})}),a.jsx(da,{path:"/agents",element:a.jsx(IV,{})}),a.jsx(da,{path:"/agents/:agentId",element:a.jsx(IG,{})}),a.jsx(da,{path:"/skills",element:a.jsx(FG,{})}),a.jsx(da,{path:"/models",element:a.jsx(wK,{})}),a.jsx(da,{path:"/usage",element:a.jsx(dW,{})}),a.jsx(da,{path:"/benchmark",element:a.jsx(MW,{})}),a.jsx(da,{path:"*",element:a.jsx(ku,{to:"/chat",replace:!0})})]})]})})}function DW(){return y.useEffect(()=>(window.addEventListener("dragover",zS),window.addEventListener("drop",BS),()=>{window.removeEventListener("dragover",zS),window.removeEventListener("drop",BS)}),[]),a.jsx(J3,{children:a.jsx(lE,{children:a.jsx(HA,{children:a.jsxs(eE,{children:[a.jsx(OW,{}),a.jsx(iI,{})]})})})})}const i4=document.getElementById("root");if(!i4)throw new Error("#root mount point not found");G3.createRoot(i4).render(a.jsx(y.StrictMode,{children:a.jsx(DW,{})}));export{TH as L,an as _,YL as a,d8 as b,fS as c,o8 as f,vx as g,u8 as h,UW as i,$W as r,ly as s,e8 as w};