@prismshadow/penguin-server 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,183 +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 l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const u of c.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&i(u)}).observe(document,{childList:!0,subtree:!0});function a(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function i(l){if(l.ep)return;l.ep=!0;const c=a(l);fetch(l.href,c)}})();function Ag(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Dp={exports:{}},Yo={};var gb;function EN(){if(gb)return Yo;gb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(i,l,c){var u=null;if(c!==void 0&&(u=""+c),l.key!==void 0&&(u=""+l.key),"key"in l){c={};for(var m in l)m!=="key"&&(c[m]=l[m])}else c=l;return l=c.ref,{$$typeof:e,type:i,key:u,ref:l!==void 0?l:null,props:c}}return Yo.Fragment=t,Yo.jsx=a,Yo.jsxs=a,Yo}var xb;function _N(){return xb||(xb=1,Dp.exports=EN()),Dp.exports}var r=_N(),Up={exports:{}},ut={};var yb;function RN(){if(yb)return ut;yb=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),u=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),k=Symbol.iterator;function w(R){return R===null||typeof R!="object"?null:(R=k&&R[k]||R["@@iterator"],typeof R=="function"?R:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},M=Object.assign,C={};function T(R,q,j){this.props=R,this.context=q,this.refs=C,this.updater=j||S}T.prototype.isReactComponent={},T.prototype.setState=function(R,q){if(typeof R!="object"&&typeof R!="function"&&R!=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,R,q,"setState")},T.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function I(){}I.prototype=T.prototype;function D(R,q,j){this.props=R,this.context=q,this.refs=C,this.updater=j||S}var K=D.prototype=new I;K.constructor=D,M(K,T.prototype),K.isPureReactComponent=!0;var F=Array.isArray;function E(){}var B={H:null,A:null,T:null,S:null},Y=Object.prototype.hasOwnProperty;function V(R,q,j){var $=j.ref;return{$$typeof:e,type:R,key:q,ref:$!==void 0?$:null,props:j}}function O(R,q){return V(R.type,q,R.props)}function U(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function _(R){var q={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(j){return q[j]})}var P=/\/+/g;function H(R,q){return typeof R=="object"&&R!==null&&R.key!=null?_(""+R.key):q.toString(36)}function G(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(E,E):(R.status="pending",R.then(function(q){R.status==="pending"&&(R.status="fulfilled",R.value=q)},function(q){R.status==="pending"&&(R.status="rejected",R.reason=q)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function z(R,q,j,$,ae){var de=typeof R;(de==="undefined"||de==="boolean")&&(R=null);var ye=!1;if(R===null)ye=!0;else switch(de){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(R.$$typeof){case e:case t:ye=!0;break;case g:return ye=R._init,z(ye(R._payload),q,j,$,ae)}}if(ye)return ae=ae(R),ye=$===""?"."+H(R,0):$,F(ae)?(j="",ye!=null&&(j=ye.replace(P,"$&/")+"/"),z(ae,q,j,"",function(ee){return ee})):ae!=null&&(U(ae)&&(ae=O(ae,j+(ae.key==null||R&&R.key===ae.key?"":(""+ae.key).replace(P,"$&/")+"/")+ye)),q.push(ae)),1;ye=0;var Se=$===""?".":$+":";if(F(R))for(var ke=0;ke<R.length;ke++)$=R[ke],de=Se+H($,ke),ye+=z($,q,j,de,ae);else if(ke=w(R),typeof ke=="function")for(R=ke.call(R),ke=0;!($=R.next()).done;)$=$.value,de=Se+H($,ke++),ye+=z($,q,j,de,ae);else if(de==="object"){if(typeof R.then=="function")return z(G(R),q,j,$,ae);throw q=String(R),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return ye}function J(R,q,j){if(R==null)return R;var $=[],ae=0;return z(R,$,"","",function(de){return q.call(j,de,ae++)}),$}function xe(R){if(R._status===-1){var q=R._result;q=q(),q.then(function(j){(R._status===0||R._status===-1)&&(R._status=1,R._result=j)},function(j){(R._status===0||R._status===-1)&&(R._status=2,R._result=j)}),R._status===-1&&(R._status=0,R._result=q)}if(R._status===1)return R._result.default;throw R._result}var me=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=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(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},A={map:J,forEach:function(R,q,j){J(R,function(){q.apply(this,arguments)},j)},count:function(R){var q=0;return J(R,function(){q++}),q},toArray:function(R){return J(R,function(q){return q})||[]},only:function(R){if(!U(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return ut.Activity=v,ut.Children=A,ut.Component=T,ut.Fragment=a,ut.Profiler=l,ut.PureComponent=D,ut.StrictMode=i,ut.Suspense=p,ut.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,ut.__COMPILER_RUNTIME={__proto__:null,c:function(R){return B.H.useMemoCache(R)}},ut.cache=function(R){return function(){return R.apply(null,arguments)}},ut.cacheSignal=function(){return null},ut.cloneElement=function(R,q,j){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var $=M({},R.props),ae=R.key;if(q!=null)for(de in q.key!==void 0&&(ae=""+q.key),q)!Y.call(q,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&q.ref===void 0||($[de]=q[de]);var de=arguments.length-2;if(de===1)$.children=j;else if(1<de){for(var ye=Array(de),Se=0;Se<de;Se++)ye[Se]=arguments[Se+2];$.children=ye}return V(R.type,ae,$)},ut.createContext=function(R){return R={$$typeof:u,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:c,_context:R},R},ut.createElement=function(R,q,j){var $,ae={},de=null;if(q!=null)for($ in q.key!==void 0&&(de=""+q.key),q)Y.call(q,$)&&$!=="key"&&$!=="__self"&&$!=="__source"&&(ae[$]=q[$]);var ye=arguments.length-2;if(ye===1)ae.children=j;else if(1<ye){for(var Se=Array(ye),ke=0;ke<ye;ke++)Se[ke]=arguments[ke+2];ae.children=Se}if(R&&R.defaultProps)for($ in ye=R.defaultProps,ye)ae[$]===void 0&&(ae[$]=ye[$]);return V(R,de,ae)},ut.createRef=function(){return{current:null}},ut.forwardRef=function(R){return{$$typeof:m,render:R}},ut.isValidElement=U,ut.lazy=function(R){return{$$typeof:g,_payload:{_status:-1,_result:R},_init:xe}},ut.memo=function(R,q){return{$$typeof:h,type:R,compare:q===void 0?null:q}},ut.startTransition=function(R){var q=B.T,j={};B.T=j;try{var $=R(),ae=B.S;ae!==null&&ae(j,$),typeof $=="object"&&$!==null&&typeof $.then=="function"&&$.then(E,me)}catch(de){me(de)}finally{q!==null&&j.types!==null&&(q.types=j.types),B.T=q}},ut.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()},ut.use=function(R){return B.H.use(R)},ut.useActionState=function(R,q,j){return B.H.useActionState(R,q,j)},ut.useCallback=function(R,q){return B.H.useCallback(R,q)},ut.useContext=function(R){return B.H.useContext(R)},ut.useDebugValue=function(){},ut.useDeferredValue=function(R,q){return B.H.useDeferredValue(R,q)},ut.useEffect=function(R,q){return B.H.useEffect(R,q)},ut.useEffectEvent=function(R){return B.H.useEffectEvent(R)},ut.useId=function(){return B.H.useId()},ut.useImperativeHandle=function(R,q,j){return B.H.useImperativeHandle(R,q,j)},ut.useInsertionEffect=function(R,q){return B.H.useInsertionEffect(R,q)},ut.useLayoutEffect=function(R,q){return B.H.useLayoutEffect(R,q)},ut.useMemo=function(R,q){return B.H.useMemo(R,q)},ut.useOptimistic=function(R,q){return B.H.useOptimistic(R,q)},ut.useReducer=function(R,q,j){return B.H.useReducer(R,q,j)},ut.useRef=function(R){return B.H.useRef(R)},ut.useState=function(R){return B.H.useState(R)},ut.useSyncExternalStore=function(R,q,j){return B.H.useSyncExternalStore(R,q,j)},ut.useTransition=function(){return B.H.useTransition()},ut.version="19.2.7",ut}var vb;function Eg(){return vb||(vb=1,Up.exports=RN()),Up.exports}var x=Eg();const od=Ag(x);var zp={exports:{}},Qo={},$p={exports:{}},Pp={};var bb;function IN(){return bb||(bb=1,(function(e){function t(z,J){var xe=z.length;z.push(J);e:for(;0<xe;){var me=xe-1>>>1,A=z[me];if(0<l(A,J))z[me]=J,z[xe]=A,xe=me;else break e}}function a(z){return z.length===0?null:z[0]}function i(z){if(z.length===0)return null;var J=z[0],xe=z.pop();if(xe!==J){z[0]=xe;e:for(var me=0,A=z.length,R=A>>>1;me<R;){var q=2*(me+1)-1,j=z[q],$=q+1,ae=z[$];if(0>l(j,xe))$<A&&0>l(ae,j)?(z[me]=ae,z[$]=xe,me=$):(z[me]=j,z[q]=xe,me=q);else if($<A&&0>l(ae,xe))z[me]=ae,z[$]=xe,me=$;else break e}}return J}function l(z,J){var xe=z.sortIndex-J.sortIndex;return xe!==0?xe:z.id-J.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,m=u.now();e.unstable_now=function(){return u.now()-m}}var p=[],h=[],g=1,v=null,k=3,w=!1,S=!1,M=!1,C=!1,T=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function K(z){for(var J=a(h);J!==null;){if(J.callback===null)i(h);else if(J.startTime<=z)i(h),J.sortIndex=J.expirationTime,t(p,J);else break;J=a(h)}}function F(z){if(M=!1,K(z),!S)if(a(p)!==null)S=!0,E||(E=!0,_());else{var J=a(h);J!==null&&G(F,J.startTime-z)}}var E=!1,B=-1,Y=5,V=-1;function O(){return C?!0:!(e.unstable_now()-V<Y)}function U(){if(C=!1,E){var z=e.unstable_now();V=z;var J=!0;try{e:{S=!1,M&&(M=!1,I(B),B=-1),w=!0;var xe=k;try{t:{for(K(z),v=a(p);v!==null&&!(v.expirationTime>z&&O());){var me=v.callback;if(typeof me=="function"){v.callback=null,k=v.priorityLevel;var A=me(v.expirationTime<=z);if(z=e.unstable_now(),typeof A=="function"){v.callback=A,K(z),J=!0;break t}v===a(p)&&i(p),K(z)}else i(p);v=a(p)}if(v!==null)J=!0;else{var R=a(h);R!==null&&G(F,R.startTime-z),J=!1}}break e}finally{v=null,k=xe,w=!1}J=void 0}}finally{J?_():E=!1}}}var _;if(typeof D=="function")_=function(){D(U)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,H=P.port2;P.port1.onmessage=U,_=function(){H.postMessage(null)}}else _=function(){T(U,0)};function G(z,J){B=T(function(){z(e.unstable_now())},J)}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(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return k},e.unstable_next=function(z){switch(k){case 1:case 2:case 3:var J=3;break;default:J=k}var xe=k;k=J;try{return z()}finally{k=xe}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(z,J){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var xe=k;k=z;try{return J()}finally{k=xe}},e.unstable_scheduleCallback=function(z,J,xe){var me=e.unstable_now();switch(typeof xe=="object"&&xe!==null?(xe=xe.delay,xe=typeof xe=="number"&&0<xe?me+xe:me):xe=me,z){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=xe+A,z={id:g++,callback:J,priorityLevel:z,startTime:xe,expirationTime:A,sortIndex:-1},xe>me?(z.sortIndex=xe,t(h,z),a(p)===null&&z===a(h)&&(M?(I(B),B=-1):M=!0,G(F,xe-me))):(z.sortIndex=A,t(p,z),S||w||(S=!0,E||(E=!0,_()))),z},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(z){var J=k;return function(){var xe=k;k=J;try{return z.apply(this,arguments)}finally{k=xe}}}})(Pp)),Pp}var kb;function LN(){return kb||(kb=1,$p.exports=IN()),$p.exports}var Bp={exports:{}},na={};var wb;function ON(){if(wb)return na;wb=1;var e=Eg();function t(p){var h="https://react.dev/errors/"+p;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}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 a(){}var i={d:{f:a,r:function(){throw Error(t(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},l=Symbol.for("react.portal");function c(p,h,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:v==null?null:""+v,children:p,containerInfo:h,implementation:g}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function m(p,h){if(p==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return na.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,na.createPortal=function(p,h){var g=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,g)},na.flushSync=function(p){var h=u.T,g=i.p;try{if(u.T=null,i.p=2,p)return p()}finally{u.T=h,i.p=g,i.d.f()}},na.preconnect=function(p,h){typeof p=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,i.d.C(p,h))},na.prefetchDNS=function(p){typeof p=="string"&&i.d.D(p)},na.preinit=function(p,h){if(typeof p=="string"&&h&&typeof h.as=="string"){var g=h.as,v=m(g,h.crossOrigin),k=typeof h.integrity=="string"?h.integrity:void 0,w=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?i.d.S(p,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:v,integrity:k,fetchPriority:w}):g==="script"&&i.d.X(p,{crossOrigin:v,integrity:k,fetchPriority:w,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},na.preinitModule=function(p,h){if(typeof p=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=m(h.as,h.crossOrigin);i.d.M(p,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&i.d.M(p)},na.preload=function(p,h){if(typeof p=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,v=m(g,h.crossOrigin);i.d.L(p,g,{crossOrigin:v,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})}},na.preloadModule=function(p,h){if(typeof p=="string")if(h){var g=m(h.as,h.crossOrigin);i.d.m(p,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else i.d.m(p)},na.requestFormReset=function(p){i.d.r(p)},na.unstable_batchedUpdates=function(p,h){return p(h)},na.useFormState=function(p,h,g){return u.H.useFormState(p,h,g)},na.useFormStatus=function(){return u.H.useHostTransitionStatus()},na.version="19.2.7",na}var Sb;function Rw(){if(Sb)return Bp.exports;Sb=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(),Bp.exports=ON(),Bp.exports}var jb;function DN(){if(jb)return Qo;jb=1;var e=LN(),t=Eg(),a=Rw();function i(n){var s="https://react.dev/errors/"+n;if(1<arguments.length){s+="?args[]="+encodeURIComponent(arguments[1]);for(var o=2;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o])}return"Minified React error #"+n+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function c(n){var s=n,o=n;if(n.alternate)for(;s.return;)s=s.return;else{n=s;do s=n,(s.flags&4098)!==0&&(o=s.return),n=s.return;while(n)}return s.tag===3?o:null}function u(n){if(n.tag===13){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function m(n){if(n.tag===31){var s=n.memoizedState;if(s===null&&(n=n.alternate,n!==null&&(s=n.memoizedState)),s!==null)return s.dehydrated}return null}function p(n){if(c(n)!==n)throw Error(i(188))}function h(n){var s=n.alternate;if(!s){if(s=c(n),s===null)throw Error(i(188));return s!==n?null:n}for(var o=n,d=s;;){var y=o.return;if(y===null)break;var b=y.alternate;if(b===null){if(d=y.return,d!==null){o=d;continue}break}if(y.child===b.child){for(b=y.child;b;){if(b===o)return p(y),n;if(b===d)return p(y),s;b=b.sibling}throw Error(i(188))}if(o.return!==d.return)o=y,d=b;else{for(var N=!1,L=y.child;L;){if(L===o){N=!0,o=y,d=b;break}if(L===d){N=!0,d=y,o=b;break}L=L.sibling}if(!N){for(L=b.child;L;){if(L===o){N=!0,o=b,d=y;break}if(L===d){N=!0,d=b,o=y;break}L=L.sibling}if(!N)throw Error(i(189))}}if(o.alternate!==d)throw Error(i(190))}if(o.tag!==3)throw Error(i(188));return o.stateNode.current===o?n:s}function g(n){var s=n.tag;if(s===5||s===26||s===27||s===6)return n;for(n=n.child;n!==null;){if(s=g(n),s!==null)return s;n=n.sibling}return null}var v=Object.assign,k=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),D=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function _(n){return n===null||typeof n!="object"?null:(n=U&&n[U]||n["@@iterator"],typeof n=="function"?n:null)}var P=Symbol.for("react.client.reference");function H(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===P?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case M:return"Fragment";case T:return"Profiler";case C:return"StrictMode";case F:return"Suspense";case E:return"SuspenseList";case V:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case S:return"Portal";case D:return n.displayName||"Context";case I:return(n._context.displayName||"Context")+".Consumer";case K:var s=n.render;return n=n.displayName,n||(n=s.displayName||s.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case B:return s=n.displayName||null,s!==null?s:H(n.type)||"Memo";case Y:s=n._payload,n=n._init;try{return H(n(s))}catch{}}return null}var G=Array.isArray,z=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,xe={pending:!1,data:null,method:null,action:null},me=[],A=-1;function R(n){return{current:n}}function q(n){0>A||(n.current=me[A],me[A]=null,A--)}function j(n,s){A++,me[A]=n.current,n.current=s}var $=R(null),ae=R(null),de=R(null),ye=R(null);function Se(n,s){switch(j(de,s),j(ae,n),j($,null),s.nodeType){case 9:case 11:n=(n=s.documentElement)&&(n=n.namespaceURI)?$v(n):0;break;default:if(n=s.tagName,s=s.namespaceURI)s=$v(s),n=Pv(s,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}q($),j($,n)}function ke(){q($),q(ae),q(de)}function ee(n){n.memoizedState!==null&&j(ye,n);var s=$.current,o=Pv(s,n.type);s!==o&&(j(ae,n),j($,o))}function je(n){ae.current===n&&(q($),q(ae)),ye.current===n&&(q(ye),qo._currentValue=xe)}var Ae,Qe;function We(n){if(Ae===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);Ae=s&&s[1]||"",Qe=-1<o.stack.indexOf(`
3
- at`)?" (<anonymous>)":-1<o.stack.indexOf("@")?"@unknown:0:0":""}return`
4
- `+Ae+n+Qe}var re=!1;function ft(n,s){if(!n||re)return"";re=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var d={DetermineComponentFrameRoot:function(){try{if(s){var we=function(){throw Error()};if(Object.defineProperty(we.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(we,[])}catch(fe){var oe=fe}Reflect.construct(n,[],we)}else{try{we.call()}catch(fe){oe=fe}n.call(we.prototype)}}else{try{throw Error()}catch(fe){oe=fe}(we=n())&&typeof we.catch=="function"&&we.catch(function(){})}}catch(fe){if(fe&&oe&&typeof fe.stack=="string")return[fe.stack,oe.stack]}return[null,null]}};d.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var y=Object.getOwnPropertyDescriptor(d.DetermineComponentFrameRoot,"name");y&&y.configurable&&Object.defineProperty(d.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var b=d.DetermineComponentFrameRoot(),N=b[0],L=b[1];if(N&&L){var Q=N.split(`
5
- `),le=L.split(`
6
- `);for(y=d=0;d<Q.length&&!Q[d].includes("DetermineComponentFrameRoot");)d++;for(;y<le.length&&!le[y].includes("DetermineComponentFrameRoot");)y++;if(d===Q.length||y===le.length)for(d=Q.length-1,y=le.length-1;1<=d&&0<=y&&Q[d]!==le[y];)y--;for(;1<=d&&0<=y;d--,y--)if(Q[d]!==le[y]){if(d!==1||y!==1)do if(d--,y--,0>y||Q[d]!==le[y]){var he=`
7
- `+Q[d].replace(" at new "," at ");return n.displayName&&he.includes("<anonymous>")&&(he=he.replace("<anonymous>",n.displayName)),he}while(1<=d&&0<=y);break}}}finally{re=!1,Error.prepareStackTrace=o}return(o=n?n.displayName||n.name:"")?We(o):""}function ge(n,s){switch(n.tag){case 26:case 27:case 5:return We(n.type);case 16:return We("Lazy");case 13:return n.child!==s&&s!==null?We("Suspense Fallback"):We("Suspense");case 19:return We("SuspenseList");case 0:case 15:return ft(n.type,!1);case 11:return ft(n.type.render,!1);case 1:return ft(n.type,!0);case 31:return We("Activity");default:return""}}function dt(n){try{var s="",o=null;do s+=ge(n,o),o=n,n=n.return;while(n);return s}catch(d){return`
8
- Error generating stack: `+d.message+`
9
- `+d.stack}}var It=Object.prototype.hasOwnProperty,zt=e.unstable_scheduleCallback,nn=e.unstable_cancelCallback,un=e.unstable_shouldYield,Wt=e.unstable_requestPaint,Ce=e.unstable_now,Ke=e.unstable_getCurrentPriorityLevel,se=e.unstable_ImmediatePriority,ce=e.unstable_UserBlockingPriority,De=e.unstable_NormalPriority,Be=e.unstable_LowPriority,Ue=e.unstable_IdlePriority,W=e.log,pe=e.unstable_setDisableYieldValue,Ne=null,Re=null;function Pe(n){if(typeof W=="function"&&pe(n),Re&&typeof Re.setStrictMode=="function")try{Re.setStrictMode(Ne,n)}catch{}}var Fe=Math.clz32?Math.clz32:Te,nt=Math.log,ot=Math.LN2;function Te(n){return n>>>=0,n===0?32:31-(nt(n)/ot|0)|0}var ze=256,yt=262144,ct=4194304;function vt(n){var s=n&42;if(s!==0)return s;switch(n&-n){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 n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function hn(n,s,o){var d=n.pendingLanes;if(d===0)return 0;var y=0,b=n.suspendedLanes,N=n.pingedLanes;n=n.warmLanes;var L=d&134217727;return L!==0?(d=L&~b,d!==0?y=vt(d):(N&=L,N!==0?y=vt(N):o||(o=L&~n,o!==0&&(y=vt(o))))):(L=d&~b,L!==0?y=vt(L):N!==0?y=vt(N):o||(o=d&~n,o!==0&&(y=vt(o)))),y===0?0:s!==0&&s!==y&&(s&b)===0&&(b=y&-y,o=s&-s,b>=o||b===32&&(o&4194048)!==0)?s:y}function bt(n,s){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&s)===0}function dn(n,s){switch(n){case 1:case 2:case 4:case 8:case 64:return s+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 s+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 Qn(){var n=ct;return ct<<=1,(ct&62914560)===0&&(ct=4194304),n}function Ht(n){for(var s=[],o=0;31>o;o++)s.push(n);return s}function Bn(n,s){n.pendingLanes|=s,s!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Ur(n,s,o,d,y,b){var N=n.pendingLanes;n.pendingLanes=o,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=o,n.entangledLanes&=o,n.errorRecoveryDisabledLanes&=o,n.shellSuspendCounter=0;var L=n.entanglements,Q=n.expirationTimes,le=n.hiddenUpdates;for(o=N&~o;0<o;){var he=31-Fe(o),we=1<<he;L[he]=0,Q[he]=-1;var oe=le[he];if(oe!==null)for(le[he]=null,he=0;he<oe.length;he++){var fe=oe[he];fe!==null&&(fe.lane&=-536870913)}o&=~we}d!==0&&ga(n,d,0),b!==0&&y===0&&n.tag!==0&&(n.suspendedLanes|=b&~(N&~s))}function ga(n,s,o){n.pendingLanes|=s,n.suspendedLanes&=~s;var d=31-Fe(s);n.entangledLanes|=s,n.entanglements[d]=n.entanglements[d]|1073741824|o&261930}function zn(n,s){var o=n.entangledLanes|=s;for(n=n.entanglements;o;){var d=31-Fe(o),y=1<<d;y&s|n[d]&s&&(n[d]|=s),o&=~y}}function xa(n,s){var o=s&-s;return o=(o&42)!==0?1:Hn(o),(o&(n.suspendedLanes|s))!==0?0:o}function Hn(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function ya(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function va(){var n=J.p;return n!==0?n:(n=window.event,n===void 0?32:cb(n.type))}function zr(n,s){var o=J.p;try{return J.p=n,s()}finally{J.p=o}}var an=Math.random().toString(36).slice(2),$t="__reactFiber$"+an,gn="__reactProps$"+an,Xn="__reactContainer$"+an,Ja="__reactEvents$"+an,Ns="__reactListeners$"+an,ba="__reactHandles$"+an,ka="__reactResources$"+an,wa="__reactMarker$"+an;function $r(n){delete n[$t],delete n[gn],delete n[Ja],delete n[Ns],delete n[ba]}function Sa(n){var s=n[$t];if(s)return s;for(var o=n.parentNode;o;){if(s=o[Xn]||o[$t]){if(o=s.alternate,s.child!==null||o!==null&&o.child!==null)for(n=Wv(n);n!==null;){if(o=n[$t])return o;n=Wv(n)}return s}n=o,o=n.parentNode}return null}function za(n){if(n=n[$t]||n[Xn]){var s=n.tag;if(s===5||s===6||s===13||s===31||s===26||s===27||s===3)return n}return null}function ja(n){var s=n.tag;if(s===5||s===26||s===27||s===6)return n.stateNode;throw Error(i(33))}function $n(n){var s=n[ka];return s||(s=n[ka]={hoistableStyles:new Map,hoistableScripts:new Map}),s}function Ft(n){n[wa]=!0}var er=new Set,Nr={};function Vt(n,s){Zn(n,s),Zn(n+"Capture",s)}function Zn(n,s){for(Nr[n]=s,n=0;n<s.length;n++)er.add(s[n])}var oa=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]*$"),tr={},nr={};function Pr(n){return It.call(nr,n)?!0:It.call(tr,n)?!1:oa.test(n)?nr[n]=!0:(tr[n]=!0,!1)}function $a(n,s,o){if(Pr(s))if(o===null)n.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":n.removeAttribute(s);return;case"boolean":var d=s.toLowerCase().slice(0,5);if(d!=="data-"&&d!=="aria-"){n.removeAttribute(s);return}}n.setAttribute(s,""+o)}}function ca(n,s,o){if(o===null)n.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(s);return}n.setAttribute(s,""+o)}}function On(n,s,o,d){if(d===null)n.removeAttribute(o);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(o);return}n.setAttributeNS(s,o,""+d)}}function bn(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ar(n){var s=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function ue(n,s,o){var d=Object.getOwnPropertyDescriptor(n.constructor.prototype,s);if(!n.hasOwnProperty(s)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var y=d.get,b=d.set;return Object.defineProperty(n,s,{configurable:!0,get:function(){return y.call(this)},set:function(N){o=""+N,b.call(this,N)}}),Object.defineProperty(n,s,{enumerable:d.enumerable}),{getValue:function(){return o},setValue:function(N){o=""+N},stopTracking:function(){n._valueTracker=null,delete n[s]}}}}function Me(n){if(!n._valueTracker){var s=ar(n)?"checked":"value";n._valueTracker=ue(n,s,""+n[s])}}function et(n){if(!n)return!1;var s=n._valueTracker;if(!s)return!0;var o=s.getValue(),d="";return n&&(d=ar(n)?n.checked?"true":"false":n.value),n=d,n!==o?(s.setValue(n),!0):!1}function it(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var gt=/[\n"\\]/g;function xt(n){return n.replace(gt,function(s){return"\\"+s.charCodeAt(0).toString(16)+" "})}function Zt(n,s,o,d,y,b,N,L){n.name="",N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?n.type=N:n.removeAttribute("type"),s!=null?N==="number"?(s===0&&n.value===""||n.value!=s)&&(n.value=""+bn(s)):n.value!==""+bn(s)&&(n.value=""+bn(s)):N!=="submit"&&N!=="reset"||n.removeAttribute("value"),s!=null?ua(n,N,bn(s)):o!=null?ua(n,N,bn(o)):d!=null&&n.removeAttribute("value"),y==null&&b!=null&&(n.defaultChecked=!!b),y!=null&&(n.checked=y&&typeof y!="function"&&typeof y!="symbol"),L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"?n.name=""+bn(L):n.removeAttribute("name")}function Pa(n,s,o,d,y,b,N,L){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(n.type=b),s!=null||o!=null){if(!(b!=="submit"&&b!=="reset"||s!=null)){Me(n);return}o=o!=null?""+bn(o):"",s=s!=null?""+bn(s):o,L||s===n.value||(n.value=s),n.defaultValue=s}d=d??y,d=typeof d!="function"&&typeof d!="symbol"&&!!d,n.checked=L?n.checked:!!d,n.defaultChecked=!!d,N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"&&(n.name=N),Me(n)}function ua(n,s,o){s==="number"&&it(n.ownerDocument)===n||n.defaultValue===""+o||(n.defaultValue=""+o)}function Fn(n,s,o,d){if(n=n.options,s){s={};for(var y=0;y<o.length;y++)s["$"+o[y]]=!0;for(o=0;o<n.length;o++)y=s.hasOwnProperty("$"+n[o].value),n[o].selected!==y&&(n[o].selected=y),y&&d&&(n[o].defaultSelected=!0)}else{for(o=""+bn(o),s=null,y=0;y<n.length;y++){if(n[y].value===o){n[y].selected=!0,d&&(n[y].defaultSelected=!0);return}s!==null||n[y].disabled||(s=n[y])}s!==null&&(s.selected=!0)}}function Ca(n,s,o){if(s!=null&&(s=""+bn(s),s!==n.value&&(n.value=s),o==null)){n.defaultValue!==s&&(n.defaultValue=s);return}n.defaultValue=o!=null?""+bn(o):""}function xi(n,s,o,d){if(s==null){if(d!=null){if(o!=null)throw Error(i(92));if(G(d)){if(1<d.length)throw Error(i(93));d=d[0]}o=d}o==null&&(o=""),s=o}o=bn(s),n.defaultValue=o,d=n.textContent,d===o&&d!==""&&d!==null&&(n.value=d),Me(n)}function rr(n,s){if(s){var o=n.firstChild;if(o&&o===n.lastChild&&o.nodeType===3){o.nodeValue=s;return}}n.textContent=s}var Bt=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 Ts(n,s,o){var d=s.indexOf("--")===0;o==null||typeof o=="boolean"||o===""?d?n.setProperty(s,""):s==="float"?n.cssFloat="":n[s]="":d?n.setProperty(s,o):typeof o!="number"||o===0||Bt.has(s)?s==="float"?n.cssFloat=o:n[s]=(""+o).trim():n[s]=o+"px"}function ts(n,s,o){if(s!=null&&typeof s!="object")throw Error(i(62));if(n=n.style,o!=null){for(var d in o)!o.hasOwnProperty(d)||s!=null&&s.hasOwnProperty(d)||(d.indexOf("--")===0?n.setProperty(d,""):d==="float"?n.cssFloat="":n[d]="");for(var y in s)d=s[y],s.hasOwnProperty(y)&&o[y]!==d&&Ts(n,y,d)}else for(var b in s)s.hasOwnProperty(b)&&Ts(n,b,s[b])}function Ms(n){if(n.indexOf("-")===-1)return!1;switch(n){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 yi=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"]]),As=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Es(n){return As.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function Jn(){}var _s=null;function vi(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var sr=null,Tr=null;function ne(n){var s=za(n);if(s&&(n=s.stateNode)){var o=n[gn]||null;e:switch(n=s.stateNode,s.type){case"input":if(Zt(n,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name),s=o.name,o.type==="radio"&&s!=null){for(o=n;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll('input[name="'+xt(""+s)+'"][type="radio"]'),s=0;s<o.length;s++){var d=o[s];if(d!==n&&d.form===n.form){var y=d[gn]||null;if(!y)throw Error(i(90));Zt(d,y.value,y.defaultValue,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name)}}for(s=0;s<o.length;s++)d=o[s],d.form===n.form&&et(d)}break e;case"textarea":Ca(n,o.value,o.defaultValue);break e;case"select":s=o.value,s!=null&&Fn(n,!!o.multiple,s,!1)}}}var Ee=!1;function Ze(n,s,o){if(Ee)return n(s,o);Ee=!0;try{var d=n(s);return d}finally{if(Ee=!1,(sr!==null||Tr!==null)&&(Pu(),sr&&(s=sr,n=Tr,Tr=sr=null,ne(s),n)))for(s=0;s<n.length;s++)ne(n[s])}}function Xe(n,s){var o=n.stateNode;if(o===null)return null;var d=o[gn]||null;if(d===null)return null;o=d[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(d=!d.disabled)||(n=n.type,d=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!d;break e;default:n=!1}if(n)return null;if(o&&typeof o!="function")throw Error(i(231,s,typeof o));return o}var at=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),kn=!1;if(at)try{var ea={};Object.defineProperty(ea,"passive",{get:function(){kn=!0}}),window.addEventListener("test",ea,ea),window.removeEventListener("test",ea,ea)}catch{kn=!1}var Na=null,ns=null,sl=null;function nu(){if(sl)return sl;var n,s=ns,o=s.length,d,y="value"in Na?Na.value:Na.textContent,b=y.length;for(n=0;n<o&&s[n]===y[n];n++);var N=o-n;for(d=1;d<=N&&s[o-d]===y[b-d];d++);return sl=y.slice(n,1<d?1-d:void 0)}function il(n){var s=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&s===13&&(n=13)):n=s,n===10&&(n=13),32<=n||n===13?n:0}function bi(){return!0}function au(){return!1}function ta(n){function s(o,d,y,b,N){this._reactName=o,this._targetInst=y,this.type=d,this.nativeEvent=b,this.target=N,this.currentTarget=null;for(var L in n)n.hasOwnProperty(L)&&(o=n[L],this[L]=o?o(b):b[L]);return this.isDefaultPrevented=(b.defaultPrevented!=null?b.defaultPrevented:b.returnValue===!1)?bi:au,this.isPropagationStopped=au,this}return v(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=bi)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=bi)},persist:function(){},isPersistent:bi}),s}var as={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ki=ta(as),wi=v({},as,{view:0,detail:0}),Uf=ta(wi),ll,ol,Si,cl=v({},wi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Br,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==Si&&(Si&&n.type==="mousemove"?(ll=n.screenX-Si.screenX,ol=n.screenY-Si.screenY):ol=ll=0,Si=n),ll)},movementY:function(n){return"movementY"in n?n.movementY:ol}}),ru=ta(cl),zf=v({},cl,{dataTransfer:0}),$f=ta(zf),X=v({},wi,{relatedTarget:0}),_e=ta(X),pt=v({},as,{animationName:0,elapsedTime:0,pseudoElement:0}),Et=ta(pt),st=v({},as,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),Mt=ta(st),xn=v({},as,{data:0}),ir=ta(xn),Lt={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lr={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"},Rs={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function rs(n){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(n):(n=Rs[n])?!!s[n]:!1}function Br(){return rs}var Pf=v({},wi,{key:function(n){if(n.key){var s=Lt[n.key]||n.key;if(s!=="Unidentified")return s}return n.type==="keypress"?(n=il(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?lr[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Br,charCode:function(n){return n.type==="keypress"?il(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?il(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),Bf=ta(Pf),or=v({},cl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),V0=ta(or),V5=v({},wi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Br}),q5=ta(V5),G5=v({},as,{propertyName:0,elapsedTime:0,pseudoElement:0}),W5=ta(G5),K5=v({},cl,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),Y5=ta(K5),Q5=v({},as,{newState:0,oldState:0}),X5=ta(Q5),Z5=[9,13,27,32],Hf=at&&"CompositionEvent"in window,fo=null;at&&"documentMode"in document&&(fo=document.documentMode);var J5=at&&"TextEvent"in window&&!fo,q0=at&&(!Hf||fo&&8<fo&&11>=fo),G0=" ",W0=!1;function K0(n,s){switch(n){case"keyup":return Z5.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Y0(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ul=!1;function eC(n,s){switch(n){case"compositionend":return Y0(s);case"keypress":return s.which!==32?null:(W0=!0,G0);case"textInput":return n=s.data,n===G0&&W0?null:n;default:return null}}function tC(n,s){if(ul)return n==="compositionend"||!Hf&&K0(n,s)?(n=nu(),sl=ns=Na=null,ul=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return q0&&s.locale!=="ko"?null:s.data;default:return null}}var nC={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 Q0(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s==="input"?!!nC[n.type]:s==="textarea"}function X0(n,s,o,d){sr?Tr?Tr.push(d):Tr=[d]:sr=d,s=Wu(s,"onChange"),0<s.length&&(o=new ki("onChange","change",null,o,d),n.push({event:o,listeners:s}))}var mo=null,po=null;function aC(n){Iv(n,0)}function su(n){var s=ja(n);if(et(s))return n}function Z0(n,s){if(n==="change")return s}var J0=!1;if(at){var Ff;if(at){var Vf="oninput"in document;if(!Vf){var ex=document.createElement("div");ex.setAttribute("oninput","return;"),Vf=typeof ex.oninput=="function"}Ff=Vf}else Ff=!1;J0=Ff&&(!document.documentMode||9<document.documentMode)}function tx(){mo&&(mo.detachEvent("onpropertychange",nx),po=mo=null)}function nx(n){if(n.propertyName==="value"&&su(po)){var s=[];X0(s,po,n,vi(n)),Ze(aC,s)}}function rC(n,s,o){n==="focusin"?(tx(),mo=s,po=o,mo.attachEvent("onpropertychange",nx)):n==="focusout"&&tx()}function sC(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return su(po)}function iC(n,s){if(n==="click")return su(s)}function lC(n,s){if(n==="input"||n==="change")return su(s)}function oC(n,s){return n===s&&(n!==0||1/n===1/s)||n!==n&&s!==s}var Ba=typeof Object.is=="function"?Object.is:oC;function ho(n,s){if(Ba(n,s))return!0;if(typeof n!="object"||n===null||typeof s!="object"||s===null)return!1;var o=Object.keys(n),d=Object.keys(s);if(o.length!==d.length)return!1;for(d=0;d<o.length;d++){var y=o[d];if(!It.call(s,y)||!Ba(n[y],s[y]))return!1}return!0}function ax(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function rx(n,s){var o=ax(n);n=0;for(var d;o;){if(o.nodeType===3){if(d=n+o.textContent.length,n<=s&&d>=s)return{node:o,offset:s-n};n=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=ax(o)}}function sx(n,s){return n&&s?n===s?!0:n&&n.nodeType===3?!1:s&&s.nodeType===3?sx(n,s.parentNode):"contains"in n?n.contains(s):n.compareDocumentPosition?!!(n.compareDocumentPosition(s)&16):!1:!1}function ix(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var s=it(n.document);s instanceof n.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)n=s.contentWindow;else break;s=it(n.document)}return s}function qf(n){var s=n&&n.nodeName&&n.nodeName.toLowerCase();return s&&(s==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||s==="textarea"||n.contentEditable==="true")}var cC=at&&"documentMode"in document&&11>=document.documentMode,dl=null,Gf=null,go=null,Wf=!1;function lx(n,s,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Wf||dl==null||dl!==it(d)||(d=dl,"selectionStart"in d&&qf(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),go&&ho(go,d)||(go=d,d=Wu(Gf,"onSelect"),0<d.length&&(s=new ki("onSelect","select",null,s,o),n.push({event:s,listeners:d}),s.target=dl)))}function ji(n,s){var o={};return o[n.toLowerCase()]=s.toLowerCase(),o["Webkit"+n]="webkit"+s,o["Moz"+n]="moz"+s,o}var fl={animationend:ji("Animation","AnimationEnd"),animationiteration:ji("Animation","AnimationIteration"),animationstart:ji("Animation","AnimationStart"),transitionrun:ji("Transition","TransitionRun"),transitionstart:ji("Transition","TransitionStart"),transitioncancel:ji("Transition","TransitionCancel"),transitionend:ji("Transition","TransitionEnd")},Kf={},ox={};at&&(ox=document.createElement("div").style,"AnimationEvent"in window||(delete fl.animationend.animation,delete fl.animationiteration.animation,delete fl.animationstart.animation),"TransitionEvent"in window||delete fl.transitionend.transition);function Ci(n){if(Kf[n])return Kf[n];if(!fl[n])return n;var s=fl[n],o;for(o in s)if(s.hasOwnProperty(o)&&o in ox)return Kf[n]=s[o];return n}var cx=Ci("animationend"),ux=Ci("animationiteration"),dx=Ci("animationstart"),uC=Ci("transitionrun"),dC=Ci("transitionstart"),fC=Ci("transitioncancel"),fx=Ci("transitionend"),mx=new Map,Yf="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(" ");Yf.push("scrollEnd");function Mr(n,s){mx.set(n,s),Vt(s,[n])}var iu=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var s=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(s))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},cr=[],ml=0,Qf=0;function lu(){for(var n=ml,s=Qf=ml=0;s<n;){var o=cr[s];cr[s++]=null;var d=cr[s];cr[s++]=null;var y=cr[s];cr[s++]=null;var b=cr[s];if(cr[s++]=null,d!==null&&y!==null){var N=d.pending;N===null?y.next=y:(y.next=N.next,N.next=y),d.pending=y}b!==0&&px(o,y,b)}}function ou(n,s,o,d){cr[ml++]=n,cr[ml++]=s,cr[ml++]=o,cr[ml++]=d,Qf|=d,n.lanes|=d,n=n.alternate,n!==null&&(n.lanes|=d)}function Xf(n,s,o,d){return ou(n,s,o,d),cu(n)}function Ni(n,s){return ou(n,null,null,s),cu(n)}function px(n,s,o){n.lanes|=o;var d=n.alternate;d!==null&&(d.lanes|=o);for(var y=!1,b=n.return;b!==null;)b.childLanes|=o,d=b.alternate,d!==null&&(d.childLanes|=o),b.tag===22&&(n=b.stateNode,n===null||n._visibility&1||(y=!0)),n=b,b=b.return;return n.tag===3?(b=n.stateNode,y&&s!==null&&(y=31-Fe(o),n=b.hiddenUpdates,d=n[y],d===null?n[y]=[s]:d.push(s),s.lane=o|536870912),b):null}function cu(n){if(50<zo)throw zo=0,ip=null,Error(i(185));for(var s=n.return;s!==null;)n=s,s=n.return;return n.tag===3?n.stateNode:null}var pl={};function mC(n,s,o,d){this.tag=n,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ha(n,s,o,d){return new mC(n,s,o,d)}function Zf(n){return n=n.prototype,!(!n||!n.isReactComponent)}function ss(n,s){var o=n.alternate;return o===null?(o=Ha(n.tag,s,n.key,n.mode),o.elementType=n.elementType,o.type=n.type,o.stateNode=n.stateNode,o.alternate=n,n.alternate=o):(o.pendingProps=s,o.type=n.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=n.flags&65011712,o.childLanes=n.childLanes,o.lanes=n.lanes,o.child=n.child,o.memoizedProps=n.memoizedProps,o.memoizedState=n.memoizedState,o.updateQueue=n.updateQueue,s=n.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=n.sibling,o.index=n.index,o.ref=n.ref,o.refCleanup=n.refCleanup,o}function hx(n,s){n.flags&=65011714;var o=n.alternate;return o===null?(n.childLanes=0,n.lanes=s,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=o.childLanes,n.lanes=o.lanes,n.child=o.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=o.memoizedProps,n.memoizedState=o.memoizedState,n.updateQueue=o.updateQueue,n.type=o.type,s=o.dependencies,n.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),n}function uu(n,s,o,d,y,b){var N=0;if(d=n,typeof n=="function")Zf(n)&&(N=1);else if(typeof n=="string")N=yN(n,o,$.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case V:return n=Ha(31,o,s,y),n.elementType=V,n.lanes=b,n;case M:return Ti(o.children,y,b,s);case C:N=8,y|=24;break;case T:return n=Ha(12,o,s,y|2),n.elementType=T,n.lanes=b,n;case F:return n=Ha(13,o,s,y),n.elementType=F,n.lanes=b,n;case E:return n=Ha(19,o,s,y),n.elementType=E,n.lanes=b,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case D:N=10;break e;case I:N=9;break e;case K:N=11;break e;case B:N=14;break e;case Y:N=16,d=null;break e}N=29,o=Error(i(130,n===null?"null":typeof n,"")),d=null}return s=Ha(N,o,s,y),s.elementType=n,s.type=d,s.lanes=b,s}function Ti(n,s,o,d){return n=Ha(7,n,d,s),n.lanes=o,n}function Jf(n,s,o){return n=Ha(6,n,null,s),n.lanes=o,n}function gx(n){var s=Ha(18,null,null,0);return s.stateNode=n,s}function em(n,s,o){return s=Ha(4,n.children!==null?n.children:[],n.key,s),s.lanes=o,s.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},s}var xx=new WeakMap;function ur(n,s){if(typeof n=="object"&&n!==null){var o=xx.get(n);return o!==void 0?o:(s={value:n,source:s,stack:dt(s)},xx.set(n,s),s)}return{value:n,source:s,stack:dt(s)}}var hl=[],gl=0,du=null,xo=0,dr=[],fr=0,Is=null,Hr=1,Fr="";function is(n,s){hl[gl++]=xo,hl[gl++]=du,du=n,xo=s}function yx(n,s,o){dr[fr++]=Hr,dr[fr++]=Fr,dr[fr++]=Is,Is=n;var d=Hr;n=Fr;var y=32-Fe(d)-1;d&=~(1<<y),o+=1;var b=32-Fe(s)+y;if(30<b){var N=y-y%5;b=(d&(1<<N)-1).toString(32),d>>=N,y-=N,Hr=1<<32-Fe(s)+y|o<<y|d,Fr=b+n}else Hr=1<<b|o<<y|d,Fr=n}function tm(n){n.return!==null&&(is(n,1),yx(n,1,0))}function nm(n){for(;n===du;)du=hl[--gl],hl[gl]=null,xo=hl[--gl],hl[gl]=null;for(;n===Is;)Is=dr[--fr],dr[fr]=null,Fr=dr[--fr],dr[fr]=null,Hr=dr[--fr],dr[fr]=null}function vx(n,s){dr[fr++]=Hr,dr[fr++]=Fr,dr[fr++]=Is,Hr=s.id,Fr=s.overflow,Is=n}var Vn=null,rn=null,Tt=!1,Ls=null,mr=!1,am=Error(i(519));function Os(n){var s=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw yo(ur(s,n)),am}function bx(n){var s=n.stateNode,o=n.type,d=n.memoizedProps;switch(s[$t]=n,s[gn]=d,o){case"dialog":St("cancel",s),St("close",s);break;case"iframe":case"object":case"embed":St("load",s);break;case"video":case"audio":for(o=0;o<Po.length;o++)St(Po[o],s);break;case"source":St("error",s);break;case"img":case"image":case"link":St("error",s),St("load",s);break;case"details":St("toggle",s);break;case"input":St("invalid",s),Pa(s,d.value,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name,!0);break;case"select":St("invalid",s);break;case"textarea":St("invalid",s),xi(s,d.value,d.defaultValue,d.children)}o=d.children,typeof o!="string"&&typeof o!="number"&&typeof o!="bigint"||s.textContent===""+o||d.suppressHydrationWarning===!0||Uv(s.textContent,o)?(d.popover!=null&&(St("beforetoggle",s),St("toggle",s)),d.onScroll!=null&&St("scroll",s),d.onScrollEnd!=null&&St("scrollend",s),d.onClick!=null&&(s.onclick=Jn),s=!0):s=!1,s||Os(n,!0)}function kx(n){for(Vn=n.return;Vn;)switch(Vn.tag){case 5:case 31:case 13:mr=!1;return;case 27:case 3:mr=!0;return;default:Vn=Vn.return}}function xl(n){if(n!==Vn)return!1;if(!Tt)return kx(n),Tt=!0,!1;var s=n.tag,o;if((o=s!==3&&s!==27)&&((o=s===5)&&(o=n.type,o=!(o!=="form"&&o!=="button")||kp(n.type,n.memoizedProps)),o=!o),o&&rn&&Os(n),kx(n),s===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));rn=Gv(n)}else if(s===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));rn=Gv(n)}else s===27?(s=rn,Ys(n.type)?(n=Np,Np=null,rn=n):rn=s):rn=Vn?hr(n.stateNode.nextSibling):null;return!0}function Mi(){rn=Vn=null,Tt=!1}function rm(){var n=Ls;return n!==null&&(Ea===null?Ea=n:Ea.push.apply(Ea,n),Ls=null),n}function yo(n){Ls===null?Ls=[n]:Ls.push(n)}var sm=R(null),Ai=null,ls=null;function Ds(n,s,o){j(sm,s._currentValue),s._currentValue=o}function os(n){n._currentValue=sm.current,q(sm)}function im(n,s,o){for(;n!==null;){var d=n.alternate;if((n.childLanes&s)!==s?(n.childLanes|=s,d!==null&&(d.childLanes|=s)):d!==null&&(d.childLanes&s)!==s&&(d.childLanes|=s),n===o)break;n=n.return}}function lm(n,s,o,d){var y=n.child;for(y!==null&&(y.return=n);y!==null;){var b=y.dependencies;if(b!==null){var N=y.child;b=b.firstContext;e:for(;b!==null;){var L=b;b=y;for(var Q=0;Q<s.length;Q++)if(L.context===s[Q]){b.lanes|=o,L=b.alternate,L!==null&&(L.lanes|=o),im(b.return,o,n),d||(N=null);break e}b=L.next}}else if(y.tag===18){if(N=y.return,N===null)throw Error(i(341));N.lanes|=o,b=N.alternate,b!==null&&(b.lanes|=o),im(N,o,n),N=null}else N=y.child;if(N!==null)N.return=y;else for(N=y;N!==null;){if(N===n){N=null;break}if(y=N.sibling,y!==null){y.return=N.return,N=y;break}N=N.return}y=N}}function yl(n,s,o,d){n=null;for(var y=s,b=!1;y!==null;){if(!b){if((y.flags&524288)!==0)b=!0;else if((y.flags&262144)!==0)break}if(y.tag===10){var N=y.alternate;if(N===null)throw Error(i(387));if(N=N.memoizedProps,N!==null){var L=y.type;Ba(y.pendingProps.value,N.value)||(n!==null?n.push(L):n=[L])}}else if(y===ye.current){if(N=y.alternate,N===null)throw Error(i(387));N.memoizedState.memoizedState!==y.memoizedState.memoizedState&&(n!==null?n.push(qo):n=[qo])}y=y.return}n!==null&&lm(s,n,o,d),s.flags|=262144}function fu(n){for(n=n.firstContext;n!==null;){if(!Ba(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Ei(n){Ai=n,ls=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function qn(n){return wx(Ai,n)}function mu(n,s){return Ai===null&&Ei(n),wx(n,s)}function wx(n,s){var o=s._currentValue;if(s={context:s,memoizedValue:o,next:null},ls===null){if(n===null)throw Error(i(308));ls=s,n.dependencies={lanes:0,firstContext:s},n.flags|=524288}else ls=ls.next=s;return o}var pC=typeof AbortController<"u"?AbortController:function(){var n=[],s=this.signal={aborted:!1,addEventListener:function(o,d){n.push(d)}};this.abort=function(){s.aborted=!0,n.forEach(function(o){return o()})}},hC=e.unstable_scheduleCallback,gC=e.unstable_NormalPriority,En={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function om(){return{controller:new pC,data:new Map,refCount:0}}function vo(n){n.refCount--,n.refCount===0&&hC(gC,function(){n.controller.abort()})}var bo=null,cm=0,vl=0,bl=null;function xC(n,s){if(bo===null){var o=bo=[];cm=0,vl=fp(),bl={status:"pending",value:void 0,then:function(d){o.push(d)}}}return cm++,s.then(Sx,Sx),s}function Sx(){if(--cm===0&&bo!==null){bl!==null&&(bl.status="fulfilled");var n=bo;bo=null,vl=0,bl=null;for(var s=0;s<n.length;s++)(0,n[s])()}}function yC(n,s){var o=[],d={status:"pending",value:null,reason:null,then:function(y){o.push(y)}};return n.then(function(){d.status="fulfilled",d.value=s;for(var y=0;y<o.length;y++)(0,o[y])(s)},function(y){for(d.status="rejected",d.reason=y,y=0;y<o.length;y++)(0,o[y])(void 0)}),d}var jx=z.S;z.S=function(n,s){lv=Ce(),typeof s=="object"&&s!==null&&typeof s.then=="function"&&xC(n,s),jx!==null&&jx(n,s)};var _i=R(null);function um(){var n=_i.current;return n!==null?n:Jt.pooledCache}function pu(n,s){s===null?j(_i,_i.current):j(_i,s.pool)}function Cx(){var n=um();return n===null?null:{parent:En._currentValue,pool:n}}var kl=Error(i(460)),dm=Error(i(474)),hu=Error(i(542)),gu={then:function(){}};function Nx(n){return n=n.status,n==="fulfilled"||n==="rejected"}function Tx(n,s,o){switch(o=n[o],o===void 0?n.push(s):o!==s&&(s.then(Jn,Jn),s=o),s.status){case"fulfilled":return s.value;case"rejected":throw n=s.reason,Ax(n),n;default:if(typeof s.status=="string")s.then(Jn,Jn);else{if(n=Jt,n!==null&&100<n.shellSuspendCounter)throw Error(i(482));n=s,n.status="pending",n.then(function(d){if(s.status==="pending"){var y=s;y.status="fulfilled",y.value=d}},function(d){if(s.status==="pending"){var y=s;y.status="rejected",y.reason=d}})}switch(s.status){case"fulfilled":return s.value;case"rejected":throw n=s.reason,Ax(n),n}throw Ii=s,kl}}function Ri(n){try{var s=n._init;return s(n._payload)}catch(o){throw o!==null&&typeof o=="object"&&typeof o.then=="function"?(Ii=o,kl):o}}var Ii=null;function Mx(){if(Ii===null)throw Error(i(459));var n=Ii;return Ii=null,n}function Ax(n){if(n===kl||n===hu)throw Error(i(483))}var wl=null,ko=0;function xu(n){var s=ko;return ko+=1,wl===null&&(wl=[]),Tx(wl,n,s)}function wo(n,s){s=s.props.ref,n.ref=s!==void 0?s:null}function yu(n,s){throw s.$$typeof===k?Error(i(525)):(n=Object.prototype.toString.call(s),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":n)))}function Ex(n){function s(te,Z){if(n){var ie=te.deletions;ie===null?(te.deletions=[Z],te.flags|=16):ie.push(Z)}}function o(te,Z){if(!n)return null;for(;Z!==null;)s(te,Z),Z=Z.sibling;return null}function d(te){for(var Z=new Map;te!==null;)te.key!==null?Z.set(te.key,te):Z.set(te.index,te),te=te.sibling;return Z}function y(te,Z){return te=ss(te,Z),te.index=0,te.sibling=null,te}function b(te,Z,ie){return te.index=ie,n?(ie=te.alternate,ie!==null?(ie=ie.index,ie<Z?(te.flags|=67108866,Z):ie):(te.flags|=67108866,Z)):(te.flags|=1048576,Z)}function N(te){return n&&te.alternate===null&&(te.flags|=67108866),te}function L(te,Z,ie,be){return Z===null||Z.tag!==6?(Z=Jf(ie,te.mode,be),Z.return=te,Z):(Z=y(Z,ie),Z.return=te,Z)}function Q(te,Z,ie,be){var Ye=ie.type;return Ye===M?he(te,Z,ie.props.children,be,ie.key):Z!==null&&(Z.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===Y&&Ri(Ye)===Z.type)?(Z=y(Z,ie.props),wo(Z,ie),Z.return=te,Z):(Z=uu(ie.type,ie.key,ie.props,null,te.mode,be),wo(Z,ie),Z.return=te,Z)}function le(te,Z,ie,be){return Z===null||Z.tag!==4||Z.stateNode.containerInfo!==ie.containerInfo||Z.stateNode.implementation!==ie.implementation?(Z=em(ie,te.mode,be),Z.return=te,Z):(Z=y(Z,ie.children||[]),Z.return=te,Z)}function he(te,Z,ie,be,Ye){return Z===null||Z.tag!==7?(Z=Ti(ie,te.mode,be,Ye),Z.return=te,Z):(Z=y(Z,ie),Z.return=te,Z)}function we(te,Z,ie){if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return Z=Jf(""+Z,te.mode,ie),Z.return=te,Z;if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:return ie=uu(Z.type,Z.key,Z.props,null,te.mode,ie),wo(ie,Z),ie.return=te,ie;case S:return Z=em(Z,te.mode,ie),Z.return=te,Z;case Y:return Z=Ri(Z),we(te,Z,ie)}if(G(Z)||_(Z))return Z=Ti(Z,te.mode,ie,null),Z.return=te,Z;if(typeof Z.then=="function")return we(te,xu(Z),ie);if(Z.$$typeof===D)return we(te,mu(te,Z),ie);yu(te,Z)}return null}function oe(te,Z,ie,be){var Ye=Z!==null?Z.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return Ye!==null?null:L(te,Z,""+ie,be);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case w:return ie.key===Ye?Q(te,Z,ie,be):null;case S:return ie.key===Ye?le(te,Z,ie,be):null;case Y:return ie=Ri(ie),oe(te,Z,ie,be)}if(G(ie)||_(ie))return Ye!==null?null:he(te,Z,ie,be,null);if(typeof ie.then=="function")return oe(te,Z,xu(ie),be);if(ie.$$typeof===D)return oe(te,Z,mu(te,ie),be);yu(te,ie)}return null}function fe(te,Z,ie,be,Ye){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return te=te.get(ie)||null,L(Z,te,""+be,Ye);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case w:return te=te.get(be.key===null?ie:be.key)||null,Q(Z,te,be,Ye);case S:return te=te.get(be.key===null?ie:be.key)||null,le(Z,te,be,Ye);case Y:return be=Ri(be),fe(te,Z,ie,be,Ye)}if(G(be)||_(be))return te=te.get(ie)||null,he(Z,te,be,Ye,null);if(typeof be.then=="function")return fe(te,Z,ie,xu(be),Ye);if(be.$$typeof===D)return fe(te,Z,ie,mu(Z,be),Ye);yu(Z,be)}return null}function He(te,Z,ie,be){for(var Ye=null,Ot=null,qe=Z,ht=Z=0,Nt=null;qe!==null&&ht<ie.length;ht++){qe.index>ht?(Nt=qe,qe=null):Nt=qe.sibling;var Dt=oe(te,qe,ie[ht],be);if(Dt===null){qe===null&&(qe=Nt);break}n&&qe&&Dt.alternate===null&&s(te,qe),Z=b(Dt,Z,ht),Ot===null?Ye=Dt:Ot.sibling=Dt,Ot=Dt,qe=Nt}if(ht===ie.length)return o(te,qe),Tt&&is(te,ht),Ye;if(qe===null){for(;ht<ie.length;ht++)qe=we(te,ie[ht],be),qe!==null&&(Z=b(qe,Z,ht),Ot===null?Ye=qe:Ot.sibling=qe,Ot=qe);return Tt&&is(te,ht),Ye}for(qe=d(qe);ht<ie.length;ht++)Nt=fe(qe,te,ht,ie[ht],be),Nt!==null&&(n&&Nt.alternate!==null&&qe.delete(Nt.key===null?ht:Nt.key),Z=b(Nt,Z,ht),Ot===null?Ye=Nt:Ot.sibling=Nt,Ot=Nt);return n&&qe.forEach(function(ei){return s(te,ei)}),Tt&&is(te,ht),Ye}function tt(te,Z,ie,be){if(ie==null)throw Error(i(151));for(var Ye=null,Ot=null,qe=Z,ht=Z=0,Nt=null,Dt=ie.next();qe!==null&&!Dt.done;ht++,Dt=ie.next()){qe.index>ht?(Nt=qe,qe=null):Nt=qe.sibling;var ei=oe(te,qe,Dt.value,be);if(ei===null){qe===null&&(qe=Nt);break}n&&qe&&ei.alternate===null&&s(te,qe),Z=b(ei,Z,ht),Ot===null?Ye=ei:Ot.sibling=ei,Ot=ei,qe=Nt}if(Dt.done)return o(te,qe),Tt&&is(te,ht),Ye;if(qe===null){for(;!Dt.done;ht++,Dt=ie.next())Dt=we(te,Dt.value,be),Dt!==null&&(Z=b(Dt,Z,ht),Ot===null?Ye=Dt:Ot.sibling=Dt,Ot=Dt);return Tt&&is(te,ht),Ye}for(qe=d(qe);!Dt.done;ht++,Dt=ie.next())Dt=fe(qe,te,ht,Dt.value,be),Dt!==null&&(n&&Dt.alternate!==null&&qe.delete(Dt.key===null?ht:Dt.key),Z=b(Dt,Z,ht),Ot===null?Ye=Dt:Ot.sibling=Dt,Ot=Dt);return n&&qe.forEach(function(AN){return s(te,AN)}),Tt&&is(te,ht),Ye}function Qt(te,Z,ie,be){if(typeof ie=="object"&&ie!==null&&ie.type===M&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case w:e:{for(var Ye=ie.key;Z!==null;){if(Z.key===Ye){if(Ye=ie.type,Ye===M){if(Z.tag===7){o(te,Z.sibling),be=y(Z,ie.props.children),be.return=te,te=be;break e}}else if(Z.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===Y&&Ri(Ye)===Z.type){o(te,Z.sibling),be=y(Z,ie.props),wo(be,ie),be.return=te,te=be;break e}o(te,Z);break}else s(te,Z);Z=Z.sibling}ie.type===M?(be=Ti(ie.props.children,te.mode,be,ie.key),be.return=te,te=be):(be=uu(ie.type,ie.key,ie.props,null,te.mode,be),wo(be,ie),be.return=te,te=be)}return N(te);case S:e:{for(Ye=ie.key;Z!==null;){if(Z.key===Ye)if(Z.tag===4&&Z.stateNode.containerInfo===ie.containerInfo&&Z.stateNode.implementation===ie.implementation){o(te,Z.sibling),be=y(Z,ie.children||[]),be.return=te,te=be;break e}else{o(te,Z);break}else s(te,Z);Z=Z.sibling}be=em(ie,te.mode,be),be.return=te,te=be}return N(te);case Y:return ie=Ri(ie),Qt(te,Z,ie,be)}if(G(ie))return He(te,Z,ie,be);if(_(ie)){if(Ye=_(ie),typeof Ye!="function")throw Error(i(150));return ie=Ye.call(ie),tt(te,Z,ie,be)}if(typeof ie.then=="function")return Qt(te,Z,xu(ie),be);if(ie.$$typeof===D)return Qt(te,Z,mu(te,ie),be);yu(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,Z!==null&&Z.tag===6?(o(te,Z.sibling),be=y(Z,ie),be.return=te,te=be):(o(te,Z),be=Jf(ie,te.mode,be),be.return=te,te=be),N(te)):o(te,Z)}return function(te,Z,ie,be){try{ko=0;var Ye=Qt(te,Z,ie,be);return wl=null,Ye}catch(qe){if(qe===kl||qe===hu)throw qe;var Ot=Ha(29,qe,null,te.mode);return Ot.lanes=be,Ot.return=te,Ot}}}var Li=Ex(!0),_x=Ex(!1),Us=!1;function fm(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mm(n,s){n=n.updateQueue,s.updateQueue===n&&(s.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function zs(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function $s(n,s,o){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(Pt&2)!==0){var y=d.pending;return y===null?s.next=s:(s.next=y.next,y.next=s),d.pending=s,s=cu(n),px(n,null,o),s}return ou(n,d,s,o),cu(n)}function So(n,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194048)!==0)){var d=s.lanes;d&=n.pendingLanes,o|=d,s.lanes=o,zn(n,o)}}function pm(n,s){var o=n.updateQueue,d=n.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var y=null,b=null;if(o=o.firstBaseUpdate,o!==null){do{var N={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};b===null?y=b=N:b=b.next=N,o=o.next}while(o!==null);b===null?y=b=s:b=b.next=s}else y=b=s;o={baseState:d.baseState,firstBaseUpdate:y,lastBaseUpdate:b,shared:d.shared,callbacks:d.callbacks},n.updateQueue=o;return}n=o.lastBaseUpdate,n===null?o.firstBaseUpdate=s:n.next=s,o.lastBaseUpdate=s}var hm=!1;function jo(){if(hm){var n=bl;if(n!==null)throw n}}function Co(n,s,o,d){hm=!1;var y=n.updateQueue;Us=!1;var b=y.firstBaseUpdate,N=y.lastBaseUpdate,L=y.shared.pending;if(L!==null){y.shared.pending=null;var Q=L,le=Q.next;Q.next=null,N===null?b=le:N.next=le,N=Q;var he=n.alternate;he!==null&&(he=he.updateQueue,L=he.lastBaseUpdate,L!==N&&(L===null?he.firstBaseUpdate=le:L.next=le,he.lastBaseUpdate=Q))}if(b!==null){var we=y.baseState;N=0,he=le=Q=null,L=b;do{var oe=L.lane&-536870913,fe=oe!==L.lane;if(fe?(Ct&oe)===oe:(d&oe)===oe){oe!==0&&oe===vl&&(hm=!0),he!==null&&(he=he.next={lane:0,tag:L.tag,payload:L.payload,callback:null,next:null});e:{var He=n,tt=L;oe=s;var Qt=o;switch(tt.tag){case 1:if(He=tt.payload,typeof He=="function"){we=He.call(Qt,we,oe);break e}we=He;break e;case 3:He.flags=He.flags&-65537|128;case 0:if(He=tt.payload,oe=typeof He=="function"?He.call(Qt,we,oe):He,oe==null)break e;we=v({},we,oe);break e;case 2:Us=!0}}oe=L.callback,oe!==null&&(n.flags|=64,fe&&(n.flags|=8192),fe=y.callbacks,fe===null?y.callbacks=[oe]:fe.push(oe))}else fe={lane:oe,tag:L.tag,payload:L.payload,callback:L.callback,next:null},he===null?(le=he=fe,Q=we):he=he.next=fe,N|=oe;if(L=L.next,L===null){if(L=y.shared.pending,L===null)break;fe=L,L=fe.next,fe.next=null,y.lastBaseUpdate=fe,y.shared.pending=null}}while(!0);he===null&&(Q=we),y.baseState=Q,y.firstBaseUpdate=le,y.lastBaseUpdate=he,b===null&&(y.shared.lanes=0),Vs|=N,n.lanes=N,n.memoizedState=we}}function Rx(n,s){if(typeof n!="function")throw Error(i(191,n));n.call(s)}function Ix(n,s){var o=n.callbacks;if(o!==null)for(n.callbacks=null,n=0;n<o.length;n++)Rx(o[n],s)}var Sl=R(null),vu=R(0);function Lx(n,s){n=xs,j(vu,n),j(Sl,s),xs=n|s.baseLanes}function gm(){j(vu,xs),j(Sl,Sl.current)}function xm(){xs=vu.current,q(Sl),q(vu)}var Fa=R(null),pr=null;function Ps(n){var s=n.alternate;j(Nn,Nn.current&1),j(Fa,n),pr===null&&(s===null||Sl.current!==null||s.memoizedState!==null)&&(pr=n)}function ym(n){j(Nn,Nn.current),j(Fa,n),pr===null&&(pr=n)}function Ox(n){n.tag===22?(j(Nn,Nn.current),j(Fa,n),pr===null&&(pr=n)):Bs()}function Bs(){j(Nn,Nn.current),j(Fa,Fa.current)}function Va(n){q(Fa),pr===n&&(pr=null),q(Nn)}var Nn=R(0);function bu(n){for(var s=n;s!==null;){if(s.tag===13){var o=s.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||jp(o)||Cp(o)))return s}else if(s.tag===19&&(s.memoizedProps.revealOrder==="forwards"||s.memoizedProps.revealOrder==="backwards"||s.memoizedProps.revealOrder==="unstable_legacy-backwards"||s.memoizedProps.revealOrder==="together")){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var cs=0,mt=null,Kt=null,_n=null,ku=!1,jl=!1,Oi=!1,wu=0,No=0,Cl=null,vC=0;function wn(){throw Error(i(321))}function vm(n,s){if(s===null)return!1;for(var o=0;o<s.length&&o<n.length;o++)if(!Ba(n[o],s[o]))return!1;return!0}function bm(n,s,o,d,y,b){return cs=b,mt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,z.H=n===null||n.memoizedState===null?yy:Om,Oi=!1,b=o(d,y),Oi=!1,jl&&(b=Ux(s,o,d,y)),Dx(n),b}function Dx(n){z.H=Ao;var s=Kt!==null&&Kt.next!==null;if(cs=0,_n=Kt=mt=null,ku=!1,No=0,Cl=null,s)throw Error(i(300));n===null||Rn||(n=n.dependencies,n!==null&&fu(n)&&(Rn=!0))}function Ux(n,s,o,d){mt=n;var y=0;do{if(jl&&(Cl=null),No=0,jl=!1,25<=y)throw Error(i(301));if(y+=1,_n=Kt=null,n.updateQueue!=null){var b=n.updateQueue;b.lastEffect=null,b.events=null,b.stores=null,b.memoCache!=null&&(b.memoCache.index=0)}z.H=vy,b=s(o,d)}while(jl);return b}function bC(){var n=z.H,s=n.useState()[0];return s=typeof s.then=="function"?To(s):s,n=n.useState()[0],(Kt!==null?Kt.memoizedState:null)!==n&&(mt.flags|=1024),s}function km(){var n=wu!==0;return wu=0,n}function wm(n,s,o){s.updateQueue=n.updateQueue,s.flags&=-2053,n.lanes&=~o}function Sm(n){if(ku){for(n=n.memoizedState;n!==null;){var s=n.queue;s!==null&&(s.pending=null),n=n.next}ku=!1}cs=0,_n=Kt=mt=null,jl=!1,No=wu=0,Cl=null}function da(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return _n===null?mt.memoizedState=_n=n:_n=_n.next=n,_n}function Tn(){if(Kt===null){var n=mt.alternate;n=n!==null?n.memoizedState:null}else n=Kt.next;var s=_n===null?mt.memoizedState:_n.next;if(s!==null)_n=s,Kt=n;else{if(n===null)throw mt.alternate===null?Error(i(467)):Error(i(310));Kt=n,n={memoizedState:Kt.memoizedState,baseState:Kt.baseState,baseQueue:Kt.baseQueue,queue:Kt.queue,next:null},_n===null?mt.memoizedState=_n=n:_n=_n.next=n}return _n}function Su(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function To(n){var s=No;return No+=1,Cl===null&&(Cl=[]),n=Tx(Cl,n,s),s=mt,(_n===null?s.memoizedState:_n.next)===null&&(s=s.alternate,z.H=s===null||s.memoizedState===null?yy:Om),n}function ju(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return To(n);if(n.$$typeof===D)return qn(n)}throw Error(i(438,String(n)))}function jm(n){var s=null,o=mt.updateQueue;if(o!==null&&(s=o.memoCache),s==null){var d=mt.alternate;d!==null&&(d=d.updateQueue,d!==null&&(d=d.memoCache,d!=null&&(s={data:d.data.map(function(y){return y.slice()}),index:0})))}if(s==null&&(s={data:[],index:0}),o===null&&(o=Su(),mt.updateQueue=o),o.memoCache=s,o=s.data[s.index],o===void 0)for(o=s.data[s.index]=Array(n),d=0;d<n;d++)o[d]=O;return s.index++,o}function us(n,s){return typeof s=="function"?s(n):s}function Cu(n){var s=Tn();return Cm(s,Kt,n)}function Cm(n,s,o){var d=n.queue;if(d===null)throw Error(i(311));d.lastRenderedReducer=o;var y=n.baseQueue,b=d.pending;if(b!==null){if(y!==null){var N=y.next;y.next=b.next,b.next=N}s.baseQueue=y=b,d.pending=null}if(b=n.baseState,y===null)n.memoizedState=b;else{s=y.next;var L=N=null,Q=null,le=s,he=!1;do{var we=le.lane&-536870913;if(we!==le.lane?(Ct&we)===we:(cs&we)===we){var oe=le.revertLane;if(oe===0)Q!==null&&(Q=Q.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),we===vl&&(he=!0);else if((cs&oe)===oe){le=le.next,oe===vl&&(he=!0);continue}else we={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},Q===null?(L=Q=we,N=b):Q=Q.next=we,mt.lanes|=oe,Vs|=oe;we=le.action,Oi&&o(b,we),b=le.hasEagerState?le.eagerState:o(b,we)}else oe={lane:we,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},Q===null?(L=Q=oe,N=b):Q=Q.next=oe,mt.lanes|=we,Vs|=we;le=le.next}while(le!==null&&le!==s);if(Q===null?N=b:Q.next=L,!Ba(b,n.memoizedState)&&(Rn=!0,he&&(o=bl,o!==null)))throw o;n.memoizedState=b,n.baseState=N,n.baseQueue=Q,d.lastRenderedState=b}return y===null&&(d.lanes=0),[n.memoizedState,d.dispatch]}function Nm(n){var s=Tn(),o=s.queue;if(o===null)throw Error(i(311));o.lastRenderedReducer=n;var d=o.dispatch,y=o.pending,b=s.memoizedState;if(y!==null){o.pending=null;var N=y=y.next;do b=n(b,N.action),N=N.next;while(N!==y);Ba(b,s.memoizedState)||(Rn=!0),s.memoizedState=b,s.baseQueue===null&&(s.baseState=b),o.lastRenderedState=b}return[b,d]}function zx(n,s,o){var d=mt,y=Tn(),b=Tt;if(b){if(o===void 0)throw Error(i(407));o=o()}else o=s();var N=!Ba((Kt||y).memoizedState,o);if(N&&(y.memoizedState=o,Rn=!0),y=y.queue,Am(Bx.bind(null,d,y,n),[n]),y.getSnapshot!==s||N||_n!==null&&_n.memoizedState.tag&1){if(d.flags|=2048,Nl(9,{destroy:void 0},Px.bind(null,d,y,o,s),null),Jt===null)throw Error(i(349));b||(cs&127)!==0||$x(d,s,o)}return o}function $x(n,s,o){n.flags|=16384,n={getSnapshot:s,value:o},s=mt.updateQueue,s===null?(s=Su(),mt.updateQueue=s,s.stores=[n]):(o=s.stores,o===null?s.stores=[n]:o.push(n))}function Px(n,s,o,d){s.value=o,s.getSnapshot=d,Hx(s)&&Fx(n)}function Bx(n,s,o){return o(function(){Hx(s)&&Fx(n)})}function Hx(n){var s=n.getSnapshot;n=n.value;try{var o=s();return!Ba(n,o)}catch{return!0}}function Fx(n){var s=Ni(n,2);s!==null&&_a(s,n,2)}function Tm(n){var s=da();if(typeof n=="function"){var o=n;if(n=o(),Oi){Pe(!0);try{o()}finally{Pe(!1)}}}return s.memoizedState=s.baseState=n,s.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:n},s}function Vx(n,s,o,d){return n.baseState=o,Cm(n,Kt,typeof d=="function"?d:us)}function kC(n,s,o,d,y){if(Mu(n))throw Error(i(485));if(n=s.action,n!==null){var b={payload:y,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(N){b.listeners.push(N)}};z.T!==null?o(!0):b.isTransition=!1,d(b),o=s.pending,o===null?(b.next=s.pending=b,qx(s,b)):(b.next=o.next,s.pending=o.next=b)}}function qx(n,s){var o=s.action,d=s.payload,y=n.state;if(s.isTransition){var b=z.T,N={};z.T=N;try{var L=o(y,d),Q=z.S;Q!==null&&Q(N,L),Gx(n,s,L)}catch(le){Mm(n,s,le)}finally{b!==null&&N.types!==null&&(b.types=N.types),z.T=b}}else try{b=o(y,d),Gx(n,s,b)}catch(le){Mm(n,s,le)}}function Gx(n,s,o){o!==null&&typeof o=="object"&&typeof o.then=="function"?o.then(function(d){Wx(n,s,d)},function(d){return Mm(n,s,d)}):Wx(n,s,o)}function Wx(n,s,o){s.status="fulfilled",s.value=o,Kx(s),n.state=o,s=n.pending,s!==null&&(o=s.next,o===s?n.pending=null:(o=o.next,s.next=o,qx(n,o)))}function Mm(n,s,o){var d=n.pending;if(n.pending=null,d!==null){d=d.next;do s.status="rejected",s.reason=o,Kx(s),s=s.next;while(s!==d)}n.action=null}function Kx(n){n=n.listeners;for(var s=0;s<n.length;s++)(0,n[s])()}function Yx(n,s){return s}function Qx(n,s){if(Tt){var o=Jt.formState;if(o!==null){e:{var d=mt;if(Tt){if(rn){t:{for(var y=rn,b=mr;y.nodeType!==8;){if(!b){y=null;break t}if(y=hr(y.nextSibling),y===null){y=null;break t}}b=y.data,y=b==="F!"||b==="F"?y:null}if(y){rn=hr(y.nextSibling),d=y.data==="F!";break e}}Os(d)}d=!1}d&&(s=o[0])}}return o=da(),o.memoizedState=o.baseState=s,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Yx,lastRenderedState:s},o.queue=d,o=hy.bind(null,mt,d),d.dispatch=o,d=Tm(!1),b=Lm.bind(null,mt,!1,d.queue),d=da(),y={state:s,dispatch:null,action:n,pending:null},d.queue=y,o=kC.bind(null,mt,y,b,o),y.dispatch=o,d.memoizedState=n,[s,o,!1]}function Xx(n){var s=Tn();return Zx(s,Kt,n)}function Zx(n,s,o){if(s=Cm(n,s,Yx)[0],n=Cu(us)[0],typeof s=="object"&&s!==null&&typeof s.then=="function")try{var d=To(s)}catch(N){throw N===kl?hu:N}else d=s;s=Tn();var y=s.queue,b=y.dispatch;return o!==s.memoizedState&&(mt.flags|=2048,Nl(9,{destroy:void 0},wC.bind(null,y,o),null)),[d,b,n]}function wC(n,s){n.action=s}function Jx(n){var s=Tn(),o=Kt;if(o!==null)return Zx(s,o,n);Tn(),s=s.memoizedState,o=Tn();var d=o.queue.dispatch;return o.memoizedState=n,[s,d,!1]}function Nl(n,s,o,d){return n={tag:n,create:o,deps:d,inst:s,next:null},s=mt.updateQueue,s===null&&(s=Su(),mt.updateQueue=s),o=s.lastEffect,o===null?s.lastEffect=n.next=n:(d=o.next,o.next=n,n.next=d,s.lastEffect=n),n}function ey(){return Tn().memoizedState}function Nu(n,s,o,d){var y=da();mt.flags|=n,y.memoizedState=Nl(1|s,{destroy:void 0},o,d===void 0?null:d)}function Tu(n,s,o,d){var y=Tn();d=d===void 0?null:d;var b=y.memoizedState.inst;Kt!==null&&d!==null&&vm(d,Kt.memoizedState.deps)?y.memoizedState=Nl(s,b,o,d):(mt.flags|=n,y.memoizedState=Nl(1|s,b,o,d))}function ty(n,s){Nu(8390656,8,n,s)}function Am(n,s){Tu(2048,8,n,s)}function SC(n){mt.flags|=4;var s=mt.updateQueue;if(s===null)s=Su(),mt.updateQueue=s,s.events=[n];else{var o=s.events;o===null?s.events=[n]:o.push(n)}}function ny(n){var s=Tn().memoizedState;return SC({ref:s,nextImpl:n}),function(){if((Pt&2)!==0)throw Error(i(440));return s.impl.apply(void 0,arguments)}}function ay(n,s){return Tu(4,2,n,s)}function ry(n,s){return Tu(4,4,n,s)}function sy(n,s){if(typeof s=="function"){n=n();var o=s(n);return function(){typeof o=="function"?o():s(null)}}if(s!=null)return n=n(),s.current=n,function(){s.current=null}}function iy(n,s,o){o=o!=null?o.concat([n]):null,Tu(4,4,sy.bind(null,s,n),o)}function Em(){}function ly(n,s){var o=Tn();s=s===void 0?null:s;var d=o.memoizedState;return s!==null&&vm(s,d[1])?d[0]:(o.memoizedState=[n,s],n)}function oy(n,s){var o=Tn();s=s===void 0?null:s;var d=o.memoizedState;if(s!==null&&vm(s,d[1]))return d[0];if(d=n(),Oi){Pe(!0);try{n()}finally{Pe(!1)}}return o.memoizedState=[d,s],d}function _m(n,s,o){return o===void 0||(cs&1073741824)!==0&&(Ct&261930)===0?n.memoizedState=s:(n.memoizedState=o,n=cv(),mt.lanes|=n,Vs|=n,o)}function cy(n,s,o,d){return Ba(o,s)?o:Sl.current!==null?(n=_m(n,o,d),Ba(n,s)||(Rn=!0),n):(cs&42)===0||(cs&1073741824)!==0&&(Ct&261930)===0?(Rn=!0,n.memoizedState=o):(n=cv(),mt.lanes|=n,Vs|=n,s)}function uy(n,s,o,d,y){var b=J.p;J.p=b!==0&&8>b?b:8;var N=z.T,L={};z.T=L,Lm(n,!1,s,o);try{var Q=y(),le=z.S;if(le!==null&&le(L,Q),Q!==null&&typeof Q=="object"&&typeof Q.then=="function"){var he=yC(Q,d);Mo(n,s,he,Wa(n))}else Mo(n,s,d,Wa(n))}catch(we){Mo(n,s,{then:function(){},status:"rejected",reason:we},Wa())}finally{J.p=b,N!==null&&L.types!==null&&(N.types=L.types),z.T=N}}function jC(){}function Rm(n,s,o,d){if(n.tag!==5)throw Error(i(476));var y=dy(n).queue;uy(n,y,s,xe,o===null?jC:function(){return fy(n),o(d)})}function dy(n){var s=n.memoizedState;if(s!==null)return s;s={memoizedState:xe,baseState:xe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:xe},next:null};var o={};return s.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:us,lastRenderedState:o},next:null},n.memoizedState=s,n=n.alternate,n!==null&&(n.memoizedState=s),s}function fy(n){var s=dy(n);s.next===null&&(s=n.alternate.memoizedState),Mo(n,s.next.queue,{},Wa())}function Im(){return qn(qo)}function my(){return Tn().memoizedState}function py(){return Tn().memoizedState}function CC(n){for(var s=n.return;s!==null;){switch(s.tag){case 24:case 3:var o=Wa();n=zs(o);var d=$s(s,n,o);d!==null&&(_a(d,s,o),So(d,s,o)),s={cache:om()},n.payload=s;return}s=s.return}}function NC(n,s,o){var d=Wa();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Mu(n)?gy(s,o):(o=Xf(n,s,o,d),o!==null&&(_a(o,n,d),xy(o,s,d)))}function hy(n,s,o){var d=Wa();Mo(n,s,o,d)}function Mo(n,s,o,d){var y={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Mu(n))gy(s,y);else{var b=n.alternate;if(n.lanes===0&&(b===null||b.lanes===0)&&(b=s.lastRenderedReducer,b!==null))try{var N=s.lastRenderedState,L=b(N,o);if(y.hasEagerState=!0,y.eagerState=L,Ba(L,N))return ou(n,s,y,0),Jt===null&&lu(),!1}catch{}if(o=Xf(n,s,y,d),o!==null)return _a(o,n,d),xy(o,s,d),!0}return!1}function Lm(n,s,o,d){if(d={lane:2,revertLane:fp(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Mu(n)){if(s)throw Error(i(479))}else s=Xf(n,o,d,2),s!==null&&_a(s,n,2)}function Mu(n){var s=n.alternate;return n===mt||s!==null&&s===mt}function gy(n,s){jl=ku=!0;var o=n.pending;o===null?s.next=s:(s.next=o.next,o.next=s),n.pending=s}function xy(n,s,o){if((o&4194048)!==0){var d=s.lanes;d&=n.pendingLanes,o|=d,s.lanes=o,zn(n,o)}}var Ao={readContext:qn,use:ju,useCallback:wn,useContext:wn,useEffect:wn,useImperativeHandle:wn,useLayoutEffect:wn,useInsertionEffect:wn,useMemo:wn,useReducer:wn,useRef:wn,useState:wn,useDebugValue:wn,useDeferredValue:wn,useTransition:wn,useSyncExternalStore:wn,useId:wn,useHostTransitionStatus:wn,useFormState:wn,useActionState:wn,useOptimistic:wn,useMemoCache:wn,useCacheRefresh:wn};Ao.useEffectEvent=wn;var yy={readContext:qn,use:ju,useCallback:function(n,s){return da().memoizedState=[n,s===void 0?null:s],n},useContext:qn,useEffect:ty,useImperativeHandle:function(n,s,o){o=o!=null?o.concat([n]):null,Nu(4194308,4,sy.bind(null,s,n),o)},useLayoutEffect:function(n,s){return Nu(4194308,4,n,s)},useInsertionEffect:function(n,s){Nu(4,2,n,s)},useMemo:function(n,s){var o=da();s=s===void 0?null:s;var d=n();if(Oi){Pe(!0);try{n()}finally{Pe(!1)}}return o.memoizedState=[d,s],d},useReducer:function(n,s,o){var d=da();if(o!==void 0){var y=o(s);if(Oi){Pe(!0);try{o(s)}finally{Pe(!1)}}}else y=s;return d.memoizedState=d.baseState=y,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:y},d.queue=n,n=n.dispatch=NC.bind(null,mt,n),[d.memoizedState,n]},useRef:function(n){var s=da();return n={current:n},s.memoizedState=n},useState:function(n){n=Tm(n);var s=n.queue,o=hy.bind(null,mt,s);return s.dispatch=o,[n.memoizedState,o]},useDebugValue:Em,useDeferredValue:function(n,s){var o=da();return _m(o,n,s)},useTransition:function(){var n=Tm(!1);return n=uy.bind(null,mt,n.queue,!0,!1),da().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,s,o){var d=mt,y=da();if(Tt){if(o===void 0)throw Error(i(407));o=o()}else{if(o=s(),Jt===null)throw Error(i(349));(Ct&127)!==0||$x(d,s,o)}y.memoizedState=o;var b={value:o,getSnapshot:s};return y.queue=b,ty(Bx.bind(null,d,b,n),[n]),d.flags|=2048,Nl(9,{destroy:void 0},Px.bind(null,d,b,o,s),null),o},useId:function(){var n=da(),s=Jt.identifierPrefix;if(Tt){var o=Fr,d=Hr;o=(d&~(1<<32-Fe(d)-1)).toString(32)+o,s="_"+s+"R_"+o,o=wu++,0<o&&(s+="H"+o.toString(32)),s+="_"}else o=vC++,s="_"+s+"r_"+o.toString(32)+"_";return n.memoizedState=s},useHostTransitionStatus:Im,useFormState:Qx,useActionState:Qx,useOptimistic:function(n){var s=da();s.memoizedState=s.baseState=n;var o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return s.queue=o,s=Lm.bind(null,mt,!0,o),o.dispatch=s,[n,s]},useMemoCache:jm,useCacheRefresh:function(){return da().memoizedState=CC.bind(null,mt)},useEffectEvent:function(n){var s=da(),o={impl:n};return s.memoizedState=o,function(){if((Pt&2)!==0)throw Error(i(440));return o.impl.apply(void 0,arguments)}}},Om={readContext:qn,use:ju,useCallback:ly,useContext:qn,useEffect:Am,useImperativeHandle:iy,useInsertionEffect:ay,useLayoutEffect:ry,useMemo:oy,useReducer:Cu,useRef:ey,useState:function(){return Cu(us)},useDebugValue:Em,useDeferredValue:function(n,s){var o=Tn();return cy(o,Kt.memoizedState,n,s)},useTransition:function(){var n=Cu(us)[0],s=Tn().memoizedState;return[typeof n=="boolean"?n:To(n),s]},useSyncExternalStore:zx,useId:my,useHostTransitionStatus:Im,useFormState:Xx,useActionState:Xx,useOptimistic:function(n,s){var o=Tn();return Vx(o,Kt,n,s)},useMemoCache:jm,useCacheRefresh:py};Om.useEffectEvent=ny;var vy={readContext:qn,use:ju,useCallback:ly,useContext:qn,useEffect:Am,useImperativeHandle:iy,useInsertionEffect:ay,useLayoutEffect:ry,useMemo:oy,useReducer:Nm,useRef:ey,useState:function(){return Nm(us)},useDebugValue:Em,useDeferredValue:function(n,s){var o=Tn();return Kt===null?_m(o,n,s):cy(o,Kt.memoizedState,n,s)},useTransition:function(){var n=Nm(us)[0],s=Tn().memoizedState;return[typeof n=="boolean"?n:To(n),s]},useSyncExternalStore:zx,useId:my,useHostTransitionStatus:Im,useFormState:Jx,useActionState:Jx,useOptimistic:function(n,s){var o=Tn();return Kt!==null?Vx(o,Kt,n,s):(o.baseState=n,[n,o.queue.dispatch])},useMemoCache:jm,useCacheRefresh:py};vy.useEffectEvent=ny;function Dm(n,s,o,d){s=n.memoizedState,o=o(d,s),o=o==null?s:v({},s,o),n.memoizedState=o,n.lanes===0&&(n.updateQueue.baseState=o)}var Um={enqueueSetState:function(n,s,o){n=n._reactInternals;var d=Wa(),y=zs(d);y.payload=s,o!=null&&(y.callback=o),s=$s(n,y,d),s!==null&&(_a(s,n,d),So(s,n,d))},enqueueReplaceState:function(n,s,o){n=n._reactInternals;var d=Wa(),y=zs(d);y.tag=1,y.payload=s,o!=null&&(y.callback=o),s=$s(n,y,d),s!==null&&(_a(s,n,d),So(s,n,d))},enqueueForceUpdate:function(n,s){n=n._reactInternals;var o=Wa(),d=zs(o);d.tag=2,s!=null&&(d.callback=s),s=$s(n,d,o),s!==null&&(_a(s,n,o),So(s,n,o))}};function by(n,s,o,d,y,b,N){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(d,b,N):s.prototype&&s.prototype.isPureReactComponent?!ho(o,d)||!ho(y,b):!0}function ky(n,s,o,d){n=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(o,d),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(o,d),s.state!==n&&Um.enqueueReplaceState(s,s.state,null)}function Di(n,s){var o=s;if("ref"in s){o={};for(var d in s)d!=="ref"&&(o[d]=s[d])}if(n=n.defaultProps){o===s&&(o=v({},o));for(var y in n)o[y]===void 0&&(o[y]=n[y])}return o}function wy(n){iu(n)}function Sy(n){console.error(n)}function jy(n){iu(n)}function Au(n,s){try{var o=n.onUncaughtError;o(s.value,{componentStack:s.stack})}catch(d){setTimeout(function(){throw d})}}function Cy(n,s,o){try{var d=n.onCaughtError;d(o.value,{componentStack:o.stack,errorBoundary:s.tag===1?s.stateNode:null})}catch(y){setTimeout(function(){throw y})}}function zm(n,s,o){return o=zs(o),o.tag=3,o.payload={element:null},o.callback=function(){Au(n,s)},o}function Ny(n){return n=zs(n),n.tag=3,n}function Ty(n,s,o,d){var y=o.type.getDerivedStateFromError;if(typeof y=="function"){var b=d.value;n.payload=function(){return y(b)},n.callback=function(){Cy(s,o,d)}}var N=o.stateNode;N!==null&&typeof N.componentDidCatch=="function"&&(n.callback=function(){Cy(s,o,d),typeof y!="function"&&(qs===null?qs=new Set([this]):qs.add(this));var L=d.stack;this.componentDidCatch(d.value,{componentStack:L!==null?L:""})})}function TC(n,s,o,d,y){if(o.flags|=32768,d!==null&&typeof d=="object"&&typeof d.then=="function"){if(s=o.alternate,s!==null&&yl(s,o,y,!0),o=Fa.current,o!==null){switch(o.tag){case 31:case 13:return pr===null?Bu():o.alternate===null&&Sn===0&&(Sn=3),o.flags&=-257,o.flags|=65536,o.lanes=y,d===gu?o.flags|=16384:(s=o.updateQueue,s===null?o.updateQueue=new Set([d]):s.add(d),cp(n,d,y)),!1;case 22:return o.flags|=65536,d===gu?o.flags|=16384:(s=o.updateQueue,s===null?(s={transitions:null,markerInstances:null,retryQueue:new Set([d])},o.updateQueue=s):(o=s.retryQueue,o===null?s.retryQueue=new Set([d]):o.add(d)),cp(n,d,y)),!1}throw Error(i(435,o.tag))}return cp(n,d,y),Bu(),!1}if(Tt)return s=Fa.current,s!==null?((s.flags&65536)===0&&(s.flags|=256),s.flags|=65536,s.lanes=y,d!==am&&(n=Error(i(422),{cause:d}),yo(ur(n,o)))):(d!==am&&(s=Error(i(423),{cause:d}),yo(ur(s,o))),n=n.current.alternate,n.flags|=65536,y&=-y,n.lanes|=y,d=ur(d,o),y=zm(n.stateNode,d,y),pm(n,y),Sn!==4&&(Sn=2)),!1;var b=Error(i(520),{cause:d});if(b=ur(b,o),Uo===null?Uo=[b]:Uo.push(b),Sn!==4&&(Sn=2),s===null)return!0;d=ur(d,o),o=s;do{switch(o.tag){case 3:return o.flags|=65536,n=y&-y,o.lanes|=n,n=zm(o.stateNode,d,n),pm(o,n),!1;case 1:if(s=o.type,b=o.stateNode,(o.flags&128)===0&&(typeof s.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(qs===null||!qs.has(b))))return o.flags|=65536,y&=-y,o.lanes|=y,y=Ny(y),Ty(y,n,o,d),pm(o,y),!1}o=o.return}while(o!==null);return!1}var $m=Error(i(461)),Rn=!1;function Gn(n,s,o,d){s.child=n===null?_x(s,null,o,d):Li(s,n.child,o,d)}function My(n,s,o,d,y){o=o.render;var b=s.ref;if("ref"in d){var N={};for(var L in d)L!=="ref"&&(N[L]=d[L])}else N=d;return Ei(s),d=bm(n,s,o,N,b,y),L=km(),n!==null&&!Rn?(wm(n,s,y),ds(n,s,y)):(Tt&&L&&tm(s),s.flags|=1,Gn(n,s,d,y),s.child)}function Ay(n,s,o,d,y){if(n===null){var b=o.type;return typeof b=="function"&&!Zf(b)&&b.defaultProps===void 0&&o.compare===null?(s.tag=15,s.type=b,Ey(n,s,b,d,y)):(n=uu(o.type,null,d,s,s.mode,y),n.ref=s.ref,n.return=s,s.child=n)}if(b=n.child,!Wm(n,y)){var N=b.memoizedProps;if(o=o.compare,o=o!==null?o:ho,o(N,d)&&n.ref===s.ref)return ds(n,s,y)}return s.flags|=1,n=ss(b,d),n.ref=s.ref,n.return=s,s.child=n}function Ey(n,s,o,d,y){if(n!==null){var b=n.memoizedProps;if(ho(b,d)&&n.ref===s.ref)if(Rn=!1,s.pendingProps=d=b,Wm(n,y))(n.flags&131072)!==0&&(Rn=!0);else return s.lanes=n.lanes,ds(n,s,y)}return Pm(n,s,o,d,y)}function _y(n,s,o,d){var y=d.children,b=n!==null?n.memoizedState:null;if(n===null&&s.stateNode===null&&(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),d.mode==="hidden"){if((s.flags&128)!==0){if(b=b!==null?b.baseLanes|o:o,n!==null){for(d=s.child=n.child,y=0;d!==null;)y=y|d.lanes|d.childLanes,d=d.sibling;d=y&~b}else d=0,s.child=null;return Ry(n,s,b,o,d)}if((o&536870912)!==0)s.memoizedState={baseLanes:0,cachePool:null},n!==null&&pu(s,b!==null?b.cachePool:null),b!==null?Lx(s,b):gm(),Ox(s);else return d=s.lanes=536870912,Ry(n,s,b!==null?b.baseLanes|o:o,o,d)}else b!==null?(pu(s,b.cachePool),Lx(s,b),Bs(),s.memoizedState=null):(n!==null&&pu(s,null),gm(),Bs());return Gn(n,s,y,o),s.child}function Eo(n,s){return n!==null&&n.tag===22||s.stateNode!==null||(s.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.sibling}function Ry(n,s,o,d,y){var b=um();return b=b===null?null:{parent:En._currentValue,pool:b},s.memoizedState={baseLanes:o,cachePool:b},n!==null&&pu(s,null),gm(),Ox(s),n!==null&&yl(n,s,d,!0),s.childLanes=y,null}function Eu(n,s){return s=Ru({mode:s.mode,children:s.children},n.mode),s.ref=n.ref,n.child=s,s.return=n,s}function Iy(n,s,o){return Li(s,n.child,null,o),n=Eu(s,s.pendingProps),n.flags|=2,Va(s),s.memoizedState=null,n}function MC(n,s,o){var d=s.pendingProps,y=(s.flags&128)!==0;if(s.flags&=-129,n===null){if(Tt){if(d.mode==="hidden")return n=Eu(s,d),s.lanes=536870912,Eo(null,n);if(ym(s),(n=rn)?(n=qv(n,mr),n=n!==null&&n.data==="&"?n:null,n!==null&&(s.memoizedState={dehydrated:n,treeContext:Is!==null?{id:Hr,overflow:Fr}:null,retryLane:536870912,hydrationErrors:null},o=gx(n),o.return=s,s.child=o,Vn=s,rn=null)):n=null,n===null)throw Os(s);return s.lanes=536870912,null}return Eu(s,d)}var b=n.memoizedState;if(b!==null){var N=b.dehydrated;if(ym(s),y)if(s.flags&256)s.flags&=-257,s=Iy(n,s,o);else if(s.memoizedState!==null)s.child=n.child,s.flags|=128,s=null;else throw Error(i(558));else if(Rn||yl(n,s,o,!1),y=(o&n.childLanes)!==0,Rn||y){if(d=Jt,d!==null&&(N=xa(d,o),N!==0&&N!==b.retryLane))throw b.retryLane=N,Ni(n,N),_a(d,n,N),$m;Bu(),s=Iy(n,s,o)}else n=b.treeContext,rn=hr(N.nextSibling),Vn=s,Tt=!0,Ls=null,mr=!1,n!==null&&vx(s,n),s=Eu(s,d),s.flags|=4096;return s}return n=ss(n.child,{mode:d.mode,children:d.children}),n.ref=s.ref,s.child=n,n.return=s,n}function _u(n,s){var o=s.ref;if(o===null)n!==null&&n.ref!==null&&(s.flags|=4194816);else{if(typeof o!="function"&&typeof o!="object")throw Error(i(284));(n===null||n.ref!==o)&&(s.flags|=4194816)}}function Pm(n,s,o,d,y){return Ei(s),o=bm(n,s,o,d,void 0,y),d=km(),n!==null&&!Rn?(wm(n,s,y),ds(n,s,y)):(Tt&&d&&tm(s),s.flags|=1,Gn(n,s,o,y),s.child)}function Ly(n,s,o,d,y,b){return Ei(s),s.updateQueue=null,o=Ux(s,d,o,y),Dx(n),d=km(),n!==null&&!Rn?(wm(n,s,b),ds(n,s,b)):(Tt&&d&&tm(s),s.flags|=1,Gn(n,s,o,b),s.child)}function Oy(n,s,o,d,y){if(Ei(s),s.stateNode===null){var b=pl,N=o.contextType;typeof N=="object"&&N!==null&&(b=qn(N)),b=new o(d,b),s.memoizedState=b.state!==null&&b.state!==void 0?b.state:null,b.updater=Um,s.stateNode=b,b._reactInternals=s,b=s.stateNode,b.props=d,b.state=s.memoizedState,b.refs={},fm(s),N=o.contextType,b.context=typeof N=="object"&&N!==null?qn(N):pl,b.state=s.memoizedState,N=o.getDerivedStateFromProps,typeof N=="function"&&(Dm(s,o,N,d),b.state=s.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof b.getSnapshotBeforeUpdate=="function"||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(N=b.state,typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount(),N!==b.state&&Um.enqueueReplaceState(b,b.state,null),Co(s,d,b,y),jo(),b.state=s.memoizedState),typeof b.componentDidMount=="function"&&(s.flags|=4194308),d=!0}else if(n===null){b=s.stateNode;var L=s.memoizedProps,Q=Di(o,L);b.props=Q;var le=b.context,he=o.contextType;N=pl,typeof he=="object"&&he!==null&&(N=qn(he));var we=o.getDerivedStateFromProps;he=typeof we=="function"||typeof b.getSnapshotBeforeUpdate=="function",L=s.pendingProps!==L,he||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(L||le!==N)&&ky(s,b,d,N),Us=!1;var oe=s.memoizedState;b.state=oe,Co(s,d,b,y),jo(),le=s.memoizedState,L||oe!==le||Us?(typeof we=="function"&&(Dm(s,o,we,d),le=s.memoizedState),(Q=Us||by(s,o,Q,d,oe,le,N))?(he||typeof b.UNSAFE_componentWillMount!="function"&&typeof b.componentWillMount!="function"||(typeof b.componentWillMount=="function"&&b.componentWillMount(),typeof b.UNSAFE_componentWillMount=="function"&&b.UNSAFE_componentWillMount()),typeof b.componentDidMount=="function"&&(s.flags|=4194308)):(typeof b.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=d,s.memoizedState=le),b.props=d,b.state=le,b.context=N,d=Q):(typeof b.componentDidMount=="function"&&(s.flags|=4194308),d=!1)}else{b=s.stateNode,mm(n,s),N=s.memoizedProps,he=Di(o,N),b.props=he,we=s.pendingProps,oe=b.context,le=o.contextType,Q=pl,typeof le=="object"&&le!==null&&(Q=qn(le)),L=o.getDerivedStateFromProps,(le=typeof L=="function"||typeof b.getSnapshotBeforeUpdate=="function")||typeof b.UNSAFE_componentWillReceiveProps!="function"&&typeof b.componentWillReceiveProps!="function"||(N!==we||oe!==Q)&&ky(s,b,d,Q),Us=!1,oe=s.memoizedState,b.state=oe,Co(s,d,b,y),jo();var fe=s.memoizedState;N!==we||oe!==fe||Us||n!==null&&n.dependencies!==null&&fu(n.dependencies)?(typeof L=="function"&&(Dm(s,o,L,d),fe=s.memoizedState),(he=Us||by(s,o,he,d,oe,fe,Q)||n!==null&&n.dependencies!==null&&fu(n.dependencies))?(le||typeof b.UNSAFE_componentWillUpdate!="function"&&typeof b.componentWillUpdate!="function"||(typeof b.componentWillUpdate=="function"&&b.componentWillUpdate(d,fe,Q),typeof b.UNSAFE_componentWillUpdate=="function"&&b.UNSAFE_componentWillUpdate(d,fe,Q)),typeof b.componentDidUpdate=="function"&&(s.flags|=4),typeof b.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof b.componentDidUpdate!="function"||N===n.memoizedProps&&oe===n.memoizedState||(s.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&oe===n.memoizedState||(s.flags|=1024),s.memoizedProps=d,s.memoizedState=fe),b.props=d,b.state=fe,b.context=Q,d=he):(typeof b.componentDidUpdate!="function"||N===n.memoizedProps&&oe===n.memoizedState||(s.flags|=4),typeof b.getSnapshotBeforeUpdate!="function"||N===n.memoizedProps&&oe===n.memoizedState||(s.flags|=1024),d=!1)}return b=d,_u(n,s),d=(s.flags&128)!==0,b||d?(b=s.stateNode,o=d&&typeof o.getDerivedStateFromError!="function"?null:b.render(),s.flags|=1,n!==null&&d?(s.child=Li(s,n.child,null,y),s.child=Li(s,null,o,y)):Gn(n,s,o,y),s.memoizedState=b.state,n=s.child):n=ds(n,s,y),n}function Dy(n,s,o,d){return Mi(),s.flags|=256,Gn(n,s,o,d),s.child}var Bm={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Hm(n){return{baseLanes:n,cachePool:Cx()}}function Fm(n,s,o){return n=n!==null?n.childLanes&~o:0,s&&(n|=Ga),n}function Uy(n,s,o){var d=s.pendingProps,y=!1,b=(s.flags&128)!==0,N;if((N=b)||(N=n!==null&&n.memoizedState===null?!1:(Nn.current&2)!==0),N&&(y=!0,s.flags&=-129),N=(s.flags&32)!==0,s.flags&=-33,n===null){if(Tt){if(y?Ps(s):Bs(),(n=rn)?(n=qv(n,mr),n=n!==null&&n.data!=="&"?n:null,n!==null&&(s.memoizedState={dehydrated:n,treeContext:Is!==null?{id:Hr,overflow:Fr}:null,retryLane:536870912,hydrationErrors:null},o=gx(n),o.return=s,s.child=o,Vn=s,rn=null)):n=null,n===null)throw Os(s);return Cp(n)?s.lanes=32:s.lanes=536870912,null}var L=d.children;return d=d.fallback,y?(Bs(),y=s.mode,L=Ru({mode:"hidden",children:L},y),d=Ti(d,y,o,null),L.return=s,d.return=s,L.sibling=d,s.child=L,d=s.child,d.memoizedState=Hm(o),d.childLanes=Fm(n,N,o),s.memoizedState=Bm,Eo(null,d)):(Ps(s),Vm(s,L))}var Q=n.memoizedState;if(Q!==null&&(L=Q.dehydrated,L!==null)){if(b)s.flags&256?(Ps(s),s.flags&=-257,s=qm(n,s,o)):s.memoizedState!==null?(Bs(),s.child=n.child,s.flags|=128,s=null):(Bs(),L=d.fallback,y=s.mode,d=Ru({mode:"visible",children:d.children},y),L=Ti(L,y,o,null),L.flags|=2,d.return=s,L.return=s,d.sibling=L,s.child=d,Li(s,n.child,null,o),d=s.child,d.memoizedState=Hm(o),d.childLanes=Fm(n,N,o),s.memoizedState=Bm,s=Eo(null,d));else if(Ps(s),Cp(L)){if(N=L.nextSibling&&L.nextSibling.dataset,N)var le=N.dgst;N=le,d=Error(i(419)),d.stack="",d.digest=N,yo({value:d,source:null,stack:null}),s=qm(n,s,o)}else if(Rn||yl(n,s,o,!1),N=(o&n.childLanes)!==0,Rn||N){if(N=Jt,N!==null&&(d=xa(N,o),d!==0&&d!==Q.retryLane))throw Q.retryLane=d,Ni(n,d),_a(N,n,d),$m;jp(L)||Bu(),s=qm(n,s,o)}else jp(L)?(s.flags|=192,s.child=n.child,s=null):(n=Q.treeContext,rn=hr(L.nextSibling),Vn=s,Tt=!0,Ls=null,mr=!1,n!==null&&vx(s,n),s=Vm(s,d.children),s.flags|=4096);return s}return y?(Bs(),L=d.fallback,y=s.mode,Q=n.child,le=Q.sibling,d=ss(Q,{mode:"hidden",children:d.children}),d.subtreeFlags=Q.subtreeFlags&65011712,le!==null?L=ss(le,L):(L=Ti(L,y,o,null),L.flags|=2),L.return=s,d.return=s,d.sibling=L,s.child=d,Eo(null,d),d=s.child,L=n.child.memoizedState,L===null?L=Hm(o):(y=L.cachePool,y!==null?(Q=En._currentValue,y=y.parent!==Q?{parent:Q,pool:Q}:y):y=Cx(),L={baseLanes:L.baseLanes|o,cachePool:y}),d.memoizedState=L,d.childLanes=Fm(n,N,o),s.memoizedState=Bm,Eo(n.child,d)):(Ps(s),o=n.child,n=o.sibling,o=ss(o,{mode:"visible",children:d.children}),o.return=s,o.sibling=null,n!==null&&(N=s.deletions,N===null?(s.deletions=[n],s.flags|=16):N.push(n)),s.child=o,s.memoizedState=null,o)}function Vm(n,s){return s=Ru({mode:"visible",children:s},n.mode),s.return=n,n.child=s}function Ru(n,s){return n=Ha(22,n,null,s),n.lanes=0,n}function qm(n,s,o){return Li(s,n.child,null,o),n=Vm(s,s.pendingProps.children),n.flags|=2,s.memoizedState=null,n}function zy(n,s,o){n.lanes|=s;var d=n.alternate;d!==null&&(d.lanes|=s),im(n.return,s,o)}function Gm(n,s,o,d,y,b){var N=n.memoizedState;N===null?n.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:d,tail:o,tailMode:y,treeForkCount:b}:(N.isBackwards=s,N.rendering=null,N.renderingStartTime=0,N.last=d,N.tail=o,N.tailMode=y,N.treeForkCount=b)}function $y(n,s,o){var d=s.pendingProps,y=d.revealOrder,b=d.tail;d=d.children;var N=Nn.current,L=(N&2)!==0;if(L?(N=N&1|2,s.flags|=128):N&=1,j(Nn,N),Gn(n,s,d,o),d=Tt?xo:0,!L&&n!==null&&(n.flags&128)!==0)e:for(n=s.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&zy(n,o,s);else if(n.tag===19)zy(n,o,s);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===s)break e;for(;n.sibling===null;){if(n.return===null||n.return===s)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(y){case"forwards":for(o=s.child,y=null;o!==null;)n=o.alternate,n!==null&&bu(n)===null&&(y=o),o=o.sibling;o=y,o===null?(y=s.child,s.child=null):(y=o.sibling,o.sibling=null),Gm(s,!1,y,o,b,d);break;case"backwards":case"unstable_legacy-backwards":for(o=null,y=s.child,s.child=null;y!==null;){if(n=y.alternate,n!==null&&bu(n)===null){s.child=y;break}n=y.sibling,y.sibling=o,o=y,y=n}Gm(s,!0,o,null,b,d);break;case"together":Gm(s,!1,null,null,void 0,d);break;default:s.memoizedState=null}return s.child}function ds(n,s,o){if(n!==null&&(s.dependencies=n.dependencies),Vs|=s.lanes,(o&s.childLanes)===0)if(n!==null){if(yl(n,s,o,!1),(o&s.childLanes)===0)return null}else return null;if(n!==null&&s.child!==n.child)throw Error(i(153));if(s.child!==null){for(n=s.child,o=ss(n,n.pendingProps),s.child=o,o.return=s;n.sibling!==null;)n=n.sibling,o=o.sibling=ss(n,n.pendingProps),o.return=s;o.sibling=null}return s.child}function Wm(n,s){return(n.lanes&s)!==0?!0:(n=n.dependencies,!!(n!==null&&fu(n)))}function AC(n,s,o){switch(s.tag){case 3:Se(s,s.stateNode.containerInfo),Ds(s,En,n.memoizedState.cache),Mi();break;case 27:case 5:ee(s);break;case 4:Se(s,s.stateNode.containerInfo);break;case 10:Ds(s,s.type,s.memoizedProps.value);break;case 31:if(s.memoizedState!==null)return s.flags|=128,ym(s),null;break;case 13:var d=s.memoizedState;if(d!==null)return d.dehydrated!==null?(Ps(s),s.flags|=128,null):(o&s.child.childLanes)!==0?Uy(n,s,o):(Ps(s),n=ds(n,s,o),n!==null?n.sibling:null);Ps(s);break;case 19:var y=(n.flags&128)!==0;if(d=(o&s.childLanes)!==0,d||(yl(n,s,o,!1),d=(o&s.childLanes)!==0),y){if(d)return $y(n,s,o);s.flags|=128}if(y=s.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),j(Nn,Nn.current),d)break;return null;case 22:return s.lanes=0,_y(n,s,o,s.pendingProps);case 24:Ds(s,En,n.memoizedState.cache)}return ds(n,s,o)}function Py(n,s,o){if(n!==null)if(n.memoizedProps!==s.pendingProps)Rn=!0;else{if(!Wm(n,o)&&(s.flags&128)===0)return Rn=!1,AC(n,s,o);Rn=(n.flags&131072)!==0}else Rn=!1,Tt&&(s.flags&1048576)!==0&&yx(s,xo,s.index);switch(s.lanes=0,s.tag){case 16:e:{var d=s.pendingProps;if(n=Ri(s.elementType),s.type=n,typeof n=="function")Zf(n)?(d=Di(n,d),s.tag=1,s=Oy(null,s,n,d,o)):(s.tag=0,s=Pm(null,s,n,d,o));else{if(n!=null){var y=n.$$typeof;if(y===K){s.tag=11,s=My(null,s,n,d,o);break e}else if(y===B){s.tag=14,s=Ay(null,s,n,d,o);break e}}throw s=H(n)||n,Error(i(306,s,""))}}return s;case 0:return Pm(n,s,s.type,s.pendingProps,o);case 1:return d=s.type,y=Di(d,s.pendingProps),Oy(n,s,d,y,o);case 3:e:{if(Se(s,s.stateNode.containerInfo),n===null)throw Error(i(387));d=s.pendingProps;var b=s.memoizedState;y=b.element,mm(n,s),Co(s,d,null,o);var N=s.memoizedState;if(d=N.cache,Ds(s,En,d),d!==b.cache&&lm(s,[En],o,!0),jo(),d=N.element,b.isDehydrated)if(b={element:d,isDehydrated:!1,cache:N.cache},s.updateQueue.baseState=b,s.memoizedState=b,s.flags&256){s=Dy(n,s,d,o);break e}else if(d!==y){y=ur(Error(i(424)),s),yo(y),s=Dy(n,s,d,o);break e}else for(n=s.stateNode.containerInfo,n.nodeType===9?n=n.body:n=n.nodeName==="HTML"?n.ownerDocument.body:n,rn=hr(n.firstChild),Vn=s,Tt=!0,Ls=null,mr=!0,o=_x(s,null,d,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Mi(),d===y){s=ds(n,s,o);break e}Gn(n,s,d,o)}s=s.child}return s;case 26:return _u(n,s),n===null?(o=Xv(s.type,null,s.pendingProps,null))?s.memoizedState=o:Tt||(o=s.type,n=s.pendingProps,d=Ku(de.current).createElement(o),d[$t]=s,d[gn]=n,Wn(d,o,n),Ft(d),s.stateNode=d):s.memoizedState=Xv(s.type,n.memoizedProps,s.pendingProps,n.memoizedState),null;case 27:return ee(s),n===null&&Tt&&(d=s.stateNode=Kv(s.type,s.pendingProps,de.current),Vn=s,mr=!0,y=rn,Ys(s.type)?(Np=y,rn=hr(d.firstChild)):rn=y),Gn(n,s,s.pendingProps.children,o),_u(n,s),n===null&&(s.flags|=4194304),s.child;case 5:return n===null&&Tt&&((y=d=rn)&&(d=sN(d,s.type,s.pendingProps,mr),d!==null?(s.stateNode=d,Vn=s,rn=hr(d.firstChild),mr=!1,y=!0):y=!1),y||Os(s)),ee(s),y=s.type,b=s.pendingProps,N=n!==null?n.memoizedProps:null,d=b.children,kp(y,b)?d=null:N!==null&&kp(y,N)&&(s.flags|=32),s.memoizedState!==null&&(y=bm(n,s,bC,null,null,o),qo._currentValue=y),_u(n,s),Gn(n,s,d,o),s.child;case 6:return n===null&&Tt&&((n=o=rn)&&(o=iN(o,s.pendingProps,mr),o!==null?(s.stateNode=o,Vn=s,rn=null,n=!0):n=!1),n||Os(s)),null;case 13:return Uy(n,s,o);case 4:return Se(s,s.stateNode.containerInfo),d=s.pendingProps,n===null?s.child=Li(s,null,d,o):Gn(n,s,d,o),s.child;case 11:return My(n,s,s.type,s.pendingProps,o);case 7:return Gn(n,s,s.pendingProps,o),s.child;case 8:return Gn(n,s,s.pendingProps.children,o),s.child;case 12:return Gn(n,s,s.pendingProps.children,o),s.child;case 10:return d=s.pendingProps,Ds(s,s.type,d.value),Gn(n,s,d.children,o),s.child;case 9:return y=s.type._context,d=s.pendingProps.children,Ei(s),y=qn(y),d=d(y),s.flags|=1,Gn(n,s,d,o),s.child;case 14:return Ay(n,s,s.type,s.pendingProps,o);case 15:return Ey(n,s,s.type,s.pendingProps,o);case 19:return $y(n,s,o);case 31:return MC(n,s,o);case 22:return _y(n,s,o,s.pendingProps);case 24:return Ei(s),d=qn(En),n===null?(y=um(),y===null&&(y=Jt,b=om(),y.pooledCache=b,b.refCount++,b!==null&&(y.pooledCacheLanes|=o),y=b),s.memoizedState={parent:d,cache:y},fm(s),Ds(s,En,y)):((n.lanes&o)!==0&&(mm(n,s),Co(s,null,null,o),jo()),y=n.memoizedState,b=s.memoizedState,y.parent!==d?(y={parent:d,cache:d},s.memoizedState=y,s.lanes===0&&(s.memoizedState=s.updateQueue.baseState=y),Ds(s,En,d)):(d=b.cache,Ds(s,En,d),d!==y.cache&&lm(s,[En],o,!0))),Gn(n,s,s.pendingProps.children,o),s.child;case 29:throw s.pendingProps}throw Error(i(156,s.tag))}function fs(n){n.flags|=4}function Km(n,s,o,d,y){if((s=(n.mode&32)!==0)&&(s=!1),s){if(n.flags|=16777216,(y&335544128)===y)if(n.stateNode.complete)n.flags|=8192;else if(mv())n.flags|=8192;else throw Ii=gu,dm}else n.flags&=-16777217}function By(n,s){if(s.type!=="stylesheet"||(s.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!nb(s))if(mv())n.flags|=8192;else throw Ii=gu,dm}function Iu(n,s){s!==null&&(n.flags|=4),n.flags&16384&&(s=n.tag!==22?Qn():536870912,n.lanes|=s,El|=s)}function _o(n,s){if(!Tt)switch(n.tailMode){case"hidden":s=n.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?n.tail=null:o.sibling=null;break;case"collapsed":o=n.tail;for(var d=null;o!==null;)o.alternate!==null&&(d=o),o=o.sibling;d===null?s||n.tail===null?n.tail=null:n.tail.sibling=null:d.sibling=null}}function sn(n){var s=n.alternate!==null&&n.alternate.child===n.child,o=0,d=0;if(s)for(var y=n.child;y!==null;)o|=y.lanes|y.childLanes,d|=y.subtreeFlags&65011712,d|=y.flags&65011712,y.return=n,y=y.sibling;else for(y=n.child;y!==null;)o|=y.lanes|y.childLanes,d|=y.subtreeFlags,d|=y.flags,y.return=n,y=y.sibling;return n.subtreeFlags|=d,n.childLanes=o,s}function EC(n,s,o){var d=s.pendingProps;switch(nm(s),s.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return sn(s),null;case 1:return sn(s),null;case 3:return o=s.stateNode,d=null,n!==null&&(d=n.memoizedState.cache),s.memoizedState.cache!==d&&(s.flags|=2048),os(En),ke(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(n===null||n.child===null)&&(xl(s)?fs(s):n===null||n.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,rm())),sn(s),null;case 26:var y=s.type,b=s.memoizedState;return n===null?(fs(s),b!==null?(sn(s),By(s,b)):(sn(s),Km(s,y,null,d,o))):b?b!==n.memoizedState?(fs(s),sn(s),By(s,b)):(sn(s),s.flags&=-16777217):(n=n.memoizedProps,n!==d&&fs(s),sn(s),Km(s,y,n,d,o)),null;case 27:if(je(s),o=de.current,y=s.type,n!==null&&s.stateNode!=null)n.memoizedProps!==d&&fs(s);else{if(!d){if(s.stateNode===null)throw Error(i(166));return sn(s),null}n=$.current,xl(s)?bx(s):(n=Kv(y,d,o),s.stateNode=n,fs(s))}return sn(s),null;case 5:if(je(s),y=s.type,n!==null&&s.stateNode!=null)n.memoizedProps!==d&&fs(s);else{if(!d){if(s.stateNode===null)throw Error(i(166));return sn(s),null}if(b=$.current,xl(s))bx(s);else{var N=Ku(de.current);switch(b){case 1:b=N.createElementNS("http://www.w3.org/2000/svg",y);break;case 2:b=N.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;default:switch(y){case"svg":b=N.createElementNS("http://www.w3.org/2000/svg",y);break;case"math":b=N.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;case"script":b=N.createElement("div"),b.innerHTML="<script><\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof d.is=="string"?N.createElement("select",{is:d.is}):N.createElement("select"),d.multiple?b.multiple=!0:d.size&&(b.size=d.size);break;default:b=typeof d.is=="string"?N.createElement(y,{is:d.is}):N.createElement(y)}}b[$t]=s,b[gn]=d;e:for(N=s.child;N!==null;){if(N.tag===5||N.tag===6)b.appendChild(N.stateNode);else if(N.tag!==4&&N.tag!==27&&N.child!==null){N.child.return=N,N=N.child;continue}if(N===s)break e;for(;N.sibling===null;){if(N.return===null||N.return===s)break e;N=N.return}N.sibling.return=N.return,N=N.sibling}s.stateNode=b;e:switch(Wn(b,y,d),y){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&fs(s)}}return sn(s),Km(s,s.type,n===null?null:n.memoizedProps,s.pendingProps,o),null;case 6:if(n&&s.stateNode!=null)n.memoizedProps!==d&&fs(s);else{if(typeof d!="string"&&s.stateNode===null)throw Error(i(166));if(n=de.current,xl(s)){if(n=s.stateNode,o=s.memoizedProps,d=null,y=Vn,y!==null)switch(y.tag){case 27:case 5:d=y.memoizedProps}n[$t]=s,n=!!(n.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||Uv(n.nodeValue,o)),n||Os(s,!0)}else n=Ku(n).createTextNode(d),n[$t]=s,s.stateNode=n}return sn(s),null;case 31:if(o=s.memoizedState,n===null||n.memoizedState!==null){if(d=xl(s),o!==null){if(n===null){if(!d)throw Error(i(318));if(n=s.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(557));n[$t]=s}else Mi(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;sn(s),n=!1}else o=rm(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=o),n=!0;if(!n)return s.flags&256?(Va(s),s):(Va(s),null);if((s.flags&128)!==0)throw Error(i(558))}return sn(s),null;case 13:if(d=s.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(y=xl(s),d!==null&&d.dehydrated!==null){if(n===null){if(!y)throw Error(i(318));if(y=s.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(i(317));y[$t]=s}else Mi(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;sn(s),y=!1}else y=rm(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=y),y=!0;if(!y)return s.flags&256?(Va(s),s):(Va(s),null)}return Va(s),(s.flags&128)!==0?(s.lanes=o,s):(o=d!==null,n=n!==null&&n.memoizedState!==null,o&&(d=s.child,y=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(y=d.alternate.memoizedState.cachePool.pool),b=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(b=d.memoizedState.cachePool.pool),b!==y&&(d.flags|=2048)),o!==n&&o&&(s.child.flags|=8192),Iu(s,s.updateQueue),sn(s),null);case 4:return ke(),n===null&&gp(s.stateNode.containerInfo),sn(s),null;case 10:return os(s.type),sn(s),null;case 19:if(q(Nn),d=s.memoizedState,d===null)return sn(s),null;if(y=(s.flags&128)!==0,b=d.rendering,b===null)if(y)_o(d,!1);else{if(Sn!==0||n!==null&&(n.flags&128)!==0)for(n=s.child;n!==null;){if(b=bu(n),b!==null){for(s.flags|=128,_o(d,!1),n=b.updateQueue,s.updateQueue=n,Iu(s,n),s.subtreeFlags=0,n=o,o=s.child;o!==null;)hx(o,n),o=o.sibling;return j(Nn,Nn.current&1|2),Tt&&is(s,d.treeForkCount),s.child}n=n.sibling}d.tail!==null&&Ce()>zu&&(s.flags|=128,y=!0,_o(d,!1),s.lanes=4194304)}else{if(!y)if(n=bu(b),n!==null){if(s.flags|=128,y=!0,n=n.updateQueue,s.updateQueue=n,Iu(s,n),_o(d,!0),d.tail===null&&d.tailMode==="hidden"&&!b.alternate&&!Tt)return sn(s),null}else 2*Ce()-d.renderingStartTime>zu&&o!==536870912&&(s.flags|=128,y=!0,_o(d,!1),s.lanes=4194304);d.isBackwards?(b.sibling=s.child,s.child=b):(n=d.last,n!==null?n.sibling=b:s.child=b,d.last=b)}return d.tail!==null?(n=d.tail,d.rendering=n,d.tail=n.sibling,d.renderingStartTime=Ce(),n.sibling=null,o=Nn.current,j(Nn,y?o&1|2:o&1),Tt&&is(s,d.treeForkCount),n):(sn(s),null);case 22:case 23:return Va(s),xm(),d=s.memoizedState!==null,n!==null?n.memoizedState!==null!==d&&(s.flags|=8192):d&&(s.flags|=8192),d?(o&536870912)!==0&&(s.flags&128)===0&&(sn(s),s.subtreeFlags&6&&(s.flags|=8192)):sn(s),o=s.updateQueue,o!==null&&Iu(s,o.retryQueue),o=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),d=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(d=s.memoizedState.cachePool.pool),d!==o&&(s.flags|=2048),n!==null&&q(_i),null;case 24:return o=null,n!==null&&(o=n.memoizedState.cache),s.memoizedState.cache!==o&&(s.flags|=2048),os(En),sn(s),null;case 25:return null;case 30:return null}throw Error(i(156,s.tag))}function _C(n,s){switch(nm(s),s.tag){case 1:return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 3:return os(En),ke(),n=s.flags,(n&65536)!==0&&(n&128)===0?(s.flags=n&-65537|128,s):null;case 26:case 27:case 5:return je(s),null;case 31:if(s.memoizedState!==null){if(Va(s),s.alternate===null)throw Error(i(340));Mi()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 13:if(Va(s),n=s.memoizedState,n!==null&&n.dehydrated!==null){if(s.alternate===null)throw Error(i(340));Mi()}return n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 19:return q(Nn),null;case 4:return ke(),null;case 10:return os(s.type),null;case 22:case 23:return Va(s),xm(),n!==null&&q(_i),n=s.flags,n&65536?(s.flags=n&-65537|128,s):null;case 24:return os(En),null;case 25:return null;default:return null}}function Hy(n,s){switch(nm(s),s.tag){case 3:os(En),ke();break;case 26:case 27:case 5:je(s);break;case 4:ke();break;case 31:s.memoizedState!==null&&Va(s);break;case 13:Va(s);break;case 19:q(Nn);break;case 10:os(s.type);break;case 22:case 23:Va(s),xm(),n!==null&&q(_i);break;case 24:os(En)}}function Ro(n,s){try{var o=s.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var y=d.next;o=y;do{if((o.tag&n)===n){d=void 0;var b=o.create,N=o.inst;d=b(),N.destroy=d}o=o.next}while(o!==y)}}catch(L){Gt(s,s.return,L)}}function Hs(n,s,o){try{var d=s.updateQueue,y=d!==null?d.lastEffect:null;if(y!==null){var b=y.next;d=b;do{if((d.tag&n)===n){var N=d.inst,L=N.destroy;if(L!==void 0){N.destroy=void 0,y=s;var Q=o,le=L;try{le()}catch(he){Gt(y,Q,he)}}}d=d.next}while(d!==b)}}catch(he){Gt(s,s.return,he)}}function Fy(n){var s=n.updateQueue;if(s!==null){var o=n.stateNode;try{Ix(s,o)}catch(d){Gt(n,n.return,d)}}}function Vy(n,s,o){o.props=Di(n.type,n.memoizedProps),o.state=n.memoizedState;try{o.componentWillUnmount()}catch(d){Gt(n,s,d)}}function Io(n,s){try{var o=n.ref;if(o!==null){switch(n.tag){case 26:case 27:case 5:var d=n.stateNode;break;case 30:d=n.stateNode;break;default:d=n.stateNode}typeof o=="function"?n.refCleanup=o(d):o.current=d}}catch(y){Gt(n,s,y)}}function Vr(n,s){var o=n.ref,d=n.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(y){Gt(n,s,y)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(y){Gt(n,s,y)}else o.current=null}function qy(n){var s=n.type,o=n.memoizedProps,d=n.stateNode;try{e:switch(s){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(y){Gt(n,n.return,y)}}function Ym(n,s,o){try{var d=n.stateNode;JC(d,n.type,o,s),d[gn]=s}catch(y){Gt(n,n.return,y)}}function Gy(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&Ys(n.type)||n.tag===4}function Qm(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Gy(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&Ys(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Xm(n,s,o){var d=n.tag;if(d===5||d===6)n=n.stateNode,s?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(n,s):(s=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,s.appendChild(n),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=Jn));else if(d!==4&&(d===27&&Ys(n.type)&&(o=n.stateNode,s=null),n=n.child,n!==null))for(Xm(n,s,o),n=n.sibling;n!==null;)Xm(n,s,o),n=n.sibling}function Lu(n,s,o){var d=n.tag;if(d===5||d===6)n=n.stateNode,s?o.insertBefore(n,s):o.appendChild(n);else if(d!==4&&(d===27&&Ys(n.type)&&(o=n.stateNode),n=n.child,n!==null))for(Lu(n,s,o),n=n.sibling;n!==null;)Lu(n,s,o),n=n.sibling}function Wy(n){var s=n.stateNode,o=n.memoizedProps;try{for(var d=n.type,y=s.attributes;y.length;)s.removeAttributeNode(y[0]);Wn(s,d,o),s[$t]=n,s[gn]=o}catch(b){Gt(n,n.return,b)}}var ms=!1,In=!1,Zm=!1,Ky=typeof WeakSet=="function"?WeakSet:Set,Pn=null;function RC(n,s){if(n=n.containerInfo,vp=td,n=ix(n),qf(n)){if("selectionStart"in n)var o={start:n.selectionStart,end:n.selectionEnd};else e:{o=(o=n.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var y=d.anchorOffset,b=d.focusNode;d=d.focusOffset;try{o.nodeType,b.nodeType}catch{o=null;break e}var N=0,L=-1,Q=-1,le=0,he=0,we=n,oe=null;t:for(;;){for(var fe;we!==o||y!==0&&we.nodeType!==3||(L=N+y),we!==b||d!==0&&we.nodeType!==3||(Q=N+d),we.nodeType===3&&(N+=we.nodeValue.length),(fe=we.firstChild)!==null;)oe=we,we=fe;for(;;){if(we===n)break t;if(oe===o&&++le===y&&(L=N),oe===b&&++he===d&&(Q=N),(fe=we.nextSibling)!==null)break;we=oe,oe=we.parentNode}we=fe}o=L===-1||Q===-1?null:{start:L,end:Q}}else o=null}o=o||{start:0,end:0}}else o=null;for(bp={focusedElem:n,selectionRange:o},td=!1,Pn=s;Pn!==null;)if(s=Pn,n=s.child,(s.subtreeFlags&1028)!==0&&n!==null)n.return=s,Pn=n;else for(;Pn!==null;){switch(s=Pn,b=s.alternate,n=s.flags,s.tag){case 0:if((n&4)!==0&&(n=s.updateQueue,n=n!==null?n.events:null,n!==null))for(o=0;o<n.length;o++)y=n[o],y.ref.impl=y.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&b!==null){n=void 0,o=s,y=b.memoizedProps,b=b.memoizedState,d=o.stateNode;try{var He=Di(o.type,y);n=d.getSnapshotBeforeUpdate(He,b),d.__reactInternalSnapshotBeforeUpdate=n}catch(tt){Gt(o,o.return,tt)}}break;case 3:if((n&1024)!==0){if(n=s.stateNode.containerInfo,o=n.nodeType,o===9)Sp(n);else if(o===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Sp(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(i(163))}if(n=s.sibling,n!==null){n.return=s.return,Pn=n;break}Pn=s.return}}function Yy(n,s,o){var d=o.flags;switch(o.tag){case 0:case 11:case 15:hs(n,o),d&4&&Ro(5,o);break;case 1:if(hs(n,o),d&4)if(n=o.stateNode,s===null)try{n.componentDidMount()}catch(N){Gt(o,o.return,N)}else{var y=Di(o.type,s.memoizedProps);s=s.memoizedState;try{n.componentDidUpdate(y,s,n.__reactInternalSnapshotBeforeUpdate)}catch(N){Gt(o,o.return,N)}}d&64&&Fy(o),d&512&&Io(o,o.return);break;case 3:if(hs(n,o),d&64&&(n=o.updateQueue,n!==null)){if(s=null,o.child!==null)switch(o.child.tag){case 27:case 5:s=o.child.stateNode;break;case 1:s=o.child.stateNode}try{Ix(n,s)}catch(N){Gt(o,o.return,N)}}break;case 27:s===null&&d&4&&Wy(o);case 26:case 5:hs(n,o),s===null&&d&4&&qy(o),d&512&&Io(o,o.return);break;case 12:hs(n,o);break;case 31:hs(n,o),d&4&&Zy(n,o);break;case 13:hs(n,o),d&4&&Jy(n,o),d&64&&(n=o.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(o=BC.bind(null,o),lN(n,o))));break;case 22:if(d=o.memoizedState!==null||ms,!d){s=s!==null&&s.memoizedState!==null||In,y=ms;var b=In;ms=d,(In=s)&&!b?gs(n,o,(o.subtreeFlags&8772)!==0):hs(n,o),ms=y,In=b}break;case 30:break;default:hs(n,o)}}function Qy(n){var s=n.alternate;s!==null&&(n.alternate=null,Qy(s)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(s=n.stateNode,s!==null&&$r(s)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var fn=null,Ta=!1;function ps(n,s,o){for(o=o.child;o!==null;)Xy(n,s,o),o=o.sibling}function Xy(n,s,o){if(Re&&typeof Re.onCommitFiberUnmount=="function")try{Re.onCommitFiberUnmount(Ne,o)}catch{}switch(o.tag){case 26:In||Vr(o,s),ps(n,s,o),o.memoizedState?o.memoizedState.count--:o.stateNode&&(o=o.stateNode,o.parentNode.removeChild(o));break;case 27:In||Vr(o,s);var d=fn,y=Ta;Ys(o.type)&&(fn=o.stateNode,Ta=!1),ps(n,s,o),Ho(o.stateNode),fn=d,Ta=y;break;case 5:In||Vr(o,s);case 6:if(d=fn,y=Ta,fn=null,ps(n,s,o),fn=d,Ta=y,fn!==null)if(Ta)try{(fn.nodeType===9?fn.body:fn.nodeName==="HTML"?fn.ownerDocument.body:fn).removeChild(o.stateNode)}catch(b){Gt(o,s,b)}else try{fn.removeChild(o.stateNode)}catch(b){Gt(o,s,b)}break;case 18:fn!==null&&(Ta?(n=fn,Fv(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,o.stateNode),zl(n)):Fv(fn,o.stateNode));break;case 4:d=fn,y=Ta,fn=o.stateNode.containerInfo,Ta=!0,ps(n,s,o),fn=d,Ta=y;break;case 0:case 11:case 14:case 15:Hs(2,o,s),In||Hs(4,o,s),ps(n,s,o);break;case 1:In||(Vr(o,s),d=o.stateNode,typeof d.componentWillUnmount=="function"&&Vy(o,s,d)),ps(n,s,o);break;case 21:ps(n,s,o);break;case 22:In=(d=In)||o.memoizedState!==null,ps(n,s,o),In=d;break;default:ps(n,s,o)}}function Zy(n,s){if(s.memoizedState===null&&(n=s.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{zl(n)}catch(o){Gt(s,s.return,o)}}}function Jy(n,s){if(s.memoizedState===null&&(n=s.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{zl(n)}catch(o){Gt(s,s.return,o)}}function IC(n){switch(n.tag){case 31:case 13:case 19:var s=n.stateNode;return s===null&&(s=n.stateNode=new Ky),s;case 22:return n=n.stateNode,s=n._retryCache,s===null&&(s=n._retryCache=new Ky),s;default:throw Error(i(435,n.tag))}}function Ou(n,s){var o=IC(n);s.forEach(function(d){if(!o.has(d)){o.add(d);var y=HC.bind(null,n,d);d.then(y,y)}})}function Ma(n,s){var o=s.deletions;if(o!==null)for(var d=0;d<o.length;d++){var y=o[d],b=n,N=s,L=N;e:for(;L!==null;){switch(L.tag){case 27:if(Ys(L.type)){fn=L.stateNode,Ta=!1;break e}break;case 5:fn=L.stateNode,Ta=!1;break e;case 3:case 4:fn=L.stateNode.containerInfo,Ta=!0;break e}L=L.return}if(fn===null)throw Error(i(160));Xy(b,N,y),fn=null,Ta=!1,b=y.alternate,b!==null&&(b.return=null),y.return=null}if(s.subtreeFlags&13886)for(s=s.child;s!==null;)ev(s,n),s=s.sibling}var Ar=null;function ev(n,s){var o=n.alternate,d=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:Ma(s,n),Aa(n),d&4&&(Hs(3,n,n.return),Ro(3,n),Hs(5,n,n.return));break;case 1:Ma(s,n),Aa(n),d&512&&(In||o===null||Vr(o,o.return)),d&64&&ms&&(n=n.updateQueue,n!==null&&(d=n.callbacks,d!==null&&(o=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=o===null?d:o.concat(d))));break;case 26:var y=Ar;if(Ma(s,n),Aa(n),d&512&&(In||o===null||Vr(o,o.return)),d&4){var b=o!==null?o.memoizedState:null;if(d=n.memoizedState,o===null)if(d===null)if(n.stateNode===null){e:{d=n.type,o=n.memoizedProps,y=y.ownerDocument||y;t:switch(d){case"title":b=y.getElementsByTagName("title")[0],(!b||b[wa]||b[$t]||b.namespaceURI==="http://www.w3.org/2000/svg"||b.hasAttribute("itemprop"))&&(b=y.createElement(d),y.head.insertBefore(b,y.querySelector("head > title"))),Wn(b,d,o),b[$t]=n,Ft(b),d=b;break e;case"link":var N=eb("link","href",y).get(d+(o.href||""));if(N){for(var L=0;L<N.length;L++)if(b=N[L],b.getAttribute("href")===(o.href==null||o.href===""?null:o.href)&&b.getAttribute("rel")===(o.rel==null?null:o.rel)&&b.getAttribute("title")===(o.title==null?null:o.title)&&b.getAttribute("crossorigin")===(o.crossOrigin==null?null:o.crossOrigin)){N.splice(L,1);break t}}b=y.createElement(d),Wn(b,d,o),y.head.appendChild(b);break;case"meta":if(N=eb("meta","content",y).get(d+(o.content||""))){for(L=0;L<N.length;L++)if(b=N[L],b.getAttribute("content")===(o.content==null?null:""+o.content)&&b.getAttribute("name")===(o.name==null?null:o.name)&&b.getAttribute("property")===(o.property==null?null:o.property)&&b.getAttribute("http-equiv")===(o.httpEquiv==null?null:o.httpEquiv)&&b.getAttribute("charset")===(o.charSet==null?null:o.charSet)){N.splice(L,1);break t}}b=y.createElement(d),Wn(b,d,o),y.head.appendChild(b);break;default:throw Error(i(468,d))}b[$t]=n,Ft(b),d=b}n.stateNode=d}else tb(y,n.type,n.stateNode);else n.stateNode=Jv(y,d,n.memoizedProps);else b!==d?(b===null?o.stateNode!==null&&(o=o.stateNode,o.parentNode.removeChild(o)):b.count--,d===null?tb(y,n.type,n.stateNode):Jv(y,d,n.memoizedProps)):d===null&&n.stateNode!==null&&Ym(n,n.memoizedProps,o.memoizedProps)}break;case 27:Ma(s,n),Aa(n),d&512&&(In||o===null||Vr(o,o.return)),o!==null&&d&4&&Ym(n,n.memoizedProps,o.memoizedProps);break;case 5:if(Ma(s,n),Aa(n),d&512&&(In||o===null||Vr(o,o.return)),n.flags&32){y=n.stateNode;try{rr(y,"")}catch(He){Gt(n,n.return,He)}}d&4&&n.stateNode!=null&&(y=n.memoizedProps,Ym(n,y,o!==null?o.memoizedProps:y)),d&1024&&(Zm=!0);break;case 6:if(Ma(s,n),Aa(n),d&4){if(n.stateNode===null)throw Error(i(162));d=n.memoizedProps,o=n.stateNode;try{o.nodeValue=d}catch(He){Gt(n,n.return,He)}}break;case 3:if(Xu=null,y=Ar,Ar=Yu(s.containerInfo),Ma(s,n),Ar=y,Aa(n),d&4&&o!==null&&o.memoizedState.isDehydrated)try{zl(s.containerInfo)}catch(He){Gt(n,n.return,He)}Zm&&(Zm=!1,tv(n));break;case 4:d=Ar,Ar=Yu(n.stateNode.containerInfo),Ma(s,n),Aa(n),Ar=d;break;case 12:Ma(s,n),Aa(n);break;case 31:Ma(s,n),Aa(n),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,Ou(n,d)));break;case 13:Ma(s,n),Aa(n),n.child.flags&8192&&n.memoizedState!==null!=(o!==null&&o.memoizedState!==null)&&(Uu=Ce()),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,Ou(n,d)));break;case 22:y=n.memoizedState!==null;var Q=o!==null&&o.memoizedState!==null,le=ms,he=In;if(ms=le||y,In=he||Q,Ma(s,n),In=he,ms=le,Aa(n),d&8192)e:for(s=n.stateNode,s._visibility=y?s._visibility&-2:s._visibility|1,y&&(o===null||Q||ms||In||Ui(n)),o=null,s=n;;){if(s.tag===5||s.tag===26){if(o===null){Q=o=s;try{if(b=Q.stateNode,y)N=b.style,typeof N.setProperty=="function"?N.setProperty("display","none","important"):N.display="none";else{L=Q.stateNode;var we=Q.memoizedProps.style,oe=we!=null&&we.hasOwnProperty("display")?we.display:null;L.style.display=oe==null||typeof oe=="boolean"?"":(""+oe).trim()}}catch(He){Gt(Q,Q.return,He)}}}else if(s.tag===6){if(o===null){Q=s;try{Q.stateNode.nodeValue=y?"":Q.memoizedProps}catch(He){Gt(Q,Q.return,He)}}}else if(s.tag===18){if(o===null){Q=s;try{var fe=Q.stateNode;y?Vv(fe,!0):Vv(Q.stateNode,!1)}catch(He){Gt(Q,Q.return,He)}}}else if((s.tag!==22&&s.tag!==23||s.memoizedState===null||s===n)&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===n)break e;for(;s.sibling===null;){if(s.return===null||s.return===n)break e;o===s&&(o=null),s=s.return}o===s&&(o=null),s.sibling.return=s.return,s=s.sibling}d&4&&(d=n.updateQueue,d!==null&&(o=d.retryQueue,o!==null&&(d.retryQueue=null,Ou(n,o))));break;case 19:Ma(s,n),Aa(n),d&4&&(d=n.updateQueue,d!==null&&(n.updateQueue=null,Ou(n,d)));break;case 30:break;case 21:break;default:Ma(s,n),Aa(n)}}function Aa(n){var s=n.flags;if(s&2){try{for(var o,d=n.return;d!==null;){if(Gy(d)){o=d;break}d=d.return}if(o==null)throw Error(i(160));switch(o.tag){case 27:var y=o.stateNode,b=Qm(n);Lu(n,b,y);break;case 5:var N=o.stateNode;o.flags&32&&(rr(N,""),o.flags&=-33);var L=Qm(n);Lu(n,L,N);break;case 3:case 4:var Q=o.stateNode.containerInfo,le=Qm(n);Xm(n,le,Q);break;default:throw Error(i(161))}}catch(he){Gt(n,n.return,he)}n.flags&=-3}s&4096&&(n.flags&=-4097)}function tv(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var s=n;tv(s),s.tag===5&&s.flags&1024&&s.stateNode.reset(),n=n.sibling}}function hs(n,s){if(s.subtreeFlags&8772)for(s=s.child;s!==null;)Yy(n,s.alternate,s),s=s.sibling}function Ui(n){for(n=n.child;n!==null;){var s=n;switch(s.tag){case 0:case 11:case 14:case 15:Hs(4,s,s.return),Ui(s);break;case 1:Vr(s,s.return);var o=s.stateNode;typeof o.componentWillUnmount=="function"&&Vy(s,s.return,o),Ui(s);break;case 27:Ho(s.stateNode);case 26:case 5:Vr(s,s.return),Ui(s);break;case 22:s.memoizedState===null&&Ui(s);break;case 30:Ui(s);break;default:Ui(s)}n=n.sibling}}function gs(n,s,o){for(o=o&&(s.subtreeFlags&8772)!==0,s=s.child;s!==null;){var d=s.alternate,y=n,b=s,N=b.flags;switch(b.tag){case 0:case 11:case 15:gs(y,b,o),Ro(4,b);break;case 1:if(gs(y,b,o),d=b,y=d.stateNode,typeof y.componentDidMount=="function")try{y.componentDidMount()}catch(le){Gt(d,d.return,le)}if(d=b,y=d.updateQueue,y!==null){var L=d.stateNode;try{var Q=y.shared.hiddenCallbacks;if(Q!==null)for(y.shared.hiddenCallbacks=null,y=0;y<Q.length;y++)Rx(Q[y],L)}catch(le){Gt(d,d.return,le)}}o&&N&64&&Fy(b),Io(b,b.return);break;case 27:Wy(b);case 26:case 5:gs(y,b,o),o&&d===null&&N&4&&qy(b),Io(b,b.return);break;case 12:gs(y,b,o);break;case 31:gs(y,b,o),o&&N&4&&Zy(y,b);break;case 13:gs(y,b,o),o&&N&4&&Jy(y,b);break;case 22:b.memoizedState===null&&gs(y,b,o),Io(b,b.return);break;case 30:break;default:gs(y,b,o)}s=s.sibling}}function Jm(n,s){var o=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),n=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(n=s.memoizedState.cachePool.pool),n!==o&&(n!=null&&n.refCount++,o!=null&&vo(o))}function ep(n,s){n=null,s.alternate!==null&&(n=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==n&&(s.refCount++,n!=null&&vo(n))}function Er(n,s,o,d){if(s.subtreeFlags&10256)for(s=s.child;s!==null;)nv(n,s,o,d),s=s.sibling}function nv(n,s,o,d){var y=s.flags;switch(s.tag){case 0:case 11:case 15:Er(n,s,o,d),y&2048&&Ro(9,s);break;case 1:Er(n,s,o,d);break;case 3:Er(n,s,o,d),y&2048&&(n=null,s.alternate!==null&&(n=s.alternate.memoizedState.cache),s=s.memoizedState.cache,s!==n&&(s.refCount++,n!=null&&vo(n)));break;case 12:if(y&2048){Er(n,s,o,d),n=s.stateNode;try{var b=s.memoizedProps,N=b.id,L=b.onPostCommit;typeof L=="function"&&L(N,s.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(Q){Gt(s,s.return,Q)}}else Er(n,s,o,d);break;case 31:Er(n,s,o,d);break;case 13:Er(n,s,o,d);break;case 23:break;case 22:b=s.stateNode,N=s.alternate,s.memoizedState!==null?b._visibility&2?Er(n,s,o,d):Lo(n,s):b._visibility&2?Er(n,s,o,d):(b._visibility|=2,Tl(n,s,o,d,(s.subtreeFlags&10256)!==0||!1)),y&2048&&Jm(N,s);break;case 24:Er(n,s,o,d),y&2048&&ep(s.alternate,s);break;default:Er(n,s,o,d)}}function Tl(n,s,o,d,y){for(y=y&&((s.subtreeFlags&10256)!==0||!1),s=s.child;s!==null;){var b=n,N=s,L=o,Q=d,le=N.flags;switch(N.tag){case 0:case 11:case 15:Tl(b,N,L,Q,y),Ro(8,N);break;case 23:break;case 22:var he=N.stateNode;N.memoizedState!==null?he._visibility&2?Tl(b,N,L,Q,y):Lo(b,N):(he._visibility|=2,Tl(b,N,L,Q,y)),y&&le&2048&&Jm(N.alternate,N);break;case 24:Tl(b,N,L,Q,y),y&&le&2048&&ep(N.alternate,N);break;default:Tl(b,N,L,Q,y)}s=s.sibling}}function Lo(n,s){if(s.subtreeFlags&10256)for(s=s.child;s!==null;){var o=n,d=s,y=d.flags;switch(d.tag){case 22:Lo(o,d),y&2048&&Jm(d.alternate,d);break;case 24:Lo(o,d),y&2048&&ep(d.alternate,d);break;default:Lo(o,d)}s=s.sibling}}var Oo=8192;function Ml(n,s,o){if(n.subtreeFlags&Oo)for(n=n.child;n!==null;)av(n,s,o),n=n.sibling}function av(n,s,o){switch(n.tag){case 26:Ml(n,s,o),n.flags&Oo&&n.memoizedState!==null&&vN(o,Ar,n.memoizedState,n.memoizedProps);break;case 5:Ml(n,s,o);break;case 3:case 4:var d=Ar;Ar=Yu(n.stateNode.containerInfo),Ml(n,s,o),Ar=d;break;case 22:n.memoizedState===null&&(d=n.alternate,d!==null&&d.memoizedState!==null?(d=Oo,Oo=16777216,Ml(n,s,o),Oo=d):Ml(n,s,o));break;default:Ml(n,s,o)}}function rv(n){var s=n.alternate;if(s!==null&&(n=s.child,n!==null)){s.child=null;do s=n.sibling,n.sibling=null,n=s;while(n!==null)}}function Do(n){var s=n.deletions;if((n.flags&16)!==0){if(s!==null)for(var o=0;o<s.length;o++){var d=s[o];Pn=d,iv(d,n)}rv(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)sv(n),n=n.sibling}function sv(n){switch(n.tag){case 0:case 11:case 15:Do(n),n.flags&2048&&Hs(9,n,n.return);break;case 3:Do(n);break;case 12:Do(n);break;case 22:var s=n.stateNode;n.memoizedState!==null&&s._visibility&2&&(n.return===null||n.return.tag!==13)?(s._visibility&=-3,Du(n)):Do(n);break;default:Do(n)}}function Du(n){var s=n.deletions;if((n.flags&16)!==0){if(s!==null)for(var o=0;o<s.length;o++){var d=s[o];Pn=d,iv(d,n)}rv(n)}for(n=n.child;n!==null;){switch(s=n,s.tag){case 0:case 11:case 15:Hs(8,s,s.return),Du(s);break;case 22:o=s.stateNode,o._visibility&2&&(o._visibility&=-3,Du(s));break;default:Du(s)}n=n.sibling}}function iv(n,s){for(;Pn!==null;){var o=Pn;switch(o.tag){case 0:case 11:case 15:Hs(8,o,s);break;case 23:case 22:if(o.memoizedState!==null&&o.memoizedState.cachePool!==null){var d=o.memoizedState.cachePool.pool;d!=null&&d.refCount++}break;case 24:vo(o.memoizedState.cache)}if(d=o.child,d!==null)d.return=o,Pn=d;else e:for(o=n;Pn!==null;){d=Pn;var y=d.sibling,b=d.return;if(Qy(d),d===o){Pn=null;break e}if(y!==null){y.return=b,Pn=y;break e}Pn=b}}}var LC={getCacheForType:function(n){var s=qn(En),o=s.data.get(n);return o===void 0&&(o=n(),s.data.set(n,o)),o},cacheSignal:function(){return qn(En).controller.signal}},OC=typeof WeakMap=="function"?WeakMap:Map,Pt=0,Jt=null,wt=null,Ct=0,qt=0,qa=null,Fs=!1,Al=!1,tp=!1,xs=0,Sn=0,Vs=0,zi=0,np=0,Ga=0,El=0,Uo=null,Ea=null,ap=!1,Uu=0,lv=0,zu=1/0,$u=null,qs=null,Dn=0,Gs=null,_l=null,ys=0,rp=0,sp=null,ov=null,zo=0,ip=null;function Wa(){return(Pt&2)!==0&&Ct!==0?Ct&-Ct:z.T!==null?fp():va()}function cv(){if(Ga===0)if((Ct&536870912)===0||Tt){var n=yt;yt<<=1,(yt&3932160)===0&&(yt=262144),Ga=n}else Ga=536870912;return n=Fa.current,n!==null&&(n.flags|=32),Ga}function _a(n,s,o){(n===Jt&&(qt===2||qt===9)||n.cancelPendingCommit!==null)&&(Rl(n,0),Ws(n,Ct,Ga,!1)),Bn(n,o),((Pt&2)===0||n!==Jt)&&(n===Jt&&((Pt&2)===0&&(zi|=o),Sn===4&&Ws(n,Ct,Ga,!1)),qr(n))}function uv(n,s,o){if((Pt&6)!==0)throw Error(i(327));var d=!o&&(s&127)===0&&(s&n.expiredLanes)===0||bt(n,s),y=d?zC(n,s):op(n,s,!0),b=d;do{if(y===0){Al&&!d&&Ws(n,s,0,!1);break}else{if(o=n.current.alternate,b&&!DC(o)){y=op(n,s,!1),b=!1;continue}if(y===2){if(b=s,n.errorRecoveryDisabledLanes&b)var N=0;else N=n.pendingLanes&-536870913,N=N!==0?N:N&536870912?536870912:0;if(N!==0){s=N;e:{var L=n;y=Uo;var Q=L.current.memoizedState.isDehydrated;if(Q&&(Rl(L,N).flags|=256),N=op(L,N,!1),N!==2){if(tp&&!Q){L.errorRecoveryDisabledLanes|=b,zi|=b,y=4;break e}b=Ea,Ea=y,b!==null&&(Ea===null?Ea=b:Ea.push.apply(Ea,b))}y=N}if(b=!1,y!==2)continue}}if(y===1){Rl(n,0),Ws(n,s,0,!0);break}e:{switch(d=n,b=y,b){case 0:case 1:throw Error(i(345));case 4:if((s&4194048)!==s)break;case 6:Ws(d,s,Ga,!Fs);break e;case 2:Ea=null;break;case 3:case 5:break;default:throw Error(i(329))}if((s&62914560)===s&&(y=Uu+300-Ce(),10<y)){if(Ws(d,s,Ga,!Fs),hn(d,0,!0)!==0)break e;ys=s,d.timeoutHandle=Bv(dv.bind(null,d,o,Ea,$u,ap,s,Ga,zi,El,Fs,b,"Throttled",-0,0),y);break e}dv(d,o,Ea,$u,ap,s,Ga,zi,El,Fs,b,null,-0,0)}}break}while(!0);qr(n)}function dv(n,s,o,d,y,b,N,L,Q,le,he,we,oe,fe){if(n.timeoutHandle=-1,we=s.subtreeFlags,we&8192||(we&16785408)===16785408){we={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Jn},av(s,b,we);var He=(b&62914560)===b?Uu-Ce():(b&4194048)===b?lv-Ce():0;if(He=bN(we,He),He!==null){ys=b,n.cancelPendingCommit=He(vv.bind(null,n,s,b,o,d,y,N,L,Q,he,we,null,oe,fe)),Ws(n,b,N,!le);return}}vv(n,s,b,o,d,y,N,L,Q)}function DC(n){for(var s=n;;){var o=s.tag;if((o===0||o===11||o===15)&&s.flags&16384&&(o=s.updateQueue,o!==null&&(o=o.stores,o!==null)))for(var d=0;d<o.length;d++){var y=o[d],b=y.getSnapshot;y=y.value;try{if(!Ba(b(),y))return!1}catch{return!1}}if(o=s.child,s.subtreeFlags&16384&&o!==null)o.return=s,s=o;else{if(s===n)break;for(;s.sibling===null;){if(s.return===null||s.return===n)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Ws(n,s,o,d){s&=~np,s&=~zi,n.suspendedLanes|=s,n.pingedLanes&=~s,d&&(n.warmLanes|=s),d=n.expirationTimes;for(var y=s;0<y;){var b=31-Fe(y),N=1<<b;d[b]=-1,y&=~N}o!==0&&ga(n,o,s)}function Pu(){return(Pt&6)===0?($o(0),!1):!0}function lp(){if(wt!==null){if(qt===0)var n=wt.return;else n=wt,ls=Ai=null,Sm(n),wl=null,ko=0,n=wt;for(;n!==null;)Hy(n.alternate,n),n=n.return;wt=null}}function Rl(n,s){var o=n.timeoutHandle;o!==-1&&(n.timeoutHandle=-1,nN(o)),o=n.cancelPendingCommit,o!==null&&(n.cancelPendingCommit=null,o()),ys=0,lp(),Jt=n,wt=o=ss(n.current,null),Ct=s,qt=0,qa=null,Fs=!1,Al=bt(n,s),tp=!1,El=Ga=np=zi=Vs=Sn=0,Ea=Uo=null,ap=!1,(s&8)!==0&&(s|=s&32);var d=n.entangledLanes;if(d!==0)for(n=n.entanglements,d&=s;0<d;){var y=31-Fe(d),b=1<<y;s|=n[y],d&=~b}return xs=s,lu(),o}function fv(n,s){mt=null,z.H=Ao,s===kl||s===hu?(s=Mx(),qt=3):s===dm?(s=Mx(),qt=4):qt=s===$m?8:s!==null&&typeof s=="object"&&typeof s.then=="function"?6:1,qa=s,wt===null&&(Sn=1,Au(n,ur(s,n.current)))}function mv(){var n=Fa.current;return n===null?!0:(Ct&4194048)===Ct?pr===null:(Ct&62914560)===Ct||(Ct&536870912)!==0?n===pr:!1}function pv(){var n=z.H;return z.H=Ao,n===null?Ao:n}function hv(){var n=z.A;return z.A=LC,n}function Bu(){Sn=4,Fs||(Ct&4194048)!==Ct&&Fa.current!==null||(Al=!0),(Vs&134217727)===0&&(zi&134217727)===0||Jt===null||Ws(Jt,Ct,Ga,!1)}function op(n,s,o){var d=Pt;Pt|=2;var y=pv(),b=hv();(Jt!==n||Ct!==s)&&($u=null,Rl(n,s)),s=!1;var N=Sn;e:do try{if(qt!==0&&wt!==null){var L=wt,Q=qa;switch(qt){case 8:lp(),N=6;break e;case 3:case 2:case 9:case 6:Fa.current===null&&(s=!0);var le=qt;if(qt=0,qa=null,Il(n,L,Q,le),o&&Al){N=0;break e}break;default:le=qt,qt=0,qa=null,Il(n,L,Q,le)}}UC(),N=Sn;break}catch(he){fv(n,he)}while(!0);return s&&n.shellSuspendCounter++,ls=Ai=null,Pt=d,z.H=y,z.A=b,wt===null&&(Jt=null,Ct=0,lu()),N}function UC(){for(;wt!==null;)gv(wt)}function zC(n,s){var o=Pt;Pt|=2;var d=pv(),y=hv();Jt!==n||Ct!==s?($u=null,zu=Ce()+500,Rl(n,s)):Al=bt(n,s);e:do try{if(qt!==0&&wt!==null){s=wt;var b=qa;t:switch(qt){case 1:qt=0,qa=null,Il(n,s,b,1);break;case 2:case 9:if(Nx(b)){qt=0,qa=null,xv(s);break}s=function(){qt!==2&&qt!==9||Jt!==n||(qt=7),qr(n)},b.then(s,s);break e;case 3:qt=7;break e;case 4:qt=5;break e;case 7:Nx(b)?(qt=0,qa=null,xv(s)):(qt=0,qa=null,Il(n,s,b,7));break;case 5:var N=null;switch(wt.tag){case 26:N=wt.memoizedState;case 5:case 27:var L=wt;if(N?nb(N):L.stateNode.complete){qt=0,qa=null;var Q=L.sibling;if(Q!==null)wt=Q;else{var le=L.return;le!==null?(wt=le,Hu(le)):wt=null}break t}}qt=0,qa=null,Il(n,s,b,5);break;case 6:qt=0,qa=null,Il(n,s,b,6);break;case 8:lp(),Sn=6;break e;default:throw Error(i(462))}}$C();break}catch(he){fv(n,he)}while(!0);return ls=Ai=null,z.H=d,z.A=y,Pt=o,wt!==null?0:(Jt=null,Ct=0,lu(),Sn)}function $C(){for(;wt!==null&&!un();)gv(wt)}function gv(n){var s=Py(n.alternate,n,xs);n.memoizedProps=n.pendingProps,s===null?Hu(n):wt=s}function xv(n){var s=n,o=s.alternate;switch(s.tag){case 15:case 0:s=Ly(o,s,s.pendingProps,s.type,void 0,Ct);break;case 11:s=Ly(o,s,s.pendingProps,s.type.render,s.ref,Ct);break;case 5:Sm(s);default:Hy(o,s),s=wt=hx(s,xs),s=Py(o,s,xs)}n.memoizedProps=n.pendingProps,s===null?Hu(n):wt=s}function Il(n,s,o,d){ls=Ai=null,Sm(s),wl=null,ko=0;var y=s.return;try{if(TC(n,y,s,o,Ct)){Sn=1,Au(n,ur(o,n.current)),wt=null;return}}catch(b){if(y!==null)throw wt=y,b;Sn=1,Au(n,ur(o,n.current)),wt=null;return}s.flags&32768?(Tt||d===1?n=!0:Al||(Ct&536870912)!==0?n=!1:(Fs=n=!0,(d===2||d===9||d===3||d===6)&&(d=Fa.current,d!==null&&d.tag===13&&(d.flags|=16384))),yv(s,n)):Hu(s)}function Hu(n){var s=n;do{if((s.flags&32768)!==0){yv(s,Fs);return}n=s.return;var o=EC(s.alternate,s,xs);if(o!==null){wt=o;return}if(s=s.sibling,s!==null){wt=s;return}wt=s=n}while(s!==null);Sn===0&&(Sn=5)}function yv(n,s){do{var o=_C(n.alternate,n);if(o!==null){o.flags&=32767,wt=o;return}if(o=n.return,o!==null&&(o.flags|=32768,o.subtreeFlags=0,o.deletions=null),!s&&(n=n.sibling,n!==null)){wt=n;return}wt=n=o}while(n!==null);Sn=6,wt=null}function vv(n,s,o,d,y,b,N,L,Q){n.cancelPendingCommit=null;do Fu();while(Dn!==0);if((Pt&6)!==0)throw Error(i(327));if(s!==null){if(s===n.current)throw Error(i(177));if(b=s.lanes|s.childLanes,b|=Qf,Ur(n,o,b,N,L,Q),n===Jt&&(wt=Jt=null,Ct=0),_l=s,Gs=n,ys=o,rp=b,sp=y,ov=d,(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,FC(De,function(){return jv(),null})):(n.callbackNode=null,n.callbackPriority=0),d=(s.flags&13878)!==0,(s.subtreeFlags&13878)!==0||d){d=z.T,z.T=null,y=J.p,J.p=2,N=Pt,Pt|=4;try{RC(n,s,o)}finally{Pt=N,J.p=y,z.T=d}}Dn=1,bv(),kv(),wv()}}function bv(){if(Dn===1){Dn=0;var n=Gs,s=_l,o=(s.flags&13878)!==0;if((s.subtreeFlags&13878)!==0||o){o=z.T,z.T=null;var d=J.p;J.p=2;var y=Pt;Pt|=4;try{ev(s,n);var b=bp,N=ix(n.containerInfo),L=b.focusedElem,Q=b.selectionRange;if(N!==L&&L&&L.ownerDocument&&sx(L.ownerDocument.documentElement,L)){if(Q!==null&&qf(L)){var le=Q.start,he=Q.end;if(he===void 0&&(he=le),"selectionStart"in L)L.selectionStart=le,L.selectionEnd=Math.min(he,L.value.length);else{var we=L.ownerDocument||document,oe=we&&we.defaultView||window;if(oe.getSelection){var fe=oe.getSelection(),He=L.textContent.length,tt=Math.min(Q.start,He),Qt=Q.end===void 0?tt:Math.min(Q.end,He);!fe.extend&&tt>Qt&&(N=Qt,Qt=tt,tt=N);var te=rx(L,tt),Z=rx(L,Qt);if(te&&Z&&(fe.rangeCount!==1||fe.anchorNode!==te.node||fe.anchorOffset!==te.offset||fe.focusNode!==Z.node||fe.focusOffset!==Z.offset)){var ie=we.createRange();ie.setStart(te.node,te.offset),fe.removeAllRanges(),tt>Qt?(fe.addRange(ie),fe.extend(Z.node,Z.offset)):(ie.setEnd(Z.node,Z.offset),fe.addRange(ie))}}}}for(we=[],fe=L;fe=fe.parentNode;)fe.nodeType===1&&we.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof L.focus=="function"&&L.focus(),L=0;L<we.length;L++){var be=we[L];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}td=!!vp,bp=vp=null}finally{Pt=y,J.p=d,z.T=o}}n.current=s,Dn=2}}function kv(){if(Dn===2){Dn=0;var n=Gs,s=_l,o=(s.flags&8772)!==0;if((s.subtreeFlags&8772)!==0||o){o=z.T,z.T=null;var d=J.p;J.p=2;var y=Pt;Pt|=4;try{Yy(n,s.alternate,s)}finally{Pt=y,J.p=d,z.T=o}}Dn=3}}function wv(){if(Dn===4||Dn===3){Dn=0,Wt();var n=Gs,s=_l,o=ys,d=ov;(s.subtreeFlags&10256)!==0||(s.flags&10256)!==0?Dn=5:(Dn=0,_l=Gs=null,Sv(n,n.pendingLanes));var y=n.pendingLanes;if(y===0&&(qs=null),ya(o),s=s.stateNode,Re&&typeof Re.onCommitFiberRoot=="function")try{Re.onCommitFiberRoot(Ne,s,void 0,(s.current.flags&128)===128)}catch{}if(d!==null){s=z.T,y=J.p,J.p=2,z.T=null;try{for(var b=n.onRecoverableError,N=0;N<d.length;N++){var L=d[N];b(L.value,{componentStack:L.stack})}}finally{z.T=s,J.p=y}}(ys&3)!==0&&Fu(),qr(n),y=n.pendingLanes,(o&261930)!==0&&(y&42)!==0?n===ip?zo++:(zo=0,ip=n):zo=0,$o(0)}}function Sv(n,s){(n.pooledCacheLanes&=s)===0&&(s=n.pooledCache,s!=null&&(n.pooledCache=null,vo(s)))}function Fu(){return bv(),kv(),wv(),jv()}function jv(){if(Dn!==5)return!1;var n=Gs,s=rp;rp=0;var o=ya(ys),d=z.T,y=J.p;try{J.p=32>o?32:o,z.T=null,o=sp,sp=null;var b=Gs,N=ys;if(Dn=0,_l=Gs=null,ys=0,(Pt&6)!==0)throw Error(i(331));var L=Pt;if(Pt|=4,sv(b.current),nv(b,b.current,N,o),Pt=L,$o(0,!1),Re&&typeof Re.onPostCommitFiberRoot=="function")try{Re.onPostCommitFiberRoot(Ne,b)}catch{}return!0}finally{J.p=y,z.T=d,Sv(n,s)}}function Cv(n,s,o){s=ur(o,s),s=zm(n.stateNode,s,2),n=$s(n,s,2),n!==null&&(Bn(n,2),qr(n))}function Gt(n,s,o){if(n.tag===3)Cv(n,n,o);else for(;s!==null;){if(s.tag===3){Cv(s,n,o);break}else if(s.tag===1){var d=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(qs===null||!qs.has(d))){n=ur(o,n),o=Ny(2),d=$s(s,o,2),d!==null&&(Ty(o,d,s,n),Bn(d,2),qr(d));break}}s=s.return}}function cp(n,s,o){var d=n.pingCache;if(d===null){d=n.pingCache=new OC;var y=new Set;d.set(s,y)}else y=d.get(s),y===void 0&&(y=new Set,d.set(s,y));y.has(o)||(tp=!0,y.add(o),n=PC.bind(null,n,s,o),s.then(n,n))}function PC(n,s,o){var d=n.pingCache;d!==null&&d.delete(s),n.pingedLanes|=n.suspendedLanes&o,n.warmLanes&=~o,Jt===n&&(Ct&o)===o&&(Sn===4||Sn===3&&(Ct&62914560)===Ct&&300>Ce()-Uu?(Pt&2)===0&&Rl(n,0):np|=o,El===Ct&&(El=0)),qr(n)}function Nv(n,s){s===0&&(s=Qn()),n=Ni(n,s),n!==null&&(Bn(n,s),qr(n))}function BC(n){var s=n.memoizedState,o=0;s!==null&&(o=s.retryLane),Nv(n,o)}function HC(n,s){var o=0;switch(n.tag){case 31:case 13:var d=n.stateNode,y=n.memoizedState;y!==null&&(o=y.retryLane);break;case 19:d=n.stateNode;break;case 22:d=n.stateNode._retryCache;break;default:throw Error(i(314))}d!==null&&d.delete(s),Nv(n,o)}function FC(n,s){return zt(n,s)}var Vu=null,Ll=null,up=!1,qu=!1,dp=!1,Ks=0;function qr(n){n!==Ll&&n.next===null&&(Ll===null?Vu=Ll=n:Ll=Ll.next=n),qu=!0,up||(up=!0,qC())}function $o(n,s){if(!dp&&qu){dp=!0;do for(var o=!1,d=Vu;d!==null;){if(n!==0){var y=d.pendingLanes;if(y===0)var b=0;else{var N=d.suspendedLanes,L=d.pingedLanes;b=(1<<31-Fe(42|n)+1)-1,b&=y&~(N&~L),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(o=!0,Ev(d,b))}else b=Ct,b=hn(d,d===Jt?b:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(b&3)===0||bt(d,b)||(o=!0,Ev(d,b));d=d.next}while(o);dp=!1}}function VC(){Tv()}function Tv(){qu=up=!1;var n=0;Ks!==0&&tN()&&(n=Ks);for(var s=Ce(),o=null,d=Vu;d!==null;){var y=d.next,b=Mv(d,s);b===0?(d.next=null,o===null?Vu=y:o.next=y,y===null&&(Ll=o)):(o=d,(n!==0||(b&3)!==0)&&(qu=!0)),d=y}Dn!==0&&Dn!==5||$o(n),Ks!==0&&(Ks=0)}function Mv(n,s){for(var o=n.suspendedLanes,d=n.pingedLanes,y=n.expirationTimes,b=n.pendingLanes&-62914561;0<b;){var N=31-Fe(b),L=1<<N,Q=y[N];Q===-1?((L&o)===0||(L&d)!==0)&&(y[N]=dn(L,s)):Q<=s&&(n.expiredLanes|=L),b&=~L}if(s=Jt,o=Ct,o=hn(n,n===s?o:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),d=n.callbackNode,o===0||n===s&&(qt===2||qt===9)||n.cancelPendingCommit!==null)return d!==null&&d!==null&&nn(d),n.callbackNode=null,n.callbackPriority=0;if((o&3)===0||bt(n,o)){if(s=o&-o,s===n.callbackPriority)return s;switch(d!==null&&nn(d),ya(o)){case 2:case 8:o=ce;break;case 32:o=De;break;case 268435456:o=Ue;break;default:o=De}return d=Av.bind(null,n),o=zt(o,d),n.callbackPriority=s,n.callbackNode=o,s}return d!==null&&d!==null&&nn(d),n.callbackPriority=2,n.callbackNode=null,2}function Av(n,s){if(Dn!==0&&Dn!==5)return n.callbackNode=null,n.callbackPriority=0,null;var o=n.callbackNode;if(Fu()&&n.callbackNode!==o)return null;var d=Ct;return d=hn(n,n===Jt?d:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),d===0?null:(uv(n,d,s),Mv(n,Ce()),n.callbackNode!=null&&n.callbackNode===o?Av.bind(null,n):null)}function Ev(n,s){if(Fu())return null;uv(n,s,!0)}function qC(){aN(function(){(Pt&6)!==0?zt(se,VC):Tv()})}function fp(){if(Ks===0){var n=vl;n===0&&(n=ze,ze<<=1,(ze&261888)===0&&(ze=256)),Ks=n}return Ks}function _v(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:Es(""+n)}function Rv(n,s){var o=s.ownerDocument.createElement("input");return o.name=s.name,o.value=s.value,n.id&&o.setAttribute("form",n.id),s.parentNode.insertBefore(o,s),n=new FormData(n),o.parentNode.removeChild(o),n}function GC(n,s,o,d,y){if(s==="submit"&&o&&o.stateNode===y){var b=_v((y[gn]||null).action),N=d.submitter;N&&(s=(s=N[gn]||null)?_v(s.formAction):N.getAttribute("formAction"),s!==null&&(b=s,N=null));var L=new ki("action","action",null,d,y);n.push({event:L,listeners:[{instance:null,listener:function(){if(d.defaultPrevented){if(Ks!==0){var Q=N?Rv(y,N):new FormData(y);Rm(o,{pending:!0,data:Q,method:y.method,action:b},null,Q)}}else typeof b=="function"&&(L.preventDefault(),Q=N?Rv(y,N):new FormData(y),Rm(o,{pending:!0,data:Q,method:y.method,action:b},b,Q))},currentTarget:y}]})}}for(var mp=0;mp<Yf.length;mp++){var pp=Yf[mp],WC=pp.toLowerCase(),KC=pp[0].toUpperCase()+pp.slice(1);Mr(WC,"on"+KC)}Mr(cx,"onAnimationEnd"),Mr(ux,"onAnimationIteration"),Mr(dx,"onAnimationStart"),Mr("dblclick","onDoubleClick"),Mr("focusin","onFocus"),Mr("focusout","onBlur"),Mr(uC,"onTransitionRun"),Mr(dC,"onTransitionStart"),Mr(fC,"onTransitionCancel"),Mr(fx,"onTransitionEnd"),Zn("onMouseEnter",["mouseout","mouseover"]),Zn("onMouseLeave",["mouseout","mouseover"]),Zn("onPointerEnter",["pointerout","pointerover"]),Zn("onPointerLeave",["pointerout","pointerover"]),Vt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Vt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Vt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Vt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Vt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Po="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(" "),YC=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Po));function Iv(n,s){s=(s&4)!==0;for(var o=0;o<n.length;o++){var d=n[o],y=d.event;d=d.listeners;e:{var b=void 0;if(s)for(var N=d.length-1;0<=N;N--){var L=d[N],Q=L.instance,le=L.currentTarget;if(L=L.listener,Q!==b&&y.isPropagationStopped())break e;b=L,y.currentTarget=le;try{b(y)}catch(he){iu(he)}y.currentTarget=null,b=Q}else for(N=0;N<d.length;N++){if(L=d[N],Q=L.instance,le=L.currentTarget,L=L.listener,Q!==b&&y.isPropagationStopped())break e;b=L,y.currentTarget=le;try{b(y)}catch(he){iu(he)}y.currentTarget=null,b=Q}}}}function St(n,s){var o=s[Ja];o===void 0&&(o=s[Ja]=new Set);var d=n+"__bubble";o.has(d)||(Lv(s,n,2,!1),o.add(d))}function hp(n,s,o){var d=0;s&&(d|=4),Lv(o,n,d,s)}var Gu="_reactListening"+Math.random().toString(36).slice(2);function gp(n){if(!n[Gu]){n[Gu]=!0,er.forEach(function(o){o!=="selectionchange"&&(YC.has(o)||hp(o,!1,n),hp(o,!0,n))});var s=n.nodeType===9?n:n.ownerDocument;s===null||s[Gu]||(s[Gu]=!0,hp("selectionchange",!1,s))}}function Lv(n,s,o,d){switch(cb(s)){case 2:var y=SN;break;case 8:y=jN;break;default:y=_p}o=y.bind(null,s,o,n),y=void 0,!kn||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(y=!0),d?y!==void 0?n.addEventListener(s,o,{capture:!0,passive:y}):n.addEventListener(s,o,!0):y!==void 0?n.addEventListener(s,o,{passive:y}):n.addEventListener(s,o,!1)}function xp(n,s,o,d,y){var b=d;if((s&1)===0&&(s&2)===0&&d!==null)e:for(;;){if(d===null)return;var N=d.tag;if(N===3||N===4){var L=d.stateNode.containerInfo;if(L===y)break;if(N===4)for(N=d.return;N!==null;){var Q=N.tag;if((Q===3||Q===4)&&N.stateNode.containerInfo===y)return;N=N.return}for(;L!==null;){if(N=Sa(L),N===null)return;if(Q=N.tag,Q===5||Q===6||Q===26||Q===27){d=b=N;continue e}L=L.parentNode}}d=d.return}Ze(function(){var le=b,he=vi(o),we=[];e:{var oe=mx.get(n);if(oe!==void 0){var fe=ki,He=n;switch(n){case"keypress":if(il(o)===0)break e;case"keydown":case"keyup":fe=Bf;break;case"focusin":He="focus",fe=_e;break;case"focusout":He="blur",fe=_e;break;case"beforeblur":case"afterblur":fe=_e;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=ru;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=$f;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=q5;break;case cx:case ux:case dx:fe=Et;break;case fx:fe=W5;break;case"scroll":case"scrollend":fe=Uf;break;case"wheel":fe=Y5;break;case"copy":case"cut":case"paste":fe=Mt;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=V0;break;case"toggle":case"beforetoggle":fe=X5}var tt=(s&4)!==0,Qt=!tt&&(n==="scroll"||n==="scrollend"),te=tt?oe!==null?oe+"Capture":null:oe;tt=[];for(var Z=le,ie;Z!==null;){var be=Z;if(ie=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||ie===null||te===null||(be=Xe(Z,te),be!=null&&tt.push(Bo(Z,be,ie))),Qt)break;Z=Z.return}0<tt.length&&(oe=new fe(oe,He,null,o,he),we.push({event:oe,listeners:tt}))}}if((s&7)===0){e:{if(oe=n==="mouseover"||n==="pointerover",fe=n==="mouseout"||n==="pointerout",oe&&o!==_s&&(He=o.relatedTarget||o.fromElement)&&(Sa(He)||He[Xn]))break e;if((fe||oe)&&(oe=he.window===he?he:(oe=he.ownerDocument)?oe.defaultView||oe.parentWindow:window,fe?(He=o.relatedTarget||o.toElement,fe=le,He=He?Sa(He):null,He!==null&&(Qt=c(He),tt=He.tag,He!==Qt||tt!==5&&tt!==27&&tt!==6)&&(He=null)):(fe=null,He=le),fe!==He)){if(tt=ru,be="onMouseLeave",te="onMouseEnter",Z="mouse",(n==="pointerout"||n==="pointerover")&&(tt=V0,be="onPointerLeave",te="onPointerEnter",Z="pointer"),Qt=fe==null?oe:ja(fe),ie=He==null?oe:ja(He),oe=new tt(be,Z+"leave",fe,o,he),oe.target=Qt,oe.relatedTarget=ie,be=null,Sa(he)===le&&(tt=new tt(te,Z+"enter",He,o,he),tt.target=ie,tt.relatedTarget=Qt,be=tt),Qt=be,fe&&He)t:{for(tt=QC,te=fe,Z=He,ie=0,be=te;be;be=tt(be))ie++;be=0;for(var Ye=Z;Ye;Ye=tt(Ye))be++;for(;0<ie-be;)te=tt(te),ie--;for(;0<be-ie;)Z=tt(Z),be--;for(;ie--;){if(te===Z||Z!==null&&te===Z.alternate){tt=te;break t}te=tt(te),Z=tt(Z)}tt=null}else tt=null;fe!==null&&Ov(we,oe,fe,tt,!1),He!==null&&Qt!==null&&Ov(we,Qt,He,tt,!0)}}e:{if(oe=le?ja(le):window,fe=oe.nodeName&&oe.nodeName.toLowerCase(),fe==="select"||fe==="input"&&oe.type==="file")var Ot=Z0;else if(Q0(oe))if(J0)Ot=lC;else{Ot=sC;var qe=rC}else fe=oe.nodeName,!fe||fe.toLowerCase()!=="input"||oe.type!=="checkbox"&&oe.type!=="radio"?le&&Ms(le.elementType)&&(Ot=Z0):Ot=iC;if(Ot&&(Ot=Ot(n,le))){X0(we,Ot,o,he);break e}qe&&qe(n,oe,le),n==="focusout"&&le&&oe.type==="number"&&le.memoizedProps.value!=null&&ua(oe,"number",oe.value)}switch(qe=le?ja(le):window,n){case"focusin":(Q0(qe)||qe.contentEditable==="true")&&(dl=qe,Gf=le,go=null);break;case"focusout":go=Gf=dl=null;break;case"mousedown":Wf=!0;break;case"contextmenu":case"mouseup":case"dragend":Wf=!1,lx(we,o,he);break;case"selectionchange":if(cC)break;case"keydown":case"keyup":lx(we,o,he)}var ht;if(Hf)e:{switch(n){case"compositionstart":var Nt="onCompositionStart";break e;case"compositionend":Nt="onCompositionEnd";break e;case"compositionupdate":Nt="onCompositionUpdate";break e}Nt=void 0}else ul?K0(n,o)&&(Nt="onCompositionEnd"):n==="keydown"&&o.keyCode===229&&(Nt="onCompositionStart");Nt&&(q0&&o.locale!=="ko"&&(ul||Nt!=="onCompositionStart"?Nt==="onCompositionEnd"&&ul&&(ht=nu()):(Na=he,ns="value"in Na?Na.value:Na.textContent,ul=!0)),qe=Wu(le,Nt),0<qe.length&&(Nt=new ir(Nt,n,null,o,he),we.push({event:Nt,listeners:qe}),ht?Nt.data=ht:(ht=Y0(o),ht!==null&&(Nt.data=ht)))),(ht=J5?eC(n,o):tC(n,o))&&(Nt=Wu(le,"onBeforeInput"),0<Nt.length&&(qe=new ir("onBeforeInput","beforeinput",null,o,he),we.push({event:qe,listeners:Nt}),qe.data=ht)),GC(we,n,le,o,he)}Iv(we,s)})}function Bo(n,s,o){return{instance:n,listener:s,currentTarget:o}}function Wu(n,s){for(var o=s+"Capture",d=[];n!==null;){var y=n,b=y.stateNode;if(y=y.tag,y!==5&&y!==26&&y!==27||b===null||(y=Xe(n,o),y!=null&&d.unshift(Bo(n,y,b)),y=Xe(n,s),y!=null&&d.push(Bo(n,y,b))),n.tag===3)return d;n=n.return}return[]}function QC(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function Ov(n,s,o,d,y){for(var b=s._reactName,N=[];o!==null&&o!==d;){var L=o,Q=L.alternate,le=L.stateNode;if(L=L.tag,Q!==null&&Q===d)break;L!==5&&L!==26&&L!==27||le===null||(Q=le,y?(le=Xe(o,b),le!=null&&N.unshift(Bo(o,le,Q))):y||(le=Xe(o,b),le!=null&&N.push(Bo(o,le,Q)))),o=o.return}N.length!==0&&n.push({event:s,listeners:N})}var XC=/\r\n?/g,ZC=/\u0000|\uFFFD/g;function Dv(n){return(typeof n=="string"?n:""+n).replace(XC,`
10
- `).replace(ZC,"")}function Uv(n,s){return s=Dv(s),Dv(n)===s}function Yt(n,s,o,d,y,b){switch(o){case"children":typeof d=="string"?s==="body"||s==="textarea"&&d===""||rr(n,d):(typeof d=="number"||typeof d=="bigint")&&s!=="body"&&rr(n,""+d);break;case"className":ca(n,"class",d);break;case"tabIndex":ca(n,"tabindex",d);break;case"dir":case"role":case"viewBox":case"width":case"height":ca(n,o,d);break;case"style":ts(n,d,b);break;case"data":if(s!=="object"){ca(n,"data",d);break}case"src":case"href":if(d===""&&(s!=="a"||o!=="href")){n.removeAttribute(o);break}if(d==null||typeof d=="function"||typeof d=="symbol"||typeof d=="boolean"){n.removeAttribute(o);break}d=Es(""+d),n.setAttribute(o,d);break;case"action":case"formAction":if(typeof d=="function"){n.setAttribute(o,"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 b=="function"&&(o==="formAction"?(s!=="input"&&Yt(n,s,"name",y.name,y,null),Yt(n,s,"formEncType",y.formEncType,y,null),Yt(n,s,"formMethod",y.formMethod,y,null),Yt(n,s,"formTarget",y.formTarget,y,null)):(Yt(n,s,"encType",y.encType,y,null),Yt(n,s,"method",y.method,y,null),Yt(n,s,"target",y.target,y,null)));if(d==null||typeof d=="symbol"||typeof d=="boolean"){n.removeAttribute(o);break}d=Es(""+d),n.setAttribute(o,d);break;case"onClick":d!=null&&(n.onclick=Jn);break;case"onScroll":d!=null&&St("scroll",n);break;case"onScrollEnd":d!=null&&St("scrollend",n);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(i(61));if(o=d.__html,o!=null){if(y.children!=null)throw Error(i(60));n.innerHTML=o}}break;case"multiple":n.multiple=d&&typeof d!="function"&&typeof d!="symbol";break;case"muted":n.muted=d&&typeof d!="function"&&typeof d!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(d==null||typeof d=="function"||typeof d=="boolean"||typeof d=="symbol"){n.removeAttribute("xlink:href");break}o=Es(""+d),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",o);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":d!=null&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(o,""+d):n.removeAttribute(o);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":d&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(o,""):n.removeAttribute(o);break;case"capture":case"download":d===!0?n.setAttribute(o,""):d!==!1&&d!=null&&typeof d!="function"&&typeof d!="symbol"?n.setAttribute(o,d):n.removeAttribute(o);break;case"cols":case"rows":case"size":case"span":d!=null&&typeof d!="function"&&typeof d!="symbol"&&!isNaN(d)&&1<=d?n.setAttribute(o,d):n.removeAttribute(o);break;case"rowSpan":case"start":d==null||typeof d=="function"||typeof d=="symbol"||isNaN(d)?n.removeAttribute(o):n.setAttribute(o,d);break;case"popover":St("beforetoggle",n),St("toggle",n),$a(n,"popover",d);break;case"xlinkActuate":On(n,"http://www.w3.org/1999/xlink","xlink:actuate",d);break;case"xlinkArcrole":On(n,"http://www.w3.org/1999/xlink","xlink:arcrole",d);break;case"xlinkRole":On(n,"http://www.w3.org/1999/xlink","xlink:role",d);break;case"xlinkShow":On(n,"http://www.w3.org/1999/xlink","xlink:show",d);break;case"xlinkTitle":On(n,"http://www.w3.org/1999/xlink","xlink:title",d);break;case"xlinkType":On(n,"http://www.w3.org/1999/xlink","xlink:type",d);break;case"xmlBase":On(n,"http://www.w3.org/XML/1998/namespace","xml:base",d);break;case"xmlLang":On(n,"http://www.w3.org/XML/1998/namespace","xml:lang",d);break;case"xmlSpace":On(n,"http://www.w3.org/XML/1998/namespace","xml:space",d);break;case"is":$a(n,"is",d);break;case"innerText":case"textContent":break;default:(!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(o=yi.get(o)||o,$a(n,o,d))}}function yp(n,s,o,d,y,b){switch(o){case"style":ts(n,d,b);break;case"dangerouslySetInnerHTML":if(d!=null){if(typeof d!="object"||!("__html"in d))throw Error(i(61));if(o=d.__html,o!=null){if(y.children!=null)throw Error(i(60));n.innerHTML=o}}break;case"children":typeof d=="string"?rr(n,d):(typeof d=="number"||typeof d=="bigint")&&rr(n,""+d);break;case"onScroll":d!=null&&St("scroll",n);break;case"onScrollEnd":d!=null&&St("scrollend",n);break;case"onClick":d!=null&&(n.onclick=Jn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Nr.hasOwnProperty(o))e:{if(o[0]==="o"&&o[1]==="n"&&(y=o.endsWith("Capture"),s=o.slice(2,y?o.length-7:void 0),b=n[gn]||null,b=b!=null?b[o]:null,typeof b=="function"&&n.removeEventListener(s,b,y),typeof d=="function")){typeof b!="function"&&b!==null&&(o in n?n[o]=null:n.hasAttribute(o)&&n.removeAttribute(o)),n.addEventListener(s,d,y);break e}o in n?n[o]=d:d===!0?n.setAttribute(o,""):$a(n,o,d)}}}function Wn(n,s,o){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":St("error",n),St("load",n);var d=!1,y=!1,b;for(b in o)if(o.hasOwnProperty(b)){var N=o[b];if(N!=null)switch(b){case"src":d=!0;break;case"srcSet":y=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,s));default:Yt(n,s,b,N,o,null)}}y&&Yt(n,s,"srcSet",o.srcSet,o,null),d&&Yt(n,s,"src",o.src,o,null);return;case"input":St("invalid",n);var L=b=N=y=null,Q=null,le=null;for(d in o)if(o.hasOwnProperty(d)){var he=o[d];if(he!=null)switch(d){case"name":y=he;break;case"type":N=he;break;case"checked":Q=he;break;case"defaultChecked":le=he;break;case"value":b=he;break;case"defaultValue":L=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(i(137,s));break;default:Yt(n,s,d,he,o,null)}}Pa(n,b,L,Q,le,N,y,!1);return;case"select":St("invalid",n),d=N=b=null;for(y in o)if(o.hasOwnProperty(y)&&(L=o[y],L!=null))switch(y){case"value":b=L;break;case"defaultValue":N=L;break;case"multiple":d=L;default:Yt(n,s,y,L,o,null)}s=b,o=N,n.multiple=!!d,s!=null?Fn(n,!!d,s,!1):o!=null&&Fn(n,!!d,o,!0);return;case"textarea":St("invalid",n),b=y=d=null;for(N in o)if(o.hasOwnProperty(N)&&(L=o[N],L!=null))switch(N){case"value":d=L;break;case"defaultValue":y=L;break;case"children":b=L;break;case"dangerouslySetInnerHTML":if(L!=null)throw Error(i(91));break;default:Yt(n,s,N,L,o,null)}xi(n,d,y,b);return;case"option":for(Q in o)o.hasOwnProperty(Q)&&(d=o[Q],d!=null)&&(Q==="selected"?n.selected=d&&typeof d!="function"&&typeof d!="symbol":Yt(n,s,Q,d,o,null));return;case"dialog":St("beforetoggle",n),St("toggle",n),St("cancel",n),St("close",n);break;case"iframe":case"object":St("load",n);break;case"video":case"audio":for(d=0;d<Po.length;d++)St(Po[d],n);break;case"image":St("error",n),St("load",n);break;case"details":St("toggle",n);break;case"embed":case"source":case"link":St("error",n),St("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(le in o)if(o.hasOwnProperty(le)&&(d=o[le],d!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,s));default:Yt(n,s,le,d,o,null)}return;default:if(Ms(s)){for(he in o)o.hasOwnProperty(he)&&(d=o[he],d!==void 0&&yp(n,s,he,d,o,void 0));return}}for(L in o)o.hasOwnProperty(L)&&(d=o[L],d!=null&&Yt(n,s,L,d,o,null))}function JC(n,s,o,d){switch(s){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var y=null,b=null,N=null,L=null,Q=null,le=null,he=null;for(fe in o){var we=o[fe];if(o.hasOwnProperty(fe)&&we!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":Q=we;default:d.hasOwnProperty(fe)||Yt(n,s,fe,null,d,we)}}for(var oe in d){var fe=d[oe];if(we=o[oe],d.hasOwnProperty(oe)&&(fe!=null||we!=null))switch(oe){case"type":b=fe;break;case"name":y=fe;break;case"checked":le=fe;break;case"defaultChecked":he=fe;break;case"value":N=fe;break;case"defaultValue":L=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(i(137,s));break;default:fe!==we&&Yt(n,s,oe,fe,d,we)}}Zt(n,N,L,Q,le,he,b,y);return;case"select":fe=N=L=oe=null;for(b in o)if(Q=o[b],o.hasOwnProperty(b)&&Q!=null)switch(b){case"value":break;case"multiple":fe=Q;default:d.hasOwnProperty(b)||Yt(n,s,b,null,d,Q)}for(y in d)if(b=d[y],Q=o[y],d.hasOwnProperty(y)&&(b!=null||Q!=null))switch(y){case"value":oe=b;break;case"defaultValue":L=b;break;case"multiple":N=b;default:b!==Q&&Yt(n,s,y,b,d,Q)}s=L,o=N,d=fe,oe!=null?Fn(n,!!o,oe,!1):!!d!=!!o&&(s!=null?Fn(n,!!o,s,!0):Fn(n,!!o,o?[]:"",!1));return;case"textarea":fe=oe=null;for(L in o)if(y=o[L],o.hasOwnProperty(L)&&y!=null&&!d.hasOwnProperty(L))switch(L){case"value":break;case"children":break;default:Yt(n,s,L,null,d,y)}for(N in d)if(y=d[N],b=o[N],d.hasOwnProperty(N)&&(y!=null||b!=null))switch(N){case"value":oe=y;break;case"defaultValue":fe=y;break;case"children":break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(i(91));break;default:y!==b&&Yt(n,s,N,y,d,b)}Ca(n,oe,fe);return;case"option":for(var He in o)oe=o[He],o.hasOwnProperty(He)&&oe!=null&&!d.hasOwnProperty(He)&&(He==="selected"?n.selected=!1:Yt(n,s,He,null,d,oe));for(Q in d)oe=d[Q],fe=o[Q],d.hasOwnProperty(Q)&&oe!==fe&&(oe!=null||fe!=null)&&(Q==="selected"?n.selected=oe&&typeof oe!="function"&&typeof oe!="symbol":Yt(n,s,Q,oe,d,fe));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 tt in o)oe=o[tt],o.hasOwnProperty(tt)&&oe!=null&&!d.hasOwnProperty(tt)&&Yt(n,s,tt,null,d,oe);for(le in d)if(oe=d[le],fe=o[le],d.hasOwnProperty(le)&&oe!==fe&&(oe!=null||fe!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(i(137,s));break;default:Yt(n,s,le,oe,d,fe)}return;default:if(Ms(s)){for(var Qt in o)oe=o[Qt],o.hasOwnProperty(Qt)&&oe!==void 0&&!d.hasOwnProperty(Qt)&&yp(n,s,Qt,void 0,d,oe);for(he in d)oe=d[he],fe=o[he],!d.hasOwnProperty(he)||oe===fe||oe===void 0&&fe===void 0||yp(n,s,he,oe,d,fe);return}}for(var te in o)oe=o[te],o.hasOwnProperty(te)&&oe!=null&&!d.hasOwnProperty(te)&&Yt(n,s,te,null,d,oe);for(we in d)oe=d[we],fe=o[we],!d.hasOwnProperty(we)||oe===fe||oe==null&&fe==null||Yt(n,s,we,oe,d,fe)}function zv(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function eN(){if(typeof performance.getEntriesByType=="function"){for(var n=0,s=0,o=performance.getEntriesByType("resource"),d=0;d<o.length;d++){var y=o[d],b=y.transferSize,N=y.initiatorType,L=y.duration;if(b&&L&&zv(N)){for(N=0,L=y.responseEnd,d+=1;d<o.length;d++){var Q=o[d],le=Q.startTime;if(le>L)break;var he=Q.transferSize,we=Q.initiatorType;he&&zv(we)&&(Q=Q.responseEnd,N+=he*(Q<L?1:(L-le)/(Q-le)))}if(--d,s+=8*(b+N)/(y.duration/1e3),n++,10<n)break}}if(0<n)return s/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var vp=null,bp=null;function Ku(n){return n.nodeType===9?n:n.ownerDocument}function $v(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Pv(n,s){if(n===0)switch(s){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&s==="foreignObject"?0:n}function kp(n,s){return n==="textarea"||n==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.children=="bigint"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var wp=null;function tN(){var n=window.event;return n&&n.type==="popstate"?n===wp?!1:(wp=n,!0):(wp=null,!1)}var Bv=typeof setTimeout=="function"?setTimeout:void 0,nN=typeof clearTimeout=="function"?clearTimeout:void 0,Hv=typeof Promise=="function"?Promise:void 0,aN=typeof queueMicrotask=="function"?queueMicrotask:typeof Hv<"u"?function(n){return Hv.resolve(null).then(n).catch(rN)}:Bv;function rN(n){setTimeout(function(){throw n})}function Ys(n){return n==="head"}function Fv(n,s){var o=s,d=0;do{var y=o.nextSibling;if(n.removeChild(o),y&&y.nodeType===8)if(o=y.data,o==="/$"||o==="/&"){if(d===0){n.removeChild(y),zl(s);return}d--}else if(o==="$"||o==="$?"||o==="$~"||o==="$!"||o==="&")d++;else if(o==="html")Ho(n.ownerDocument.documentElement);else if(o==="head"){o=n.ownerDocument.head,Ho(o);for(var b=o.firstChild;b;){var N=b.nextSibling,L=b.nodeName;b[wa]||L==="SCRIPT"||L==="STYLE"||L==="LINK"&&b.rel.toLowerCase()==="stylesheet"||o.removeChild(b),b=N}}else o==="body"&&Ho(n.ownerDocument.body);o=y}while(o);zl(s)}function Vv(n,s){var o=n;n=0;do{var d=o.nextSibling;if(o.nodeType===1?s?(o._stashedDisplay=o.style.display,o.style.display="none"):(o.style.display=o._stashedDisplay||"",o.getAttribute("style")===""&&o.removeAttribute("style")):o.nodeType===3&&(s?(o._stashedText=o.nodeValue,o.nodeValue=""):o.nodeValue=o._stashedText||""),d&&d.nodeType===8)if(o=d.data,o==="/$"){if(n===0)break;n--}else o!=="$"&&o!=="$?"&&o!=="$~"&&o!=="$!"||n++;o=d}while(o)}function Sp(n){var s=n.firstChild;for(s&&s.nodeType===10&&(s=s.nextSibling);s;){var o=s;switch(s=s.nextSibling,o.nodeName){case"HTML":case"HEAD":case"BODY":Sp(o),$r(o);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(o.rel.toLowerCase()==="stylesheet")continue}n.removeChild(o)}}function sN(n,s,o,d){for(;n.nodeType===1;){var y=o;if(n.nodeName.toLowerCase()!==s.toLowerCase()){if(!d&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(d){if(!n[wa])switch(s){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(b=n.getAttribute("rel"),b==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(b!==y.rel||n.getAttribute("href")!==(y.href==null||y.href===""?null:y.href)||n.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin)||n.getAttribute("title")!==(y.title==null?null:y.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(b=n.getAttribute("src"),(b!==(y.src==null?null:y.src)||n.getAttribute("type")!==(y.type==null?null:y.type)||n.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin))&&b&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(s==="input"&&n.type==="hidden"){var b=y.name==null?null:""+y.name;if(y.type==="hidden"&&n.getAttribute("name")===b)return n}else return n;if(n=hr(n.nextSibling),n===null)break}return null}function iN(n,s,o){if(s==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!o||(n=hr(n.nextSibling),n===null))return null;return n}function qv(n,s){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!s||(n=hr(n.nextSibling),n===null))return null;return n}function jp(n){return n.data==="$?"||n.data==="$~"}function Cp(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function lN(n,s){var o=n.ownerDocument;if(n.data==="$~")n._reactRetry=s;else if(n.data!=="$?"||o.readyState!=="loading")s();else{var d=function(){s(),o.removeEventListener("DOMContentLoaded",d)};o.addEventListener("DOMContentLoaded",d),n._reactRetry=d}}function hr(n){for(;n!=null;n=n.nextSibling){var s=n.nodeType;if(s===1||s===3)break;if(s===8){if(s=n.data,s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"||s==="F!"||s==="F")break;if(s==="/$"||s==="/&")return null}}return n}var Np=null;function Gv(n){n=n.nextSibling;for(var s=0;n;){if(n.nodeType===8){var o=n.data;if(o==="/$"||o==="/&"){if(s===0)return hr(n.nextSibling);s--}else o!=="$"&&o!=="$!"&&o!=="$?"&&o!=="$~"&&o!=="&"||s++}n=n.nextSibling}return null}function Wv(n){n=n.previousSibling;for(var s=0;n;){if(n.nodeType===8){var o=n.data;if(o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"){if(s===0)return n;s--}else o!=="/$"&&o!=="/&"||s++}n=n.previousSibling}return null}function Kv(n,s,o){switch(s=Ku(o),n){case"html":if(n=s.documentElement,!n)throw Error(i(452));return n;case"head":if(n=s.head,!n)throw Error(i(453));return n;case"body":if(n=s.body,!n)throw Error(i(454));return n;default:throw Error(i(451))}}function Ho(n){for(var s=n.attributes;s.length;)n.removeAttributeNode(s[0]);$r(n)}var gr=new Map,Yv=new Set;function Yu(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var vs=J.d;J.d={f:oN,r:cN,D:uN,C:dN,L:fN,m:mN,X:hN,S:pN,M:gN};function oN(){var n=vs.f(),s=Pu();return n||s}function cN(n){var s=za(n);s!==null&&s.tag===5&&s.type==="form"?fy(s):vs.r(n)}var Ol=typeof document>"u"?null:document;function Qv(n,s,o){var d=Ol;if(d&&typeof s=="string"&&s){var y=xt(s);y='link[rel="'+n+'"][href="'+y+'"]',typeof o=="string"&&(y+='[crossorigin="'+o+'"]'),Yv.has(y)||(Yv.add(y),n={rel:n,crossOrigin:o,href:s},d.querySelector(y)===null&&(s=d.createElement("link"),Wn(s,"link",n),Ft(s),d.head.appendChild(s)))}}function uN(n){vs.D(n),Qv("dns-prefetch",n,null)}function dN(n,s){vs.C(n,s),Qv("preconnect",n,s)}function fN(n,s,o){vs.L(n,s,o);var d=Ol;if(d&&n&&s){var y='link[rel="preload"][as="'+xt(s)+'"]';s==="image"&&o&&o.imageSrcSet?(y+='[imagesrcset="'+xt(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(y+='[imagesizes="'+xt(o.imageSizes)+'"]')):y+='[href="'+xt(n)+'"]';var b=y;switch(s){case"style":b=Dl(n);break;case"script":b=Ul(n)}gr.has(b)||(n=v({rel:"preload",href:s==="image"&&o&&o.imageSrcSet?void 0:n,as:s},o),gr.set(b,n),d.querySelector(y)!==null||s==="style"&&d.querySelector(Fo(b))||s==="script"&&d.querySelector(Vo(b))||(s=d.createElement("link"),Wn(s,"link",n),Ft(s),d.head.appendChild(s)))}}function mN(n,s){vs.m(n,s);var o=Ol;if(o&&n){var d=s&&typeof s.as=="string"?s.as:"script",y='link[rel="modulepreload"][as="'+xt(d)+'"][href="'+xt(n)+'"]',b=y;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=Ul(n)}if(!gr.has(b)&&(n=v({rel:"modulepreload",href:n},s),gr.set(b,n),o.querySelector(y)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Vo(b)))return}d=o.createElement("link"),Wn(d,"link",n),Ft(d),o.head.appendChild(d)}}}function pN(n,s,o){vs.S(n,s,o);var d=Ol;if(d&&n){var y=$n(d).hoistableStyles,b=Dl(n);s=s||"default";var N=y.get(b);if(!N){var L={loading:0,preload:null};if(N=d.querySelector(Fo(b)))L.loading=5;else{n=v({rel:"stylesheet",href:n,"data-precedence":s},o),(o=gr.get(b))&&Tp(n,o);var Q=N=d.createElement("link");Ft(Q),Wn(Q,"link",n),Q._p=new Promise(function(le,he){Q.onload=le,Q.onerror=he}),Q.addEventListener("load",function(){L.loading|=1}),Q.addEventListener("error",function(){L.loading|=2}),L.loading|=4,Qu(N,s,d)}N={type:"stylesheet",instance:N,count:1,state:L},y.set(b,N)}}}function hN(n,s){vs.X(n,s);var o=Ol;if(o&&n){var d=$n(o).hoistableScripts,y=Ul(n),b=d.get(y);b||(b=o.querySelector(Vo(y)),b||(n=v({src:n,async:!0},s),(s=gr.get(y))&&Mp(n,s),b=o.createElement("script"),Ft(b),Wn(b,"link",n),o.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},d.set(y,b))}}function gN(n,s){vs.M(n,s);var o=Ol;if(o&&n){var d=$n(o).hoistableScripts,y=Ul(n),b=d.get(y);b||(b=o.querySelector(Vo(y)),b||(n=v({src:n,async:!0,type:"module"},s),(s=gr.get(y))&&Mp(n,s),b=o.createElement("script"),Ft(b),Wn(b,"link",n),o.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},d.set(y,b))}}function Xv(n,s,o,d){var y=(y=de.current)?Yu(y):null;if(!y)throw Error(i(446));switch(n){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(s=Dl(o.href),o=$n(y).hoistableStyles,d=o.get(s),d||(d={type:"style",instance:null,count:0,state:null},o.set(s,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){n=Dl(o.href);var b=$n(y).hoistableStyles,N=b.get(n);if(N||(y=y.ownerDocument||y,N={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(n,N),(b=y.querySelector(Fo(n)))&&!b._p&&(N.instance=b,N.state.loading=5),gr.has(n)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},gr.set(n,o),b||xN(y,n,o,N.state))),s&&d===null)throw Error(i(528,""));return N}if(s&&d!==null)throw Error(i(529,""));return null;case"script":return s=o.async,o=o.src,typeof o=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(s=Ul(o),o=$n(y).hoistableScripts,d=o.get(s),d||(d={type:"script",instance:null,count:0,state:null},o.set(s,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,n))}}function Dl(n){return'href="'+xt(n)+'"'}function Fo(n){return'link[rel="stylesheet"]['+n+"]"}function Zv(n){return v({},n,{"data-precedence":n.precedence,precedence:null})}function xN(n,s,o,d){n.querySelector('link[rel="preload"][as="style"]['+s+"]")?d.loading=1:(s=n.createElement("link"),d.preload=s,s.addEventListener("load",function(){return d.loading|=1}),s.addEventListener("error",function(){return d.loading|=2}),Wn(s,"link",o),Ft(s),n.head.appendChild(s))}function Ul(n){return'[src="'+xt(n)+'"]'}function Vo(n){return"script[async]"+n}function Jv(n,s,o){if(s.count++,s.instance===null)switch(s.type){case"style":var d=n.querySelector('style[data-href~="'+xt(o.href)+'"]');if(d)return s.instance=d,Ft(d),d;var y=v({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(n.ownerDocument||n).createElement("style"),Ft(d),Wn(d,"style",y),Qu(d,o.precedence,n),s.instance=d;case"stylesheet":y=Dl(o.href);var b=n.querySelector(Fo(y));if(b)return s.state.loading|=4,s.instance=b,Ft(b),b;d=Zv(o),(y=gr.get(y))&&Tp(d,y),b=(n.ownerDocument||n).createElement("link"),Ft(b);var N=b;return N._p=new Promise(function(L,Q){N.onload=L,N.onerror=Q}),Wn(b,"link",d),s.state.loading|=4,Qu(b,o.precedence,n),s.instance=b;case"script":return b=Ul(o.src),(y=n.querySelector(Vo(b)))?(s.instance=y,Ft(y),y):(d=o,(y=gr.get(b))&&(d=v({},o),Mp(d,y)),n=n.ownerDocument||n,y=n.createElement("script"),Ft(y),Wn(y,"link",d),n.head.appendChild(y),s.instance=y);case"void":return null;default:throw Error(i(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(d=s.instance,s.state.loading|=4,Qu(d,o.precedence,n));return s.instance}function Qu(n,s,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=d.length?d[d.length-1]:null,b=y,N=0;N<d.length;N++){var L=d[N];if(L.dataset.precedence===s)b=L;else if(b!==y)break}b?b.parentNode.insertBefore(n,b.nextSibling):(s=o.nodeType===9?o.head:o,s.insertBefore(n,s.firstChild))}function Tp(n,s){n.crossOrigin==null&&(n.crossOrigin=s.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=s.referrerPolicy),n.title==null&&(n.title=s.title)}function Mp(n,s){n.crossOrigin==null&&(n.crossOrigin=s.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=s.referrerPolicy),n.integrity==null&&(n.integrity=s.integrity)}var Xu=null;function eb(n,s,o){if(Xu===null){var d=new Map,y=Xu=new Map;y.set(o,d)}else y=Xu,d=y.get(o),d||(d=new Map,y.set(o,d));if(d.has(n))return d;for(d.set(n,null),o=o.getElementsByTagName(n),y=0;y<o.length;y++){var b=o[y];if(!(b[wa]||b[$t]||n==="link"&&b.getAttribute("rel")==="stylesheet")&&b.namespaceURI!=="http://www.w3.org/2000/svg"){var N=b.getAttribute(s)||"";N=n+N;var L=d.get(N);L?L.push(b):d.set(N,[b])}}return d}function tb(n,s,o){n=n.ownerDocument||n,n.head.insertBefore(o,s==="title"?n.querySelector("head > title"):null)}function yN(n,s,o){if(o===1||s.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;return s.rel==="stylesheet"?(n=s.disabled,typeof s.precedence=="string"&&n==null):!0;case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function nb(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function vN(n,s,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var y=Dl(d.href),b=s.querySelector(Fo(y));if(b){s=b._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(n.count++,n=Zu.bind(n),s.then(n,n)),o.state.loading|=4,o.instance=b,Ft(b);return}b=s.ownerDocument||s,d=Zv(d),(y=gr.get(y))&&Tp(d,y),b=b.createElement("link"),Ft(b);var N=b;N._p=new Promise(function(L,Q){N.onload=L,N.onerror=Q}),Wn(b,"link",d),o.instance=b}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(o,s),(s=o.state.preload)&&(o.state.loading&3)===0&&(n.count++,o=Zu.bind(n),s.addEventListener("load",o),s.addEventListener("error",o))}}var Ap=0;function bN(n,s){return n.stylesheets&&n.count===0&&ed(n,n.stylesheets),0<n.count||0<n.imgCount?function(o){var d=setTimeout(function(){if(n.stylesheets&&ed(n,n.stylesheets),n.unsuspend){var b=n.unsuspend;n.unsuspend=null,b()}},6e4+s);0<n.imgBytes&&Ap===0&&(Ap=62500*eN());var y=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&ed(n,n.stylesheets),n.unsuspend)){var b=n.unsuspend;n.unsuspend=null,b()}},(n.imgBytes>Ap?50:800)+s);return n.unsuspend=o,function(){n.unsuspend=null,clearTimeout(d),clearTimeout(y)}}:null}function Zu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ed(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Ju=null;function ed(n,s){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Ju=new Map,s.forEach(kN,n),Ju=null,Zu.call(n))}function kN(n,s){if(!(s.state.loading&4)){var o=Ju.get(n);if(o)var d=o.get(null);else{o=new Map,Ju.set(n,o);for(var y=n.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b<y.length;b++){var N=y[b];(N.nodeName==="LINK"||N.getAttribute("media")!=="not all")&&(o.set(N.dataset.precedence,N),d=N)}d&&o.set(null,d)}y=s.instance,N=y.getAttribute("data-precedence"),b=o.get(N)||d,b===d&&o.set(null,y),o.set(N,y),this.count++,d=Zu.bind(this),y.addEventListener("load",d),y.addEventListener("error",d),b?b.parentNode.insertBefore(y,b.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(y,n.firstChild)),s.state.loading|=4}}var qo={$$typeof:D,Provider:null,Consumer:null,_currentValue:xe,_currentValue2:xe,_threadCount:0};function wN(n,s,o,d,y,b,N,L,Q){this.tag=1,this.containerInfo=n,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=Ht(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ht(0),this.hiddenUpdates=Ht(null),this.identifierPrefix=d,this.onUncaughtError=y,this.onCaughtError=b,this.onRecoverableError=N,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Q,this.incompleteTransitions=new Map}function ab(n,s,o,d,y,b,N,L,Q,le,he,we){return n=new wN(n,s,o,N,Q,le,he,we,L),s=1,b===!0&&(s|=24),b=Ha(3,null,null,s),n.current=b,b.stateNode=n,s=om(),s.refCount++,n.pooledCache=s,s.refCount++,b.memoizedState={element:d,isDehydrated:o,cache:s},fm(b),n}function rb(n){return n?(n=pl,n):pl}function sb(n,s,o,d,y,b){y=rb(y),d.context===null?d.context=y:d.pendingContext=y,d=zs(s),d.payload={element:o},b=b===void 0?null:b,b!==null&&(d.callback=b),o=$s(n,d,s),o!==null&&(_a(o,n,s),So(o,n,s))}function ib(n,s){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var o=n.retryLane;n.retryLane=o!==0&&o<s?o:s}}function Ep(n,s){ib(n,s),(n=n.alternate)&&ib(n,s)}function lb(n){if(n.tag===13||n.tag===31){var s=Ni(n,67108864);s!==null&&_a(s,n,67108864),Ep(n,67108864)}}function ob(n){if(n.tag===13||n.tag===31){var s=Wa();s=Hn(s);var o=Ni(n,s);o!==null&&_a(o,n,s),Ep(n,s)}}var td=!0;function SN(n,s,o,d){var y=z.T;z.T=null;var b=J.p;try{J.p=2,_p(n,s,o,d)}finally{J.p=b,z.T=y}}function jN(n,s,o,d){var y=z.T;z.T=null;var b=J.p;try{J.p=8,_p(n,s,o,d)}finally{J.p=b,z.T=y}}function _p(n,s,o,d){if(td){var y=Rp(d);if(y===null)xp(n,s,d,nd,o),ub(n,d);else if(NN(y,n,s,o,d))d.stopPropagation();else if(ub(n,d),s&4&&-1<CN.indexOf(n)){for(;y!==null;){var b=za(y);if(b!==null)switch(b.tag){case 3:if(b=b.stateNode,b.current.memoizedState.isDehydrated){var N=vt(b.pendingLanes);if(N!==0){var L=b;for(L.pendingLanes|=2,L.entangledLanes|=2;N;){var Q=1<<31-Fe(N);L.entanglements[1]|=Q,N&=~Q}qr(b),(Pt&6)===0&&(zu=Ce()+500,$o(0))}}break;case 31:case 13:L=Ni(b,2),L!==null&&_a(L,b,2),Pu(),Ep(b,2)}if(b=Rp(d),b===null&&xp(n,s,d,nd,o),b===y)break;y=b}y!==null&&d.stopPropagation()}else xp(n,s,d,null,o)}}function Rp(n){return n=vi(n),Ip(n)}var nd=null;function Ip(n){if(nd=null,n=Sa(n),n!==null){var s=c(n);if(s===null)n=null;else{var o=s.tag;if(o===13){if(n=u(s),n!==null)return n;n=null}else if(o===31){if(n=m(s),n!==null)return n;n=null}else if(o===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;n=null}else s!==n&&(n=null)}}return nd=n,null}function cb(n){switch(n){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(Ke()){case se:return 2;case ce:return 8;case De:case Be:return 32;case Ue:return 268435456;default:return 32}default:return 32}}var Lp=!1,Qs=null,Xs=null,Zs=null,Go=new Map,Wo=new Map,Js=[],CN="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 ub(n,s){switch(n){case"focusin":case"focusout":Qs=null;break;case"dragenter":case"dragleave":Xs=null;break;case"mouseover":case"mouseout":Zs=null;break;case"pointerover":case"pointerout":Go.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Wo.delete(s.pointerId)}}function Ko(n,s,o,d,y,b){return n===null||n.nativeEvent!==b?(n={blockedOn:s,domEventName:o,eventSystemFlags:d,nativeEvent:b,targetContainers:[y]},s!==null&&(s=za(s),s!==null&&lb(s)),n):(n.eventSystemFlags|=d,s=n.targetContainers,y!==null&&s.indexOf(y)===-1&&s.push(y),n)}function NN(n,s,o,d,y){switch(s){case"focusin":return Qs=Ko(Qs,n,s,o,d,y),!0;case"dragenter":return Xs=Ko(Xs,n,s,o,d,y),!0;case"mouseover":return Zs=Ko(Zs,n,s,o,d,y),!0;case"pointerover":var b=y.pointerId;return Go.set(b,Ko(Go.get(b)||null,n,s,o,d,y)),!0;case"gotpointercapture":return b=y.pointerId,Wo.set(b,Ko(Wo.get(b)||null,n,s,o,d,y)),!0}return!1}function db(n){var s=Sa(n.target);if(s!==null){var o=c(s);if(o!==null){if(s=o.tag,s===13){if(s=u(o),s!==null){n.blockedOn=s,zr(n.priority,function(){ob(o)});return}}else if(s===31){if(s=m(o),s!==null){n.blockedOn=s,zr(n.priority,function(){ob(o)});return}}else if(s===3&&o.stateNode.current.memoizedState.isDehydrated){n.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}n.blockedOn=null}function ad(n){if(n.blockedOn!==null)return!1;for(var s=n.targetContainers;0<s.length;){var o=Rp(n.nativeEvent);if(o===null){o=n.nativeEvent;var d=new o.constructor(o.type,o);_s=d,o.target.dispatchEvent(d),_s=null}else return s=za(o),s!==null&&lb(s),n.blockedOn=o,!1;s.shift()}return!0}function fb(n,s,o){ad(n)&&o.delete(s)}function TN(){Lp=!1,Qs!==null&&ad(Qs)&&(Qs=null),Xs!==null&&ad(Xs)&&(Xs=null),Zs!==null&&ad(Zs)&&(Zs=null),Go.forEach(fb),Wo.forEach(fb)}function rd(n,s){n.blockedOn===s&&(n.blockedOn=null,Lp||(Lp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,TN)))}var sd=null;function mb(n){sd!==n&&(sd=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){sd===n&&(sd=null);for(var s=0;s<n.length;s+=3){var o=n[s],d=n[s+1],y=n[s+2];if(typeof d!="function"){if(Ip(d||o)===null)continue;break}var b=za(o);b!==null&&(n.splice(s,3),s-=3,Rm(b,{pending:!0,data:y,method:o.method,action:d},d,y))}}))}function zl(n){function s(Q){return rd(Q,n)}Qs!==null&&rd(Qs,n),Xs!==null&&rd(Xs,n),Zs!==null&&rd(Zs,n),Go.forEach(s),Wo.forEach(s);for(var o=0;o<Js.length;o++){var d=Js[o];d.blockedOn===n&&(d.blockedOn=null)}for(;0<Js.length&&(o=Js[0],o.blockedOn===null);)db(o),o.blockedOn===null&&Js.shift();if(o=(n.ownerDocument||n).$$reactFormReplay,o!=null)for(d=0;d<o.length;d+=3){var y=o[d],b=o[d+1],N=y[gn]||null;if(typeof b=="function")N||mb(o);else if(N){var L=null;if(b&&b.hasAttribute("formAction")){if(y=b,N=b[gn]||null)L=N.formAction;else if(Ip(y)!==null)continue}else L=N.action;typeof L=="function"?o[d+1]=L:(o.splice(d,3),d-=3),mb(o)}}}function pb(){function n(b){b.canIntercept&&b.info==="react-transition"&&b.intercept({handler:function(){return new Promise(function(N){return y=N})},focusReset:"manual",scroll:"manual"})}function s(){y!==null&&(y(),y=null),d||setTimeout(o,20)}function o(){if(!d&&!navigation.transition){var b=navigation.currentEntry;b&&b.url!=null&&navigation.navigate(b.url,{state:b.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var d=!1,y=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",s),navigation.addEventListener("navigateerror",s),setTimeout(o,100),function(){d=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",s),navigation.removeEventListener("navigateerror",s),y!==null&&(y(),y=null)}}}function Op(n){this._internalRoot=n}id.prototype.render=Op.prototype.render=function(n){var s=this._internalRoot;if(s===null)throw Error(i(409));var o=s.current,d=Wa();sb(o,d,n,s,null,null)},id.prototype.unmount=Op.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var s=n.containerInfo;sb(n.current,2,null,n,null,null),Pu(),s[Xn]=null}};function id(n){this._internalRoot=n}id.prototype.unstable_scheduleHydration=function(n){if(n){var s=va();n={blockedOn:null,target:n,priority:s};for(var o=0;o<Js.length&&s!==0&&s<Js[o].priority;o++);Js.splice(o,0,n),o===0&&db(n)}};var hb=t.version;if(hb!=="19.2.7")throw Error(i(527,hb,"19.2.7"));J.findDOMNode=function(n){var s=n._reactInternals;if(s===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=h(s),n=n!==null?g(n):null,n=n===null?null:n.stateNode,n};var MN={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ld=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ld.isDisabled&&ld.supportsFiber)try{Ne=ld.inject(MN),Re=ld}catch{}}return Qo.createRoot=function(n,s){if(!l(n))throw Error(i(299));var o=!1,d="",y=wy,b=Sy,N=jy;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(d=s.identifierPrefix),s.onUncaughtError!==void 0&&(y=s.onUncaughtError),s.onCaughtError!==void 0&&(b=s.onCaughtError),s.onRecoverableError!==void 0&&(N=s.onRecoverableError)),s=ab(n,1,!1,null,null,o,d,null,y,b,N,pb),n[Xn]=s.current,gp(n),new Op(s)},Qo.hydrateRoot=function(n,s,o){if(!l(n))throw Error(i(299));var d=!1,y="",b=wy,N=Sy,L=jy,Q=null;return o!=null&&(o.unstable_strictMode===!0&&(d=!0),o.identifierPrefix!==void 0&&(y=o.identifierPrefix),o.onUncaughtError!==void 0&&(b=o.onUncaughtError),o.onCaughtError!==void 0&&(N=o.onCaughtError),o.onRecoverableError!==void 0&&(L=o.onRecoverableError),o.formState!==void 0&&(Q=o.formState)),s=ab(n,1,!0,s,o??null,d,y,Q,b,N,L,pb),s.context=rb(null),o=s.current,d=Wa(),d=Hn(d),y=zs(d),y.callback=null,$s(o,y,d),o=d,s.current.lanes=o,Bn(s,o),qr(s),n[Xn]=s.current,gp(n),new id(s)},Qo.version="19.2.7",Qo}var Cb;function UN(){if(Cb)return zp.exports;Cb=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(),zp.exports=DN(),zp.exports}var zN=UN();const Iw={appName:"PenguinHarness",nav:{chat:"对话",newChat:"新对话",agents:"智能体",skills:"技能库",models:"模型库",usage:"成本中心",traces:"轨迹观测",benchmark:"评估中心",lastConversation:"最近一次对话",collapseSidebar:"收起侧栏",expandSidebar:"展开侧栏",collapseGroup:"折叠",expandGroup:"展开",pinGroup:"置顶分组",unpinGroup:"取消置顶"},settings:{language:"语言",showCliSessions:"显示 CLI 会话",proxyMenu:"代理选项",proxyDialogTitle:"代理选项",proxyForApp:"应用程序使用代理",proxyForAgent:"Agent 环境使用代理",proxyAddress:"代理地址",proxyAddressPlaceholder:"留空 = 跟随系统代理",uploadLimitsMenu:"上传限制",uploadLimitsDialogTitle:"上传限制",attachmentMaxMb:"单个附件上限(MB)",attachmentTotalMb:"单条消息附件合计上限(MB)",uploadLimitsHint:(e,t,a,i)=>`取值 ${e}–${t} MB,合计不得低于单个上限。一条消息最多 ${a} 个附件;对话内嵌图片另有 ${i}MB 上限,不随此设置变化——图片会进入对话与轨迹,每次翻阅历史与恢复会话都要重新付出它的体积。`,theme:"主题",themeLight:"浅色",themeDark:"深色",followSystem:"跟随系统",langZh:"中文",langEn:"English",fontSize:"字号",fontSmall:"小",fontMedium:"中",fontLarge:"大",accent:"主题色",accentNames:{neutral:"灰白",blue:"蓝",green:"绿",violet:"紫",rose:"红",amber:"橙"}},update:{lastUpdated:e=>`最近更新日期 ${e}`,newVersionBadge:"有新版本可用",newVersion:e=>`新版本 v${e} 可用`,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:"只有管理员可以在这里执行更新。"},notify:{taskCompleteTitle:"任务完成",taskCompleteBody:e=>`「${e}」已完成,点击查看`},common:{save:"保存",cancel:"取消",create:"创建",delete:"删除",edit:"编辑",settings:"设置",confirm:"确认",close:"关闭",loading:"加载中…",saved:"已保存",saving:"保存中…",noChangesToSave:"当前没有需要保存的修改",confirmSaveTitle:"保存修改",confirmSaveBody:"确定保存这些修改吗?修改将写入服务器上的配置文件。",none:"(无)",retry:"重试",unknownError:"请求失败,请稍后重试",requiredField:"此项必填",copied:"已复制",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 固定以「用户名-」为前缀,后接小写字母、数字或下划线;创建后不可修改",name:"显示名(可选,缺省为 Project id)",displayName:"显示名",settings:"Project 设置",settingsTitle:"Project 设置",members:"成员",addMember:"添加成员",removeMember:"移除",chatDefaultsTitle:"新对话默认值",chatDefaultsHint:"新建对话时预填的默认值:Agent、工作目录、审批模式、思考等级与默认模型。",chatDefaultsAgent:"Agent",chatDefaultsNotSet:"未设置",chatDefaultsApprovalNotSet:"未设置(默认全部放行)",chatDefaultsThinkingNotSet:"未设置(跟随智能体配置)",chatDefaultsWorkspaceHint:"留空表示使用临时工作区",chatDefaultsModelHint:"与模型页的默认模型同步",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:"描述",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 等认证头)",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 a=t!==void 0?`(${(t/1e3).toFixed(1)}s)`:"";return e===0?`连接成功,但该 Server 未暴露任何工具${a}`:`连接成功,发现 ${e} 个工具${a}`},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:"内核有更新",kernelUpToDate:"已是最新",kernelUpdateTitle:"更新内核",kernelCurrent:"当前",kernelLatest:"最新",kernelUpdateAction:"更新内核",kernelUpdateConfirmBody:"将把未自定义的字段更新为当前内置默认值;自定义过的字段保持不变并在结果中列出。名称、描述、版本号与 MCP Server 不受影响。确认继续?",kernelUpdateDone:(e,t)=>t>0?`内核已更新至 ${e},${t} 个字段跟进新默认`:`内核已更新至 ${e},字段均已是当前默认或保持自定义`,kernelUpdateKeptIntro:"以下字段因自定义被保留:",kernelListSeparator:"、",kernelFieldTool:e=>`工具 ${e}`,kernelFields:{system_prompt:"系统提示词模板",max_turns:"单任务最大轮数","model.max_tokens":"模型最大输出 Token","model.thinking_level":"思考力度","model.timeoutMs":"请求超时","compaction.max_context_length":"压缩上下文阈值","compaction.max_session_turns":"压缩会话轮数阈值","compaction.mode":"压缩模式","compaction.prompt":"压缩提示词","memory.enabled":"记忆开关","memory.prompt":"记忆提示词","memory.workspace_prompt":"工作区记忆提示词","vault.enabled":"Vault 小节开关","vault.prompt":"Vault 提示词","skills.enabled":"技能小节开关","skills.prompt":"技能提示词","schedules.enabled":"定时任务小节开关","schedules.prompt":"定时任务提示词"}},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 同语义:接口协议可手动选择,也可按 base URL 检测(base URL 必填,API key 留空按所选协议读取 OPENAI_* / ANTHROPIC_* 环境变量)。分组由模型条目承载,保存首个模型后即出现。",groupNameLabel:"分组名",groupNameHint:"小写字母 / 数字开头,可含 - 与 _",groupNameInvalid:"分组名只能用小写字母、数字、- 与 _(首字符为字母或数字),长度不超过 32",groupNameExists:"该分组名已被内置分组或既有条目占用",groupEmptyHint:"该分组暂无模型,点「新增模型」添加",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:"统一配置 API key",groupApiKeyTitle:e=>`为「${e}」统一配置 API key`,groupApiKeyHint:e=>`将写入该分组下全部 ${e} 个模型;留空不改动。`,getApiKey:"获取 API key",getModelIds:"获取模型 id",groupKeyApplied:e=>`已为 ${e} 个模型配置 API 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",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:"添加",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:"修改要求:"},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 安装该技能后才能快捷调用",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 分组",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:"搭建和优化智能体"},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 自测一次。`},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-creation\` 和 \`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`"}},sessionList:"Session",defaultSessionTitle:"新对话",model:"Model",workspace:"Workspace",workspaceHint:"留空自动创建临时工作区;指定时必须是服务器上已存在的目录",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:"自动",thinking:"思考",subagent:"子会话",subagentRunning:"运行中",aborted:e=>`[已中断]${e?`:${e}`:""}`,modelAuthDead:"模型 API 认证失败:请在模型配置页更新该模型的 API key,或新建会话。",modelAuthDeadOpenModels:"打开模型配置",modelAuthDeadRetry:"重试",modelAuthDeadCta:"新建会话",modelAuthDeadPlaceholder:"模型认证失败,请先更新 API key",reconnect:(e,t,a,i)=>{const l=e==="timeout"?"连接超时或网络中断":e==="malformed"?"响应不完整或无法解析":"模型服务返回错误",c=t==="gaveUp"?"已停止重试":t==="retried"?`已发起第 ${a} 次重试`:i!==void 0?`第 ${a} 次重试,${i} 秒后发起…`:`正在发起第 ${a} 次重试…`;return`[重试] ${l},${c}`},reconnectRetryNow:"立即重试",reconnectGiveUp:"放弃",imageAlt:"用户上传的图片",toolImageAlt:"工具输出的图片",imagesAsPathHint:"当前模型不支持直接查看图片:发送时图片将保存到会话临时目录,以文件路径转交(模型经 describe_image 查看)",infoPanel:"Session 信息",sessionStats:"统计",sessionIdLabel:"Session id",copySessionId:"复制 Session id",traceFile:"轨迹文件",copyTracePath:"复制完整路径",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:"移除图片",openWorkspace:"打开工作区",openAgents:"智能体面板",filesInMessage:e=>`${e} 个文件`,imagesInMessage:e=>`${e} 张图片`,openPreview:"点击预览",showMoreFiles:e=>`显示其余 ${e} 个文件`,showLess:"收起",moreGroups:e=>`更多分组(${e})`,contextUsage:"上下文占用",contextUnknown:"上下文占用:压缩后待下次请求回报",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}」触发`,emptyGreeting:"开始一段新对话",mcpConnectTitle:"MCP 连接",mcpServerList:e=>e.join("、"),mcpConnectResult:(e,t)=>{const a=[];return(e>0||t.length===0)&&a.push(`发现 ${e} 个工具`),t.length>0&&a.push(`不可用:${t.join("、")}`),a.join(";")},mcpToolsCount:e=>`${e} 个工具`,mcpServerFailed:"连接失败",mcpConnectAborted:"已中断,下次发送时重新连接",compactionTitle:e=>e==="discard"?"清空":"压缩",compactionFailed:(e,t)=>e==="aborted"?"已中断,保留当前上下文":t!==void 0?`失败(${t}),保留当前上下文`:"失败,保留当前上下文",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:"已置顶",loadMore:"更多",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:"已中断"}},subagentPanel:{title:"智能体面板",topologyLabel:"调用关系",mainSessionNote:"主会话请在对话区查看",empty:"本次任务尚未派生子智能体",nodeRunning:"运行中",nodeDone:"已完成"},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:"返回列表",resizeHandle:"拖拽调整宽度,双击恢复默认"},usage:{title:"成本与统计",today:"今日",last7d:"近 7 天",total:"累计",tokens:"Token",requests:"Requests",from:"起始日期",to:"结束日期",colCacheRead:"cache_read",colCacheWrite:"cache_write",colOutput:"output",uncostedNote:"* 只计入配置了价格的模型成本",filterAllAgents:"全部 Agent",filterAllModels:"全部模型",chartAgentCalls:"各 Agent 调用次数",chartSuccessRate:"各模型成功率",chartTokenTrend:"Token 逐日变化",chartCostTrend:"成本逐日变化",empty:"暂无用量记录",successAborted:"已中断(不计入)",errors:"异常",errorsTotal:"总数",errorsUnexpected:"未预期",errorsExpected:"预期内",errorsTopCode:"最常见",errorsColCode:"来源 · 错误码",errorsColKind:"类型",errorsColMessage:"消息",errorsEmpty:"暂无异常",errorsNewer:"较新",errorsOlder:"更早",errorsPageOf:(e,t,a)=>`第 ${e} / ${t} 页 · 共 ${a} 条`},traces:{title:"轨迹观测",timeline:"执行时间线",laneLLM:"模型",kindThinking:"思考",kindModelReply:"模型回复",kindToolGen:"工具调用生成",legendToolExec:"工具调用执行",legendOther:"其他",toolParams:"参数 Schema",legendApprovalWait:"审批等待",task:e=>`第 ${e} 轮`,globalSummary:"全局统计",tasksLabel:"轮次",messages:"消息",truncatedNote:(e,t)=>`仅展示前 ${e} / ${t} 条消息`,zoom:"缩放",zoomReset:"双击复位缩放",zoomOut:"缩小",zoomIn:"放大",linkHint:"鼠标移到时间线段或消息行即可联动高亮,点击时间线段跳转到对应消息;图例可高亮同类;拖动下方滑块平移/缩放",filesTitle:"Trace 文件",selectSession:"在左侧选择一个 Session",toolCalls:"工具调用",taskInput:"本轮输入 tokens",taskOutput:"本轮输出 tokens",cacheHit:"命中缓存",hitRate:"命中率",compactions:"压缩次数",empty:"该 Agent 暂无 Trace",inProgress:"进行中",systemPrompt:"系统提示词",toolDefs:e=>`工具定义(${e})`,exportFile:"导出",importTrace:"导入 Trace",importAgent:"导入到 Agent",importPickFile:"选择文件",importing:"导入中…",fileTooLarge:"文件超过 14MB 上限。"},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 的所有者。",schedule_exists:"已存在同名定时任务。",schedule_not_found:"该定时任务已不存在。",unknown_skill:"该技能不在技能库中。",skill_too_large:"该技能目录过大,超出了导入限制。",file_not_found:"该文件已不存在。",not_pending:"该消息已发出,无法撤回。",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。"}}};let f=Iw;function $N(e){f=e}const PN={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"},settings:{language:"Language",showCliSessions:"Show CLI sessions",proxyMenu:"Proxy options…",proxyDialogTitle:"Proxy options",proxyForApp:"Application uses the proxy",proxyForAgent:"Agent environment uses the proxy",proxyAddress:"Proxy address",proxyAddressPlaceholder:"Empty = follow system proxy",uploadLimitsMenu:"Upload limits…",uploadLimitsDialogTitle:"Upload limits",attachmentMaxMb:"Max attachment size (MB)",attachmentTotalMb:"Max total per message (MB)",uploadLimitsHint:(e,t,a,i)=>`${e}–${t} MB; the total may not be below the per-file limit. A message may carry at most ${a} attachments. Images placed inline in the conversation keep a separate ${i}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",themeLight:"Light",themeDark:"Dark",followSystem:"System",langZh:"中文",langEn:"English",fontSize:"Font size",fontSmall:"S",fontMedium:"M",fontLarge:"L",accent:"Accent",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`,checkNow:"Check for updates",checking:"Checking…",foundNew:e=>`New version v${e} found — use the update entry below 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."},notify:{taskCompleteTitle:"Task completed",taskCompleteBody:e=>`"${e}" has finished — click to view`},common:{save:"Save",cancel:"Cancel",create:"Create",delete:"Delete",edit:"Edit",settings:"Settings",confirm:"Confirm",close:"Close",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",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.",name:"Display name (optional, defaults to the Project id)",displayName:"Display 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)",chatDefaultsWorkspaceHint:"Empty = temporary workspace",chatDefaultsModelHint:"Same default model as the Models page",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",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)",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 a=t!==void 0?` (${(t/1e3).toFixed(1)}s)`:"";return e===0?`Connected, but the server exposes no tools${a}`:`Connected — ${e} tool${e===1?"":"s"}${a}`},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",kernelUpToDate:"Up to date",kernelUpdateTitle:"Update kernel",kernelCurrent:"current",kernelLatest:"latest",kernelUpdateAction:"Update kernel",kernelUpdateConfirmBody:"Fields you have not customized will be updated to the current built-in defaults; customized fields stay unchanged and are 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} field(s) now follow the new defaults`:`Kernel updated to ${e}; every field was already current or kept as customized`,kernelUpdateKeptIntro:"Kept because customized:",kernelListSeparator:", ",kernelFieldTool:e=>`tool ${e}`,kernelFields:{system_prompt:"system prompt template",max_turns:"max turns per task","model.max_tokens":"model max output tokens","model.thinking_level":"thinking level","model.timeoutMs":"request timeout","compaction.max_context_length":"compaction context threshold","compaction.max_session_turns":"compaction session-turn threshold","compaction.mode":"compaction mode","compaction.prompt":"compaction prompt","memory.enabled":"memory switch","memory.prompt":"memory prompt","memory.workspace_prompt":"workspace memory prompt","vault.enabled":"Vault section switch","vault.prompt":"Vault prompt","skills.enabled":"Skills section switch","skills.prompt":"Skills prompt","schedules.enabled":"Schedules section switch","schedules.prompt":"Schedules prompt"}},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: the protocol is picked manually or detected from the base URL (base URL required; an empty API key reads the OPENAI_* / ANTHROPIC_* env vars per the chosen protocol). Groups live on model entries — the group appears once its first model is saved.",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",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 API key for group",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:"Get API key",getModelIds:"Get model IDs",groupKeyApplied:e=>`API key set for ${e} models`,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",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",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 (optional — 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: "},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 (optional)",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 (optional; a temporary workspace is created when empty)",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",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",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"},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.`},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-creation\` 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`"}},sessionList:"Sessions",defaultSessionTitle:"New chat",model:"Model",workspace:"Workspace",workspaceHint:"Leave empty for an auto-created temporary workspace; if set, it must be an existing directory on the server",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",thinking:"Thinking",subagent:"Subagent",subagentRunning:"Running",aborted:e=>`[Aborted]${e?`: ${e}`:""}`,modelAuthDead:"Model API authentication failed: update this model's API key on the Models page, or start a new Session.",modelAuthDeadOpenModels:"Open Models page",modelAuthDeadRetry:"Retry",modelAuthDeadCta:"New Session",modelAuthDeadPlaceholder:"Model authentication failed — update the API key first",reconnect:(e,t,a,i)=>{const l=e==="timeout"?"Connection timed out":e==="malformed"?"Response incomplete or unparseable":"The model provider returned an error",c=t==="gaveUp"?"no further retries":t==="retried"?`retry #${a} sent`:i!==void 0?`retry #${a} in ${i}s…`:`starting retry #${a}…`;return`[Retry] ${l}; ${c}`},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",traceFile:"Trace file",copyTracePath:"Copy full path",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",openWorkspace:"Open workspace",openAgents:"Agents panel",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",moreGroups:e=>`More groups (${e})`,contextUsage:"Context usage",contextUnknown:"Context usage: unknown until the next request reports it",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}"`,emptyGreeting:"Start a new conversation",mcpConnectTitle:"MCP connect",mcpServerList:e=>e.join(", "),mcpConnectResult:(e,t)=>{const a=[];return(e>0||t.length===0)&&a.push(`${e} tool${e===1?"":"s"} discovered`),t.length>0&&a.push(`unavailable: ${t.join(", ")}`),a.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)=>e==="aborted"?"aborted, keeping current context":t!==void 0?`failed (${t}), keeping current context`:"failed, 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",loadMore:"More",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"}},subagentPanel:{title:"Agents panel",topologyLabel:"Call graph",mainSessionNote:"The main conversation stays in the chat area",empty:"No subagents in the current task yet",nodeRunning:"running",nodeDone:"done"},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",resizeHandle:"Drag to resize, double-click to reset"},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",chartAgentCalls:"Calls per agent",chartSuccessRate:"Model success rate",chartTokenTrend:"Daily token trend",chartCostTrend:"Daily cost trend",empty:"No usage records",successAborted:"Aborted (excluded)",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,a)=>`Page ${e} / ${t} · ${a} total`},traces:{title:"Traces",timeline:"Execution timeline",laneLLM:"Model",kindThinking:"thinking",kindModelReply:"model reply",kindToolGen:"tool call gen",legendToolExec:"tool exec",legendOther:"Other",toolParams:"Parameter schema",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",selectSession:"Select a Session on the left",toolCalls:"Tool calls",taskInput:"Input tokens this turn",taskOutput:"Output tokens this turn",cacheHit:"Cache hits",hitRate:"Hit rate",compactions:"compactions",empty:"No Traces for this agent",inProgress:"in progress",systemPrompt:"System prompt",toolDefs:e=>`Tool definitions (${e})`,exportFile:"Export",importTrace:"Import Trace",importAgent:"Import into Agent",importPickFile:"Choose file",importing:"Importing…",fileTooLarge:"The file exceeds the 14MB limit."},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.",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 message already went out 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."}}},Lw="penguin.lang",Ow=x.createContext(null);function BN(e){return e?.toLowerCase().startsWith("zh")?"zh":"en"}function HN(){return BN(navigator.language)}function FN(e){return e==="system"?HN():e}function VN(){const e=localStorage.getItem(Lw);return e==="zh"||e==="en"||e==="system"?e:"system"}function qN({children:e}){const[t,a]=x.useState(VN),[,i]=x.useState(0),l=FN(t);$N(l==="en"?PN:Iw),x.useEffect(()=>{if(t!=="system")return;const u=()=>i(m=>m+1);return window.addEventListener("languagechange",u),()=>window.removeEventListener("languagechange",u)},[t]);const c=x.useCallback(u=>{localStorage.setItem(Lw,u),a(u)},[]);return r.jsx(Ow.Provider,{value:{lang:t,locale:l,setLang:c},children:e})}function GN({children:e}){const{locale:t}=Za();return r.jsx("div",{className:"contents",children:e},t)}function Za(){const e=x.useContext(Ow);if(!e)throw new Error("useLocale must be used within a LocaleProvider");return e}const _g=7,Dw="penguin.theme",Uw="penguin.fontScale",zw="penguin.accent",$w="penguin.currency",WN={sm:"16px",md:"18px",lg:"20px"},Pw=x.createContext(null);function KN(){const e=localStorage.getItem(Dw);return e==="light"||e==="dark"||e==="system"?e:"system"}function YN(){const e=localStorage.getItem(Uw);return e==="sm"||e==="md"||e==="lg"?e:"md"}function QN(){const e=localStorage.getItem(zw);return e==="neutral"||e==="blue"||e==="green"||e==="violet"||e==="rose"||e==="amber"?e:"neutral"}function XN(){return localStorage.getItem($w)==="CNY"?"CNY":"USD"}function ZN(){return window.matchMedia("(prefers-color-scheme: dark)").matches}function JN({children:e}){const[t,a]=x.useState(KN),[i,l]=x.useState(ZN),[c,u]=x.useState(YN),[m,p]=x.useState(QN),[h,g]=x.useState(XN),v=t==="system"?i:t==="dark";x.useEffect(()=>{document.documentElement.classList.toggle("dark",v)},[v]),x.useEffect(()=>{document.documentElement.style.fontSize=WN[c]},[c]),x.useEffect(()=>{m==="neutral"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=m},[m]),x.useEffect(()=>{if(t!=="system")return;const C=window.matchMedia("(prefers-color-scheme: dark)"),T=I=>l(I.matches);return l(C.matches),C.addEventListener("change",T),()=>C.removeEventListener("change",T)},[t]);const k=x.useCallback(C=>{localStorage.setItem(Dw,C),a(C)},[]),w=x.useCallback(C=>{localStorage.setItem(Uw,C),u(C)},[]),S=x.useCallback(C=>{localStorage.setItem(zw,C),p(C)},[]),M=x.useCallback(C=>{localStorage.setItem($w,C),g(C)},[]);return r.jsx(Pw.Provider,{value:{mode:t,dark:v,setMode:k,fontScale:c,setFontScale:w,accent:m,setAccent:S,currency:h,setCurrency:M},children:e})}function mi(){const e=x.useContext(Pw);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}const e4=[{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 sa extends Error{status;code;constructor(t,a,i){super(i),this.name="ApiError",this.status=t,this.code=a}}let Bw=null;function Nb(e){Bw=e}function t4(e){return e.startsWith("/api/auth/")}async function Le(e,t={}){return(await Hw(e,t)).data}async function Hw(e,t={}){let a=e;if(t.query){const m=new URLSearchParams;for(const[h,g]of Object.entries(t.query))g!==void 0&&m.set(h,String(g));const p=m.toString();p&&(a+=`?${p}`)}let i;try{i=await fetch(a,{method:t.method??"GET",credentials:"same-origin",...t.body!==void 0?{headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)}:{}})}catch{throw new sa(0,"network_error",f.errors.networkError)}if(!i.ok){let m="http_error",p=f.common.unknownError;try{const h=await i.json();h.error?.code&&(m=h.error.code),h.error?.message&&(p=h.error.message)}catch{}throw i.status===401&&!t4(e)&&Bw?.(),new sa(i.status,m,p)}const l=Date.parse(i.headers.get("date")??""),c=Number.isFinite(l)?l:null;if(i.status===204)return{data:void 0,serverNowMs:c};const u=await i.text();return u?{data:JSON.parse(u),serverNowMs:c}:{data:void 0,serverNowMs:c}}const n4=e=>Le("/api/auth/login",{method:"POST",body:e}),a4=()=>Le("/api/auth/logout",{method:"POST",body:{}}),Ld=()=>Le("/api/me"),r4=e=>Le("/api/me/password",{method:"PUT",body:e}),Rg=()=>Le("/api/me/prefs"),pf=e=>Le("/api/me/prefs",{method:"PUT",body:e}),s4=()=>Le("/api/admin/users"),i4=e=>Le("/api/admin/users",{method:"POST",body:e}),l4=(e,t)=>Le(`/api/admin/users/${encodeURIComponent(e)}/password`,{method:"POST",body:t}),o4=e=>Le(`/api/admin/users/${encodeURIComponent(e)}`,{method:"DELETE"}),Fw=()=>Le("/api/admin/settings"),Vw=e=>Le("/api/admin/settings",{method:"PUT",body:e}),c4=()=>Le("/api/projects"),u4=e=>Le("/api/projects",{method:"POST",body:e}),d4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}`,{method:"PATCH",body:t}),f4=e=>Le(`/api/projects/${encodeURIComponent(e)}`,{method:"DELETE"}),Hp=e=>Le(`/api/projects/${encodeURIComponent(e)}/members`),m4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/members`,{method:"POST",body:t}),p4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:"DELETE"}),qw=e=>Le(`/api/projects/${encodeURIComponent(e)}/chat-defaults`),h4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/chat-defaults`,{method:"PUT",body:t}),Yl=e=>Le(`/api/projects/${encodeURIComponent(e)}/models`),g4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/models`,{method:"PUT",body:t}),x4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/models/default`,{method:"PUT",body:t}),Gw=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/models/test`,{method:"POST",body:t}),y4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/models/detect`,{method:"POST",body:t}),v4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/models/detect-vision`,{method:"POST",body:t}),b4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault`),k4=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault`,{method:"PUT",body:a}),w4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/vault/template-placeholder`,{method:"POST",body:{}}),S4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/template-placeholder`,{method:"POST",body:{}}),j4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/template-placeholder`,{method:"POST",body:{}}),Ig=(e,t)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/memory`,Lg=(e,t,a)=>`${Ig(e,t)}/scopes/${encodeURIComponent(a)}/files`,C4=(e,t)=>Le(Ig(e,t)),N4=(e,t)=>Le(`${Ig(e,t)}/template-placeholder`,{method:"POST",body:{}}),T4=(e,t,a)=>Le(Lg(e,t,a)),M4=(e,t,a,i)=>Le(`${Lg(e,t,a)}/${encodeURIComponent(i)}`),A4=(e,t,a,i)=>Le(`${Lg(e,t,a)}/${encodeURIComponent(i)}`,{method:"DELETE"}),E4=e=>Le(`/api/projects/${encodeURIComponent(e)}/agents`),_4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents`,{method:"POST",body:t}),el=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config`),Zi=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config`,{method:"PUT",body:a}),Tb=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/mcp-test`,{method:"POST",body:a}),R4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/reset`,{method:"POST"}),I4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/config/kernel-update`,{method:"POST"}),Ww=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces${a?`?limit=${a.limit}&offset=${a.offset}`+(a.category?`&category=${a.category}`:"")+(a.cli?"&cli=1":""):""}`),Oh=(e,t,a)=>{const i=a?`?limit=${a.limit}&offset=${a.offset}`+(a.category?`&category=${a.category}`:"")+(a.withCounts?"&counts=1":"")+(a.cli?"&cli=1":""):"";return Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/sessions${i}`)},L4=(e,t="")=>Le(`/api/projects/${encodeURIComponent(e)}/dirs?path=${encodeURIComponent(t)}`),Dh=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/sessions`,{method:"POST",body:a}),O4=(e,t)=>Le(`/api/sessions/${encodeURIComponent(e)}/fork`,{method:"POST",body:t}),Fp=e=>Le(`/api/sessions/${encodeURIComponent(e)}`),Pd=(e,t)=>Le(`/api/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:t}),Bd=e=>Le(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"}),Kw=(e,t)=>{const a=t===void 0?"":t.kind==="tail"?`?tailLimit=${t.limit}`:`?before=${encodeURIComponent(t.cursor)}&limit=${t.limit}`;return Hw(`/api/sessions/${encodeURIComponent(e)}/messages${a}`).then(({data:i,serverNowMs:l})=>({...i,serverNowMs:l}))},fc=(e,t)=>Le(`/api/sessions/${encodeURIComponent(e)}/tasks`,{method:"POST",body:t}),D4=e=>Le(`/api/sessions/${encodeURIComponent(e)}/goal`),U4=(e,t,a)=>Le(`/api/sessions/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{method:"POST",body:a}),z4=e=>Le(`/api/sessions/${encodeURIComponent(e)}/abort`,{method:"POST",body:{}}),$4=e=>Le(`/api/sessions/${encodeURIComponent(e)}/retry-now`,{method:"POST",body:{}}),Mb=e=>Le(`/api/sessions/${encodeURIComponent(e)}/processes`),P4=(e,t)=>Le(`/api/sessions/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}/kill`,{method:"POST",body:{}}),B4=(e,t)=>Le(`/api/sessions/${encodeURIComponent(e)}/processes/${encodeURIComponent(t)}`,{method:"DELETE"}),H4=(e,t)=>Le(`/api/sessions/${encodeURIComponent(e)}/steer`,{method:"POST",body:t}),F4=(e,t)=>Le(`/api/sessions/${encodeURIComponent(e)}/steer/${encodeURIComponent(t)}`,{method:"DELETE"}),V4=(e,t)=>Le(`/api/sessions/${encodeURIComponent(e)}/follow-ups/${encodeURIComponent(t)}`,{method:"DELETE"}),q4=e=>Le(`/api/sessions/${encodeURIComponent(e)}/compact`,{method:"POST",body:{}}),G4=(e,t,a,i,l,c)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(a)}/${i}`,{query:{offset:l,limit:c}}),W4=(e,t,a,i)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(a)}/${i}/analysis`),K4=(e,t,a,i)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/${encodeURIComponent(a)}/${i}/download`,Y4=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/traces/import`,{method:"POST",body:a}),Q4=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/usage/errors`,{query:{offset:String(t.offset),limit:String(t.limit),from:t.from,to:t.to,agentId:t.agentId}}),Yw=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/usage`,{query:{from:t.from,to:t.to,groupBy:t.groupBy,agentId:t.agentId,provider:t.provider,modelId:t.modelId}}),X4=(e,t)=>Le(`/api/projects/${e}/agents/${t}`,{method:"DELETE"}),Z4=(e,t)=>Le(`/api/sessions/${e}/files`,{query:{path:t}}),ti=(e,t,a=!1)=>`/api/sessions/${e}/files/content?path=${encodeURIComponent(t)}${a?"&download=1":""}`,Ab=(e,t)=>`/api/sessions/${e}/files/preview-redirect?path=${encodeURIComponent(t)}`,J4=(e,t,a)=>Le(`/api/sessions/${e}/files/content`,{method:"PUT",body:{dataBase64:a},query:{path:t}}),eT=(e,t)=>Le(`/api/sessions/${e}/files/stat`,{method:"POST",body:{paths:t}}),tT=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules`),nT=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules`,{method:"POST",body:a}),Eb=(e,t,a,i)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/${encodeURIComponent(a)}`,{method:"PUT",body:i}),aT=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/schedules/${encodeURIComponent(a)}`,{method:"DELETE"}),rT=()=>Le("/api/skills"),hf=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills`),_b=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills`,{method:"POST",body:{names:a}}),sT=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/archive`,{method:"POST",body:a}),iT=(e,t,a)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/${encodeURIComponent(a)}/archive`,Qw=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/skills/${encodeURIComponent(a)}`,{method:"DELETE"}),lT=(e,t)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks`),oT=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks/${encodeURIComponent(a)}/cases`),Xw=(e,t,a,i,l)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/benchmarks/${encodeURIComponent(a)}/cases/${encodeURIComponent(i)}${l==="rubric"?"/rubric":""}/files`,cT=(e,t,a,i,l,c)=>Le(Xw(e,t,a,i,c),{query:{path:l}}),uT=(e,t,a,i,l,c,u)=>`${Xw(e,t,a,i,c)}/content?path=${encodeURIComponent(l)}`+(u?.download?"&download=1":"")+(u?.preview&&!u.download?"&preview=1":""),dT=(e,t)=>`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/export`,fT=(e,t,a)=>Le(`/api/projects/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}/import`,{method:"POST",body:a}),mT=()=>Le("/api/version"),Zw=(e=!1)=>Le(`/api/version/update-check${e?"?force=1":""}`),pT=()=>Le("/api/version/update",{method:"POST",body:{}}),hT={attachmentMaxMb:100,attachmentTotalMb:120,attachmentMaxCount:20,imageMaxMb:20,attachmentLimitMinMb:1,attachmentLimitMaxMb:200},Jw=x.createContext(null);function gT({children:e}){const[t,a]=x.useState(void 0),[i,l]=x.useState(!0),[c,u]=x.useState(!1),[m,p]=x.useState("password"),[h,g]=x.useState(hT);x.useEffect(()=>(Nb(()=>a(null)),()=>Nb(null)),[]),x.useEffect(()=>{let S=!1;return Ld().then(M=>{S||(a(M.user),l(M.previewIsolated),u(M.desktopMode),p(M.sessionVia),g(M.uploadLimits))}).catch(M=>{S||(M instanceof sa&&M.status,a(null))}),()=>{S=!0}},[]);const v=x.useCallback(async(S,M)=>{const C=await n4({userId:S,password:M});a(C.user);try{const T=await Ld();a(T.user),l(T.previewIsolated),u(T.desktopMode),p(T.sessionVia),g(T.uploadLimits)}catch{}},[]),k=x.useCallback(async()=>{try{await a4()}finally{a(null)}},[]),w=x.useCallback(async()=>{const S=await Ld();a(S.user),l(S.previewIsolated),u(S.desktopMode),p(S.sessionVia),g(S.uploadLimits)},[]);return r.jsx(Jw.Provider,{value:{user:t,previewIsolated:i,desktopMode:c,sessionVia:m,uploadLimits:h,login:v,logout:k,refresh:w},children:e})}function vn(){const e=x.useContext(Jw);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const Og=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,e2=/^[\\/]{2}/;function xT(e,t){return t+e.replace(/\\/g,"/")}const Rb="popstate";function Ib(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function yT(e={}){function t(i,l){let c=l.state?.masked,{pathname:u,search:m,hash:p}=c||i.location;return Uh("",{pathname:u,search:m,hash:p},l.state&&l.state.usr||null,l.state&&l.state.key||"default",c?{pathname:i.location.pathname,search:i.location.search,hash:i.location.hash}:void 0)}function a(i,l){return typeof l=="string"?l:Nc(l)}return bT(t,a,null,e)}function on(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Zr(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function vT(){return Math.random().toString(36).substring(2,10)}function Lb(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 Uh(e,t,a=null,i,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?to(t):t,state:a,key:t&&t.key||i||vT(),mask:l}}function Nc({pathname:e="/",search:t="",hash:a=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function to(e){let t={};if(e){let a=e.indexOf("#");a>=0&&(t.hash=e.substring(a),e=e.substring(0,a));let i=e.indexOf("?");i>=0&&(t.search=e.substring(i),e=e.substring(0,i)),e&&(t.pathname=e)}return t}function bT(e,t,a,i={}){let{window:l=document.defaultView,v5Compat:c=!1}=i,u=l.history,m="POP",p=null,h=g();h==null&&(h=0,u.replaceState({...u.state,idx:h},""));function g(){return(u.state||{idx:null}).idx}function v(){m="POP";let C=g(),T=C==null?null:C-h;h=C,p&&p({action:m,location:M.location,delta:T})}function k(C,T){m="PUSH";let I=Ib(C)?C:Uh(M.location,C,T);h=g()+1;let D=Lb(I,h),K=M.createHref(I.mask||I);try{u.pushState(D,"",K)}catch(F){if(F instanceof DOMException&&F.name==="DataCloneError")throw F;l.location.assign(K)}c&&p&&p({action:m,location:M.location,delta:1})}function w(C,T){m="REPLACE";let I=Ib(C)?C:Uh(M.location,C,T);h=g();let D=Lb(I,h),K=M.createHref(I.mask||I);u.replaceState(D,"",K),c&&p&&p({action:m,location:M.location,delta:0})}function S(C){return kT(l,C)}let M={get action(){return m},get location(){return e(l,u)},listen(C){if(p)throw new Error("A history only accepts one active listener");return l.addEventListener(Rb,v),p=C,()=>{l.removeEventListener(Rb,v),p=null}},createHref(C){return t(l,C)},createURL:S,encodeLocation(C){let T=S(C);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:k,replace:w,go(C){return u.go(C)}};return M}function kT(e,t,a=!1){let i="http://localhost";e&&(i=e.location.origin!=="null"?e.location.origin:e.location.href),on(i,"No window.location.(origin|href) available to create URL");let l=typeof t=="string"?t:Nc(t);return l=l.replace(/ $/,"%20"),!a&&e2.test(l)&&(l=i+l),new URL(l,i)}function t2(e,t,a="/"){return wT(e,t,a,!1)}function wT(e,t,a,i,l){let c=ui((typeof t=="string"?to(t):t).pathname||"/",a);if(c==null)return null;let u=ST(e),m=null,p=i2(c);for(let h=0;m==null&&h<u.length;++h)m=OT(u[h],p,i);return m}function ST(e){let t=n2(e);return jT(t),t}function n2(e,t=[],a=[],i="",l=!1){let c=(u,m,p=l,h)=>{let g={relativePath:h===void 0?u.path||"":h,caseSensitive:u.caseSensitive===!0,childrenIndex:m,route:u};if(g.relativePath.startsWith("/")){if(!g.relativePath.startsWith(i)&&p)return;on(g.relativePath.startsWith(i),`Absolute route path "${g.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),g.relativePath=g.relativePath.slice(i.length)}let v=Lr([i,g.relativePath]),k=a.concat(g);u.children&&u.children.length>0&&(on(u.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),n2(u.children,t,k,v,p)),!(u.path==null&&!u.index)&&t.push({path:v,score:IT(v,u.index),routesMeta:k.map((w,S)=>{let[M,C]=s2(w.relativePath,w.caseSensitive,S===k.length-1);return{...w,matcher:M,compiledParams:C}})})};return e.forEach((u,m)=>{if(u.path===""||!u.path?.includes("?"))c(u,m);else for(let p of a2(u.path))c(u,m,!0,p)}),t}function a2(e){let t=e.split("/");if(t.length===0)return[];let[a,...i]=t,l=a.endsWith("?"),c=a.replace(/\?$/,"");if(i.length===0)return l?[c,""]:[c];let u=a2(i.join("/")),m=[];return m.push(...u.map(p=>p===""?c:[c,p].join("/"))),l&&m.push(...u),m.map(p=>e.startsWith("/")&&p===""?"/":p)}function jT(e){e.sort((t,a)=>t.score!==a.score?a.score-t.score:LT(t.routesMeta.map(i=>i.childrenIndex),a.routesMeta.map(i=>i.childrenIndex)))}const CT=/^:[\w-]+$/,NT=/^:[\w-]+/,TT=3.5,MT=3,AT=2,ET=1,_T=10,RT=-2,Ob=e=>e==="*";function IT(e,t){let a=e.split("/"),i=a.length;return a.some(Ob)&&(i+=RT),t&&(i+=AT),a.filter(l=>!Ob(l)).reduce((l,c)=>l+(CT.test(c)?MT:NT.test(c)?TT:c===""?ET:_T),i)}function LT(e,t){return e.length===t.length&&e.slice(0,-1).every((a,i)=>a===t[i])?e[e.length-1]-t[t.length-1]:0}function OT(e,t,a=!1){let{routesMeta:i}=e,l={},c="/",u=[];for(let m=0;m<i.length;++m){let p=i[m],h=m===i.length-1,g=c==="/"?t:t.slice(c.length)||"/",v={path:p.relativePath,caseSensitive:p.caseSensitive,end:h},k=p.matcher&&p.compiledParams?r2(v,g,p.matcher,p.compiledParams):Tc(v,g),w=p.route;if(!k&&h&&a&&!i[i.length-1].route.index&&(k=Tc({path:p.relativePath,caseSensitive:p.caseSensitive,end:!1},g)),!k)return null;Object.assign(l,k.params),u.push({params:l,pathname:Lr([c,k.pathname]),pathnameBase:zT(Lr([c,k.pathnameBase])),route:w}),k.pathnameBase!=="/"&&(c=Lr([c,k.pathnameBase]))}return u}function Tc(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[a,i]=s2(e.path,e.caseSensitive,e.end);return r2(e,t,a,i)}function r2(e,t,a,i){let l=t.match(a);if(!l)return null;let c=l[0],u=c.replace(/(.)\/+$/,"$1"),m=l.slice(1);return{params:i.reduce((p,{paramName:h,isOptional:g},v)=>{if(h==="*"){let w=m[v]||"";u=c.slice(0,c.length-w.length).replace(/(.)\/+$/,"$1")}const k=m[v];return g&&!k?p[h]=void 0:p[h]=(k||"").replace(/%2F/g,"/"),p},{}),pathname:c,pathnameBase:u,pattern:e}}function s2(e,t=!1,a=!0){Zr(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 i=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,u,m,p,h)=>{if(i.push({paramName:u,isOptional:m!=null}),m){let g=h.charAt(p+c.length);return g&&g!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(?=\/|$|\()/g,"(?:/$1)?");return e.endsWith("*")?(i.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),i]}function i2(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Zr(!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 ui(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let a=t.endsWith("/")?t.length-1:t.length,i=e.charAt(a);return i&&i!=="/"?null:e.slice(a)||"/"}function DT(e,t="/"){let{pathname:a,search:i="",hash:l=""}=typeof e=="string"?to(e):e,c;return a?(a=l2(a),a.startsWith("/")?c=Db(a.substring(1),"/"):c=Db(a,t)):c=t,{pathname:c,search:$T(i),hash:PT(l)}}function Db(e,t){let a=o2(t).split("/");return e.split("/").forEach(i=>{i===".."?a.length>1&&a.pop():i!=="."&&a.push(i)}),a.length>1?a.join("/"):"/"}function Vp(e,t,a,i){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function UT(e){return e.filter((t,a)=>a===0||t.route.path&&t.route.path.length>0)}function Dg(e){let t=UT(e);return t.map((a,i)=>i===t.length-1?a.pathname:a.pathnameBase)}function gf(e,t,a,i=!1){let l;typeof e=="string"?l=to(e):(l={...e},on(!l.pathname||!l.pathname.includes("?"),Vp("?","pathname","search",l)),on(!l.pathname||!l.pathname.includes("#"),Vp("#","pathname","hash",l)),on(!l.search||!l.search.includes("#"),Vp("#","search","hash",l)));let c=e===""||l.pathname==="",u=c?"/":l.pathname,m;if(u==null)m=a;else{let v=t.length-1;if(!i&&u.startsWith("..")){let k=u.split("/");for(;k[0]==="..";)k.shift(),v-=1;l.pathname=k.join("/")}m=v>=0?t[v]:"/"}let p=DT(l,m),h=u&&u!=="/"&&u.endsWith("/"),g=(c||u===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(h||g)&&(p.pathname+="/"),p}const l2=e=>e.replace(/[\\/]{2,}/g,"/"),Lr=e=>l2(e.join("/")),o2=e=>e.replace(/\/+$/,""),zT=e=>o2(e).replace(/^\/*/,"/"),$T=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,PT=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;var BT=class{status;statusText;data;error;internal;constructor(e,t,a,i=!1){this.status=e,this.statusText=t||"",this.internal=i,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function HT(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function FT(e){return Lr(e.map(t=>t.route.path).filter(Boolean))||"/"}const c2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function u2(e,t){let a=e;if(typeof a!="string"||!Og.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let i=a,l=!1;if(c2)try{let c=new URL(window.location.href),u=e2.test(a)?new URL(xT(a,c.protocol)):new URL(a),m=ui(u.pathname,t);u.origin===c.origin&&m!=null?a=m+u.search+u.hash:l=!0}catch{Zr(!1,`<Link to="${a}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:l,to:a}}const d2=["POST","PUT","PATCH","DELETE"];new Set(d2);const VT=["GET",...d2];new Set(VT);const qT=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function GT(e){try{return qT.includes(new URL(e).protocol)}catch{return!1}}const no=x.createContext(null);no.displayName="DataRouter";const xf=x.createContext(null);xf.displayName="DataRouterState";const f2=x.createContext(!1);function WT(){return x.useContext(f2)}const m2=x.createContext({isTransitioning:!1});m2.displayName="ViewTransition";const KT=x.createContext(new Map);KT.displayName="Fetchers";const YT=x.createContext(null);YT.displayName="Await";const jr=x.createContext(null);jr.displayName="Navigation";const Hc=x.createContext(null);Hc.displayName="Location";const Cr=x.createContext({outlet:null,matches:[],isDataRoute:!1});Cr.displayName="Route";const Ug=x.createContext(null);Ug.displayName="RouteError";const p2="REACT_ROUTER_ERROR",QT="REDIRECT",XT="ROUTE_ERROR_RESPONSE";function ZT(e){if(e.startsWith(`${p2}:${QT}:{`))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 JT(e){if(e.startsWith(`${p2}:${XT}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new BT(t.status,t.statusText,t.data)}catch{}}function eM(e,{relative:t}={}){on(tl(),"useHref() may be used only in the context of a <Router> component.");let{basename:a,navigator:i}=x.useContext(jr),{hash:l,pathname:c,search:u}=Fc(e,{relative:t}),m=c;return a!=="/"&&(m=c==="/"?a:Lr([a,c])),i.createHref({pathname:m,search:u,hash:l})}function tl(){return x.useContext(Hc)!=null}function ha(){return on(tl(),"useLocation() may be used only in the context of a <Router> component."),x.useContext(Hc).location}function h2(e){on(tl(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:t}=ha();return x.useMemo(()=>Tc(e,i2(t)),[t,e])}const g2="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ia(){let{isDataRoute:e}=x.useContext(Cr);return e?gM():tM()}function tM(){on(tl(),"useNavigate() may be used only in the context of a <Router> component.");let e=x.useContext(no),{basename:t,navigator:a}=x.useContext(jr),{matches:i}=x.useContext(Cr),{pathname:l}=ha(),c=JSON.stringify(Dg(i)),u=x.useRef(!1);return x.useLayoutEffect(()=>{u.current=!0}),x.useCallback((m,p={})=>{if(Zr(u.current,g2),!u.current)return;if(typeof m=="number"){a.go(m);return}let h=gf(m,JSON.parse(c),l,p.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:Lr([t,h.pathname])),(p.replace?a.replace:a.push)(h,p.state,p)},[t,a,c,l,e])}const nM=x.createContext(null);function aM(e){let t=x.useContext(Cr).outlet;return x.useMemo(()=>t&&x.createElement(nM.Provider,{value:e},t),[t,e])}function x2(){let{matches:e}=x.useContext(Cr);return e[e.length-1]?.params??{}}function Fc(e,{relative:t}={}){let{matches:a}=x.useContext(Cr),{pathname:i}=ha(),l=JSON.stringify(Dg(a));return x.useMemo(()=>gf(e,JSON.parse(l),i,t==="path"),[e,l,i,t])}function rM(e,t){return y2(e,t)}function y2(e,t,a){on(tl(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=x.useContext(jr),{matches:l}=x.useContext(Cr),c=l[l.length-1],u=c?c.params:{};c&&c.pathname;let m=c?c.pathnameBase:"/";c&&c.route;let p=ha(),h;if(t){let S=typeof t=="string"?to(t):t;on(m==="/"||S.pathname?.startsWith(m),`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 "${m}" but pathname "${S.pathname}" was given in the \`location\` prop.`),h=S}else h=p;let g=h.pathname||"/",v=g;if(m!=="/"){let S=m.replace(/^\//,"").split("/");v="/"+g.replace(/^\//,"").split("/").slice(S.length).join("/")}let k=a&&a.state.matches.length?a.state.matches.map(S=>Object.assign(S,{route:a.manifest[S.route.id]||S.route})):t2(e,{pathname:v}),w=uM(k&&k.map(S=>Object.assign({},S,{params:Object.assign({},u,S.params),pathname:Lr([m,i.encodeLocation?i.encodeLocation(S.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?m:Lr([m,i.encodeLocation?i.encodeLocation(S.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),l,a);return t&&w?x.createElement(Hc.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...h},navigationType:"POP"}},w):w}function sM(){let e=hM(),t=HT(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null;return x.createElement(x.Fragment,null,x.createElement("h2",null,"Unexpected Application Error!"),x.createElement("h3",{style:{fontStyle:"italic"}},t),a?x.createElement("pre",{style:{padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"}},a):null,null)}const iM=x.createElement(sM,null);var lM=class extends x.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static contextType=f2;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 a=JT(e.digest);a&&(e=a)}let t=e!==void 0?x.createElement(Cr.Provider,{value:this.props.routeContext},x.createElement(Ug.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?x.createElement(oM,{error:e},t):t}};const qp=new WeakMap;function oM({children:e,error:t}){let{basename:a}=x.useContext(jr);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let i=ZT(t.digest);if(i){let l=qp.get(t);if(l)throw l;let c=u2(i.location,a),u=c.absoluteURL||c.to;if(GT(u))throw new Error("Invalid redirect location");if(c2&&!qp.get(t))if(c.isExternal||i.reloadDocument)window.location.href=u;else{const m=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(c.to,{replace:i.replace}));throw qp.set(t,m),m}return x.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u}`})}}return e}function cM({routeContext:e,match:t,children:a}){let i=x.useContext(no);return i&&i.static&&i.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=t.route.id),x.createElement(Cr.Provider,{value:e},a)}function uM(e,t=[],a){let i=a?.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(t.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let l=e,c=i?.errors;if(c!=null){let g=l.findIndex(v=>v.route.id&&c?.[v.route.id]!==void 0);on(g>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(c).join(",")}`),l=l.slice(0,Math.min(l.length,g+1))}let u=!1,m=-1;if(a&&i){u=i.renderFallback;for(let g=0;g<l.length;g++){let v=l[g];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(m=g),v.route.id){let{loaderData:k,errors:w}=i,S=v.route.loader&&!k.hasOwnProperty(v.route.id)&&(!w||w[v.route.id]===void 0);if(v.route.lazy||S){a.isStatic&&(u=!0),m>=0?l=l.slice(0,m+1):l=[l[0]];break}}}}let p=a?.onError,h=i&&p?(g,v)=>{p(g,{location:i.location,params:i.matches?.[0]?.params??{},pattern:FT(i.matches),errorInfo:v})}:void 0;return l.reduceRight((g,v,k)=>{let w,S=!1,M=null,C=null;i&&(w=c&&v.route.id?c[v.route.id]:void 0,M=v.route.errorElement||iM,u&&(m<0&&k===0?(xM("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),S=!0,C=null):m===k&&(S=!0,C=v.route.hydrateFallbackElement||null)));let T=t.concat(l.slice(0,k+1)),I=()=>{let D;return w?D=M:S?D=C:v.route.Component?D=x.createElement(v.route.Component,null):v.route.element?D=v.route.element:D=g,x.createElement(cM,{match:v,routeContext:{outlet:g,matches:T,isDataRoute:i!=null},children:D})};return i&&(v.route.ErrorBoundary||v.route.errorElement||k===0)?x.createElement(lM,{location:i.location,revalidation:i.revalidation,component:M,error:w,children:I(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:h}):I()},null)}function zg(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function dM(e){let t=x.useContext(no);return on(t,zg(e)),t}function fM(e){let t=x.useContext(xf);return on(t,zg(e)),t}function mM(e){let t=x.useContext(Cr);return on(t,zg(e)),t}function $g(e){let t=mM(e),a=t.matches[t.matches.length-1];return on(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function pM(){return $g("useRouteId")}function hM(){let e=x.useContext(Ug),t=fM("useRouteError"),a=$g("useRouteError");return e!==void 0?e:t.errors?.[a]}function gM(){let{router:e}=dM("useNavigate"),t=$g("useNavigate"),a=x.useRef(!1);return x.useLayoutEffect(()=>{a.current=!0}),x.useCallback(async(i,l={})=>{Zr(a.current,g2),a.current&&(typeof i=="number"?await e.navigate(i):await e.navigate(i,{fromRouteId:t,...l}))},[e,t])}const Ub={};function xM(e,t,a){Ub[e]||(Ub[e]=!0,Zr(!1,a))}x.memo(yM);function yM({routes:e,manifest:t,future:a,state:i,isStatic:l,onError:c}){return y2(e,void 0,{manifest:t,state:i,isStatic:l,onError:c})}function Mc({to:e,replace:t,state:a,relative:i}){on(tl(),"<Navigate> may be used only in the context of a <Router> component.");let{static:l}=x.useContext(jr);Zr(!l,"<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}=x.useContext(Cr),{pathname:u}=ha(),m=ia(),p=gf(e,Dg(c),u,i==="path"),h=JSON.stringify(p);return x.useEffect(()=>{m(JSON.parse(h),{replace:t,state:a,relative:i})},[m,h,i,t,a]),null}function vM(e){return aM(e.context)}function Ra(e){on(!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 bM({basename:e="/",children:t=null,location:a,navigationType:i="POP",navigator:l,static:c=!1,useTransitions:u}){on(!tl(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let m=e.replace(/^\/*/,"/"),p=x.useMemo(()=>({basename:m,navigator:l,static:c,useTransitions:u,future:{}}),[m,l,c,u]);typeof a=="string"&&(a=to(a));let{pathname:h="/",search:g="",hash:v="",state:k=null,key:w="default",mask:S}=a,M=x.useMemo(()=>{let C=ui(h,m);return C==null?null:{location:{pathname:C,search:g,hash:v,state:k,key:w,mask:S},navigationType:i}},[m,h,g,v,k,w,i,S]);return Zr(M!=null,`<Router basename="${m}"> is not able to match the URL "${h}${g}${v}" because it does not start with the basename, so the <Router> won't render anything.`),M==null?null:x.createElement(jr.Provider,{value:p},x.createElement(Hc.Provider,{children:t,value:M}))}function kM({children:e,location:t}){return rM(zh(e),t)}function zh(e,t=[]){let a=[];return x.Children.forEach(e,(i,l)=>{if(!x.isValidElement(i))return;let c=[...t,l];if(i.type===x.Fragment){a.push.apply(a,zh(i.props.children,c));return}on(i.type===Ra,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`);let u=i.props;on(!u.index||!u.children,"An index route cannot have child routes.");let m={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&&(m.children=zh(u.children,c)),a.push(m)}),a}const Od="application/x-www-form-urlencoded";function yf(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function wM(e){return yf(e)&&e.tagName.toLowerCase()==="button"}function SM(e){return yf(e)&&e.tagName.toLowerCase()==="form"}function jM(e){return yf(e)&&e.tagName.toLowerCase()==="input"}function CM(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function NM(e,t){return e.button===0&&(!t||t==="_self")&&!CM(e)}function $h(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,a)=>{let i=e[a];return t.concat(Array.isArray(i)?i.map(l=>[a,l]):[[a,i]])},[]))}function TM(e,t){let a=$h(e);return t&&t.forEach((i,l)=>{a.has(l)||t.getAll(l).forEach(c=>{a.append(l,c)})}),a}let cd=null;function MM(){if(cd===null)try{new FormData(document.createElement("form"),0),cd=!1}catch{cd=!0}return cd}const AM=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Gp(e){return e!=null&&!AM.has(e)?(Zr(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Od}"`),null):e}function EM(e,t){let a,i,l,c,u;if(SM(e)){let m=e.getAttribute("action");i=m?ui(m,t):null,a=e.getAttribute("method")||"get",l=Gp(e.getAttribute("enctype"))||Od,c=new FormData(e)}else if(wM(e)||jM(e)&&(e.type==="submit"||e.type==="image")){let m=e.form;if(m==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let p=e.getAttribute("formaction")||m.getAttribute("action");if(i=p?ui(p,t):null,a=e.getAttribute("formmethod")||m.getAttribute("method")||"get",l=Gp(e.getAttribute("formenctype"))||Gp(m.getAttribute("enctype"))||Od,c=new FormData(m,e),!MM()){let{name:h,type:g,value:v}=e;if(g==="image"){let k=h?`${h}.`:"";c.append(`${k}x`,"0"),c.append(`${k}y`,"0")}else h&&c.append(h,v)}}else{if(yf(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');a="get",i=null,l=Od,u=e}return c&&l==="text/plain"&&(u=c,c=void 0),{action:i,method:a.toLowerCase(),encType:l,formData:c,body:u}}function Pg(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function v2(e,t){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${t}`:a.pathname=`${a.pathname}.${t}`,a}async function _M(e,t){if(e.id in t)return t[e.id];try{let a=await import(e.module);return t[e.id]=a,a}catch(a){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(a),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function RM(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 IM(e,t,a){return UM((await Promise.all(e.map(async i=>{let l=t.routes[i.route.id];if(l){let c=await _M(l,a);return c.links?c.links():[]}return[]}))).flat(1).filter(RM).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function zb(e,t,a,i,l,c){let u=(p,h)=>a[h]?p.route.id!==a[h].route.id:!0,m=(p,h)=>a[h].pathname!==p.pathname||a[h].route.path?.endsWith("*")&&a[h].params["*"]!==p.params["*"];return c==="assets"?t.filter((p,h)=>u(p,h)||m(p,h)):c==="data"?t.filter((p,h)=>{let g=i.routes[p.route.id];if(!g||!g.hasLoader)return!1;if(u(p,h)||m(p,h))return!0;if(p.route.shouldRevalidate){let v=p.route.shouldRevalidate({currentUrl:new URL(l.pathname+l.search+l.hash,window.origin),currentParams:a[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:p.params,defaultShouldRevalidate:!0});if(typeof v=="boolean")return v}return!0}):[]}function LM(e,t,{includeHydrateFallback:a}={}){return OM(e.map(i=>{let l=t.routes[i.route.id];if(!l)return[];let c=[l.module];return l.clientActionModule&&(c=c.concat(l.clientActionModule)),l.clientLoaderModule&&(c=c.concat(l.clientLoaderModule)),a&&l.hydrateFallbackModule&&(c=c.concat(l.hydrateFallbackModule)),l.imports&&(c=c.concat(l.imports)),c}).flat(1))}function OM(e){return[...new Set(e)]}function DM(e){let t={},a=Object.keys(e).sort();for(let i of a)t[i]=e[i];return t}function UM(e,t){let a=new Set;return new Set(t),e.reduce((i,l)=>{let c=JSON.stringify(DM(l));return a.has(c)||(a.add(c),i.push({key:c,link:l})),i},[])}function zM(){let e=x.useContext(no);return Pg(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function $M(){let e=x.useContext(xf);return Pg(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}const Bg=x.createContext(void 0);Bg.displayName="FrameworkContext";function Hg(){let e=x.useContext(Bg);return Pg(e,"You must render this element inside a <HydratedRouter> element"),e}function PM(e,t){let a=x.useContext(Bg),[i,l]=x.useState(!1),[c,u]=x.useState(!1),{onFocus:m,onBlur:p,onMouseEnter:h,onMouseLeave:g,onTouchStart:v}=t,k=x.useRef(null);x.useEffect(()=>{if(e==="render"&&u(!0),e==="viewport"){let M=T=>{T.forEach(I=>{u(I.isIntersecting)})},C=new IntersectionObserver(M,{threshold:.5});return k.current&&C.observe(k.current),()=>{C.disconnect()}}},[e]),x.useEffect(()=>{if(i){let M=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(M)}}},[i]);let w=()=>{l(!0)},S=()=>{l(!1),u(!1)};return a?e!=="intent"?[c,k,{}]:[c,k,{onFocus:Xo(m,w),onBlur:Xo(p,S),onMouseEnter:Xo(h,w),onMouseLeave:Xo(g,S),onTouchStart:Xo(v,w)}]:[!1,k,{}]}function Xo(e,t){return a=>{e&&e(a),a.defaultPrevented||t(a)}}function BM({page:e,...t}){let a=WT(),{nonce:i}=Hg(),{router:l}=zM(),c=x.useMemo(()=>t2(l.routes,e,l.basename),[l.routes,e,l.basename]);return c?(t.nonce==null&&i&&(t={...t,nonce:i}),a?x.createElement(FM,{page:e,matches:c,...t}):x.createElement(VM,{page:e,matches:c,...t})):null}function HM(e){let{manifest:t,routeModules:a}=Hg(),[i,l]=x.useState([]);return x.useEffect(()=>{let c=!1;return IM(e,t,a).then(u=>{c||l(u)}),()=>{c=!0}},[e,t,a]),i}function FM({page:e,matches:t,...a}){let i=ha(),l=x.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let c=v2(e,"rsc"),u=!1,m=[];for(let p of t)typeof p.route.shouldRevalidate=="function"?u=!0:m.push(p.route.id);return u&&m.length>0&&c.searchParams.set("_routes",m.join(",")),[c.pathname+c.search]},[e,i,t]);return x.createElement(x.Fragment,null,l.map(c=>x.createElement("link",{key:c,rel:"prefetch",as:"fetch",href:c,...a})))}function VM({page:e,matches:t,...a}){let i=ha(),{manifest:l,routeModules:c}=Hg(),{loaderData:u,matches:m}=$M(),p=x.useMemo(()=>zb(e,t,m,l,i,"data"),[e,t,m,l,i]),h=x.useMemo(()=>zb(e,t,m,l,i,"assets"),[e,t,m,l,i]),g=x.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let w=new Set,S=!1;if(t.forEach(C=>{let T=l.routes[C.route.id];!T||!T.hasLoader||(!p.some(I=>I.route.id===C.route.id)&&C.route.id in u&&c[C.route.id]?.shouldRevalidate||T.hasClientLoader?S=!0:w.add(C.route.id))}),w.size===0)return[];let M=v2(e,"data");return S&&w.size>0&&M.searchParams.set("_routes",t.filter(C=>w.has(C.route.id)).map(C=>C.route.id).join(",")),[M.pathname+M.search]},[u,i,l,p,t,e,c]),v=x.useMemo(()=>LM(h,l),[h,l]),k=HM(h);return x.createElement(x.Fragment,null,g.map(w=>x.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...a})),v.map(w=>x.createElement("link",{key:w,rel:"modulepreload",href:w,...a})),k.map(({key:w,link:S})=>x.createElement("link",{key:w,nonce:a.nonce,...S,crossOrigin:S.crossOrigin??a.crossOrigin})))}function qM(...e){return t=>{e.forEach(a=>{typeof a=="function"?a(t):a!=null&&(a.current=t)})}}const GM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{GM&&(window.__reactRouterVersion="8.3.0")}catch{}function WM({basename:e,children:t,useTransitions:a,window:i}){let l=x.useRef(null);l.current==null&&(l.current=yT({window:i,v5Compat:!0}));let c=l.current,[u,m]=x.useState({action:c.action,location:c.location}),p=x.useCallback(h=>{a===!1?m(h):x.startTransition(()=>m(h))},[a]);return x.useLayoutEffect(()=>c.listen(p),[c,p]),x.createElement(bM,{basename:e,children:t,location:u.location,navigationType:u.action,navigator:c,useTransitions:a})}const Fg=x.forwardRef(function({onClick:t,discover:a="render",prefetch:i="none",relative:l,reloadDocument:c,replace:u,mask:m,state:p,target:h,to:g,preventScrollReset:v,viewTransition:k,defaultShouldRevalidate:w,...S},M){let{basename:C,navigator:T,useTransitions:I}=x.useContext(jr),D=typeof g=="string"&&Og.test(g),K=u2(g,C);g=K.to;let F=eM(g,{relative:l}),E=ha(),B=null;if(m){let G=gf(m,[],E.mask?E.mask.pathname:"/",!0);C!=="/"&&(G.pathname=G.pathname==="/"?C:Lr([C,G.pathname])),B=T.createHref(G)}let[Y,V,O]=PM(i,S),U=QM(g,{replace:u,mask:m,state:p,target:h,preventScrollReset:v,relative:l,viewTransition:k,defaultShouldRevalidate:w,useTransitions:I});function _(G){t&&t(G),G.defaultPrevented||U(G)}let P=!(K.isExternal||c),H=x.createElement("a",{...S,...O,href:(P?B:void 0)||K.absoluteURL||F,onClick:P?_:t,ref:qM(M,V),target:h,"data-discover":!D&&a==="render"?"true":void 0});return Y&&!D?x.createElement(x.Fragment,null,H,x.createElement(BM,{page:F})):H});Fg.displayName="Link";const Vg=x.forwardRef(function({"aria-current":t="page",caseSensitive:a=!1,className:i="",end:l=!1,style:c,to:u,viewTransition:m,children:p,...h},g){let v=Fc(u,{relative:h.relative}),k=ha(),w=x.useContext(xf),{navigator:S,basename:M}=x.useContext(jr),C=w!=null&&t3(v)&&m===!0,T=S.encodeLocation?S.encodeLocation(v).pathname:v.pathname,I=k.pathname,D=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;a||(I=I.toLowerCase(),D=D?D.toLowerCase():null,T=T.toLowerCase()),D&&M&&(D=ui(D,M)||D);const K=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let F=I===T||!l&&I.startsWith(T)&&I.charAt(K)==="/",E=D!=null&&(D===T||!l&&D.startsWith(T)&&D.charAt(K)==="/"),B={isActive:F,isPending:E,isTransitioning:C},Y=F?t:void 0,V;typeof i=="function"?V=i(B):V=[i,F?"active":null,E?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let O=typeof c=="function"?c(B):c;return x.createElement(Fg,{...h,"aria-current":Y,className:V,ref:g,style:O,to:u,viewTransition:m},typeof p=="function"?p(B):p)});Vg.displayName="NavLink";const KM=x.forwardRef(({discover:e="render",fetcherKey:t,navigate:a,reloadDocument:i,replace:l,state:c,method:u="get",action:m,onSubmit:p,relative:h,preventScrollReset:g,viewTransition:v,defaultShouldRevalidate:k,...w},S)=>{let{useTransitions:M}=x.useContext(jr),C=JM(),T=e3(m,{relative:h}),I=u.toLowerCase()==="get"?"get":"post",D=typeof m=="string"&&Og.test(m),K=F=>{if(p&&p(F),F.defaultPrevented)return;F.preventDefault();let E=F.nativeEvent.submitter,B=E?.getAttribute("formmethod")||u,Y=()=>C(E||F.currentTarget,{fetcherKey:t,method:B,navigate:a,replace:l,state:c,relative:h,preventScrollReset:g,viewTransition:v,defaultShouldRevalidate:k});M&&a!==!1?x.startTransition(()=>Y()):Y()};return x.createElement("form",{ref:S,method:I,action:T,onSubmit:i?p:K,...w,"data-discover":!D&&e==="render"?"true":void 0})});KM.displayName="Form";function YM(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function b2(e){let t=x.useContext(no);return on(t,YM(e)),t}function QM(e,{target:t,replace:a,mask:i,state:l,preventScrollReset:c,relative:u,viewTransition:m,defaultShouldRevalidate:p,useTransitions:h}={}){let g=ia(),v=ha(),k=Fc(e,{relative:u});return x.useCallback(w=>{if(NM(w,t)){w.preventDefault();let S=a!==void 0?a:Nc(v)===Nc(k),M=()=>g(e,{replace:S,mask:i,state:l,preventScrollReset:c,relative:u,viewTransition:m,defaultShouldRevalidate:p});h?x.startTransition(()=>M()):M()}},[v,g,k,a,i,l,t,e,c,u,m,p,h])}function vf(e){Zr(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=x.useRef($h(e)),a=x.useRef(!1),i=ha(),l=x.useMemo(()=>TM(i.search,a.current?null:t.current),[i.search]),c=ia();return[l,x.useCallback((u,m)=>{const p=$h(typeof u=="function"?u(new URLSearchParams(l)):u);a.current=!0,c("?"+p,m)},[c,l])]}let XM=0,ZM=()=>`__${String(++XM)}__`;function JM(){let{router:e}=b2("useSubmit"),{basename:t}=x.useContext(jr),a=pM(),i=e.fetch,l=e.navigate;return x.useCallback(async(c,u={})=>{let{action:m,method:p,encType:h,formData:g,body:v}=EM(c,t);u.navigate===!1?await i(u.fetcherKey||ZM(),a,u.action||m,{defaultShouldRevalidate:u.defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:g,body:v,formMethod:u.method||p,formEncType:u.encType||h,flushSync:u.flushSync}):await l(u.action||m,{defaultShouldRevalidate:u.defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:g,body:v,formMethod:u.method||p,formEncType:u.encType||h,replace:u.replace,state:u.state,fromRouteId:a,flushSync:u.flushSync,viewTransition:u.viewTransition})},[i,l,t,a])}function e3(e,{relative:t}={}){let{basename:a}=x.useContext(jr),i=x.useContext(Cr);on(i,"useFormAction must be used inside a RouteContext");let[l]=i.matches.slice(-1),c={...Fc(e||".",{relative:t})},u=ha();if(e==null){c.search=u.search;let m=new URLSearchParams(c.search),p=m.getAll("index");if(p.some(h=>h==="")){m.delete("index"),p.filter(g=>g).forEach(g=>m.append("index",g));let h=m.toString();c.search=h?`?${h}`:""}}return(!e||e===".")&&l.route.index&&(c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index"),a!=="/"&&(c.pathname=c.pathname==="/"?a:Lr([a,c.pathname])),Nc(c)}function t3(e,{relative:t}={}){let a=x.useContext(m2);on(a!=null,"`useViewTransitionState` must be used within `react-router/dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=b2("useViewTransitionState"),l=Fc(e,{relative:t});if(!a.isTransitioning)return!1;let c=ui(a.currentLocation.pathname,i)||a.currentLocation.pathname,u=ui(a.nextLocation.pathname,i)||a.nextLocation.pathname;return Tc(l.pathname,u)!=null||Tc(l.pathname,c)!=null}const $b=e=>{let t;const a=new Set,i=(h,g)=>{const v=typeof h=="function"?h(t):h;if(!Object.is(v,t)){const k=t;t=g??(typeof v!="object"||v===null)?v:Object.assign({},t,v),a.forEach(w=>w(t,k))}},l=()=>t,m={setState:i,getState:l,getInitialState:()=>p,subscribe:h=>(a.add(h),()=>a.delete(h))},p=t=e(i,l,m);return m},ao=(e=>e?$b(e):$b),n3=e=>e;function ro(e,t=n3){const a=od.useSyncExternalStore(e.subscribe,od.useCallback(()=>t(e.getState()),[e,t]),od.useCallback(()=>t(e.getInitialState()),[e,t]));return od.useDebugValue(a),a}const Pb="penguin.lastProjectId",Bb=e=>`penguin.lastAgentId.${e}`,k2=x.createContext(null);function Ph(e){return e.name??e.projectId}function pn(e){return e.name??e.agentId}function a3(){return ao((e,t)=>({projects:[],projectsLoading:!0,currentProjectId:null,agents:[],agentsLoading:!0,currentAgentId:null,reloadProjects:async()=>{e({projectsLoading:!0});try{const a=await c4(),i=t().currentProjectId??localStorage.getItem(Pb),l=a.projects.find(c=>c.projectId===i);e({projects:a.projects,currentProjectId:(l??a.projects[0])?.projectId??null})}finally{e({projectsLoading:!1})}},setCurrentProjectId:a=>{a!==t().currentProjectId&&(localStorage.setItem(Pb,a),e({currentProjectId:a,currentAgentId:null,agents:[],agentsLoading:!0}),pf({lastProjectId:a}).catch(()=>{}))},reloadAgents:async()=>{const a=t().currentProjectId;if(a){e({agentsLoading:!0});try{const i=await E4(a),l=t().currentAgentId??localStorage.getItem(Bb(a)),c=i.agents.find(m=>m.agentId===l),u=i.agents.find(m=>m.agentId==="default_agent")??i.agents[0]??null;e({agents:i.agents,currentAgentId:(c??u)?.agentId??null})}finally{e({agentsLoading:!1})}}},setCurrentAgentId:a=>{const i=t().currentProjectId;i&&localStorage.setItem(Bb(i),a),e({currentAgentId:a})}}))}function r3({children:e}){const[t]=x.useState(a3),a=ro(t);x.useEffect(()=>{t.getState().reloadProjects()},[t]);const{currentProjectId:i}=a;x.useEffect(()=>{t.setState({agents:[]}),t.getState().reloadAgents()},[t,i]);const l=x.useMemo(()=>{const c=a.projects.find(m=>m.projectId===a.currentProjectId)??null,u=a.agents.find(m=>m.agentId===a.currentAgentId)??null;return{projects:a.projects,projectsLoading:a.projectsLoading,currentProject:c,setCurrentProjectId:a.setCurrentProjectId,reloadProjects:a.reloadProjects,agents:a.agents,agentsLoading:a.agentsLoading,currentAgent:u,setCurrentAgentId:a.setCurrentAgentId,reloadAgents:a.reloadAgents}},[a]);return r.jsx(k2.Provider,{value:l,children:e})}function cn(){const e=x.useContext(k2);if(!e)throw new Error("useProject must be used within a ProjectProvider");return e}function w2(e,t){const a=new EventSource(e);a.onmessage=l=>{try{t.onOmniMessage(JSON.parse(l.data),l.lastEventId||null)}catch{}},a.addEventListener("server_event",l=>{try{t.onServerEvent(JSON.parse(l.data),l.lastEventId||null)}catch{}}),t.onOpen&&(a.onopen=t.onOpen);const{onError:i}=t;return i&&(a.onerror=()=>i(a.readyState===EventSource.CLOSED)),{close:()=>a.close()}}function s3(e,t){return w2(`/api/sessions/${encodeURIComponent(e)}/stream`,t)}function i3(e){return w2("/api/events",e)}const S2="\0temp-workspaces",l3=/[/\\]workspaces[/\\]tmp-[0-9a-f]{8}$/;function j2(e){const t=e.trim();return t===""||l3.test(t)}function Ac(e){return j2(e)?S2:e.trim()}function qg(e){const t=e.trim().split(/[/\\]+/).filter(Boolean);return t[t.length-1]??"/"}const qi=10,ud=10;function Bh(e,t){return e.length>t?{items:e.slice(0,t),hasMore:!0}:{items:e,hasMore:!1}}function Ir(e){return e.archived?"archived":e.source==="subagent"||e.source==="schedule"?e.source:"active"}function o3(e,t){const a=t.trim().toLowerCase();return a===""?!0:(e.title??"").toLowerCase().includes(a)}const Vc=["subagent","schedule","archived"];function Hb(e){const t={active:[],subagent:[],schedule:[],archived:[]};for(const a of e)t[Ir(a)].push(a);return t}const c3=["active",...Vc];function C2(e){const t=new Map;for(const[a,i]of e)for(const[l,c]of Object.entries(i)){const u=Ac(l);let m=t.get(u);m||(m={totals:{active:0,subagent:0,schedule:0,archived:0},agents:{active:[],subagent:[],schedule:[],archived:[]}},t.set(u,m));for(const p of c3){const h=c[p];h>0&&(m.totals[p]+=h,m.agents[p].includes(a)||m.agents[p].push(a))}}return t}function N2(e){let t=null;for(const a of e){const i=Ir(a);i!=="active"&&i!=="schedule"||(!t||a.createdAt>t.createdAt||a.createdAt===t.createdAt&&a.sessionId>t.sessionId)&&(t=a)}return t}function T2(e){const t=new Map;for(const l of e){const c=Ac(l.workspace);let u=t.get(c);if(!u){const m=c===S2;u={key:c,label:m?"":qg(l.workspace),fullPath:m?null:l.workspace.trim(),temp:m,sessions:[]},t.set(c,u)}u.sessions.push(l)}const a=(l,c)=>l<c?1:l>c?-1:0,i=[...t.values()];for(const l of i)l.sessions.sort((c,u)=>a(c.createdAt,u.createdAt));return i.sort((l,c)=>l.temp!==c.temp?l.temp?1:-1:a(l.sessions[0]?.createdAt??"",c.sessions[0]?.createdAt??"")),i}function Hd(e,t,a){if(a.size===0)return[...e];const i=[],l=[];for(const c of e)(a.has(t(c))?i:l).push(c);return[...i,...l]}const M2=x.createContext(null),ii=(e,t)=>`${e}\0${t}`,u3=500;function d3(){let e=0;return ao((t,a)=>{const i=(l,c,u)=>{const{agentId:m,workspace:p}=l,h=a().countsByAgent,g=h.get(m);if(g){const w=new Map(h);w.set(m,{...g,[c]:Math.max(0,g[c]+u)}),t({countsByAgent:w})}const v=a().workspaceCountsByAgent,k=v.get(m);if(k){const w=k[p]??{active:0,subagent:0,schedule:0,archived:0},S=new Map(v);S.set(m,{...k,[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,showCliSessions:!1,reload:async()=>{const{projectId:l,agentIds:c,showCliSessions:u}=a();if(!l||c.length===0)return;const m=++e;t({loading:!0});try{const p=await Promise.all(c.map(async S=>{const M=["active",...Vc.filter(C=>a().pageState.has(ii(S,C)))];try{const C=await Promise.all(M.map(async T=>{const I=await Oh(l,S,{offset:0,limit:qi+1,category:T,...T==="active"?{withCounts:!0}:{},...u?{cli:!0}:{}});return{category:T,counts:I.counts,workspaceCounts:I.workspaceCounts,...Bh(I.sessions,qi)}}));return{agentId:S,pages:C}}catch{return{agentId:S,pages:[]}}}));if(m!==e)return;const h=[],g=new Set,v=new Map,k=new Map,w=new Map;for(const S of p)for(const M of S.pages){v.set(ii(S.agentId,M.category),{hasMore:M.hasMore,fetched:M.items.length}),M.counts&&k.set(S.agentId,M.counts),M.workspaceCounts&&w.set(S.agentId,M.workspaceCounts);for(const C of M.items)g.has(C.sessionId)||(g.add(C.sessionId),h.push(C))}t({sessions:h,pageState:v,countsByAgent:k,workspaceCountsByAgent:w})}finally{m===e&&t({loading:!1})}},loadMoreFor:async(l,c)=>{const{projectId:u,showCliSessions:m}=a();if(!u)return;const p=[...new Set(l)].filter(T=>{const I=a().pageState.get(ii(T,c));return I===void 0?(a().countsByAgent.get(T)?.[c]??0)>0:I.hasMore});if(p.length===0)return;const h=e,g=await Promise.all(p.map(async T=>{const I=a().pageState.get(ii(T,c))?.fetched??0;try{const D=(await Oh(u,T,{offset:I,limit:qi+1,category:c,...m?{cli:!0}:{}})).sessions;return{agentId:T,...Bh(D,qi)}}catch{return null}}));if(h!==e)return;const v=g.filter(T=>T!==null),k=a().sessions,w=new Set(k.map(T=>T.sessionId)),S=v.flatMap(T=>T.items.filter(I=>!w.has(I.sessionId))),M=a().pageState,C=new Map(M);for(const T of v){const I=ii(T.agentId,c);C.set(I,{hasMore:T.hasMore,fetched:(M.get(I)?.fetched??0)+T.items.length})}t({...S.length>0?{sessions:[...k,...S]}:{},pageState:C})},add:l=>{e+=1,!a().sessions.some(u=>u.sessionId===l.sessionId)&&a().pageState.get(ii(l.agentId,Ir(l)))?.hasMore===!1&&i(l,Ir(l),1),t({sessions:[l,...a().sessions.filter(u=>u.sessionId!==l.sessionId)]})},remove:l=>{e+=1;const c=a().sessions.find(m=>m.sessionId===l);c&&i(c,Ir(c),-1);const u=new Set(a().deletedSessionIds);for(u.add(l);u.size>u3;){const m=u.values().next();if(m.done)break;u.delete(m.value)}t({deletedSessionIds:u,sessions:a().sessions.filter(m=>m.sessionId!==l)})},replace:l=>{const c=a().sessions.find(u=>u.sessionId===l.sessionId);c&&Ir(c)!==Ir(l)&&(i(l,Ir(c),-1),i(l,Ir(l),1)),t({sessions:a().sessions.map(u=>u.sessionId===l.sessionId?l:u)})},setStatus:(l,c,u)=>{const m=a().sessions,p=m.find(k=>k.sessionId===l);if(!p)return;const h=u?.lastActiveAt??p.lastActiveAt,g=c==="running"||c==="compacting",v=p.hasTrace||u?.hasTrace===!0||g;p.status===c&&p.lastActiveAt===h&&p.hasTrace===v||t({sessions:m.map(k=>k.sessionId===l?{...k,status:c,lastActiveAt:h,hasTrace:v}:k)})},setTitle:(l,c)=>{t({sessions:a().sessions.map(u=>u.sessionId===l?{...u,title:c}:u)})},setShowCliSessions:l=>{t({showCliSessions:l}),pf({showCliSessions:l}).catch(()=>{})}}})}function f3(e,t,a){if(t.type==="web_updated"){a();return}if(t.type==="session_state"){e.getState().setStatus(t.sessionId,t.state,{lastActiveAt:t.lastActiveAt,hasTrace:t.hasTrace});return}if(t.type==="resync_required"){e.getState().reload();return}t.type==="schedule_fired"&&t.projectId===e.getState().projectId&&e.getState().reload()}function m3({children:e}){const{currentProject:t,agents:a}=cn(),i=t?.projectId??null,l=a.map(S=>S.agentId).join(","),[c]=x.useState(d3),u=ro(c);x.useEffect(()=>{let S=!1;return Rg().then(M=>{!S&&M.prefs.showCliSessions===!0&&c.setState({showCliSessions:!0})}).catch(()=>{}),()=>{S=!0}},[c]);const{showCliSessions:m}=u;x.useEffect(()=>{c.setState({projectId:i,agentIds:l===""?[]:l.split(","),sessions:[],pageState:new Map,countsByAgent:new Map,workspaceCountsByAgent:new Map}),c.getState().reload()},[c,i,l,m]),x.useEffect(()=>{const S=i3({onOmniMessage:()=>{},onServerEvent:M=>f3(c,M,()=>window.location.reload())});return()=>S.close()},[c]);const{pageState:p,countsByAgent:h}=u,g=x.useCallback((S,M)=>p.has(ii(S,M)),[p]),v=x.useCallback((S,M)=>{const C=p.get(ii(S,M));return C!==void 0?C.hasMore:(h.get(S)?.[M]??0)>0},[p,h]),k=x.useCallback(S=>c.getState().deletedSessionIds.has(S),[c]),w=x.useMemo(()=>{const S=new Map;for(const M of u.sessions){const C=S.get(M.agentId);C?C.push(M):S.set(M.agentId,[M])}for(const M of S.values())M.sort((C,T)=>T.createdAt.localeCompare(C.createdAt)||T.sessionId.localeCompare(C.sessionId));return{sessions:u.sessions,byAgent:S,countsByAgent:u.countsByAgent,workspaceCountsByAgent:u.workspaceCountsByAgent,isLoadedFor:g,hasMoreFor:v,loading:u.loading,reload:u.reload,loadMoreFor:u.loadMoreFor,add:u.add,remove:u.remove,isDeleted:k,replace:u.replace,setStatus:u.setStatus,setTitle:u.setTitle,showCliSessions:u.showCliSessions,setShowCliSessions:u.setShowCliSessions}},[u,g,v,k]);return r.jsx(M2.Provider,{value:w,children:e})}function pi(){const e=x.useContext(M2);if(!e)throw new Error("useSessions must be used within a SessionsProvider");return e}let Wp=null,Kp=null,Dd=null,Gl=null;const Hh=new Set;function Fh(){for(const e of Hh)e()}function p3(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 Gg(e){const[t,a]=x.useState(Wp),[i,l]=x.useState(Dd);return x.useEffect(()=>{const c=()=>{a(Wp),l(Dd)};return Hh.add(c),()=>{Hh.delete(c)}},[]),x.useEffect(()=>{if(!e)return;let c=!1;return Kp??=mT().then(u=>(Wp=u,Fh(),u)),Kp.then(u=>{c||a(u)}).catch(()=>{Kp=null}),Gl??=Zw().then(u=>(Dd=u,Fh(),u)),Gl.then(u=>{c||l(u)}).catch(()=>{Gl=null}),()=>{c=!0}},[e]),{version:t,update:i}}async function Fb(){const e=Zw(!0).then(t=>(Dd=t,t));Gl=e;try{return await e}catch(t){throw Gl===e&&(Gl=null),t}finally{Fh()}}function h3(e){return e==="running"||e==="compacting"}const g3=1e4;function x3(e=g3){const t=new Map;return{observe(a,i=Date.now()){const l=[],c=new Set;for(const u of a){if(c.has(u.sessionId))continue;c.add(u.sessionId);const m=h3(u.status),p=t.get(u.sessionId);if(p===void 0){t.set(u.sessionId,{active:m,lastFiredAt:null});continue}p.active&&!m&&(p.lastFiredAt===null||i-p.lastFiredAt>=e)&&(l.push(u.sessionId),p.lastFiredAt=i),p.active=m}for(const u of[...t.keys()])c.has(u)||t.delete(u);return l}}}function y3(){const{sessionVia:e}=vn(),{sessions:t}=pi(),{setCurrentAgentId:a}=cn(),i=ia(),l=x.useRef(x3()),c=x.useRef(i);c.current=i;const u=x.useRef(a);u.current=a;const m=e==="desktop";x.useEffect(()=>{if(!m)return;const p=l.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 g=t.find(w=>w.sessionId===h),v=g?.title??f.chat.defaultSessionTitle,k=g?.agentId??null;try{const w=new Notification(f.notify.taskCompleteTitle,{body:f.notify.taskCompleteBody(v),tag:`penguin-task-${h}`,icon:"/penguin-logo.svg"});w.onclick=()=>{w.close(),window.focus(),k!==null&&u.current(k),c.current(`/chat/${h}`)}}catch{}}},[m,t])}function Yn({open:e,size:t=14,className:a=""}){return r.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":""} ${a}`,children:r.jsx("path",{d:"M9 5l7 7-7 7"})})}function Mn({d:e,size:t=16}){return r.jsx("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:r.jsx("path",{d:e})})}const Fd="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",A2="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",E2="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",v3="M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0M12 6v6l4 2",b3="m21 16-4 4-4-4M17 20V4M3 8l4-4 4 4M7 4v16",Vd={workspace:Fd,agent:E2},Vb={recent:v3,manual:b3},_2="penguin.sidebarGroupMode";function Vh(){return localStorage.getItem(_2)==="agent"?"agent":"workspace"}function qb(e){return e==="agent"?"agent":"workspace"}function R2(e){localStorage.setItem(_2,e)}function k3({value:e,onChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5",children:[{value:"workspace",icon:Vd.workspace,label:f.chat.groupByWorkspace},{value:"agent",icon:Vd.agent,label:f.chat.groupByAgent}].map(a=>r.jsx("button",{type:"button",title:a.label,"aria-label":a.label,"aria-pressed":e===a.value,onClick:()=>t(a.value),className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md transition-colors duration-150 ${e===a.value?"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"}`,children:r.jsx(Mn,{d:a.icon,size:14})},a.value))})}const I2="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 Wl({label:e,pending:t=!1,onClick:a,className:i}){return r.jsxs("button",{type:"button","aria-label":f.chat.loadMore,disabled:t,onClick:a,className:`${I2}${i?` ${i}`:""} disabled:opacity-60`,children:[r.jsx("span",{className:"w-3","aria-hidden":!0}),t?f.common.loading:e]})}function L2({label:e,open:t,onToggle:a,more:i=!1,pending:l=!1,onMore:c,children:u}){return r.jsxs("div",{className:"mt-1",children:[r.jsxs("button",{type:"button",onClick:a,className:I2,children:[r.jsx(Yn,{open:t,size:12}),e]}),t&&u,t&&i&&r.jsx(Wl,{label:f.chat.loadMore,pending:l,onClick:()=>c?.()})]})}function gc({open:e,onToggle:t,icon:a,label:i,uppercase:l=!1,count:c,title:u,actions:m}){return r.jsxs("div",{className:"group/header flex items-center gap-0.5 px-1 pb-0.5",children:[r.jsxs("button",{type:"button",onClick:t,"aria-expanded":e,"aria-label":e?f.nav.collapseGroup:f.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:[a,r.jsx("span",{className:`min-w-0 truncate text-xs font-semibold ${l?"uppercase tracking-wide ":""}text-gray-500 dark:text-gray-400`,children:i}),c!==void 0&&r.jsx("span",{className:"shrink-0 text-[11px] text-gray-400 dark:text-gray-500",children:c}),r.jsx(Yn,{open:e,size:12,className:"text-gray-400"}),r.jsx("span",{className:"min-w-0 flex-1"})]}),m]})}function Ql({size:e=12,className:t=""}){return r.jsx("svg",{width:e,height:e,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:r.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function bf({size:e=13,className:t=""}){return r.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:r.jsx("path",{d:"M5 12l4 4L19 6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function O2({size:e=13,className:t=""}){return r.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:r.jsx("path",{d:"M12 4v11m0 0l-5-5m5 5l5-5M4 20h16",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function Gb({size:e=13,className:t=""}){return r.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,className:`shrink-0 ${t}`,children:r.jsx("path",{d:"M12 15V4m0 0L7 9m5-5l5 5M4 20h16",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function Wg({onClose:e,className:t="",...a}){return r.jsx("button",{type:"button","aria-label":f.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}`,...a,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})})}const D2="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",li={agents:E2,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"};function U2({open:e,side:t="left",title:a,onClose:i,children:l,widthClass:c}){return x.useEffect(()=>{if(!e)return;const u=m=>{m.key==="Escape"&&i()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e,i]),e?r.jsxs("div",{className:"fixed inset-0 z-50",children:[r.jsx("div",{className:"anim-fade absolute inset-0 bg-black/45",onMouseDown:i}),r.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:[r.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800",children:[r.jsx("span",{className:"text-base font-semibold",children:a??""}),r.jsx(Wg,{onClose:i})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pb-[env(safe-area-inset-bottom)]",children:l})]})]}):null}function Ge({d:e,size:t=13,className:a=""}){return r.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",className:`block shrink-0 ${a}`,"aria-hidden":!0,children:r.jsx("path",{d:e})})}function Ki(e){const t=e.toFixed(1);return t.endsWith(".0")?t.slice(0,-2):t}function Rt(e){const t=Math.abs(e);return t<1e3?`${e}`:t<1e6?`${Ki(e/1e3)}k`:`${Ki(e/1e6)}M`}function An(e,t){if(e<1e3)return`${Math.round(e)}ms`;const a=e/1e3;if(a<60&&!(t?.compact&&a>=10))return`${Ki(a)}s`;const i=Math.round(a);return i<60?`${i}s`:`${Math.floor(i/60)}m${i%60}s`}function z2(e){const t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`}function qh(e,t){return t>0?e/(t/1e3):null}function qd(e){return e==null||!Number.isFinite(e)?"—":`${Math.abs(e)<1e3?Ki(e):Rt(e)} tok/s`}function $2(e,t){const a=e+t;return a>0?e/a:null}function Kg(e){return e==null||!Number.isFinite(e)?"—":`${Math.round(e*100)}%`}function Dr(e,t="USD",a){if(e==null)return"—";const i=t==="CNY"?"¥":"$",l=t==="CNY"?e*7:e;if(l===0)return`${i}0`;const c=Math.abs(l);if(a?.compact&&c<1)return`${i}${Number(l.toPrecision(2))}`;const u=c>=100?0:c>=1?2:4;return`${i}${l.toFixed(u)}`}function Ec(e){return Number.isInteger(e)?`${e}`:e.toFixed(2).replace(/0+$/,"").replace(/\.$/,"")}function Wb(e){return Number(e.toFixed(1))<1024}function _c(e){if(e<1024)return`${e}B`;const t=e/1024;if(Wb(t))return`${Ki(t)}KB`;const a=t/1024;return Wb(a)?`${Ki(a)}MB`:`${Ki(a/1024)}GB`}function Gi(e){return e<10?`0${e}`:`${e}`}function Oa(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.getFullYear()}-${Gi(t.getMonth()+1)}-${Gi(t.getDate())} ${Gi(t.getHours())}:${Gi(t.getMinutes())}`}const w3=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Gd(e,t){const a=/^\d{4}-(\d{2})-(\d{2})(?:$|T)/.exec(e);if(!a)return e;const i=Number(a[1]),l=Number(a[2]);return i<1||i>12||l<1||l>31?e:t==="en"?`${w3[i-1]} ${l}`:`${i} 月 ${l} 日`}function P2(e,t){const a=new Date(e);return Number.isNaN(a.getTime())?"":a.toLocaleString(t==="en"?"en-US":"zh-CN",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Wd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function S3(e,t){const a=new Date(e);if(Number.isNaN(a.getTime()))return e;const i=Math.round((Wd(new Date)-Wd(a))/864e5);return i<0?Oa(e):i===0?t==="en"?"today":"今天":i===1?t==="en"?"yesterday":"昨天":t==="en"?`${i} days ago`:`${i} 天前`}function Kd(e,t){const a=new Date(e);if(Number.isNaN(a.getTime()))return e;const i=Math.round((Wd(new Date)-Wd(a))/864e5);return i<0?e:i===0?t==="en"?"updated today":"今天更新":i===1?t==="en"?"updated yesterday":"昨天更新":t==="en"?`updated ${i} days ago`:`${i} 天前更新`}function j3(e,t){const a=new Date(e);if(Number.isNaN(a.getTime()))return"";const i=Date.now()-a.getTime();if(i<0)return Gd(e,t);const l=Math.floor(i/6e4);if(l<1)return t==="en"?"now":"刚刚";if(l<60)return t==="en"?`${l}m`:`${l} 分钟前`;const c=Math.floor(l/60);if(c<24)return t==="en"?`${c}h`:`${c} 小时前`;const u=Math.floor(c/24);return u<7?t==="en"?`${u}d`:`${u} 天前`:Gd(e,t)}function C3(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:`${Gi(t.getHours())}:${Gi(t.getMinutes())}:${Gi(t.getSeconds())}`}const Yg=e=>`penguin.sessionSeen.${e}`,Kb=500,Kl={seededAt:0,seen:new Map};function B2(e){try{return localStorage}catch{return null}}function N3(e){if(e===null)return Kl;try{const t=JSON.parse(e);if(typeof t!="object"||t===null)return Kl;const a=t,i=typeof a.seededAt=="number"&&Number.isFinite(a.seededAt)?a.seededAt:0,l=new Map;if(typeof a.seen=="object"&&a.seen!==null)for(const[c,u]of Object.entries(a.seen))typeof u=="number"&&Number.isFinite(u)&&l.set(c,u);return{seededAt:i,seen:l}}catch{return Kl}}function T3(e){let t=[...e.seen];return t.length>Kb&&(t.sort((a,i)=>i[1]-a[1]),t=t.slice(0,Kb)),JSON.stringify({seededAt:e.seededAt,seen:Object.fromEntries(t)})}function M3(e,t,a,i=Date.now()){const l=Date.parse(a),c=Number.isNaN(l)?i:Math.max(i,l);return e.seen.get(t)===c?e:{seededAt:e.seededAt,seen:new Map(e.seen).set(t,c)}}function A3(e,t){if(!e.seen.has(t))return e;const a=new Map(e.seen);return a.delete(t),{seededAt:e.seededAt,seen:a}}function E3(e,t,a){const i=Date.parse(a);return Number.isNaN(i)?!1:i>(e.seen.get(t)??e.seededAt)}const Qg=ao(()=>({cache:new Map}));function Xg(e,t){const{cache:a}=Qg.getState(),i=a.get(e);if(i)return i;const l=B2();let c=Kl;if(l)try{c=N3(l.getItem(e))}catch{c=Kl}return a.set(e,c),c}function H2(e,t,a){const i=B2();if(i)try{i.setItem(e,T3(t))}catch{}Qg.setState(l=>({cache:new Map(l.cache).set(e,t)}))}function _3(e){return ro(Qg,()=>e?Xg(Yg(e)):Kl)}function F2(e,t,a,i){if(e===null)return;const l=Yg(e),c=Xg(l),u=c.seededAt===0?{seededAt:Date.now(),seen:c.seen}:c,m=M3(u,t,a);m!==c&&H2(l,m)}function R3(e,t,a){if(e===null)return;const i=Yg(e),l=Xg(i),c=A3(l,t);c!==l&&H2(i,c)}function V2(e,t,a){return e==="running"?"running":e==="compacting"?"compacting":t&&a?"completedUnread":null}function I3(e,t,a){const i=e.sessionId!==a&&E3(t,e.sessionId,e.lastActiveAt);return V2(e.status,e.hasTrace,i)}function Oe(e,t){return e instanceof sa?e.code==="model_credential_missing"?t?.modelId?f.errors.modelCredentialMissing(t.modelId):e.message:e.code==="no_default_model"?f.errors.noDefaultModel:f.errors.byCode[e.code]??e.message:f.common.unknownError}function L3(e){return!(e.desktopMode&&e.sessionVia==="desktop")}const O3=["agents","skills","models","usage","traces","benchmark"],q2="penguin.sidebarNavGroupCollapsed";function D3(e){try{return(e??localStorage).getItem(q2)==="collapsed"}catch{return!1}}function U3(e,t){try{(t??localStorage).setItem(q2,e?"collapsed":"expanded")}catch{}}const G2=e=>`penguin.pinnedSessions.${e}`;function Yb(e,t){if(e===null)return new Set;try{const a=t??localStorage,i=JSON.parse(a.getItem(G2(e))??"[]");return new Set(Array.isArray(i)?i.filter(l=>typeof l=="string"):[])}catch{return new Set}}function Qb(e,t,a){if(e!==null)try{(a??localStorage).setItem(G2(e),JSON.stringify([...t]))}catch{}}function z3(e,t){const a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a}function $3(e,t){if(!e.has(t))return e;const a=new Set(e);return a.delete(t),a}const W2=e=>`penguin.sidebarWorkspaces.${e}`;function Gh(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 P3(e){if(typeof e=="string"){const t=Gh(e);return t===""?null:{path:t}}if(typeof e=="object"&&e!==null&&typeof e.path=="string"){const t=Gh(e.path);if(t==="")return null;const a=e.alias,i=typeof a=="string"?a.trim():"";return i===""?{path:t}:{path:t,alias:i}}return null}function Xb(e,t){if(e===null)return[];try{const a=t??localStorage,i=JSON.parse(a.getItem(W2(e))??"[]");if(!Array.isArray(i))return[];const l=[];for(const c of i){const u=P3(c);u!==null&&!l.some(m=>m.path===u.path)&&l.push(u)}return l}catch{return[]}}function B3(e,t,a){if(e!==null)try{(a??localStorage).setItem(W2(e),JSON.stringify(t))}catch{}}function H3(e,t){const a=Gh(t);return a===""||j2(a)||e.some(i=>i.path===a)?e:[{path:a},...e]}function F3(e,t,a){const i=a.trim(),l=e.find(c=>c.path===t);return!l||(l.alias??"")===i?e:e.map(c=>c.path===t?i===""?{path:c.path}:{path:c.path,alias:i}:c)}function V3(e,t){return e.some(a=>a.path===t)?e.filter(a=>a.path!==t):e}function q3(e,t){const a=new Map(t.filter(u=>u.alias!==void 0).map(u=>[u.path,u.alias])),i=new Set(e.map(u=>u.key)),l=[];for(const{path:u,alias:m}of t){const p=Ac(u);i.has(p)||p!==u||(i.add(p),l.push({key:p,label:m??qg(u),fullPath:u,temp:!1,sessions:[]}))}const c=e.map(u=>{const m=a.get(u.key);return m===void 0?u:{...u,label:m}});return l.length===0?c:[...c,...l]}const K2="penguin.sidebarSortMode";function G3(e){try{return(e??localStorage).getItem(K2)==="manual"?"manual":"recent"}catch{return"recent"}}function W3(e,t){try{(t??localStorage).setItem(K2,e)}catch{}}const Y2=(e,t)=>`penguin.sessionOrder.${e}.${t}`;function Yp(e,t,a){if(e===null)return[];try{const i=a??localStorage,l=JSON.parse(i.getItem(Y2(e,t))??"[]");return Array.isArray(l)?l.filter(c=>typeof c=="string"):[]}catch{return[]}}function Zb(e,t,a,i){if(e!==null)try{(i??localStorage).setItem(Y2(e,t),JSON.stringify(a))}catch{}}function Jb(e,t,a){if(a.length===0)return[...e];const i=new Map(a.map((u,m)=>[u,m])),l=[],c=[];for(const u of e)(i.has(t(u))?c:l).push(u);return c.sort((u,m)=>(i.get(t(u))??0)-(i.get(t(m))??0)),[...l,...c]}function K3(e,t,a){const i=a.recencyOf,l=i?[...e].sort((p,h)=>i(h).localeCompare(i(p))||t(h).localeCompare(t(p))):e,c=Hd(l,t,a.pinned);if(a.sortMode!=="manual")return c;const u=c.filter(p=>a.pinned.has(t(p))),m=c.filter(p=>!a.pinned.has(t(p)));return[...Jb(u,t,a.order),...Jb(m,t,a.order)]}function Y3(e,t,a,i){if(t===a||!e.includes(t))return e;const l=e.filter(u=>u!==t),c=l.indexOf(a);return c<0?e:(l.splice(i?c+1:c,0,t),l.every((u,m)=>u===e[m])?e:l)}function Q3(e,t){const a=new Set(t);return[...t,...e.filter(i=>!a.has(i))]}function X3(e,t){return e.includes(t)?e.filter(a=>a!==t):e}function di({checked:e,onChange:t,disabled:a,className:i,...l}){return r.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:a,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")+` ${i??""}`,...l,children:r.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"}`})})}var nl=Rw();const Rc=[];function Q2(){const e=Symbol("esc-layer");return Rc.push(e),e}function X2(e){const t=Rc.lastIndexOf(e);t!==-1&&Rc.splice(t,1)}function Z2(e){return Rc[Rc.length-1]===e}function Xt({open:e,title:t,onClose:a,children:i,footer:l,widthClass:c,headerless:u}){return x.useEffect(()=>{if(!e)return;const m=Q2(),p=h=>{h.key==="Escape"&&Z2(m)&&a()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p),X2(m)}},[e,a]),e?nl.createPortal(r.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:m=>{m.target===m.currentTarget&&a()},children:r.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&&r.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800",children:[r.jsx("h2",{className:"text-base font-semibold",children:t}),r.jsx(Wg,{onClose:a})]}),r.jsx("div",{className:"max-h-[70vh] overflow-y-auto px-4 py-4",children:i}),l&&r.jsx("div",{className:"flex justify-end gap-2 border-t border-gray-200 px-4 py-3 dark:border-gray-800",children:l})]})}),document.body):null}const dd=4,Zo=8;function Un({button:e,open:t,setOpen:a,children:i,menuClass:l,menuStyle:c,className:u,portal:m,anchorRect:p,returnFocus:h,onEscape:g}){const v=x.useRef(null),k=x.useRef(null),[w,S]=x.useState(null),M=x.useCallback(()=>h?.()??v.current?.querySelector("button")??null,[h]),C=x.useCallback(()=>k.current?[...k.current.querySelectorAll('button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')]:[],[]);x.useEffect(()=>{t&&C()[0]?.focus()},[t,C]);const T=E=>{if(E.key!=="ArrowDown"&&E.key!=="ArrowUp"||E.defaultPrevented)return;const Y=document.activeElement?.tagName;if(Y==="INPUT"||Y==="TEXTAREA"||Y==="SELECT")return;const V=C();if(V.length===0)return;E.preventDefault();const O=V.indexOf(document.activeElement),U=E.key==="ArrowDown"?1:-1,_=O<0?U===1?0:V.length-1:(O+U+V.length)%V.length;V[_]?.focus()},I=x.useRef(a);I.current=a;const D=x.useRef(g);D.current=g,x.useEffect(()=>{if(!t)return;const E=V=>{const O=V.target;v.current?.contains(O)||k.current?.contains(O)||I.current(!1)},B=Q2(),Y=V=>{if(V.key!=="Escape"||!Z2(B))return;M()?.focus();const O=D.current;O?O():I.current(!1)};return window.addEventListener("mousedown",E),window.addEventListener("keydown",Y),()=>{X2(B),window.removeEventListener("mousedown",E),window.removeEventListener("keydown",Y)}},[t]);const K=x.useCallback(()=>{if(!t||!m||!v.current){S(null);return}const E=p??v.current.getBoundingClientRect(),B=k.current,Y=B?.offsetWidth??0,V=B?.offsetHeight??0,O=m.align==="right"?E.right-Y:E.left,U=Math.max(Zo,Math.min(O,window.innerWidth-Y-Zo)),_=window.innerHeight-E.bottom-dd-Zo,P=E.top-dd-Zo,H=m.direction==="up",z=(H?V<=P:V<=_)?H:P>_;S({left:U,maxHeight:Math.max(0,z?P:_),...z?{bottom:window.innerHeight-E.top+dd}:{top:E.bottom+dd}})},[t,m?.direction,m?.align,i,p?.top,p?.left,p?.bottom,p?.right]);x.useLayoutEffect(K,[K]),x.useEffect(()=>{if(!t||!m)return;const E=Y=>{k.current?.contains(Y.target)||(p?I.current(!1):K())},B=()=>{p?I.current(!1):K()};return window.addEventListener("scroll",E,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",B)}},[t,m,K,p]);const F=`anim-pop ${m?"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 ${m?"":"max-h-[70vh]"} ${l??"left-0 top-full mt-1 w-64 max-w-[calc(100vw-2rem)] origin-top-left"}`;return r.jsxs("div",{className:`relative ${u??""}`,ref:v,children:[e,t&&(m?nl.createPortal(r.jsx("div",{ref:k,onKeyDown:T,style:{position:"fixed",...w?{left:w.left,maxHeight:w.maxHeight,...w.top!==void 0?{top:w.top}:{},...w.bottom!==void 0?{bottom:w.bottom}:{}}:{left:0,top:0,visibility:"hidden"},maxWidth:`calc(100vw - ${Zo*2}px)`,...c},className:F,children:i}),document.body):r.jsx("div",{ref:k,onKeyDown:T,...c!==void 0?{style:c}:{},className:`absolute ${F}`,children:i}))]})}function J2(e,t){return{top:t,bottom:t,left:e,right:e}}function Z3(e){return e.button===2&&!(e.clientX===0&&e.clientY===0)}function J3(e,t){return Z3(e)?J2(e.clientX,e.clientY):t}function eA(e){return e.shiftKey&&e.key==="F10"}const tA=500,e1=10,nA=350;function eS(e){return e==="touch"||e==="pen"}function aA(e,t){return Math.abs(t.x-e.x)>e1||Math.abs(t.y-e.y)>e1}function rA(e,t){return t-e<nA}const sA={pointer:"",held:!1,settleFrom:0},Gr={open:null,close:!1,swallow:!1};function iA(e,t){switch(t.kind){case"pointerdown":return{...Gr,state:{...e,pointer:t.pointerType,held:!1}};case"hold":return{...Gr,state:{...e,held:!0,settleFrom:t.at},open:"held"};case"nativemenu":return e.held?{...Gr,state:e}:eS(e.pointer)?{...Gr,state:{...e,held:!0,settleFrom:t.at},open:"event"}:{...Gr,state:e,open:"event"};case"pointerup":return{...Gr,state:{...e,pointer:"",settleFrom:e.held?t.at:e.settleFrom}};case"dismiss":return e.held&&rA(e.settleFrom,t.at)?{...Gr,state:e}:{...Gr,state:{...e,held:!1},close:!0};case"click":return e.held?{...Gr,state:{...e,held:!1},swallow:!0}:{...Gr,state:e}}}function lA(){const e=x.useRef(null),[t,a]=x.useState(null),i=x.useRef(null),l=x.useRef(null),c=x.useRef(sA),u=x.useCallback(()=>{i.current!==null&&(clearTimeout(i.current),i.current=null),l.current=null},[]);x.useEffect(()=>u,[u]);const m=x.useCallback(()=>{const k=e.current?.getBoundingClientRect();return k?{top:k.top,bottom:k.bottom,left:k.left,right:k.right}:{top:0,bottom:0,left:0,right:0}},[]),p=x.useCallback((k,w)=>{const S=iA(c.current,k);if(c.current=S.state,S.open==="held"){const M=l.current;M&&a(J2(M.x,M.y))}else S.open==="event"&&w&&a(w);return S.close&&a(null),S},[]),h=k=>{const w=k.currentTarget;return w instanceof Node&&w.contains(k.target)},g={onContextMenu:k=>{h(k)&&(k.preventDefault(),p({kind:"nativemenu",at:Date.now()},J3(k,m())),c.current.held&&u())},onKeyDown:k=>{h(k)&&eA(k)&&(k.preventDefault(),a(m()))},onPointerDown:k=>{if(!h(k)||(p({kind:"pointerdown",pointerType:k.pointerType}),!eS(k.pointerType)))return;const w=k.clientX,S=k.clientY;l.current={x:w,y:S},i.current=setTimeout(()=>{i.current=null,p({kind:"hold",at:Date.now()})},tA)},onPointerMove:k=>{const w=l.current;w!==null&&aA(w,{x:k.clientX,y:k.clientY})&&u()},onPointerUp:()=>{u(),p({kind:"pointerup",at:Date.now()})},onPointerCancel:()=>{u(),p({kind:"pointerup",at:Date.now()})}},v=x.useCallback(()=>{c.current={...c.current,held:!1},a(null)},[]);return{rowRef:x.useCallback(k=>{e.current=k},[]),rowProps:g,open:t!==null,setOpen:k=>{k||p({kind:"dismiss",at:Date.now()})},anchor:t,returnFocus:()=>e.current?.querySelector("button")??null,consumeLongPressClick:()=>p({kind:"click"}).swallow,close:v}}const Zg="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",tS="M4 20h4L18.5 9.5a2.1 2.1 0 0 0-3-3L5 17v3zM14 7l3 3",oA="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",cA="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",nS="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",Jg="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",aS="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",e0=e=>r.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:r.jsx(Mn,{d:e,size:13})}),uA=["archive","delete"];function dA(e){return e?["pin","rename","archive","delete"]:["rename","archive","delete"]}function rS(e,t){switch(e){case"pin":return{label:t.pinned?f.chat.unpinSession:f.chat.pinSession,icon:Zg,danger:!1};case"rename":return{label:f.chat.renameSession,icon:tS,danger:!1};case"archive":return{label:t.archived?f.chat.unarchiveSession:f.chat.archiveSession,icon:t.archived?cA:oA,danger:!1};case"delete":return{label:f.chat.deleteSession,icon:nS,danger:!0}}}function fA({actions:e,state:t,onRun:a}){return r.jsx(r.Fragment,{children:e.map(i=>{const l=rS(i,t);return r.jsxs("button",{type:"button",className:l.danger?aS:Jg,onClick:()=>a(i),children:[l.danger?r.jsx("span",{className:"shrink-0",children:r.jsx(Mn,{d:l.icon,size:13})}):e0(l.icon),l.label]},i)})})}function mA({actions:e,state:t,onRun:a}){return r.jsx(r.Fragment,{children:e.map(i=>{const l=rS(i,t);return r.jsx("button",{type:"button",title:l.label,"aria-label":l.label,onClick:()=>a(i),className:`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 ${l.danger?"hover:text-red-600 dark:hover:text-red-400":"hover:text-gray-700 dark:text-gray-500 dark:hover:text-gray-200"}`,children:r.jsx(Mn,{d:l.icon,size:14})},i)})})}function pA(e){let t=2166136261;for(let a=0;a<e.length;a++)t^=e.charCodeAt(a),t=Math.imul(t,16777619);return t>>>0}function hA(e){return pA(e)%360}function sS(e){const t=hA(e);return{bg:`hsl(${t} 55% 50% / 0.14)`,fg:`hsl(${t} 55% 28%)`,fgDark:`hsl(${t} 55% 73%)`}}const t1=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"grapheme"}):void 0;function n1(e){if(e){if(!t1)return Array.from(e)[0];for(const t of t1.segment(e))return t.segment}}function iS(e,t){const a=n1(e.trim())??n1((t??"").trim());return a?a.toUpperCase():"?"}function Da({id:e,name:t,size:a=18,className:i}){const l=sS(e);return r.jsxs("svg",{width:a,height:a,viewBox:"0 0 24 24",className:i,style:{"--tile-fg":l.fg,"--tile-fg-dark":l.fgDark},"aria-hidden":!0,role:"img",children:[r.jsx("rect",{x:"0",y:"0",width:"24",height:"24",rx:"5",fill:l.bg}),r.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:iS(t??"",e)})]})}const gA={success:2500,info:4e3,error:6e3},xc=ao(()=>({items:[]}));let xA=1;const yA=160;function lS(e){const t=xc.getState().items.find(a=>a.id===e);!t||t.leaving||(xc.setState(a=>({items:a.items.map(i=>i.id===e?{...i,leaving:!0}:i)})),setTimeout(()=>{xc.setState(a=>({items:a.items.filter(i=>i.id!==e)}))},yA))}function t0(e,t){if(!t)return;const a=xA++;xc.setState(i=>({items:[...i.items,{id:a,kind:e,text:t}]})),setTimeout(()=>lS(a),gA[e])}const Ut=e=>t0("success",e),Ve=e=>t0("error",e),pa=e=>t0("info",e),vA={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 bA(){const e=ro(xc,t=>t.items);return e.length===0?null:nl.createPortal(r.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=>r.jsx("button",{type:"button",onClick:()=>lS(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"} ${vA[t.kind]}`,children:t.text},t.id))}),document.body)}const kA=1,wA=60,SA=350,jA=4e3;function CA(e,t){const a=e-t;return a>kA?a:0}function NA(e){if(e<=0)return 0;const t=e/wA*1e3;return Math.round(Math.min(jA,Math.max(SA,t)))}function qc({text:e,className:t="",scrollReveal:a=!1}){const i=x.useRef(null),[l,c]=x.useState(0);x.useLayoutEffect(()=>{const p=i.current;if(!p)return;const h=()=>c(CA(p.scrollWidth,p.clientWidth));if(h(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(h);return g.observe(p),()=>g.disconnect()},[e,t]);const u=l>0,m=a&&u;return r.jsx("span",{ref:i,className:`truncate ${t}${m?" title-scroll":""}`,...m?{style:{"--title-scroll-shift":`-${l}px`,"--title-scroll-ms":`${NA(l)}ms`}}:{},...u?{title:e}:{},children:a?r.jsx("span",{className:"title-scroll-text",children:e}):e})}const TA={gray:"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300",brand:"bg-gray-200/80 text-gray-700 dark:bg-gray-700/60 dark:text-gray-200",green:"bg-emerald-50 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300",yellow:"bg-yellow-50 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-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"};function Cn({tone:e="gray",children:t}){return r.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-semibold ${TA[e]}`,children:t})}function MA(e){switch(e){case"completed":return"green";case"aborted":return"amber";default:return"red"}}const AA={running:"M6 3h12M6 21h12M8 3v3.5L12 10l4-3.5V3M8 21v-3.5L12 14l4 3.5V21",compacting:"M6 3h12M6 21h12M8 3v3.5L12 10l4-3.5V3M8 21v-3.5L12 14l4 3.5V21"},EA={running:"hourglass-turn text-gray-500 dark:text-gray-400",compacting:"hourglass-turn text-amber-600 dark:text-amber-400"};function Wh(e){return e==="running"?f.chat.statusRunning:e==="compacting"?f.chat.statusCompacting:f.chat.statusCompletedUnread}function oS({activity:e,size:t=12}){const a=Wh(e);return e==="completedUnread"?r.jsx("span",{role:"img","aria-label":a,title:a,style:{width:t,height:t},className:"flex shrink-0 items-center justify-center",children:r.jsx("span",{className:"block h-1.5 w-1.5 rounded-full bg-emerald-500"})}):r.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":a,className:`block shrink-0 ${EA[e]}`,children:[r.jsx("title",{children:a}),r.jsx("path",{d:AA[e]})]})}const _A={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"},RA={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 ve({variant:e="secondary",size:t="md",className:a,...i}){return r.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 ${_A[e]} ${RA[t]} ${a??""}`,...i})}function IA({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 r.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:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:t})})})}function yn({open:e,title:t,onClose:a,onConfirm:i,confirmLabel:l,confirmDisabled:c=!1,secondaryLabel:u,onSecondary:m,tone:p="danger",busy:h=!1,children:g}){return r.jsxs(Xt,{open:e,title:t,onClose:a,headerless:!0,widthClass:"sm:max-w-sm",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(IA,{tone:p}),r.jsx("div",{className:"min-w-0 flex-1 pt-1.5",children:g})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[r.jsx(ve,{size:"sm",onClick:a,disabled:h,children:f.common.cancel}),u!==void 0&&m!==void 0&&r.jsx(ve,{size:"sm",onClick:m,disabled:h,children:u}),r.jsx(ve,{size:"sm",variant:p,disabled:h||c,onClick:i,children:l??f.common.confirm})]})]})}function so(){const[e,t]=x.useState(null),a=r.jsx(yn,{open:e!==null,title:f.common.confirmSaveTitle,tone:"primary",confirmLabel:f.common.save,onClose:()=>t(null),onConfirm:()=>{e?.(),t(null)},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.common.confirmSaveBody})});return{requestSave:i=>t(()=>i),element:a}}const kf="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",n0="w-full px-3 py-1.5 text-left transition-colors duration-150";function wr({children:e,required:t}){return r.jsxs("span",{className:"mb-1 block text-xs font-semibold text-gray-600 dark:text-gray-400",children:[e,t&&r.jsx("span",{className:"ml-0.5 text-red-500 dark:text-red-400","aria-hidden":!0,children:"*"})]})}function Yd({children:e}){return r.jsx("span",{className:"mt-1 block text-xs text-gray-500 dark:text-gray-500",children:e})}function Kr({id:e,children:t}){return r.jsx("span",{id:e,role:"alert",className:"mt-1 block text-xs text-red-600 dark:text-red-400",children:t})}function Gc({label:e,hint:t,error:a,errorId:i,required:l,children:c}){return!e&&!t&&!a?r.jsx(r.Fragment,{children:c}):r.jsxs("label",{className:"block",children:[e!=null&&e!==""&&r.jsx(wr,{required:l,children:e}),c,a?r.jsx(Kr,{id:i,children:a}):t?r.jsx(Yd,{children:t}):null]})}const cS=`w-full ${kf} placeholder:text-gray-400 disabled:cursor-not-allowed disabled:opacity-60 dark:placeholder:text-gray-500`,wf={base:"px-3 py-2 text-base",sm:"px-2 py-1 text-xs"},Sf="!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 a0(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 Wc=a0(void 0,!1);function rt({label:e,hint:t,error:a,invalid:i,required:l,size:c="base",className:u,autoComplete:m,...p}){const h=!!a||!!i,g=x.useId();return r.jsx(Gc,{label:e,hint:t,error:a,errorId:g,required:l,children:r.jsx("input",{className:`${cS} ${wf[c]} ${h?Sf:""} ${u??""}`,"aria-invalid":h?!0:void 0,"aria-required":l||void 0,"aria-describedby":a?g:void 0,...a0(m,p.type==="password"),...p})})}const Kn=x.forwardRef(function({label:t,hint:a,error:i,invalid:l,required:c,mono:u,size:m="base",className:p,autoComplete:h,...g},v){const k=!!i||!!l,w=x.useId();return r.jsx(Gc,{label:t,hint:a,error:i,errorId:w,required:c,children:r.jsx("textarea",{ref:v,className:`${cS} px-3 py-2 ${m==="sm"?"text-xs leading-relaxed":"text-base"} ${u?"font-mono":""} ${k?Sf:""} ${p??""}`,"aria-invalid":k?!0:void 0,"aria-required":c||void 0,"aria-describedby":i?w:void 0,...a0(h,!1),...g})})});function Wi({options:e,value:t,onChange:a,cols:i=3}){return r.jsx("div",{className:`grid ${i===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(l=>r.jsx("button",{type:"button",onClick:()=>a(l.value),className:`rounded px-1 py-1 text-xs transition-colors duration-150 ${t===l.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:l.label},l.value))})}function mn({className:e}){return r.jsx("div",{className:`animate-pulse rounded bg-gray-200 dark:bg-gray-800 ${e??"h-4 w-full"}`})}function La({rows:e=3}){return r.jsx("div",{className:"space-y-2 p-2",children:Array.from({length:e},(t,a)=>r.jsx(mn,{className:"h-8 w-full"},a))})}function uS({className:e,children:t}){return r.jsx("div",{className:`rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900 ${e??"p-4"}`,children:t??r.jsxs(r.Fragment,{children:[r.jsx(mn,{className:"h-3 w-20"}),r.jsx(mn,{className:"mt-2.5 h-6 w-28"}),r.jsx(mn,{className:"mt-2.5 h-3 w-24"})]})})}const LA=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"]),OA=/^[a-z][a-z0-9+.-]*:\/\//i;function DA(e){const t=e.trim();if(t.length===0||t.length>200||/\s/.test(t)||OA.test(t)||t.startsWith("www."))return!1;const a=/\.([A-Za-z0-9]{1,8})$/.exec(t);if(!a)return!1;const i=a[1].toLowerCase();return/^\d+$/.test(i)?!1:LA.has(i)}function Ud(e,t){return e===""?t:`${e}/${t}`}function UA(e){const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),a=t===-1?e:e.slice(t+1);return a===""?e:a}const zA=512;function $A(e,t){const a=e.trim();if(a.length===0||a.length>zA||a.startsWith("~"))return null;const i=t!==null&&t.length>0?t:null,l=i!==null&&(i.includes("\\")||/^[A-Za-z]:/.test(i)),c=v=>{if(!l)return v;const k=v.replaceAll("\\","/");return/^[A-Za-z]:/.test(k)?k[0].toLowerCase()+k.slice(1):k},u=c(a),m=i===null?null:c(i),p=u.startsWith("/")||l&&/^[a-z]:/.test(u);let h=u;if(p){if(m===null||!u.startsWith(`${m}/`))return null;h=u.slice(m.length+1)}const g=[];for(const v of h.split("/"))if(!(v===""||v===".")){if(v===".."){if(g.length===0)return null;g.pop();continue}g.push(v)}return g.length>0?g.join("/"):null}function Jr(e){x.useEffect(()=>{document.title=e?`${e} · ${f.appName}`:f.appName},[e])}var PA=["partial_text","partial_thinking","partial_tool_call","partial_tool_call_output"];function Ic(e){return PA.includes(e.type??"")}function r0(e){return e.type==="event_msg"}function dS(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s0(e,t){return`[${e}]
127
- ${t}
128
- [/${e}]`}function Kc(e,t,a=""){const i=dS(e);return[new RegExp(`\\[${i}\\]${t}\\[/${i}\\]`,a),new RegExp(`<${i}>${t}</${i}>`,a)]}function jf(e,t){return e[0].exec(t)??e[1].exec(t)}function a1(e,t){const a=dS(t);return e.replace(new RegExp(`\\[${a}\\][\\s\\S]*?\\[/${a}\\]`,"g"),"").replace(new RegExp(`\\[/?${a}\\]`,"g"),"").replace(new RegExp(`<${a}>[\\s\\S]*?</${a}>`,"g"),"").replace(new RegExp(`</?${a}>`,"g"),"")}var Sr={summary:"summary",userSteering:"user_steering",useSkills:"use_skills",handoffFrom:"handoff_from",scheduledTask:"scheduled_task",modelSwitchFrom:"model_switch_from"},BA="[attached image: ",HA="[attached file: ",FA=/^\[attached image: (.+)\]$/,VA=/^\[attached file: (.+)\]$/;function qA(e){return FA.exec(e)?.[1]??null}function GA(e){return VA.exec(e)?.[1]??null}var WA=Kc(Sr.summary,"([\\s\\S]*?)","g");function KA(e){for(const t of WA)for(const a of e.matchAll(t)){const i=a1(a[1],Sr.summary).trim();if(i!=="")return i}return a1(e,Sr.summary).trim()}function Kh(e,t){if(e.length===0)return t;const a=s0(Sr.useSkills,`skills: ${e.join(", ")}`);return t?`${a}
129
-
130
- ${t}`:a}var YA=Kc(Sr.useSkills,"\\nskills: ([^\\n]+)\\n");function fS(e){const t=jf(YA,e);if(!t||t.index!==0)return null;const a=t[1].split(",").map(i=>i.trim()).filter(i=>i.length>0);return a.length===0?null:{skills:a,rest:e.slice(t[0].length).replace(/^\n+/,"")}}function mS(e){const t=/^([\w-]+) \((.*)\)$/.exec(e);return t?{id:t[1],label:t[2]}:{id:e}}function i0(e,t){const a=new RegExp(`^(${t.join("|")}): (.+)$`),i=[];for(const l of e.split(`
131
- `)){const c=a.exec(l);c&&i.push([c[1],c[2]])}return i}function QA(e){const t=e.agentName&&e.agentName!==e.agentId?` (${e.agentName})`:"",a=[`agent: ${e.agentId}${t}`];if(e.sessionId){const i=e.sessionTitle?` (${e.sessionTitle})`:"";a.push(`session: ${e.sessionId}${i}`)}return e.workspace&&a.push(`workspace: ${e.workspace}`),s0(Sr.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.",...a].join(`
132
- `))}var XA=Kc(Sr.handoffFrom,"\\n([\\s\\S]*)\\n","");function pS(e){const t=e.trim(),a=jf(XA,t);if(!a||a.index!==0||a[0].length!==t.length)return null;const i={agentId:""};for(const[l,c]of i0(a[1],["agent","session","workspace"])){if(l==="workspace"){i.workspace=c;continue}const{id:u,label:m}=mS(c);l==="agent"?(i.agentId=u,m!==void 0&&(i.agentName=m)):(i.sessionId=u,m!==void 0&&(i.sessionTitle=m))}return i.agentId?i:null}var ZA=Kc(Sr.scheduledTask,"\\n([\\s\\S]*?)\\n");function hS(e){const t=jf(ZA,e);if(!t||t.index!==0)return null;const a={name:"",firedAt:""};for(const[i,l]of i0(t[1],["schedule","fired_at"]))i==="schedule"?a.name=l:a.firedAt=l;return a.name?{origin:a,rest:e.slice(t[0].length).replace(/^\n+/,"")}:null}function JA(e){const t=e.sessionTitle?` (${e.sessionTitle})`:"",a=[`session: ${e.sessionId}${t}`];return e.tracePath&&a.push(`trace: ${e.tracePath}`),e.workspace&&a.push(`workspace: ${e.workspace}`),e.prevModelId&&a.push(`previous_model: ${e.prevModelId}`),e.prevProvider&&a.push(`previous_provider: ${e.prevProvider}`),s0(Sr.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).",...a].join(`
133
- `))}var eE=Kc(Sr.modelSwitchFrom,"\\n([\\s\\S]*)\\n");function gS(e){const t=e.trim(),a=jf(eE,t);if(!a||a.index!==0||a[0].length!==t.length)return null;const i={sessionId:""},l=["session","trace","workspace","previous_model","previous_provider"];for(const[c,u]of i0(a[1],l))if(c==="session"){const{id:m,label:p}=mS(u);i.sessionId=m,p!==void 0&&(i.sessionTitle=p)}else c==="trace"?i.tracePath=u:c==="workspace"?i.workspace=u:c==="previous_model"?i.prevModelId=u:i.prevProvider=u;return i.sessionId?i:null}var tE=new RegExp(`^\\[${Sr.userSteering}\\]\\n([\\s\\S]*?)\\n\\[/${Sr.userSteering}\\]\\s*$`);function nE(e){const t=tE.exec(e);return t?t[1]:null}function xS(e){const t=/^\[goal\]\nround: (\d+)\n[\s\S]*?\n\[\/goal\](?:\n|$)/.exec(e);if(!t)return null;const a=Number(t[1]);return!Number.isInteger(a)||a<=0?null:{round:a,rest:e.slice(t[0].length).replace(/^\n+/,"")}}function r1(e,t){return t?(e.cacheRead*t.cacheRead+e.cacheWrite*t.cacheWrite+e.output*t.output)/1e6:null}function aE(){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 s1(e,t){e.subagentTotal=t.subagentTokens,e.sessionElapsedMs=t.elapsedMs,e.sessionTotal=t.sessionTokens,e.contextNow=t.contextTokens,e.contextAtLastStats=t.contextTokens}function yS(e,t){e.taskCacheRead+=t.request.cache_read,e.taskCacheWrite+=t.request.cache_write,e.taskOutput+=t.request.output}function rE(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,yS(e,t),e.contextNow=t.request.total,e.contextStale=!1,e.taskMainOutput+=t.request.output,e.hasUsage=!0}function sE(e){e.pendingCompactionTokens!==0&&(e.taskTokens+=e.pendingCompactionTokens,e.taskCacheRead+=e.pendingCompactionCacheRead,e.taskCacheWrite+=e.pendingCompactionCacheWrite,e.taskOutput+=e.pendingCompactionOutput,e.hasUsage=!0,l0(e))}function l0(e){e.pendingCompactionTokens=0,e.pendingCompactionCacheRead=0,e.pendingCompactionCacheWrite=0,e.pendingCompactionOutput=0}function iE(e,t){t>0&&(e.taskLlmMs+=t)}function lE(e,t){e.taskTokens+=t.request.total,yS(e,t),e.subagentTotal+=t.request.total,e.hasUsage=!0}function oE(e){e.compactionActive=!0}function cE(e,t){e.compactionActive=!1,t==="completed"&&(e.contextStale=!0)}function uE(e){e.taskTokens=0,e.taskCacheRead=0,e.taskCacheWrite=0,e.taskOutput=0,e.taskMainOutput=0,e.taskLlmMs=0,l0(e),e.hasUsage=!1,e.compactionActive=!1}function dE(e,t){if(e.sessionElapsedMs+=t,l0(e),!e.hasUsage)return e.taskTokens=0,null;const a={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:qh(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,a}function fE(e,t,a,i){const l=t&&a!=null?Math.max(0,i-a):0;return e.sessionElapsedMs+l}function mE(e,t){const a=e.tokensByBucket;return`[${t.stats}] ${t.input} ${Rt(a.cacheRead+a.cacheWrite)}${t.parenOpen}${t.cached} ${Rt(a.cacheRead)}${t.parenClose} · ${t.output} ${Rt(a.output)} · ${qd(e.outputTps)}`}function pE(e){return e==="failed"||e==="timeout"||e==="malformed"}function vS(e,t){return{items:[],nested:e,meta:null,stats:aE(),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,lastAuthFailureMs:null,taskOpen:!1,taskStartLocalMs:0,taskFirstTsMs:0,taskLastTsMs:0,taskLastReqEndMs:null,turnToolOutputs:!1,reopenTaskAtSteering:!1,nextItemId:1}}function ql(e=new Set){return vS(!1,e)}function hE(e,t){return e===null?!1:t===null||e>t}function fa(e){return e.nextItemId++}function Lc(e,t,a=Date.now()){if(t.origin&&t.origin.length>0){AE(e,t,a);return}if(gE(t)||(e.openSteering=null),t.type==="model_msg"){if(e.stats.compactionActive){if(br(e,t.timestamp),Ic(t.payload)){const l=t.payload;l.type==="partial_text"&&l.text&&o1(e,l.text);return}Qp(e,t.timestamp);const i=t.payload;i.type==="text"&&i.role==="assistant"&&i.text&&o1(e,i.text);return}if(Ic(t.payload)){br(e,t.timestamp),SE(e,t.payload,Rr(t.timestamp));return}jE(e,t.payload,t.timestamp,a,t.tracePosition),Qp(e,t.timestamp);return}if(r0(t)){br(e,t.timestamp),CE(e,t.payload,Rr(t.timestamp),a),Qp(e,t.timestamp);return}if(t.type==="session_meta"&&e.nested){const i=t.payload,l={agentId:xE(i.agent_state),provider:i.provider,modelId:i.model_id};i.source!==void 0&&(l.source=i.source),e.meta=l}}function gE(e){return e.type==="model_msg"&&e.payload.type==="image_url"}function xE(e){const t=e.split(/[\\/]/).filter(a=>a.length>0);return t.length>=2?t[t.length-2]:null}function yE(e,t){const a=t.join("/");for(const i of e)if(i.startsWith(`${a} `)||i.startsWith(`${a}/`))return!0;return!1}function Rr(e){const t=Date.parse(e);return Number.isFinite(t)?t:void 0}function Qp(e,t){const a=Date.parse(t);Number.isFinite(a)&&(e.lastTsMs=a)}function i1(e,t,a=Date.now(),i=null){for(const l of t)Lc(e,l,a);if(e.taskOpen){const l=e.taskLastTsMs-e.taskFirstTsMs,c=i===null?0:i-e.taskFirstTsMs;e.taskStartLocalMs=a-Math.max(0,l,c)}}function vE(e){Cf(e)}function Yh(e){Cf(e)}function bE(e,t){e.localDecisions.add(t)}function Xl(e,t){return`${e?.join("/")??""} ${t}`}function kE(e,t,a){let i=e;for(const l of t??[])if(i=i.subagents.get(l),!i)return null;return i.toolCards.get(a)??null}function br(e,t){if(!e.taskOpen||e.stats.compactionActive)return;const a=Date.parse(t);!Number.isFinite(a)||a<=e.taskLastTsMs||(e.taskLastTsMs=a)}function Xp(e,t,a){Cf(e);const i=Jh(e);i&&(i.gaveUp=!0),e.openRequestBeginMs=null,e.openApprovalWaitMs=0,e.turnToolOutputs=!1,e.reopenTaskAtSteering=!1,e.taskOpen=!0,e.taskStartLocalMs=a;const l=Date.parse(t);e.taskFirstTsMs=Number.isFinite(l)?l:a,e.taskLastTsMs=e.taskFirstTsMs,e.taskLastReqEndMs=null,uE(e.stats)}function Cf(e){if(!e.taskOpen)return;e.taskOpen=!1,bS(e);const t=e.taskLastReqEndMs??e.taskLastTsMs,a=Math.max(0,t-e.taskFirstTsMs),i=dE(e.stats,a);if(e.nested)return;const l=wE(e);if(i===null&&l.text==="")return;const c={kind:"task_stats",id:fa(e),stats:i,assistantText:l.text,forkable:l.completed,...l.atMs!==void 0?{atMs:l.atMs}:{},...l.tracePosition!==void 0?{forkPosition:l.tracePosition}:{}};let u=e.items.length;for(;u>0&&e.items[u-1].kind==="compaction";)u--;e.items.splice(u,0,c)}function wE(e){const t=[];let a,i,l=!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),a===void 0&&(a=u.atMs,i=u.tracePosition,l=u.stopReason==="completed"))}return{text:t.reverse().join(`
134
-
135
- `),...a!==void 0?{atMs:a}:{},...i!==void 0?{tracePosition:i}:{},completed:l}}function SE(e,t,a){switch(t.type){case"partial_text":{if(t.event_type==="start"){e.pendingText=null;const l={kind:"assistant_text",id:fa(e),text:t.text??"",streaming:!0,...a!==void 0?{atMs:a}:{}};e.openText=l,e.items.push(l);return}const i=e.openText;if(!i)return;t.text&&(i.text+=t.text),t.event_type==="stop"&&(i.streaming=!1,t.stop_reason!==void 0&&(i.stopReason=t.stop_reason),e.pendingText=i,e.openText=null);return}case"partial_thinking":{if(t.event_type==="start"){e.pendingThinking=null;const l={kind:"thinking",id:fa(e),thinking:t.thinking??"",streaming:!0};a!==void 0&&(l.startedAtMs=a),e.openThinking=l,e.items.push(l);return}const i=e.openThinking;if(!i)return;t.thinking&&(i.thinking+=t.thinking),t.event_type==="stop"&&(i.streaming=!1,t.stop_reason!==void 0&&(i.stopReason=t.stop_reason),Qh(i,a),e.pendingThinking=i,e.openThinking=null);return}case"partial_tool_call":{const i=e.toolCards.get(t.tool_call_id);if(i?.callComplete)return;if(t.event_type==="start"){if(i){i.name=t.name||i.name,i.argumentsText=t.arguments??"",i.callStreaming=!0,a!==void 0&&i.argStartedAtMs===void 0&&(i.argStartedAtMs=a);return}const l=Zh(e,{toolCallId:t.tool_call_id,name:t.name,argumentsText:t.arguments??"",callStreaming:!0});a!==void 0&&(l.argStartedAtMs=a);return}if(!i)return;t.name&&!i.name&&(i.name=t.name),t.arguments&&(i.argumentsText+=t.arguments),t.event_type==="stop"&&(i.callStreaming=!1,t.stop_reason!==void 0&&(i.callStopReason=t.stop_reason),a!==void 0&&(i.callStartedAtMs=a));return}case"partial_tool_call_output":{const i=e.toolCards.get(t.tool_call_id);if(!i||i.outputComplete)return;if(t.event_type==="start"){i.outputStreaming=!0,t.output&&(i.output+=t.output),t.images&&t.images.length>0&&(i.images=t.images);return}if(!i.outputStreaming)return;t.output&&(i.output+=t.output),t.images&&t.images.length>0&&(i.images=t.images),t.event_type==="stop"&&(i.outputStreaming=!1,t.stop_reason!==void 0&&(i.outputStopReason=t.stop_reason),kS(i,a));return}}}function jE(e,t,a,i,l){switch(t.type){case"text":{if(t.role==="user"){if(t.text.startsWith("[context_summary]")||t.text.startsWith("<context_summary>")){br(e,a);return}const p=nE(t.text);if(p!==null){e.reopenTaskAtSteering&&!e.taskOpen&&Xp(e,a,i),br(e,a);const g=Rr(a),v={kind:"user_steering",id:fa(e),text:p,...g!==void 0?{atMs:g}:{}};e.items.push(v),e.openSteering=v;return}Xp(e,a,i);const h=Rr(a);e.items.push({kind:"user_text",id:fa(e),text:t.text,...h!==void 0?{atMs:h}:{}});return}br(e,a);const c=e.pendingText??e.openText;if(c){if(!t.text.trim()){yc(e,c),c===e.openText&&(e.openText=null),e.pendingText=null;return}c.text=t.text,c.streaming=!1;const p=Rr(a);p!==void 0&&(c.atMs=p),l!==void 0&&(c.tracePosition=l),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=Rr(a),m={kind:"assistant_text",id:fa(e),text:t.text,streaming:!1,...u!==void 0?{atMs:u}:{},...l!==void 0?{tracePosition:l}:{}};t.stop_reason!==void 0&&(m.stopReason=t.stop_reason),e.items.push(m);return}case"image_url":{if(e.openSteering){br(e,a),e.openSteering.images=[...e.openSteering.images??[],t.image_url];return}Xp(e,a,i);const c=Rr(a);e.items.push({kind:"user_image",id:fa(e),imageUrl:t.image_url,...c!==void 0?{atMs:c}:{}});return}case"thinking":{br(e,a);const c=Rr(a),u=e.pendingThinking??e.openThinking;if(u){if(!t.thinking.trim()){yc(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),Qh(u,c),u===e.openThinking&&(e.openThinking=null),e.pendingThinking=null;return}if(!t.thinking.trim())return;const m={kind:"thinking",id:fa(e),thinking:t.thinking,streaming:!1};t.stop_reason!==void 0&&(m.stopReason=t.stop_reason),e.lastTsMs>0&&(m.startedAtMs=e.lastTsMs),Qh(m,c),e.items.push(m);return}case"tool_call":{br(e,a);const c=Rr(a),u=e.toolCards.get(t.tool_call_id),m=u?.callComplete?void 0:u;if(m){m.name=t.name,m.argumentsText=t.arguments,m.callStreaming=!1,m.callComplete=!0,t.stop_reason!==void 0&&(m.callStopReason=t.stop_reason),c!==void 0&&(m.callStartedAtMs=c),Xh(e,m),l1(m);return}u&&!u.outputComplete&&(u.outputComplete=!0,u.outputStreaming=!1,u.outputStopReason??="aborted");const p=Zh(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),Xh(e,p),e.lastTsMs>0&&(p.argStartedAtMs=e.lastTsMs),l1(p);return}case"tool_call_output":{br(e,a);let c=e.toolCards.get(t.tool_call_id);c||(c=Zh(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),kS(c,Rr(a)),e.turnToolOutputs=!0;return}case"inline_data":case"inline_thinking":br(e,a);return}}function bS(e){for(const t of e.toolCards.values())t.callComplete&&!t.outputComplete&&(t.outputComplete=!0,t.outputStreaming=!1,t.outputStopReason??="aborted")}function l1(e){!e.callStopReason||e.callStopReason==="completed"||e.outputComplete||(e.outputComplete=!0,e.outputStreaming=!1,e.outputStopReason??=e.callStopReason)}function Qh(e,t){t===void 0||e.startedAtMs===void 0||(e.durationMs=Math.max(0,t-e.startedAtMs))}function kS(e,t){if(t===void 0)return;const a=e.approvalAtMs??e.callStartedAtMs;if(a===void 0)return;const i=e.argStartedAtMs!==void 0&&e.callStartedAtMs!==void 0?Math.max(0,e.callStartedAtMs-e.argStartedAtMs):0;e.durationMs=i+Math.max(0,t-a)}function Xh(e,t){if(t.approvalWaitCounted)return;const{callStartedAtMs:a,approvalAtMs:i}=t;if(a===void 0||i===void 0)return;t.approvalWaitCounted=!0;const l=i-a;l>0&&(e.openApprovalWaitMs+=l)}function Zh(e,t){const a={kind:"tool_call",id:fa(e),toolCallId:t.toolCallId,name:t.name,argumentsText:t.argumentsText,callStreaming:t.callStreaming,callComplete:!1,output:"",outputStreaming:!1,outputComplete:!1},i=e.pendingDecisions.get(t.toolCallId);if(i!==void 0){a.decision=i,a.decisionSource=e.localDecisions.has(t.toolCallId)?"manual":"remote",e.pendingDecisions.delete(t.toolCallId);const l=e.pendingDecisionTs.get(t.toolCallId);l!==void 0&&(a.approvalAtMs=l,e.pendingDecisionTs.delete(t.toolCallId))}return e.toolCards.set(t.toolCallId,a),e.items.push(a),a}function CE(e,t,a,i){switch(t.type){case"approval_decision":{const l=e.toolCards.get(t.tool_call_id);l?(l.decision=t.decision,l.decisionSource=e.localDecisions.has(t.tool_call_id)?"manual":"remote",a!==void 0&&l.approvalAtMs===void 0&&(l.approvalAtMs=a),Xh(e,l)):(e.pendingDecisions.set(t.tool_call_id,t.decision),a!==void 0&&e.pendingDecisionTs.set(t.tool_call_id,a));return}case"abort":{bS(e);const l=Jh(e);l&&(l.gaveUp=!0);const c={kind:"abort",id:fa(e)};t.reason!=null&&(c.reason=t.reason),e.items.push(c);return}case"token_usage":rE(e.stats,t);return;case"mcp_connect_begin":{e.items.push({kind:"mcp_connect",id:fa(e),servers:t.servers,running:!0,...a!==void 0?{beginTsMs:a}:{}});return}case"mcp_connect_end":{const l=NE(e);if(!l)return;l.running=!1,a!==void 0&&l.beginTsMs!==void 0&&(l.durationMs=Math.max(0,a-l.beginTsMs)),t.status==="aborted"&&(l.aborted=!0),l.toolCount=t.results.reduce((u,m)=>u+(m.tools??0),0),l.results=t.results.map(u=>({server:u.server,status:u.status,durationMs:u.duration_ms,...u.tools!==void 0?{tools:u.tools}:{},...u.error!==void 0?{error:u.error.slice(0,500)}:{}}));const c=t.results.filter(u=>u.status==="failed");c.length>0&&(l.failed=c.map(u=>u.server));return}case"tool_list_ready":{const l=TE(e);if(!l)return;const c=t.tools.filter(u=>u.name.startsWith("mcp__"));c.length>0&&(l.tools=c.map(u=>({name:u.name,...u.description!==void 0?{description:u.description}:{}})));return}case"compaction_begin":{ME(e)&&(Cf(e),e.reopenTaskAtSteering=!0),oE(e.stats),e.items.push({kind:"compaction",id:fa(e),reason:t.reason,mode:t.mode,running:!0,...a!==void 0?{beginTsMs:a}:{}});return}case"compaction_end":{cE(e.stats,t.status);const l=wS(e);if(l)l.running=!1,l.status=t.status,t.error_message!==void 0&&(l.errorMessage=t.error_message),a!==void 0&&l.beginTsMs!==void 0&&(l.durationMs=Math.max(0,a-l.beginTsMs)),t.status!=="completed"&&delete l.summaryText;else{const c={kind:"compaction",id:fa(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 l=Jh(e);l&&(l.retrying=!0),e.stats.compactionActive||(e.openRequestBeginMs=a??null,e.openApprovalWaitMs=0,e.turnToolOutputs=!1);return}case"request_end":{if(e.stats.compactionActive)return;if(t.status==="auth"&&(e.lastAuthFailureMs=a??Date.now()),t.status==="completed"&&(e.lastAuthFailureMs=null),e.openRequestBeginMs!==null&&a!==void 0&&iE(e.stats,a-e.openRequestBeginMs-e.openApprovalWaitMs),e.openRequestBeginMs=null,e.openApprovalWaitMs=0,a!==void 0&&(e.taskLastReqEndMs=a),sE(e.stats),pE(t.status)){const l={kind:"reconnect",id:fa(e),status:t.status,attempt:t.attempt??1,retrying:!1};typeof t.retry_in_ms=="number"&&t.retry_in_ms>0&&(l.plannedDelayMs=t.retry_in_ms,l.arrivedAtMs=i??Date.now()),e.items.push(l)}return}}}function NE(e){for(let t=e.items.length-1;t>=0;t-=1){const a=e.items[t];if(a.kind==="mcp_connect"&&a.running)return a}return null}function TE(e){for(let t=e.items.length-1;t>=0;t-=1){const a=e.items[t];if(a.kind==="mcp_connect")return a}return null}function wS(e){for(let t=e.items.length-1;t>=0;t--){const a=e.items[t];if(a.kind==="compaction"&&a.running)return a}return null}function o1(e,t){if(!t)return;const a=wS(e);a&&(a.summaryText=(a.summaryText??"")+t)}function ME(e){return!e.taskOpen||e.turnToolOutputs?!1:e.items[e.items.length-1]?.kind==="assistant_text"}function Jh(e){for(let t=e.items.length-1;t>=0;t--){const a=e.items[t];if(a.kind==="reconnect")return!a.retrying&&!a.gaveUp?a:null}return null}function AE(e,t,a){const i=t.origin[0];r0(t)&&t.payload.type==="token_usage"&&lE(e.stats,t.payload),br(e,t.timestamp);let l=e.subagents.get(i);l||(l=vS(!0,e.localDecisions),l.firstSeenLocalMs=a,e.subagents.set(i,l),EE(e,i,l)),l.lastActivityLocalMs=a;const c=Rr(t.timestamp);c!==void 0&&(l.firstTsMs===void 0&&(l.firstTsMs=c),(l.lastActivityTsMs===void 0||c>l.lastActivityTsMs)&&(l.lastActivityTsMs=c));const u=t.origin.slice(1),m={...t};u.length>0?m.origin=u:delete m.origin,Lc(l,m,a)}function EE(e,t,a){for(let i=e.items.length-1;i>=0;i--){const l=e.items[i];if(l.kind==="tool_call"&&l.name==="run_subagent"&&!l.subagent&&!l.outputComplete&&l.decision==="allow"){l.subagent=a,l.subagentSessionId=t;return}}e.items.push({kind:"subagent",id:fa(e),sessionId:t,model:a})}function SS(e){const{tracePosition:t,...a}=e;return JSON.stringify(a)}function _E(e,t=100){const a=new Set;for(let i=Math.max(0,e.length-t);i<e.length;i++)a.add(SS(e[i]));return a}function RE(e,t){return e.has(SS(t))}function jS(e,t){if(t.origin&&t.origin.length>0){const i=e.subagents.get(t.origin[0]);if(!i)return;const l=t.origin.slice(1),c={...t};l.length>0?c.origin=l:delete c.origin,jS(i,c);return}if(t.type!=="model_msg"||Ic(t.payload))return;const a=t.payload;switch(a.type){case"text":{if(a.role!=="assistant")return;const i=e.pendingText??e.openText;i&&(yc(e,i),i===e.openText&&(e.openText=null),e.pendingText=null);return}case"thinking":{const i=e.pendingThinking??e.openThinking;i&&(yc(e,i),i===e.openThinking&&(e.openThinking=null),e.pendingThinking=null);return}case"tool_call":{const i=e.toolCards.get(a.tool_call_id);i&&!i.callComplete&&(yc(e,i),e.toolCards.delete(a.tool_call_id));return}case"tool_call_output":{const i=e.toolCards.get(a.tool_call_id);i&&!i.outputComplete&&(i.output="",i.outputStreaming=!1);return}default:return}}function yc(e,t){const a=e.items.indexOf(t);a>=0&&e.items.splice(a,1)}const aa={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",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",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"},IE=1500;function LE(e){navigator.clipboard?.writeText(e)}function Qd(){const[e,t]=x.useState(!1),a=x.useRef(null);return x.useEffect(()=>()=>{a.current!==null&&clearTimeout(a.current)},[]),{copied:e,flash:l=>{LE(l),t(!0),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,t(!1)},IE)}}}function Xd({copied:e,size:t}){return r.jsx(Ge,{d:e?aa.check:aa.copy,size:t})}function Zd({copied:e}){return r.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:e?f.common.copied:""})}const OE="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",o0="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 io({text:e,label:t,className:a=OE}){const{copied:i,flash:l}=Qd();return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",title:i?f.common.copied:t,"aria-label":t,onClick:()=>l(typeof e=="function"?e():e),className:a,children:r.jsx(Xd,{copied:i})}),r.jsx(Zd,{copied:i})]})}function Xr({title:e,description:t,action:a}){return r.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center",children:[r.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:e}),t&&r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-500",children:t}),a&&r.jsx("div",{className:"mt-2",children:a})]})}const CS=/[/\\]scratchpad[/\\]([^/\\]+)[/\\]([^/\\]+)$/;function DE(e){if(/^https?:\/\//i.test(e))return e;const t=CS.exec(e);return t?`/api/sessions/${encodeURIComponent(t[1])}/scratchpad/${encodeURIComponent(t[2])}`:null}function Jd(e){if(!e.includes(BA)&&!e.includes(HA))return{text:e,images:[],files:[]};const t=[],a=[],i=[];for(const l of e.split(`
136
- `)){const c=l.trim(),u=qA(c),m=u!==null?DE(u):null;if(m){a.push(m);continue}const p=GA(c);if(p!==null&&CS.test(p)){i.push(p);continue}t.push(l)}return{text:t.join(`
137
- `).replace(/\n+$/,""),images:a,files:i}}function UE(e){const t=e.split(/[/\\]/);return t[t.length-1]||e}function zE(e,t){const a=t||{};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const $E=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,BE={};function c1(e,t){return(BE.jsx?PE:$E).test(e)}const HE=/[ \t\n\f\r]/g;function FE(e){return typeof e=="object"?e.type==="text"?u1(e.value):!1:u1(e)}function u1(e){return e.replace(HE,"")===""}class Yc{constructor(t,a,i){this.normal=a,this.property=t,i&&(this.space=i)}}Yc.prototype.normal={};Yc.prototype.property={};Yc.prototype.space=void 0;function NS(e,t){const a={},i={};for(const l of e)Object.assign(a,l.property),Object.assign(i,l.normal);return new Yc(a,i,t)}function eg(e){return e.toLowerCase()}class Ua{constructor(t,a){this.attribute=a,this.property=t}}Ua.prototype.attribute="";Ua.prototype.booleanish=!1;Ua.prototype.boolean=!1;Ua.prototype.commaOrSpaceSeparated=!1;Ua.prototype.commaSeparated=!1;Ua.prototype.defined=!1;Ua.prototype.mustUseProperty=!1;Ua.prototype.number=!1;Ua.prototype.overloadedBoolean=!1;Ua.prototype.property="";Ua.prototype.spaceSeparated=!1;Ua.prototype.space=void 0;let VE=0;const lt=al(),Ln=al(),tg=al(),Ie=al(),en=al(),Yi=al(),Ka=al();function al(){return 2**++VE}const ng=Object.freeze(Object.defineProperty({__proto__:null,boolean:lt,booleanish:Ln,commaOrSpaceSeparated:Ka,commaSeparated:Yi,number:Ie,overloadedBoolean:tg,spaceSeparated:en},Symbol.toStringTag,{value:"Module"})),Zp=Object.keys(ng);class c0 extends Ua{constructor(t,a,i,l){let c=-1;if(super(t,a),d1(this,"space",l),typeof i=="number")for(;++c<Zp.length;){const u=Zp[c];d1(this,Zp[c],(i&ng[u])===ng[u])}}}c0.prototype.defined=!0;function d1(e,t,a){a&&(e[t]=a)}function lo(e){const t={},a={};for(const[i,l]of Object.entries(e.properties)){const c=new c0(i,e.transform(e.attributes||{},i),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(c.mustUseProperty=!0),t[i]=c,a[eg(i)]=i,a[eg(c.attribute)]=i}return new Yc(t,a,e.space)}const TS=lo({properties:{ariaActiveDescendant:null,ariaAtomic:Ln,ariaAutoComplete:null,ariaBusy:Ln,ariaChecked:Ln,ariaColCount:Ie,ariaColIndex:Ie,ariaColSpan:Ie,ariaControls:en,ariaCurrent:null,ariaDescribedBy:en,ariaDetails:null,ariaDisabled:Ln,ariaDropEffect:en,ariaErrorMessage:null,ariaExpanded:Ln,ariaFlowTo:en,ariaGrabbed:Ln,ariaHasPopup:null,ariaHidden:Ln,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:en,ariaLevel:Ie,ariaLive:null,ariaModal:Ln,ariaMultiLine:Ln,ariaMultiSelectable:Ln,ariaOrientation:null,ariaOwns:en,ariaPlaceholder:null,ariaPosInSet:Ie,ariaPressed:Ln,ariaReadOnly:Ln,ariaRelevant:null,ariaRequired:Ln,ariaRoleDescription:en,ariaRowCount:Ie,ariaRowIndex:Ie,ariaRowSpan:Ie,ariaSelected:Ln,ariaSetSize:Ie,ariaSort:null,ariaValueMax:Ie,ariaValueMin:Ie,ariaValueNow:Ie,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function MS(e,t){return t in e?e[t]:t}function AS(e,t){return MS(e,t.toLowerCase())}const qE=lo({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Yi,acceptCharset:en,accessKey:en,action:null,allow:null,allowFullScreen:lt,allowPaymentRequest:lt,allowUserMedia:lt,alpha:lt,alt:null,as:null,async:lt,autoCapitalize:null,autoComplete:en,autoFocus:lt,autoPlay:lt,blocking:en,capture:null,charSet:null,checked:lt,cite:null,className:en,closedBy:null,colorSpace:null,cols:Ie,colSpan:Ie,command:null,commandFor:null,content:null,contentEditable:Ln,controls:lt,controlsList:en,coords:Ie|Yi,crossOrigin:null,data:null,dateTime:null,decoding:null,default:lt,defer:lt,dir:null,dirName:null,disabled:lt,download:tg,draggable:Ln,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:lt,formTarget:null,headers:en,height:Ie,hidden:tg,high:Ie,href:null,hrefLang:null,htmlFor:en,httpEquiv:en,id:null,imageSizes:null,imageSrcSet:null,inert:lt,inputMode:null,integrity:null,is:null,isMap:lt,itemId:null,itemProp:en,itemRef:en,itemScope:lt,itemType:en,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:lt,low:Ie,manifest:null,max:null,maxLength:Ie,media:null,method:null,min:null,minLength:Ie,multiple:lt,muted:lt,name:null,nonce:null,noModule:lt,noValidate:lt,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:lt,optimum:Ie,pattern:null,ping:en,placeholder:null,playsInline:lt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:lt,referrerPolicy:null,rel:en,required:lt,reversed:lt,rows:Ie,rowSpan:Ie,sandbox:en,scope:null,scoped:lt,seamless:lt,selected:lt,shadowRootClonable:lt,shadowRootCustomElementRegistry:lt,shadowRootDelegatesFocus:lt,shadowRootMode:null,shadowRootSerializable:lt,shape:null,size:Ie,sizes:null,slot:null,span:Ie,spellCheck:Ln,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ie,step:null,style:null,tabIndex:Ie,target:null,title:null,translate:null,type:null,typeMustMatch:lt,useMap:null,value:Ln,width:Ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:en,axis:null,background:null,bgColor:null,border:Ie,borderColor:null,bottomMargin:Ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:lt,declare:lt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ie,leftMargin:Ie,link:null,longDesc:null,lowSrc:null,marginHeight:Ie,marginWidth:Ie,noResize:lt,noHref:lt,noShade:lt,noWrap:lt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ie,rules:null,scheme:null,scrolling:Ln,standby:null,summary:null,text:null,topMargin:Ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ie,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:lt,disablePictureInPicture:lt,disableRemotePlayback:lt,exportParts:Yi,part:en,prefix:null,property:null,results:Ie,security:null,unselectable:null},space:"html",transform:AS}),GE=lo({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:Ka,accentHeight:Ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ie,amplitude:Ie,arabicForm:null,ascent:Ie,attributeName:null,attributeType:null,azimuth:Ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ie,by:null,calcMode:null,capHeight:Ie,className:en,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:Ie,diffuseConstant:Ie,direction:null,display:null,dur:null,divisor:Ie,dominantBaseline:null,download:lt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ie,enableBackground:null,end:null,event:null,exponent:Ie,externalResourcesRequired:null,fill:null,fillOpacity:Ie,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:Yi,g2:Yi,glyphName:Yi,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ie,horizOriginX:Ie,horizOriginY:Ie,id:null,ideographic:Ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ie,k:Ie,k1:Ie,k2:Ie,k3:Ie,k4:Ie,kernelMatrix:Ka,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ie,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:Ie,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:Ie,overlineThickness:Ie,paintOrder:null,panose1:null,path:null,pathLength:Ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:en,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ie,pointsAtY:Ie,pointsAtZ:Ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ka,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ka,rev:Ka,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ka,requiredFeatures:Ka,requiredFonts:Ka,requiredFormats:Ka,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:Ie,specularExponent:Ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ie,strikethroughThickness:Ie,string:null,stroke:null,strokeDashArray:Ka,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ie,strokeOpacity:Ie,strokeWidth:null,style:null,surfaceScale:Ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ka,tabIndex:Ie,tableValues:null,target:null,targetX:Ie,targetY:Ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ka,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ie,underlineThickness:Ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ie,values:null,vAlphabetic:Ie,vMathematical:Ie,vectorEffect:null,vHanging:Ie,vIdeographic:Ie,version:null,vertAdvY:Ie,vertOriginX:Ie,vertOriginY:Ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:MS}),ES=lo({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()}}),_S=lo({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:AS}),RS=lo({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),WE={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"},KE=/[A-Z]/g,f1=/-[a-z]/g,YE=/^data[-\w.:]+$/i;function QE(e,t){const a=eg(t);let i=t,l=Ua;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&YE.test(t)){if(t.charAt(4)==="-"){const c=t.slice(5).replace(f1,ZE);i="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=t.slice(4);if(!f1.test(c)){let u=c.replace(KE,XE);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}l=c0}return new l(i,t)}function XE(e){return"-"+e.toLowerCase()}function ZE(e){return e.charAt(1).toUpperCase()}const JE=NS([TS,qE,ES,_S,RS],"html"),u0=NS([TS,GE,ES,_S,RS],"svg");function e6(e){return e.join(" ").trim()}var $l={},Jp,m1;function t6(){if(m1)return Jp;m1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,m=/^\s+|\s+$/g,p=`
138
- `,h="/",g="*",v="",k="comment",w="declaration";function S(C,T){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];T=T||{};var I=1,D=1;function K(H){var G=H.match(t);G&&(I+=G.length);var z=H.lastIndexOf(p);D=~z?H.length-z:D+H.length}function F(){var H={line:I,column:D};return function(G){return G.position=new E(H),V(),G}}function E(H){this.start=H,this.end={line:I,column:D},this.source=T.source}E.prototype.content=C;function B(H){var G=new Error(T.source+":"+I+":"+D+": "+H);if(G.reason=H,G.filename=T.source,G.line=I,G.column=D,G.source=C,!T.silent)throw G}function Y(H){var G=H.exec(C);if(G){var z=G[0];return K(z),C=C.slice(z.length),G}}function V(){Y(a)}function O(H){var G;for(H=H||[];G=U();)G!==!1&&H.push(G);return H}function U(){var H=F();if(!(h!=C.charAt(0)||g!=C.charAt(1))){for(var G=2;v!=C.charAt(G)&&(g!=C.charAt(G)||h!=C.charAt(G+1));)++G;if(G+=2,v===C.charAt(G-1))return B("End of comment missing");var z=C.slice(2,G-2);return D+=2,K(z),C=C.slice(G),D+=2,H({type:k,comment:z})}}function _(){var H=F(),G=Y(i);if(G){if(U(),!Y(l))return B("property missing ':'");var z=Y(c),J=H({type:w,property:M(G[0].replace(e,v)),value:z?M(z[0].replace(e,v)):v});return Y(u),J}}function P(){var H=[];O(H);for(var G;G=_();)G!==!1&&(H.push(G),O(H));return H}return V(),P()}function M(C){return C?C.replace(m,v):v}return Jp=S,Jp}var p1;function n6(){if(p1)return $l;p1=1;var e=$l&&$l.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty($l,"__esModule",{value:!0}),$l.default=a;const t=e(t6());function a(i,l){let c=null;if(!i||typeof i!="string")return c;const u=(0,t.default)(i),m=typeof l=="function";return u.forEach(p=>{if(p.type!=="declaration")return;const{property:h,value:g}=p;m?l(h,g,p):g&&(c=c||{},c[h]=g)}),c}return $l}var Jo={},h1;function a6(){if(h1)return Jo;h1=1,Object.defineProperty(Jo,"__esModule",{value:!0}),Jo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,c=function(h){return!h||a.test(h)||e.test(h)},u=function(h,g){return g.toUpperCase()},m=function(h,g){return"".concat(g,"-")},p=function(h,g){return g===void 0&&(g={}),c(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(l,m):h=h.replace(i,m),h.replace(t,u))};return Jo.camelCase=p,Jo}var ec,g1;function r6(){if(g1)return ec;g1=1;var e=ec&&ec.__importDefault||function(l){return l&&l.__esModule?l:{default:l}},t=e(n6()),a=a6();function i(l,c){var u={};return!l||typeof l!="string"||(0,t.default)(l,function(m,p){m&&p&&(u[(0,a.camelCase)(m,c)]=p)}),u}return i.default=i,ec=i,ec}var s6=r6();const i6=Ag(s6),IS=LS("end"),d0=LS("start");function LS(e){return t;function t(a){const i=a&&a.position&&a.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function l6(e){const t=d0(e),a=IS(e);if(t&&a)return{start:t,end:a}}function vc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?x1(e.position):"start"in e||"end"in e?x1(e):"line"in e||"column"in e?ag(e):""}function ag(e){return y1(e&&e.line)+":"+y1(e&&e.column)}function x1(e){return ag(e&&e.start)+"-"+ag(e&&e.end)}function y1(e){return e&&typeof e=="number"?e:1}class la extends Error{constructor(t,a,i){super(),typeof a=="string"&&(i=a,a=void 0);let l="",c={},u=!1;if(a&&("line"in a&&"column"in a?c={place:a}:"start"in a&&"end"in a?c={place:a}:"type"in a?c={ancestors:[a],place:a.position}:c={...a}),typeof t=="string"?l=t:!c.cause&&t&&(u=!0,l=t.message,c.cause=t),!c.ruleId&&!c.source&&typeof i=="string"){const p=i.indexOf(":");p===-1?c.ruleId=i:(c.source=i.slice(0,p),c.ruleId=i.slice(p+1))}if(!c.place&&c.ancestors&&c.ancestors){const p=c.ancestors[c.ancestors.length-1];p&&(c.place=p.position)}const m=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=m?m.column:void 0,this.fatal=void 0,this.file="",this.message=l,this.line=m?m.line:void 0,this.name=vc(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}}la.prototype.file="";la.prototype.name="";la.prototype.reason="";la.prototype.message="";la.prototype.stack="";la.prototype.column=void 0;la.prototype.line=void 0;la.prototype.ancestors=void 0;la.prototype.cause=void 0;la.prototype.fatal=void 0;la.prototype.place=void 0;la.prototype.ruleId=void 0;la.prototype.source=void 0;const f0={}.hasOwnProperty,o6=new Map,c6=/[A-Z]/g,u6=new Set(["table","tbody","thead","tfoot","tr"]),d6=new Set(["td","th"]),OS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function f6(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=t.filePath||void 0;let i;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=b6(a,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");i=v6(a,t.jsx,t.jsxs)}const l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?u0:JE,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},c=DS(l,e,void 0);return c&&typeof c!="string"?c:l.create(e,l.Fragment,{children:c||void 0},void 0)}function DS(e,t,a){if(t.type==="element")return m6(e,t,a);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return p6(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return g6(e,t,a);if(t.type==="mdxjsEsm")return h6(e,t);if(t.type==="root")return x6(e,t,a);if(t.type==="text")return y6(e,t)}function m6(e,t,a){const i=e.schema;let l=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(l=u0,e.schema=l),e.ancestors.push(t);const c=zS(e,t.tagName,!1),u=k6(e,t);let m=p0(e,t);return u6.has(t.tagName)&&(m=m.filter(function(p){return typeof p=="string"?!FE(p):!0})),US(e,u,c,t),m0(u,m),e.ancestors.pop(),e.schema=i,e.create(t,c,u,a)}function p6(e,t){if(t.data&&t.data.estree&&e.evaluater){const i=t.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}Oc(e,t.position)}function h6(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Oc(e,t.position)}function g6(e,t,a){const i=e.schema;let l=i;t.name==="svg"&&i.space==="html"&&(l=u0,e.schema=l),e.ancestors.push(t);const c=t.name===null?e.Fragment:zS(e,t.name,!0),u=w6(e,t),m=p0(e,t);return US(e,u,c,t),m0(u,m),e.ancestors.pop(),e.schema=i,e.create(t,c,u,a)}function x6(e,t,a){const i={};return m0(i,p0(e,t)),e.create(t,e.Fragment,i,a)}function y6(e,t){return t.value}function US(e,t,a,i){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(t.node=i)}function m0(e,t){if(t.length>0){const a=t.length>1?t:t[0];a&&(e.children=a)}}function v6(e,t,a){return i;function i(l,c,u,m){const h=Array.isArray(u.children)?a:t;return m?h(c,u,m):h(c,u)}}function b6(e,t){return a;function a(i,l,c,u){const m=Array.isArray(c.children),p=d0(i);return t(l,c,u,m,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function k6(e,t){const a={};let i,l;for(l in t.properties)if(l!=="children"&&f0.call(t.properties,l)){const c=S6(e,l,t.properties[l]);if(c){const[u,m]=c;e.tableCellAlignToStyle&&u==="align"&&typeof m=="string"&&d6.has(t.tagName)?i=m:a[u]=m}}if(i){const c=a.style||(a.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return a}function w6(e,t){const a={};for(const i of t.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const c=i.data.estree.body[0];c.type;const u=c.expression;u.type;const m=u.properties[0];m.type,Object.assign(a,e.evaluater.evaluateExpression(m.argument))}else Oc(e,t.position);else{const l=i.name;let c;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const m=i.value.data.estree.body[0];m.type,c=e.evaluater.evaluateExpression(m.expression)}else Oc(e,t.position);else c=i.value===null?!0:i.value;a[l]=c}return a}function p0(e,t){const a=[];let i=-1;const l=e.passKeys?new Map:o6;for(;++i<t.children.length;){const c=t.children[i];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=l.get(p)||0;u=p+"-"+h,l.set(p,h+1)}}const m=DS(e,c,u);m!==void 0&&a.push(m)}return a}function S6(e,t,a){const i=QE(e.schema,t);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=i.commaSeparated?zE(a):e6(a)),i.property==="style"){let l=typeof a=="object"?a:j6(e,String(a));return e.stylePropertyNameCase==="css"&&(l=C6(l)),["style",l]}return[e.elementAttributeNameCase==="react"&&i.space?WE[i.property]||i.property:i.attribute,a]}}function j6(e,t){try{return i6(t,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const i=a,l=new la("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=OS+"#cannot-parse-style-attribute",l}}function zS(e,t,a){let i;if(!a)i={type:"Literal",value:t};else if(t.includes(".")){const l=t.split(".");let c=-1,u;for(;++c<l.length;){const m=c1(l[c])?{type:"Identifier",name:l[c]}:{type:"Literal",value:l[c]};u=u?{type:"MemberExpression",object:u,property:m,computed:!!(c&&m.type==="Literal"),optional:!1}:m}i=u}else i=c1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(i.type==="Literal"){const l=i.value;return f0.call(e.components,l)?e.components[l]:l}if(e.evaluater)return e.evaluater.evaluateExpression(i);Oc(e)}function Oc(e,t){const a=new la("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=OS+"#cannot-handle-mdx-estrees-without-createevaluater",a}function C6(e){const t={};let a;for(a in e)f0.call(e,a)&&(t[N6(a)]=e[a]);return t}function N6(e){let t=e.replace(c6,T6);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function T6(e){return"-"+e.toLowerCase()}const eh={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"]},M6={};function h0(e,t){const a=M6,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,l=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return $S(e,i,l)}function $S(e,t,a){if(A6(e)){if("value"in e)return e.type==="html"&&!a?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return v1(e.children,t,a)}return Array.isArray(e)?v1(e,t,a):""}function v1(e,t,a){const i=[];let l=-1;for(;++l<e.length;)i[l]=$S(e[l],t,a);return i.join("")}function A6(e){return!!(e&&typeof e=="object")}const b1=document.createElement("i");function g0(e){const t="&"+e+";";b1.innerHTML=t;const a=b1.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===t?!1:a}function Qa(e,t,a,i){const l=e.length;let c=0,u;if(t<0?t=-t>l?0:l+t:t=t>l?l:t,a=a>0?a:0,i.length<1e4)u=Array.from(i),u.unshift(t,a),e.splice(...u);else for(a&&e.splice(t,a);c<i.length;)u=i.slice(c,c+1e4),u.unshift(t,0),e.splice(...u),c+=1e4,t+=1e4}function kr(e,t){return e.length>0?(Qa(e,e.length,0,t),e):t}const k1={}.hasOwnProperty;function PS(e){const t={};let a=-1;for(;++a<e.length;)E6(t,e[a]);return t}function E6(e,t){let a;for(a in t){const l=(k1.call(e,a)?e[a]:void 0)||(e[a]={}),c=t[a];let u;if(c)for(u in c){k1.call(l,u)||(l[u]=[]);const m=c[u];_6(l[u],Array.isArray(m)?m:m?[m]:[])}}}function _6(e,t){let a=-1;const i=[];for(;++a<t.length;)(t[a].add==="after"?e:i).push(t[a]);Qa(e,0,0,i)}function BS(e,t){const a=Number.parseInt(e,t);return a<9||a===11||a>13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function Or(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ma=hi(/[A-Za-z]/),ra=hi(/[\dA-Za-z]/),R6=hi(/[#-'*+\--9=?A-Z^-~]/);function ef(e){return e!==null&&(e<32||e===127)}const rg=hi(/\d/),I6=hi(/[\dA-Fa-f]/),L6=hi(/[!-/:-@[-`{-~]/);function Je(e){return e!==null&&e<-2}function tn(e){return e!==null&&(e<0||e===32)}function jt(e){return e===-2||e===-1||e===32}const Nf=hi(new RegExp("\\p{P}|\\p{S}","u")),Ji=hi(/\s/);function hi(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function oo(e){const t=[];let a=-1,i=0,l=0;for(;++a<e.length;){const c=e.charCodeAt(a);let u="";if(c===37&&ra(e.charCodeAt(a+1))&&ra(e.charCodeAt(a+2)))l=2;else if(c<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(c))||(u=String.fromCharCode(c));else if(c>55295&&c<57344){const m=e.charCodeAt(a+1);c<56320&&m>56319&&m<57344?(u=String.fromCharCode(c,m),l=1):u="�"}else u=String.fromCharCode(c);u&&(t.push(e.slice(i,a),encodeURIComponent(u)),i=a+l+1,u=""),l&&(a+=l,l=0)}return t.join("")+e.slice(i)}function At(e,t,a,i){const l=i?i-1:Number.POSITIVE_INFINITY;let c=0;return u;function u(p){return jt(p)?(e.enter(a),m(p)):t(p)}function m(p){return jt(p)&&c++<l?(e.consume(p),m):(e.exit(a),t(p))}}const O6={tokenize:D6};function D6(e){const t=e.attempt(this.parser.constructs.contentInitial,i,l);let a;return t;function i(m){if(m===null){e.consume(m);return}return e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),At(e,t,"linePrefix")}function l(m){return e.enter("paragraph"),c(m)}function c(m){const p=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=p),a=p,u(m)}function u(m){if(m===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(m);return}return Je(m)?(e.consume(m),e.exit("chunkText"),c):(e.consume(m),u)}}const U6={tokenize:z6},w1={tokenize:$6};function z6(e){const t=this,a=[];let i=0,l,c,u;return m;function m(D){if(i<a.length){const K=a[i];return t.containerState=K[1],e.attempt(K[0].continuation,p,h)(D)}return h(D)}function p(D){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,l&&I();const K=t.events.length;let F=K,E;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){E=t.events[F][1].end;break}T(i);let B=K;for(;B<t.events.length;)t.events[B][1].end={...E},B++;return Qa(t.events,F+1,0,t.events.slice(K)),t.events.length=B,h(D)}return m(D)}function h(D){if(i===a.length){if(!l)return k(D);if(l.currentConstruct&&l.currentConstruct.concrete)return S(D);t.interrupt=!!(l.currentConstruct&&!l._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(w1,g,v)(D)}function g(D){return l&&I(),T(i),k(D)}function v(D){return t.parser.lazy[t.now().line]=i!==a.length,u=t.now().offset,S(D)}function k(D){return t.containerState={},e.attempt(w1,w,S)(D)}function w(D){return i++,a.push([t.currentConstruct,t.containerState]),k(D)}function S(D){if(D===null){l&&I(),T(0),e.consume(D);return}return l=l||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:l,contentType:"flow",previous:c}),M(D)}function M(D){if(D===null){C(e.exit("chunkFlow"),!0),T(0),e.consume(D);return}return Je(D)?(e.consume(D),C(e.exit("chunkFlow")),i=0,t.interrupt=void 0,m):(e.consume(D),M)}function C(D,K){const F=t.sliceStream(D);if(K&&F.push(null),D.previous=c,c&&(c.next=D),c=D,l.defineSkip(D.start),l.write(F),t.parser.lazy[D.start.line]){let E=l.events.length;for(;E--;)if(l.events[E][1].start.offset<u&&(!l.events[E][1].end||l.events[E][1].end.offset>u))return;const B=t.events.length;let Y=B,V,O;for(;Y--;)if(t.events[Y][0]==="exit"&&t.events[Y][1].type==="chunkFlow"){if(V){O=t.events[Y][1].end;break}V=!0}for(T(i),E=B;E<t.events.length;)t.events[E][1].end={...O},E++;Qa(t.events,Y+1,0,t.events.slice(B)),t.events.length=E}}function T(D){let K=a.length;for(;K-- >D;){const F=a[K];t.containerState=F[1],F[0].exit.call(t,e)}a.length=D}function I(){l.write([null]),c=void 0,l=void 0,t.containerState._closeFlow=void 0}}function $6(e,t,a){return At(e,e.attempt(this.parser.constructs.document,t,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Zl(e){if(e===null||tn(e)||Ji(e))return 1;if(Nf(e))return 2}function Tf(e,t,a){const i=[];let l=-1;for(;++l<e.length;){const c=e[l].resolveAll;c&&!i.includes(c)&&(t=c(t,a),i.push(c))}return t}const sg={name:"attention",resolveAll:P6,tokenize:B6};function P6(e,t){let a=-1,i,l,c,u,m,p,h,g;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(i=a;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[i][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;p=e[i][1].end.offset-e[i][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const v={...e[i][1].end},k={...e[a][1].start};S1(v,-p),S1(k,p),u={type:p>1?"strongSequence":"emphasisSequence",start:v,end:{...e[i][1].end}},m={type:p>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:k},c={type:p>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[a][1].start}},l={type:p>1?"strong":"emphasis",start:{...u.start},end:{...m.end}},e[i][1].end={...u.start},e[a][1].start={...m.end},h=[],e[i][1].end.offset-e[i][1].start.offset&&(h=kr(h,[["enter",e[i][1],t],["exit",e[i][1],t]])),h=kr(h,[["enter",l,t],["enter",u,t],["exit",u,t],["enter",c,t]]),h=kr(h,Tf(t.parser.constructs.insideSpan.null,e.slice(i+1,a),t)),h=kr(h,[["exit",c,t],["enter",m,t],["exit",m,t],["exit",l,t]]),e[a][1].end.offset-e[a][1].start.offset?(g=2,h=kr(h,[["enter",e[a][1],t],["exit",e[a][1],t]])):g=0,Qa(e,i-1,a-i+3,h),a=i+h.length-g-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function B6(e,t){const a=this.parser.constructs.attentionMarkers.null,i=this.previous,l=Zl(i);let c;return u;function u(p){return c=p,e.enter("attentionSequence"),m(p)}function m(p){if(p===c)return e.consume(p),m;const h=e.exit("attentionSequence"),g=Zl(p),v=!g||g===2&&l||a.includes(p),k=!l||l===2&&g||a.includes(i);return h._open=!!(c===42?v:v&&(l||!k)),h._close=!!(c===42?k:k&&(g||!v)),t(p)}}function S1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const H6={name:"autolink",tokenize:F6};function F6(e,t,a){let i=0;return l;function l(w){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),c}function c(w){return ma(w)?(e.consume(w),u):w===64?a(w):h(w)}function u(w){return w===43||w===45||w===46||ra(w)?(i=1,m(w)):h(w)}function m(w){return w===58?(e.consume(w),i=0,p):(w===43||w===45||w===46||ra(w))&&i++<32?(e.consume(w),m):(i=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||ef(w)?a(w):(e.consume(w),p)}function h(w){return w===64?(e.consume(w),g):R6(w)?(e.consume(w),h):a(w)}function g(w){return ra(w)?v(w):a(w)}function v(w){return w===46?(e.consume(w),i=0,g):w===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.exit("autolink"),t):k(w)}function k(w){if((w===45||ra(w))&&i++<63){const S=w===45?k:v;return e.consume(w),S}return a(w)}}const Qc={partial:!0,tokenize:V6};function V6(e,t,a){return i;function i(c){return jt(c)?At(e,l,"linePrefix")(c):l(c)}function l(c){return c===null||Je(c)?t(c):a(c)}}const HS={continuation:{tokenize:G6},exit:W6,name:"blockQuote",tokenize:q6};function q6(e,t,a){const i=this;return l;function l(u){if(u===62){const m=i.containerState;return m.open||(e.enter("blockQuote",{_container:!0}),m.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),c}return a(u)}function c(u){return jt(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function G6(e,t,a){const i=this;return l;function l(u){return jt(u)?At(e,c,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):c(u)}function c(u){return e.attempt(HS,t,a)(u)}}function W6(e){e.exit("blockQuote")}const FS={name:"characterEscape",tokenize:K6};function K6(e,t,a){return i;function i(c){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(c),e.exit("escapeMarker"),l}function l(c){return L6(c)?(e.enter("characterEscapeValue"),e.consume(c),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):a(c)}}const VS={name:"characterReference",tokenize:Y6};function Y6(e,t,a){const i=this;let l=0,c,u;return m;function m(v){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(v),e.exit("characterReferenceMarker"),p}function p(v){return v===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(v),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),c=31,u=ra,g(v))}function h(v){return v===88||v===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(v),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),c=6,u=I6,g):(e.enter("characterReferenceValue"),c=7,u=rg,g(v))}function g(v){if(v===59&&l){const k=e.exit("characterReferenceValue");return u===ra&&!g0(i.sliceSerialize(k))?a(v):(e.enter("characterReferenceMarker"),e.consume(v),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(v)&&l++<c?(e.consume(v),g):a(v)}}const j1={partial:!0,tokenize:X6},C1={concrete:!0,name:"codeFenced",tokenize:Q6};function Q6(e,t,a){const i=this,l={partial:!0,tokenize:F};let c=0,u=0,m;return p;function p(E){return h(E)}function h(E){const B=i.events[i.events.length-1];return c=B&&B[1].type==="linePrefix"?B[2].sliceSerialize(B[1],!0).length:0,m=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(E)}function g(E){return E===m?(u++,e.consume(E),g):u<3?a(E):(e.exit("codeFencedFenceSequence"),jt(E)?At(e,v,"whitespace")(E):v(E))}function v(E){return E===null||Je(E)?(e.exit("codeFencedFence"),i.interrupt?t(E):e.check(j1,M,K)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),k(E))}function k(E){return E===null||Je(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),v(E)):jt(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),At(e,w,"whitespace")(E)):E===96&&E===m?a(E):(e.consume(E),k)}function w(E){return E===null||Je(E)?v(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),S(E))}function S(E){return E===null||Je(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),v(E)):E===96&&E===m?a(E):(e.consume(E),S)}function M(E){return e.attempt(l,K,C)(E)}function C(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),T}function T(E){return c>0&&jt(E)?At(e,I,"linePrefix",c+1)(E):I(E)}function I(E){return E===null||Je(E)?e.check(j1,M,K)(E):(e.enter("codeFlowValue"),D(E))}function D(E){return E===null||Je(E)?(e.exit("codeFlowValue"),I(E)):(e.consume(E),D)}function K(E){return e.exit("codeFenced"),t(E)}function F(E,B,Y){let V=0;return O;function O(G){return E.enter("lineEnding"),E.consume(G),E.exit("lineEnding"),U}function U(G){return E.enter("codeFencedFence"),jt(G)?At(E,_,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):_(G)}function _(G){return G===m?(E.enter("codeFencedFenceSequence"),P(G)):Y(G)}function P(G){return G===m?(V++,E.consume(G),P):V>=u?(E.exit("codeFencedFenceSequence"),jt(G)?At(E,H,"whitespace")(G):H(G)):Y(G)}function H(G){return G===null||Je(G)?(E.exit("codeFencedFence"),B(G)):Y(G)}}}function X6(e,t,a){const i=this;return l;function l(u){return u===null?a(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c)}function c(u){return i.parser.lazy[i.now().line]?a(u):t(u)}}const th={name:"codeIndented",tokenize:J6},Z6={partial:!0,tokenize:e_};function J6(e,t,a){const i=this;return l;function l(h){return e.enter("codeIndented"),At(e,c,"linePrefix",5)(h)}function c(h){const g=i.events[i.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?u(h):a(h)}function u(h){return h===null?p(h):Je(h)?e.attempt(Z6,u,p)(h):(e.enter("codeFlowValue"),m(h))}function m(h){return h===null||Je(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),m)}function p(h){return e.exit("codeIndented"),t(h)}}function e_(e,t,a){const i=this;return l;function l(u){return i.parser.lazy[i.now().line]?a(u):Je(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):At(e,c,"linePrefix",5)(u)}function c(u){const m=i.events[i.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?t(u):Je(u)?l(u):a(u)}}const t_={name:"codeText",previous:a_,resolve:n_,tokenize:r_};function n_(e){let t=e.length-4,a=3,i,l;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=a;++i<t;)if(e[i][1].type==="codeTextData"){e[a][1].type="codeTextPadding",e[t][1].type="codeTextPadding",a+=2,t-=2;break}}for(i=a-1,t++;++i<=t;)l===void 0?i!==t&&e[i][1].type!=="lineEnding"&&(l=i):(i===t||e[i][1].type==="lineEnding")&&(e[l][1].type="codeTextData",i!==l+2&&(e[l][1].end=e[i-1][1].end,e.splice(l+2,i-l-2),t-=i-l-2,i=l+2),l=void 0);return e}function a_(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function r_(e,t,a){let i=0,l,c;return u;function u(v){return e.enter("codeText"),e.enter("codeTextSequence"),m(v)}function m(v){return v===96?(e.consume(v),i++,m):(e.exit("codeTextSequence"),p(v))}function p(v){return v===null?a(v):v===32?(e.enter("space"),e.consume(v),e.exit("space"),p):v===96?(c=e.enter("codeTextSequence"),l=0,g(v)):Je(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),p):(e.enter("codeTextData"),h(v))}function h(v){return v===null||v===32||v===96||Je(v)?(e.exit("codeTextData"),p(v)):(e.consume(v),h)}function g(v){return v===96?(e.consume(v),l++,g):l===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(v)):(c.type="codeTextData",h(v))}}class s_{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,a){const i=a??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(t,i):t>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(t,a,i){const l=a||0;this.setCursor(Math.trunc(t));const c=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&tc(this.left,i),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),tc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),tc(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 a=this.left.splice(t,Number.POSITIVE_INFINITY);tc(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);tc(this.left,a.reverse())}}}function tc(e,t){let a=0;if(t.length<1e4)e.push(...t);else for(;a<t.length;)e.push(...t.slice(a,a+1e4)),a+=1e4}function qS(e){const t={};let a=-1,i,l,c,u,m,p,h;const g=new s_(e);for(;++a<g.length;){for(;a in t;)a=t[a];if(i=g.get(a),a&&i[1].type==="chunkFlow"&&g.get(a-1)[1].type==="listItemPrefix"&&(p=i[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(i[0]==="enter")i[1].contentType&&(Object.assign(t,i_(g,a)),a=t[a],h=!0);else if(i[1]._container){for(c=a,l=void 0;c--;)if(u=g.get(c),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(l&&(g.get(l)[1].type="lineEndingBlank"),u[1].type="lineEnding",l=c);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;l&&(i[1].end={...g.get(l)[1].start},m=g.slice(l,a),m.unshift(i),g.splice(l,a-l+1,m))}}return Qa(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!h}function i_(e,t){const a=e.get(t)[1],i=e.get(t)[2];let l=t-1;const c=[];let u=a._tokenizer;u||(u=i.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const m=u.events,p=[],h={};let g,v,k=-1,w=a,S=0,M=0;const C=[M];for(;w;){for(;e.get(++l)[1]!==w;);c.push(l),w._tokenizer||(g=i.sliceStream(w),w.next||g.push(null),v&&u.defineSkip(w.start),w._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(g),w._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),v=w,w=w.next}for(w=a;++k<m.length;)m[k][0]==="exit"&&m[k-1][0]==="enter"&&m[k][1].type===m[k-1][1].type&&m[k][1].start.line!==m[k][1].end.line&&(M=k+1,C.push(M),w._tokenizer=void 0,w.previous=void 0,w=w.next);for(u.events=[],w?(w._tokenizer=void 0,w.previous=void 0):C.pop(),k=C.length;k--;){const T=m.slice(C[k],C[k+1]),I=c.pop();p.push([I,I+T.length-1]),e.splice(I,2,T)}for(p.reverse(),k=-1;++k<p.length;)h[S+p[k][0]]=S+p[k][1],S+=p[k][1]-p[k][0]-1;return h}const l_={resolve:c_,tokenize:u_},o_={partial:!0,tokenize:d_};function c_(e){return qS(e),e}function u_(e,t){let a;return i;function i(m){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),l(m)}function l(m){return m===null?c(m):Je(m)?e.check(o_,u,c)(m):(e.consume(m),l)}function c(m){return e.exit("chunkContent"),e.exit("content"),t(m)}function u(m){return e.consume(m),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,l}}function d_(e,t,a){const i=this;return l;function l(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),At(e,c,"linePrefix")}function c(u){if(u===null||Je(u))return a(u);const m=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?t(u):e.interrupt(i.parser.constructs.flow,a,t)(u)}}function GS(e,t,a,i,l,c,u,m,p){const h=p||Number.POSITIVE_INFINITY;let g=0;return v;function v(T){return T===60?(e.enter(i),e.enter(l),e.enter(c),e.consume(T),e.exit(c),k):T===null||T===32||T===41||ef(T)?a(T):(e.enter(i),e.enter(u),e.enter(m),e.enter("chunkString",{contentType:"string"}),M(T))}function k(T){return T===62?(e.enter(c),e.consume(T),e.exit(c),e.exit(l),e.exit(i),t):(e.enter(m),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===62?(e.exit("chunkString"),e.exit(m),k(T)):T===null||T===60||Je(T)?a(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 M(T){return!g&&(T===null||T===41||tn(T))?(e.exit("chunkString"),e.exit(m),e.exit(u),e.exit(i),t(T)):g<h&&T===40?(e.consume(T),g++,M):T===41?(e.consume(T),g--,M):T===null||T===32||T===40||ef(T)?a(T):(e.consume(T),T===92?C:M)}function C(T){return T===40||T===41||T===92?(e.consume(T),M):M(T)}}function WS(e,t,a,i,l,c){const u=this;let m=0,p;return h;function h(w){return e.enter(i),e.enter(l),e.consume(w),e.exit(l),e.enter(c),g}function g(w){return m>999||w===null||w===91||w===93&&!p||w===94&&!m&&"_hiddenFootnoteSupport"in u.parser.constructs?a(w):w===93?(e.exit(c),e.enter(l),e.consume(w),e.exit(l),e.exit(i),t):Je(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),v(w))}function v(w){return w===null||w===91||w===93||Je(w)||m++>999?(e.exit("chunkString"),g(w)):(e.consume(w),p||(p=!jt(w)),w===92?k:v)}function k(w){return w===91||w===92||w===93?(e.consume(w),m++,v):v(w)}}function KS(e,t,a,i,l,c){let u;return m;function m(k){return k===34||k===39||k===40?(e.enter(i),e.enter(l),e.consume(k),e.exit(l),u=k===40?41:k,p):a(k)}function p(k){return k===u?(e.enter(l),e.consume(k),e.exit(l),e.exit(i),t):(e.enter(c),h(k))}function h(k){return k===u?(e.exit(c),p(u)):k===null?a(k):Je(k)?(e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),At(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===u||k===null||Je(k)?(e.exit("chunkString"),h(k)):(e.consume(k),k===92?v:g)}function v(k){return k===u||k===92?(e.consume(k),g):g(k)}}function bc(e,t){let a;return i;function i(l){return Je(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),a=!0,i):jt(l)?At(e,i,a?"linePrefix":"lineSuffix")(l):t(l)}}const f_={name:"definition",tokenize:p_},m_={partial:!0,tokenize:h_};function p_(e,t,a){const i=this;let l;return c;function c(w){return e.enter("definition"),u(w)}function u(w){return WS.call(i,e,m,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(w)}function m(w){return l=Or(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),p):a(w)}function p(w){return tn(w)?bc(e,h)(w):h(w)}function h(w){return GS(e,g,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(w)}function g(w){return e.attempt(m_,v,v)(w)}function v(w){return jt(w)?At(e,k,"whitespace")(w):k(w)}function k(w){return w===null||Je(w)?(e.exit("definition"),i.parser.defined.push(l),t(w)):a(w)}}function h_(e,t,a){return i;function i(m){return tn(m)?bc(e,l)(m):a(m)}function l(m){return KS(e,c,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(m)}function c(m){return jt(m)?At(e,u,"whitespace")(m):u(m)}function u(m){return m===null||Je(m)?t(m):a(m)}}const g_={name:"hardBreakEscape",tokenize:x_};function x_(e,t,a){return i;function i(c){return e.enter("hardBreakEscape"),e.consume(c),l}function l(c){return Je(c)?(e.exit("hardBreakEscape"),t(c)):a(c)}}const y_={name:"headingAtx",resolve:v_,tokenize:b_};function v_(e,t){let a=e.length-2,i=3,l,c;return e[i][1].type==="whitespace"&&(i+=2),a-2>i&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(i===a-1||a-4>i&&e[a-2][1].type==="whitespace")&&(a-=i+1===a?2:4),a>i&&(l={type:"atxHeadingText",start:e[i][1].start,end:e[a][1].end},c={type:"chunkText",start:e[i][1].start,end:e[a][1].end,contentType:"text"},Qa(e,i,a-i+1,[["enter",l,t],["enter",c,t],["exit",c,t],["exit",l,t]])),e}function b_(e,t,a){let i=0;return l;function l(g){return e.enter("atxHeading"),c(g)}function c(g){return e.enter("atxHeadingSequence"),u(g)}function u(g){return g===35&&i++<6?(e.consume(g),u):g===null||tn(g)?(e.exit("atxHeadingSequence"),m(g)):a(g)}function m(g){return g===35?(e.enter("atxHeadingSequence"),p(g)):g===null||Je(g)?(e.exit("atxHeading"),t(g)):jt(g)?At(e,m,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function p(g){return g===35?(e.consume(g),p):(e.exit("atxHeadingSequence"),m(g))}function h(g){return g===null||g===35||tn(g)?(e.exit("atxHeadingText"),m(g)):(e.consume(g),h)}}const k_=["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"],N1=["pre","script","style","textarea"],w_={concrete:!0,name:"htmlFlow",resolveTo:C_,tokenize:N_},S_={partial:!0,tokenize:M_},j_={partial:!0,tokenize:T_};function C_(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 N_(e,t,a){const i=this;let l,c,u,m,p;return h;function h(j){return g(j)}function g(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),v}function v(j){return j===33?(e.consume(j),k):j===47?(e.consume(j),c=!0,M):j===63?(e.consume(j),l=3,i.interrupt?t:A):ma(j)?(e.consume(j),u=String.fromCharCode(j),C):a(j)}function k(j){return j===45?(e.consume(j),l=2,w):j===91?(e.consume(j),l=5,m=0,S):ma(j)?(e.consume(j),l=4,i.interrupt?t:A):a(j)}function w(j){return j===45?(e.consume(j),i.interrupt?t:A):a(j)}function S(j){const $="CDATA[";return j===$.charCodeAt(m++)?(e.consume(j),m===$.length?i.interrupt?t:_:S):a(j)}function M(j){return ma(j)?(e.consume(j),u=String.fromCharCode(j),C):a(j)}function C(j){if(j===null||j===47||j===62||tn(j)){const $=j===47,ae=u.toLowerCase();return!$&&!c&&N1.includes(ae)?(l=1,i.interrupt?t(j):_(j)):k_.includes(u.toLowerCase())?(l=6,$?(e.consume(j),T):i.interrupt?t(j):_(j)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(j):c?I(j):D(j))}return j===45||ra(j)?(e.consume(j),u+=String.fromCharCode(j),C):a(j)}function T(j){return j===62?(e.consume(j),i.interrupt?t:_):a(j)}function I(j){return jt(j)?(e.consume(j),I):O(j)}function D(j){return j===47?(e.consume(j),O):j===58||j===95||ma(j)?(e.consume(j),K):jt(j)?(e.consume(j),D):O(j)}function K(j){return j===45||j===46||j===58||j===95||ra(j)?(e.consume(j),K):F(j)}function F(j){return j===61?(e.consume(j),E):jt(j)?(e.consume(j),F):D(j)}function E(j){return j===null||j===60||j===61||j===62||j===96?a(j):j===34||j===39?(e.consume(j),p=j,B):jt(j)?(e.consume(j),E):Y(j)}function B(j){return j===p?(e.consume(j),p=null,V):j===null||Je(j)?a(j):(e.consume(j),B)}function Y(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||tn(j)?F(j):(e.consume(j),Y)}function V(j){return j===47||j===62||jt(j)?D(j):a(j)}function O(j){return j===62?(e.consume(j),U):a(j)}function U(j){return j===null||Je(j)?_(j):jt(j)?(e.consume(j),U):a(j)}function _(j){return j===45&&l===2?(e.consume(j),z):j===60&&l===1?(e.consume(j),J):j===62&&l===4?(e.consume(j),R):j===63&&l===3?(e.consume(j),A):j===93&&l===5?(e.consume(j),me):Je(j)&&(l===6||l===7)?(e.exit("htmlFlowData"),e.check(S_,q,P)(j)):j===null||Je(j)?(e.exit("htmlFlowData"),P(j)):(e.consume(j),_)}function P(j){return e.check(j_,H,q)(j)}function H(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),G}function G(j){return j===null||Je(j)?P(j):(e.enter("htmlFlowData"),_(j))}function z(j){return j===45?(e.consume(j),A):_(j)}function J(j){return j===47?(e.consume(j),u="",xe):_(j)}function xe(j){if(j===62){const $=u.toLowerCase();return N1.includes($)?(e.consume(j),R):_(j)}return ma(j)&&u.length<8?(e.consume(j),u+=String.fromCharCode(j),xe):_(j)}function me(j){return j===93?(e.consume(j),A):_(j)}function A(j){return j===62?(e.consume(j),R):j===45&&l===2?(e.consume(j),A):_(j)}function R(j){return j===null||Je(j)?(e.exit("htmlFlowData"),q(j)):(e.consume(j),R)}function q(j){return e.exit("htmlFlow"),t(j)}}function T_(e,t,a){const i=this;return l;function l(u){return Je(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):a(u)}function c(u){return i.parser.lazy[i.now().line]?a(u):t(u)}}function M_(e,t,a){return i;function i(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),e.attempt(Qc,t,a)}}const A_={name:"htmlText",tokenize:E_};function E_(e,t,a){const i=this;let l,c,u;return m;function m(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),p}function p(A){return A===33?(e.consume(A),h):A===47?(e.consume(A),F):A===63?(e.consume(A),D):ma(A)?(e.consume(A),Y):a(A)}function h(A){return A===45?(e.consume(A),g):A===91?(e.consume(A),c=0,S):ma(A)?(e.consume(A),I):a(A)}function g(A){return A===45?(e.consume(A),w):a(A)}function v(A){return A===null?a(A):A===45?(e.consume(A),k):Je(A)?(u=v,J(A)):(e.consume(A),v)}function k(A){return A===45?(e.consume(A),w):v(A)}function w(A){return A===62?z(A):A===45?k(A):v(A)}function S(A){const R="CDATA[";return A===R.charCodeAt(c++)?(e.consume(A),c===R.length?M:S):a(A)}function M(A){return A===null?a(A):A===93?(e.consume(A),C):Je(A)?(u=M,J(A)):(e.consume(A),M)}function C(A){return A===93?(e.consume(A),T):M(A)}function T(A){return A===62?z(A):A===93?(e.consume(A),T):M(A)}function I(A){return A===null||A===62?z(A):Je(A)?(u=I,J(A)):(e.consume(A),I)}function D(A){return A===null?a(A):A===63?(e.consume(A),K):Je(A)?(u=D,J(A)):(e.consume(A),D)}function K(A){return A===62?z(A):D(A)}function F(A){return ma(A)?(e.consume(A),E):a(A)}function E(A){return A===45||ra(A)?(e.consume(A),E):B(A)}function B(A){return Je(A)?(u=B,J(A)):jt(A)?(e.consume(A),B):z(A)}function Y(A){return A===45||ra(A)?(e.consume(A),Y):A===47||A===62||tn(A)?V(A):a(A)}function V(A){return A===47?(e.consume(A),z):A===58||A===95||ma(A)?(e.consume(A),O):Je(A)?(u=V,J(A)):jt(A)?(e.consume(A),V):z(A)}function O(A){return A===45||A===46||A===58||A===95||ra(A)?(e.consume(A),O):U(A)}function U(A){return A===61?(e.consume(A),_):Je(A)?(u=U,J(A)):jt(A)?(e.consume(A),U):V(A)}function _(A){return A===null||A===60||A===61||A===62||A===96?a(A):A===34||A===39?(e.consume(A),l=A,P):Je(A)?(u=_,J(A)):jt(A)?(e.consume(A),_):(e.consume(A),H)}function P(A){return A===l?(e.consume(A),l=void 0,G):A===null?a(A):Je(A)?(u=P,J(A)):(e.consume(A),P)}function H(A){return A===null||A===34||A===39||A===60||A===61||A===96?a(A):A===47||A===62||tn(A)?V(A):(e.consume(A),H)}function G(A){return A===47||A===62||tn(A)?V(A):a(A)}function z(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):a(A)}function J(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),xe}function xe(A){return jt(A)?At(e,me,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):me(A)}function me(A){return e.enter("htmlTextData"),u(A)}}const x0={name:"labelEnd",resolveAll:L_,resolveTo:O_,tokenize:D_},__={tokenize:U_},R_={tokenize:z_},I_={tokenize:$_};function L_(e){let t=-1;const a=[];for(;++t<e.length;){const i=e[t][1];if(a.push(e[t]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const l=i.type==="labelImage"?4:2;i.type="data",t+=l}}return e.length!==a.length&&Qa(e,0,e.length,a),e}function O_(e,t){let a=e.length,i=0,l,c,u,m;for(;a--;)if(l=e[a][1],c){if(l.type==="link"||l.type==="labelLink"&&l._inactive)break;e[a][0]==="enter"&&l.type==="labelLink"&&(l._inactive=!0)}else if(u){if(e[a][0]==="enter"&&(l.type==="labelImage"||l.type==="labelLink")&&!l._balanced&&(c=a,l.type!=="labelLink")){i=2;break}}else l.type==="labelEnd"&&(u=a);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}},g={type:"labelText",start:{...e[c+i+2][1].end},end:{...e[u-2][1].start}};return m=[["enter",p,t],["enter",h,t]],m=kr(m,e.slice(c+1,c+i+3)),m=kr(m,[["enter",g,t]]),m=kr(m,Tf(t.parser.constructs.insideSpan.null,e.slice(c+i+4,u-3),t)),m=kr(m,[["exit",g,t],e[u-2],e[u-1],["exit",h,t]]),m=kr(m,e.slice(u+1)),m=kr(m,[["exit",p,t]]),Qa(e,c,e.length,m),e}function D_(e,t,a){const i=this;let l=i.events.length,c,u;for(;l--;)if((i.events[l][1].type==="labelImage"||i.events[l][1].type==="labelLink")&&!i.events[l][1]._balanced){c=i.events[l][1];break}return m;function m(k){return c?c._inactive?v(k):(u=i.parser.defined.includes(Or(i.sliceSerialize({start:c.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(k),e.exit("labelMarker"),e.exit("labelEnd"),p):a(k)}function p(k){return k===40?e.attempt(__,g,u?g:v)(k):k===91?e.attempt(R_,g,u?h:v)(k):u?g(k):v(k)}function h(k){return e.attempt(I_,g,v)(k)}function g(k){return t(k)}function v(k){return c._balanced=!0,a(k)}}function U_(e,t,a){return i;function i(v){return e.enter("resource"),e.enter("resourceMarker"),e.consume(v),e.exit("resourceMarker"),l}function l(v){return tn(v)?bc(e,c)(v):c(v)}function c(v){return v===41?g(v):GS(e,u,m,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(v)}function u(v){return tn(v)?bc(e,p)(v):g(v)}function m(v){return a(v)}function p(v){return v===34||v===39||v===40?KS(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(v):g(v)}function h(v){return tn(v)?bc(e,g)(v):g(v)}function g(v){return v===41?(e.enter("resourceMarker"),e.consume(v),e.exit("resourceMarker"),e.exit("resource"),t):a(v)}}function z_(e,t,a){const i=this;return l;function l(m){return WS.call(i,e,c,u,"reference","referenceMarker","referenceString")(m)}function c(m){return i.parser.defined.includes(Or(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(m):a(m)}function u(m){return a(m)}}function $_(e,t,a){return i;function i(c){return e.enter("reference"),e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),l}function l(c){return c===93?(e.enter("referenceMarker"),e.consume(c),e.exit("referenceMarker"),e.exit("reference"),t):a(c)}}const P_={name:"labelStartImage",resolveAll:x0.resolveAll,tokenize:B_};function B_(e,t,a){const i=this;return l;function l(m){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(m),e.exit("labelImageMarker"),c}function c(m){return m===91?(e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelImage"),u):a(m)}function u(m){return m===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(m):t(m)}}const H_={name:"labelStartLink",resolveAll:x0.resolveAll,tokenize:F_};function F_(e,t,a){const i=this;return l;function l(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 i.parser.constructs?a(u):t(u)}}const nh={name:"lineEnding",tokenize:V_};function V_(e,t){return a;function a(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),At(e,t,"linePrefix")}}const zd={name:"thematicBreak",tokenize:q_};function q_(e,t,a){let i=0,l;return c;function c(h){return e.enter("thematicBreak"),u(h)}function u(h){return l=h,m(h)}function m(h){return h===l?(e.enter("thematicBreakSequence"),p(h)):i>=3&&(h===null||Je(h))?(e.exit("thematicBreak"),t(h)):a(h)}function p(h){return h===l?(e.consume(h),i++,p):(e.exit("thematicBreakSequence"),jt(h)?At(e,m,"whitespace")(h):m(h))}}const Ia={continuation:{tokenize:Y_},exit:X_,name:"list",tokenize:K_},G_={partial:!0,tokenize:Z_},W_={partial:!0,tokenize:Q_};function K_(e,t,a){const i=this,l=i.events[i.events.length-1];let c=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,u=0;return m;function m(w){const S=i.containerState.type||(w===42||w===43||w===45?"listUnordered":"listOrdered");if(S==="listUnordered"?!i.containerState.marker||w===i.containerState.marker:rg(w)){if(i.containerState.type||(i.containerState.type=S,e.enter(S,{_container:!0})),S==="listUnordered")return e.enter("listItemPrefix"),w===42||w===45?e.check(zd,a,h)(w):h(w);if(!i.interrupt||w===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(w)}return a(w)}function p(w){return rg(w)&&++u<10?(e.consume(w),p):(!i.interrupt||u<2)&&(i.containerState.marker?w===i.containerState.marker:w===41||w===46)?(e.exit("listItemValue"),h(w)):a(w)}function h(w){return e.enter("listItemMarker"),e.consume(w),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||w,e.check(Qc,i.interrupt?a:g,e.attempt(G_,k,v))}function g(w){return i.containerState.initialBlankLine=!0,c++,k(w)}function v(w){return jt(w)?(e.enter("listItemPrefixWhitespace"),e.consume(w),e.exit("listItemPrefixWhitespace"),k):a(w)}function k(w){return i.containerState.size=c+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(w)}}function Y_(e,t,a){const i=this;return i.containerState._closeFlow=void 0,e.check(Qc,l,c);function l(m){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,At(e,t,"listItemIndent",i.containerState.size+1)(m)}function c(m){return i.containerState.furtherBlankLines||!jt(m)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,u(m)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(W_,t,u)(m))}function u(m){return i.containerState._closeFlow=!0,i.interrupt=void 0,At(e,e.attempt(Ia,t,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m)}}function Q_(e,t,a){const i=this;return At(e,l,"listItemIndent",i.containerState.size+1);function l(c){const u=i.events[i.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===i.containerState.size?t(c):a(c)}}function X_(e){e.exit(this.containerState.type)}function Z_(e,t,a){const i=this;return At(e,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(c){const u=i.events[i.events.length-1];return!jt(c)&&u&&u[1].type==="listItemPrefixWhitespace"?t(c):a(c)}}const T1={name:"setextUnderline",resolveTo:J_,tokenize:eR};function J_(e,t){let a=e.length,i,l,c;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){i=a;break}e[a][1].type==="paragraph"&&(l=a)}else e[a][1].type==="content"&&e.splice(a,1),!c&&e[a][1].type==="definition"&&(c=a);const u={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[l][1].type="setextHeadingText",c?(e.splice(l,0,["enter",u,t]),e.splice(c+1,0,["exit",e[i][1],t]),e[i][1].end={...e[c][1].end}):e[i][1]=u,e.push(["exit",u,t]),e}function eR(e,t,a){const i=this;let l;return c;function c(h){let g=i.events.length,v;for(;g--;)if(i.events[g][1].type!=="lineEnding"&&i.events[g][1].type!=="linePrefix"&&i.events[g][1].type!=="content"){v=i.events[g][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||v)?(e.enter("setextHeadingLine"),l=h,u(h)):a(h)}function u(h){return e.enter("setextHeadingLineSequence"),m(h)}function m(h){return h===l?(e.consume(h),m):(e.exit("setextHeadingLineSequence"),jt(h)?At(e,p,"lineSuffix")(h):p(h))}function p(h){return h===null||Je(h)?(e.exit("setextHeadingLine"),t(h)):a(h)}}const tR={tokenize:nR};function nR(e){const t=this,a=e.attempt(Qc,i,e.attempt(this.parser.constructs.flowInitial,l,At(e,e.attempt(this.parser.constructs.flow,l,e.attempt(l_,l)),"linePrefix")));return a;function i(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),t.currentConstruct=void 0,a}function l(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),t.currentConstruct=void 0,a}}const aR={resolveAll:QS()},rR=YS("string"),sR=YS("text");function YS(e){return{resolveAll:QS(e==="text"?iR:void 0),tokenize:t};function t(a){const i=this,l=this.parser.constructs[e],c=a.attempt(l,u,m);return u;function u(g){return h(g)?c(g):m(g)}function m(g){if(g===null){a.consume(g);return}return a.enter("data"),a.consume(g),p}function p(g){return h(g)?(a.exit("data"),c(g)):(a.consume(g),p)}function h(g){if(g===null)return!0;const v=l[g];let k=-1;if(v)for(;++k<v.length;){const w=v[k];if(!w.previous||w.previous.call(i,i.previous))return!0}return!1}}}function QS(e){return t;function t(a,i){let l=-1,c;for(;++l<=a.length;)c===void 0?a[l]&&a[l][1].type==="data"&&(c=l,l++):(!a[l]||a[l][1].type!=="data")&&(l!==c+2&&(a[c][1].end=a[l-1][1].end,a.splice(c+2,l-c-2),l=c+2),c=void 0);return e?e(a,i):a}}function iR(e,t){let a=0;for(;++a<=e.length;)if((a===e.length||e[a][1].type==="lineEnding")&&e[a-1][1].type==="data"){const i=e[a-1][1],l=t.sliceStream(i);let c=l.length,u=-1,m=0,p;for(;c--;){const h=l[c];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)m++,u--;if(u)break;u=-1}else if(h===-2)p=!0,m++;else if(h!==-1){c++;break}}if(t._contentTypeTextTrailing&&a===e.length&&(m=0),m){const h={type:a===e.length||p||m<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:c?u:i.start._bufferIndex+u,_index:i.start._index+c,line:i.end.line,column:i.end.column-m,offset:i.end.offset-m},end:{...i.end}};i.end={...h.start},i.start.offset===i.end.offset?Object.assign(i,h):(e.splice(a,0,["enter",h,t],["exit",h,t]),a+=2)}a++}return e}const lR={42:Ia,43:Ia,45:Ia,48:Ia,49:Ia,50:Ia,51:Ia,52:Ia,53:Ia,54:Ia,55:Ia,56:Ia,57:Ia,62:HS},oR={91:f_},cR={[-2]:th,[-1]:th,32:th},uR={35:y_,42:zd,45:[T1,zd],60:w_,61:T1,95:zd,96:C1,126:C1},dR={38:VS,92:FS},fR={[-5]:nh,[-4]:nh,[-3]:nh,33:P_,38:VS,42:sg,60:[H6,A_],91:H_,92:[g_,FS],93:x0,95:sg,96:t_},mR={null:[sg,aR]},pR={null:[42,95]},hR={null:[]},gR=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:pR,contentInitial:oR,disable:hR,document:lR,flow:uR,flowInitial:cR,insideSpan:mR,string:dR,text:fR},Symbol.toStringTag,{value:"Module"}));function xR(e,t,a){let i={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const l={},c=[];let u=[],m=[];const p={attempt:B(F),check:B(E),consume:I,enter:D,exit:K,interrupt:B(E,{interrupt:!0})},h={code:null,containerState:{},defineSkip:M,events:[],now:S,parser:e,previous:null,sliceSerialize:k,sliceStream:w,write:v};let g=t.tokenize.call(h,p);return t.resolveAll&&c.push(t),h;function v(U){return u=kr(u,U),C(),u[u.length-1]!==null?[]:(Y(t,0),h.events=Tf(c,h.events,h),h.events)}function k(U,_){return vR(w(U),_)}function w(U){return yR(u,U)}function S(){const{_bufferIndex:U,_index:_,line:P,column:H,offset:G}=i;return{_bufferIndex:U,_index:_,line:P,column:H,offset:G}}function M(U){l[U.line]=U.column,O()}function C(){let U;for(;i._index<u.length;){const _=u[i._index];if(typeof _=="string")for(U=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===U&&i._bufferIndex<_.length;)T(_.charCodeAt(i._bufferIndex));else T(_)}}function T(U){g=g(U)}function I(U){Je(U)?(i.line++,i.column=1,i.offset+=U===-3?2:1,O()):U!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===u[i._index].length&&(i._bufferIndex=-1,i._index++)),h.previous=U}function D(U,_){const P=_||{};return P.type=U,P.start=S(),h.events.push(["enter",P,h]),m.push(P),P}function K(U){const _=m.pop();return _.end=S(),h.events.push(["exit",_,h]),_}function F(U,_){Y(U,_.from)}function E(U,_){_.restore()}function B(U,_){return P;function P(H,G,z){let J,xe,me,A;return Array.isArray(H)?q(H):"tokenize"in H?q([H]):R(H);function R(de){return ye;function ye(Se){const ke=Se!==null&&de[Se],ee=Se!==null&&de.null,je=[...Array.isArray(ke)?ke:ke?[ke]:[],...Array.isArray(ee)?ee:ee?[ee]:[]];return q(je)(Se)}}function q(de){return J=de,xe=0,de.length===0?z:j(de[xe])}function j(de){return ye;function ye(Se){return A=V(),me=de,de.partial||(h.currentConstruct=de),de.name&&h.parser.constructs.disable.null.includes(de.name)?ae():de.tokenize.call(_?Object.assign(Object.create(h),_):h,p,$,ae)(Se)}}function $(de){return U(me,A),G}function ae(de){return A.restore(),++xe<J.length?j(J[xe]):z}}}function Y(U,_){U.resolveAll&&!c.includes(U)&&c.push(U),U.resolve&&Qa(h.events,_,h.events.length-_,U.resolve(h.events.slice(_),h)),U.resolveTo&&(h.events=U.resolveTo(h.events,h))}function V(){const U=S(),_=h.previous,P=h.currentConstruct,H=h.events.length,G=Array.from(m);return{from:H,restore:z};function z(){i=U,h.previous=_,h.currentConstruct=P,h.events.length=H,m=G,O()}}function O(){i.line in l&&i.column<2&&(i.column=l[i.line],i.offset+=l[i.line]-1)}}function yR(e,t){const a=t.start._index,i=t.start._bufferIndex,l=t.end._index,c=t.end._bufferIndex;let u;if(a===l)u=[e[a].slice(i,c)];else{if(u=e.slice(a,l),i>-1){const m=u[0];typeof m=="string"?u[0]=m.slice(i):u.shift()}c>0&&u.push(e[l].slice(0,c))}return u}function vR(e,t){let a=-1;const i=[];let l;for(;++a<e.length;){const c=e[a];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&&l)continue;u=" ";break}default:u=String.fromCharCode(c)}l=c===-2,i.push(u)}return i.join("")}function bR(e){const i={constructs:PS([gR,...(e||{}).extensions||[]]),content:l(O6),defined:[],document:l(U6),flow:l(tR),lazy:{},string:l(rR),text:l(sR)};return i;function l(c){return u;function u(m){return xR(i,c,m)}}}function kR(e){for(;!qS(e););return e}const M1=/[\0\t\n\r]/g;function wR(){let e=1,t="",a=!0,i;return l;function l(c,u,m){const p=[];let h,g,v,k,w;for(c=t+(typeof c=="string"?c.toString():new TextDecoder(u||void 0).decode(c)),v=0,t="",a&&(c.charCodeAt(0)===65279&&v++,a=void 0);v<c.length;){if(M1.lastIndex=v,h=M1.exec(c),k=h&&h.index!==void 0?h.index:c.length,w=c.charCodeAt(k),!h){t=c.slice(v);break}if(w===10&&v===k&&i)p.push(-3),i=void 0;else switch(i&&(p.push(-5),i=void 0),v<k&&(p.push(c.slice(v,k)),e+=k-v),w){case 0:{p.push(65533),e++;break}case 9:{for(g=Math.ceil(e/4)*4,p.push(-2);e++<g;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:i=!0,e=1}v=k+1}return m&&(i&&p.push(-5),t&&p.push(t),p.push(null)),p}}const SR=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function jR(e){return e.replace(SR,CR)}function CR(e,t,a){if(t)return t;if(a.charCodeAt(0)===35){const l=a.charCodeAt(1),c=l===120||l===88;return BS(a.slice(c?2:1),c?16:10)}return g0(a)||e}const XS={}.hasOwnProperty;function NR(e,t,a){return t&&typeof t=="object"&&(a=t,t=void 0),TR(a)(kR(bR(a).document().write(wR()(e,t,!0))))}function TR(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:c(It),autolinkProtocol:V,autolinkEmail:V,atxHeading:c(re),blockQuote:c(ee),characterEscape:V,characterReference:V,codeFenced:c(je),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:c(je,u),codeText:c(Ae,u),codeTextData:V,data:V,codeFlowValue:V,definition:c(Qe),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:c(We),hardBreakEscape:c(ft),hardBreakTrailing:c(ft),htmlFlow:c(ge,u),htmlFlowData:V,htmlText:c(ge,u),htmlTextData:V,image:c(dt),label:u,link:c(It),listItem:c(nn),listItemValue:k,listOrdered:c(zt,v),listUnordered:c(zt),paragraph:c(un),reference:j,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:c(re),strong:c(Wt),thematicBreak:c(Ke)},exit:{atxHeading:p(),atxHeadingSequence:F,autolink:p(),autolinkEmail:ke,autolinkProtocol:Se,blockQuote:p(),characterEscapeValue:O,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:de,characterReference:ye,codeFenced:p(C),codeFencedFence:M,codeFencedFenceInfo:w,codeFencedFenceMeta:S,codeFlowValue:O,codeIndented:p(T),codeText:p(G),codeTextData:O,data:O,definition:p(),definitionDestinationString:K,definitionLabelString:I,definitionTitleString:D,emphasis:p(),hardBreakEscape:p(_),hardBreakTrailing:p(_),htmlFlow:p(P),htmlFlowData:O,htmlText:p(H),htmlTextData:O,image:p(J),label:me,labelText:xe,lineEnding:U,link:p(z),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:$,resourceDestinationString:A,resourceTitleString:R,resource:q,setextHeading:p(Y),setextHeadingLineSequence:B,setextHeadingText:E,strong:p(),thematicBreak:p()}};ZS(t,(e||{}).mdastExtensions||[]);const a={};return i;function i(se){let ce={type:"root",children:[]};const De={stack:[ce],tokenStack:[],config:t,enter:m,exit:h,buffer:u,resume:g,data:a},Be=[];let Ue=-1;for(;++Ue<se.length;)if(se[Ue][1].type==="listOrdered"||se[Ue][1].type==="listUnordered")if(se[Ue][0]==="enter")Be.push(Ue);else{const W=Be.pop();Ue=l(se,W,Ue)}for(Ue=-1;++Ue<se.length;){const W=t[se[Ue][0]];XS.call(W,se[Ue][1].type)&&W[se[Ue][1].type].call(Object.assign({sliceSerialize:se[Ue][2].sliceSerialize},De),se[Ue][1])}if(De.tokenStack.length>0){const W=De.tokenStack[De.tokenStack.length-1];(W[1]||A1).call(De,void 0,W[0])}for(ce.position={start:ni(se.length>0?se[0][1].start:{line:1,column:1,offset:0}),end:ni(se.length>0?se[se.length-2][1].end:{line:1,column:1,offset:0})},Ue=-1;++Ue<t.transforms.length;)ce=t.transforms[Ue](ce)||ce;return ce}function l(se,ce,De){let Be=ce-1,Ue=-1,W=!1,pe,Ne,Re,Pe;for(;++Be<=De;){const Fe=se[Be];switch(Fe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Fe[0]==="enter"?Ue++:Ue--,Pe=void 0;break}case"lineEndingBlank":{Fe[0]==="enter"&&(pe&&!Pe&&!Ue&&!Re&&(Re=Be),Pe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Pe=void 0}if(!Ue&&Fe[0]==="enter"&&Fe[1].type==="listItemPrefix"||Ue===-1&&Fe[0]==="exit"&&(Fe[1].type==="listUnordered"||Fe[1].type==="listOrdered")){if(pe){let nt=Be;for(Ne=void 0;nt--;){const ot=se[nt];if(ot[1].type==="lineEnding"||ot[1].type==="lineEndingBlank"){if(ot[0]==="exit")continue;Ne&&(se[Ne][1].type="lineEndingBlank",W=!0),ot[1].type="lineEnding",Ne=nt}else if(!(ot[1].type==="linePrefix"||ot[1].type==="blockQuotePrefix"||ot[1].type==="blockQuotePrefixWhitespace"||ot[1].type==="blockQuoteMarker"||ot[1].type==="listItemIndent"))break}Re&&(!Ne||Re<Ne)&&(pe._spread=!0),pe.end=Object.assign({},Ne?se[Ne][1].start:Fe[1].end),se.splice(Ne||Be,0,["exit",pe,Fe[2]]),Be++,De++}if(Fe[1].type==="listItemPrefix"){const nt={type:"listItem",_spread:!1,start:Object.assign({},Fe[1].start),end:void 0};pe=nt,se.splice(Be,0,["enter",nt,Fe[2]]),Be++,De++,Re=void 0,Pe=!0}}}return se[ce][1]._spread=W,De}function c(se,ce){return De;function De(Be){m.call(this,se(Be),Be),ce&&ce.call(this,Be)}}function u(){this.stack.push({type:"fragment",children:[]})}function m(se,ce,De){this.stack[this.stack.length-1].children.push(se),this.stack.push(se),this.tokenStack.push([ce,De||void 0]),se.position={start:ni(ce.start),end:void 0}}function p(se){return ce;function ce(De){se&&se.call(this,De),h.call(this,De)}}function h(se,ce){const De=this.stack.pop(),Be=this.tokenStack.pop();if(Be)Be[0].type!==se.type&&(ce?ce.call(this,se,Be[0]):(Be[1]||A1).call(this,se,Be[0]));else throw new Error("Cannot close `"+se.type+"` ("+vc({start:se.start,end:se.end})+"): it’s not open");De.position.end=ni(se.end)}function g(){return h0(this.stack.pop())}function v(){this.data.expectingFirstListItemValue=!0}function k(se){if(this.data.expectingFirstListItemValue){const ce=this.stack[this.stack.length-2];ce.start=Number.parseInt(this.sliceSerialize(se),10),this.data.expectingFirstListItemValue=void 0}}function w(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.lang=se}function S(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.meta=se}function M(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.value=se.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function T(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.value=se.replace(/(\r?\n|\r)$/g,"")}function I(se){const ce=this.resume(),De=this.stack[this.stack.length-1];De.label=ce,De.identifier=Or(this.sliceSerialize(se)).toLowerCase()}function D(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.title=se}function K(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.url=se}function F(se){const ce=this.stack[this.stack.length-1];if(!ce.depth){const De=this.sliceSerialize(se).length;ce.depth=De}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function B(se){const ce=this.stack[this.stack.length-1];ce.depth=this.sliceSerialize(se).codePointAt(0)===61?1:2}function Y(){this.data.setextHeadingSlurpLineEnding=void 0}function V(se){const De=this.stack[this.stack.length-1].children;let Be=De[De.length-1];(!Be||Be.type!=="text")&&(Be=Ce(),Be.position={start:ni(se.start),end:void 0},De.push(Be)),this.stack.push(Be)}function O(se){const ce=this.stack.pop();ce.value+=this.sliceSerialize(se),ce.position.end=ni(se.end)}function U(se){const ce=this.stack[this.stack.length-1];if(this.data.atHardBreak){const De=ce.children[ce.children.length-1];De.position.end=ni(se.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ce.type)&&(V.call(this,se),O.call(this,se))}function _(){this.data.atHardBreak=!0}function P(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.value=se}function H(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.value=se}function G(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.value=se}function z(){const se=this.stack[this.stack.length-1];if(this.data.inReference){const ce=this.data.referenceType||"shortcut";se.type+="Reference",se.referenceType=ce,delete se.url,delete se.title}else delete se.identifier,delete se.label;this.data.referenceType=void 0}function J(){const se=this.stack[this.stack.length-1];if(this.data.inReference){const ce=this.data.referenceType||"shortcut";se.type+="Reference",se.referenceType=ce,delete se.url,delete se.title}else delete se.identifier,delete se.label;this.data.referenceType=void 0}function xe(se){const ce=this.sliceSerialize(se),De=this.stack[this.stack.length-2];De.label=jR(ce),De.identifier=Or(ce).toLowerCase()}function me(){const se=this.stack[this.stack.length-1],ce=this.resume(),De=this.stack[this.stack.length-1];if(this.data.inReference=!0,De.type==="link"){const Be=se.children;De.children=Be}else De.alt=ce}function A(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.url=se}function R(){const se=this.resume(),ce=this.stack[this.stack.length-1];ce.title=se}function q(){this.data.inReference=void 0}function j(){this.data.referenceType="collapsed"}function $(se){const ce=this.resume(),De=this.stack[this.stack.length-1];De.label=ce,De.identifier=Or(this.sliceSerialize(se)).toLowerCase(),this.data.referenceType="full"}function ae(se){this.data.characterReferenceType=se.type}function de(se){const ce=this.sliceSerialize(se),De=this.data.characterReferenceType;let Be;De?(Be=BS(ce,De==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Be=g0(ce);const Ue=this.stack[this.stack.length-1];Ue.value+=Be}function ye(se){const ce=this.stack.pop();ce.position.end=ni(se.end)}function Se(se){O.call(this,se);const ce=this.stack[this.stack.length-1];ce.url=this.sliceSerialize(se)}function ke(se){O.call(this,se);const ce=this.stack[this.stack.length-1];ce.url="mailto:"+this.sliceSerialize(se)}function ee(){return{type:"blockquote",children:[]}}function je(){return{type:"code",lang:null,meta:null,value:""}}function Ae(){return{type:"inlineCode",value:""}}function Qe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function We(){return{type:"emphasis",children:[]}}function re(){return{type:"heading",depth:0,children:[]}}function ft(){return{type:"break"}}function ge(){return{type:"html",value:""}}function dt(){return{type:"image",title:null,url:"",alt:null}}function It(){return{type:"link",title:null,url:"",children:[]}}function zt(se){return{type:"list",ordered:se.type==="listOrdered",start:null,spread:se._spread,children:[]}}function nn(se){return{type:"listItem",spread:se._spread,checked:null,children:[]}}function un(){return{type:"paragraph",children:[]}}function Wt(){return{type:"strong",children:[]}}function Ce(){return{type:"text",value:""}}function Ke(){return{type:"thematicBreak"}}}function ni(e){return{line:e.line,column:e.column,offset:e.offset}}function ZS(e,t){let a=-1;for(;++a<t.length;){const i=t[a];Array.isArray(i)?ZS(e,i):MR(e,i)}}function MR(e,t){let a;for(a in t)if(XS.call(t,a))switch(a){case"canContainEols":{const i=t[a];i&&e[a].push(...i);break}case"transforms":{const i=t[a];i&&e[a].push(...i);break}case"enter":case"exit":{const i=t[a];i&&Object.assign(e[a],i);break}}}function A1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+vc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+vc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+vc({start:t.start,end:t.end})+") is still open")}function AR(e){const t=this;t.parser=a;function a(i){return NR(i,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function ER(e,t){const a={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,a),e.applyData(t,a)}function _R(e,t){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,a),[e.applyData(t,a),{type:"text",value:`
141
- `}]}function RR(e,t){const a=t.value?t.value+`
142
- `:"",i={},l=t.lang?t.lang.split(/\s+/):[];l.length>0&&(i.className=["language-"+l[0]]);let c={type:"element",tagName:"code",properties:i,children:[{type:"text",value:a}]};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 IR(e,t){const a={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function LR(e,t){const a={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function OR(e,t){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),l=oo(i.toLowerCase()),c=e.footnoteOrder.indexOf(i);let u,m=e.footnoteCounts.get(i);m===void 0?(m=0,e.footnoteOrder.push(i),u=e.footnoteOrder.length):u=c+1,m+=1,e.footnoteCounts.set(i,m);const p={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+l,id:a+"fnref-"+l+(m>1?"-"+m:""),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 DR(e,t){const a={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function UR(e,t){if(e.options.allowDangerousHtml){const a={type:"raw",value:t.value};return e.patch(t,a),e.applyData(t,a)}}function JS(e,t){const a=t.referenceType;let i="]";if(a==="collapsed"?i+="[]":a==="full"&&(i+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+i}];const l=e.all(t),c=l[0];c&&c.type==="text"?c.value="["+c.value:l.unshift({type:"text",value:"["});const u=l[l.length-1];return u&&u.type==="text"?u.value+=i:l.push({type:"text",value:i}),l}function zR(e,t){const a=String(t.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return JS(e,t);const l={src:oo(i.url||""),alt:t.alt};i.title!==null&&i.title!==void 0&&(l.title=i.title);const c={type:"element",tagName:"img",properties:l,children:[]};return e.patch(t,c),e.applyData(t,c)}function $R(e,t){const a={src:oo(t.url)};t.alt!==null&&t.alt!==void 0&&(a.alt=t.alt),t.title!==null&&t.title!==void 0&&(a.title=t.title);const i={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,i),e.applyData(t,i)}function PR(e,t){const a={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,a);const i={type:"element",tagName:"code",properties:{},children:[a]};return e.patch(t,i),e.applyData(t,i)}function BR(e,t){const a=String(t.identifier).toUpperCase(),i=e.definitionById.get(a);if(!i)return JS(e,t);const l={href:oo(i.url||"")};i.title!==null&&i.title!==void 0&&(l.title=i.title);const c={type:"element",tagName:"a",properties:l,children:e.all(t)};return e.patch(t,c),e.applyData(t,c)}function HR(e,t){const a={href:oo(t.url)};t.title!==null&&t.title!==void 0&&(a.title=t.title);const i={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function FR(e,t,a){const i=e.all(t),l=a?VR(a):ej(t),c={},u=[];if(typeof t.checked=="boolean"){const g=i[0];let v;g&&g.type==="element"&&g.tagName==="p"?v=g:(v={type:"element",tagName:"p",properties:{},children:[]},i.unshift(v)),v.children.length>0&&v.children.unshift({type:"text",value:" "}),v.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let m=-1;for(;++m<i.length;){const g=i[m];(l||m!==0||g.type!=="element"||g.tagName!=="p")&&u.push({type:"text",value:`
143
- `}),g.type==="element"&&g.tagName==="p"&&!l?u.push(...g.children):u.push(g)}const p=i[i.length-1];p&&(l||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 VR(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const a=e.children;let i=-1;for(;!t&&++i<a.length;)t=ej(a[i])}return t}function ej(e){const t=e.spread;return t??e.children.length>1}function qR(e,t){const a={},i=e.all(t);let l=-1;for(typeof t.start=="number"&&t.start!==1&&(a.start=t.start);++l<i.length;){const u=i[l];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){a.className=["contains-task-list"];break}}const c={type:"element",tagName:t.ordered?"ol":"ul",properties:a,children:e.wrap(i,!0)};return e.patch(t,c),e.applyData(t,c)}function GR(e,t){const a={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function WR(e,t){const a={type:"root",children:e.wrap(e.all(t))};return e.patch(t,a),e.applyData(t,a)}function KR(e,t){const a={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function YR(e,t){const a=e.all(t),i=a.shift(),l=[];if(i){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(t.children[0],u),l.push(u)}if(a.length>0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},m=d0(t.children[1]),p=IS(t.children[t.children.length-1]);m&&p&&(u.position={start:m,end:p}),l.push(u)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)}function QR(e,t,a){const i=a?a.children:void 0,c=(i?i.indexOf(t):1)===0?"th":"td",u=a&&a.type==="table"?a.align:void 0,m=u?u.length:t.children.length;let p=-1;const h=[];for(;++p<m;){const v=t.children[p],k={},w=u?u[p]:void 0;w&&(k.align=w);let S={type:"element",tagName:c,properties:k,children:[]};v&&(S.children=e.all(v),e.patch(v,S),S=e.applyData(v,S)),h.push(S)}const g={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,g),e.applyData(t,g)}function XR(e,t){const a={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}const E1=9,_1=32;function ZR(e){const t=String(e),a=/\r?\n|\r/g;let i=a.exec(t),l=0;const c=[];for(;i;)c.push(R1(t.slice(l,i.index),l>0,!0),i[0]),l=i.index+i[0].length,i=a.exec(t);return c.push(R1(t.slice(l),l>0,!1)),c.join("")}function R1(e,t,a){let i=0,l=e.length;if(t){let c=e.codePointAt(i);for(;c===E1||c===_1;)i++,c=e.codePointAt(i)}if(a){let c=e.codePointAt(l-1);for(;c===E1||c===_1;)l--,c=e.codePointAt(l-1)}return l>i?e.slice(i,l):""}function JR(e,t){const a={type:"text",value:ZR(String(t.value))};return e.patch(t,a),e.applyData(t,a)}function eI(e,t){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,a),e.applyData(t,a)}const tI={blockquote:ER,break:_R,code:RR,delete:IR,emphasis:LR,footnoteReference:OR,heading:DR,html:UR,imageReference:zR,image:$R,inlineCode:PR,linkReference:BR,link:HR,listItem:FR,list:qR,paragraph:GR,root:WR,strong:KR,table:YR,tableCell:XR,tableRow:QR,text:JR,thematicBreak:eI,toml:fd,yaml:fd,definition:fd,footnoteDefinition:fd};function fd(){}const tj=-1,Mf=0,kc=1,tf=2,y0=3,v0=4,b0=5,k0=6,nj=7,aj=8,nI=typeof self=="object"?self:globalThis,I1=(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 nI[e](t)},aI=(e,t)=>{const a=(l,c)=>(e.set(c,l),l),i=l=>{if(e.has(l))return e.get(l);const[c,u]=t[l];switch(c){case Mf:case tj:return a(u,l);case kc:{const m=a([],l);for(const p of u)m.push(i(p));return m}case tf:{const m=a({},l);for(const[p,h]of u)m[i(p)]=i(h);return m}case y0:return a(new Date(u),l);case v0:{const{source:m,flags:p}=u;return a(new RegExp(m,p),l)}case b0:{const m=a(new Map,l);for(const[p,h]of u)m.set(i(p),i(h));return m}case k0:{const m=a(new Set,l);for(const p of u)m.add(i(p));return m}case nj:{const{name:m,message:p}=u;return a(I1(m,p),l)}case aj:return a(BigInt(u),l);case"BigInt":return a(Object(BigInt(u)),l);case"ArrayBuffer":return a(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:m}=new Uint8Array(u);return a(new DataView(m),u)}}return a(I1(c,u),l)};return i},L1=e=>aI(new Map,e)(0),Fi="",{toString:rI}={},{keys:sI}=Object,nc=e=>{const t=typeof e;if(t!=="object"||!e)return[Mf,t];const a=rI.call(e).slice(8,-1);switch(a){case"Array":return[kc,Fi];case"Object":return[tf,Fi];case"Date":return[y0,Fi];case"RegExp":return[v0,Fi];case"Map":return[b0,Fi];case"Set":return[k0,Fi];case"DataView":return[kc,a]}return a.includes("Array")?[kc,a]:a.includes("Error")?[nj,a]:[tf,a]},md=([e,t])=>e===Mf&&(t==="function"||t==="symbol"),iI=(e,t,a,i)=>{const l=(u,m)=>{const p=i.push(u)-1;return a.set(m,p),p},c=u=>{if(a.has(u))return a.get(u);let[m,p]=nc(u);switch(m){case Mf:{let g=u;switch(p){case"bigint":m=aj,g=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);g=null;break;case"undefined":return l([tj],u)}return l([m,g],u)}case kc:{if(p){let k=u;return p==="DataView"?k=new Uint8Array(u.buffer):p==="ArrayBuffer"&&(k=new Uint8Array(u)),l([p,[...k]],u)}const g=[],v=l([m,g],u);for(const k of u)g.push(c(k));return v}case tf:{if(p)switch(p){case"BigInt":return l([p,u.toString()],u);case"Boolean":case"Number":case"String":return l([p,u.valueOf()],u)}if(t&&"toJSON"in u)return c(u.toJSON());const g=[],v=l([m,g],u);for(const k of sI(u))(e||!md(nc(u[k])))&&g.push([c(k),c(u[k])]);return v}case y0:return l([m,isNaN(u.getTime())?Fi:u.toISOString()],u);case v0:{const{source:g,flags:v}=u;return l([m,{source:g,flags:v}],u)}case b0:{const g=[],v=l([m,g],u);for(const[k,w]of u)(e||!(md(nc(k))||md(nc(w))))&&g.push([c(k),c(w)]);return v}case k0:{const g=[],v=l([m,g],u);for(const k of u)(e||!md(nc(k)))&&g.push(c(k));return v}}const{message:h}=u;return l([m,{name:p,message:h}],u)};return c},O1=(e,{json:t,lossy:a}={})=>{const i=[];return iI(!(t||a),!!t,new Map,i)(e),i},nf=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?L1(O1(e,t)):structuredClone(e):(e,t)=>L1(O1(e,t));function lI(e,t){const a=[{type:"text",value:"↩"}];return t>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),a}function oI(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function cI(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||lI,i=e.options.footnoteBackLabel||oI,l=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},m=[];let p=-1;for(;++p<e.footnoteOrder.length;){const h=e.footnoteById.get(e.footnoteOrder[p]);if(!h)continue;const g=e.all(h),v=String(h.identifier).toUpperCase(),k=oo(v.toLowerCase());let w=0;const S=[],M=e.footnoteCounts.get(v);for(;M!==void 0&&++w<=M;){S.length>0&&S.push({type:"text",value:" "});let I=typeof a=="string"?a:a(p,w);typeof I=="string"&&(I={type:"text",value:I}),S.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+k+(w>1?"-"+w:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(p,w),className:["data-footnote-backref"]},children:Array.isArray(I)?I:[I]})}const C=g[g.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const I=C.children[C.children.length-1];I&&I.type==="text"?I.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...S)}else g.push(...S);const T={type:"element",tagName:"li",properties:{id:t+"fn-"+k},children:e.wrap(g,!0)};e.patch(h,T),m.push(T)}if(m.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...nf(u),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:`
145
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(m,!0)},{type:"text",value:`
146
- `}]}}const Af=(function(e){if(e==null)return mI;if(typeof e=="function")return Ef(e);if(typeof e=="object")return Array.isArray(e)?uI(e):dI(e);if(typeof e=="string")return fI(e);throw new Error("Expected function, string, or object as test")});function uI(e){const t=[];let a=-1;for(;++a<e.length;)t[a]=Af(e[a]);return Ef(i);function i(...l){let c=-1;for(;++c<t.length;)if(t[c].apply(this,l))return!0;return!1}}function dI(e){const t=e;return Ef(a);function a(i){const l=i;let c;for(c in e)if(l[c]!==t[c])return!1;return!0}}function fI(e){return Ef(t);function t(a){return a&&a.type===e}}function Ef(e){return t;function t(a,i,l){return!!(pI(a)&&e.call(this,a,typeof i=="number"?i:void 0,l||void 0))}}function mI(){return!0}function pI(e){return e!==null&&typeof e=="object"&&"type"in e}const rj=[],hI=!0,ig=!1,gI="skip";function sj(e,t,a,i){let l;typeof t=="function"&&typeof a!="function"?(i=a,a=t):l=t;const c=Af(l),u=i?-1:1;m(e,void 0,[])();function m(p,h,g){const v=p&&typeof p=="object"?p:{};if(typeof v.type=="string"){const w=typeof v.tagName=="string"?v.tagName:typeof v.name=="string"?v.name:void 0;Object.defineProperty(k,"name",{value:"node ("+(p.type+(w?"<"+w+">":""))+")"})}return k;function k(){let w=rj,S,M,C;if((!t||c(p,h,g[g.length-1]||void 0))&&(w=xI(a(p,g)),w[0]===ig))return w;if("children"in p&&p.children){const T=p;if(T.children&&w[0]!==gI)for(M=(i?T.children.length:-1)+u,C=g.concat(T);M>-1&&M<T.children.length;){const I=T.children[M];if(S=m(I,M,C)(),S[0]===ig)return S;M=typeof S[1]=="number"?S[1]:M+u}}return w}}}function xI(e){return Array.isArray(e)?e:typeof e=="number"?[hI,e]:e==null?rj:[e]}function w0(e,t,a,i){let l,c,u;typeof t=="function"&&typeof a!="function"?(c=void 0,u=t,l=a):(c=t,u=a,l=i),sj(e,c,m,l);function m(p,h){const g=h[h.length-1],v=g?g.children.indexOf(p):void 0;return u(p,v,g)}}const lg={}.hasOwnProperty,yI={};function vI(e,t){const a=t||yI,i=new Map,l=new Map,c=new Map,u={...tI,...a.handlers},m={all:h,applyData:kI,definitionById:i,footnoteById:l,footnoteCounts:c,footnoteOrder:[],handlers:u,one:p,options:a,patch:bI,wrap:SI};return w0(e,function(g){if(g.type==="definition"||g.type==="footnoteDefinition"){const v=g.type==="definition"?i:l,k=String(g.identifier).toUpperCase();v.has(k)||v.set(k,g)}}),m;function p(g,v){const k=g.type,w=m.handlers[k];if(lg.call(m.handlers,k)&&w)return w(m,g,v);if(m.options.passThrough&&m.options.passThrough.includes(k)){if("children"in g){const{children:M,...C}=g,T=nf(C);return T.children=m.all(g),T}return nf(g)}return(m.options.unknownHandler||wI)(m,g,v)}function h(g){const v=[];if("children"in g){const k=g.children;let w=-1;for(;++w<k.length;){const S=m.one(k[w],g);if(S){if(w&&k[w-1].type==="break"&&(!Array.isArray(S)&&S.type==="text"&&(S.value=D1(S.value)),!Array.isArray(S)&&S.type==="element")){const M=S.children[0];M&&M.type==="text"&&(M.value=D1(M.value))}Array.isArray(S)?v.push(...S):v.push(S)}}}return v}}function bI(e,t){e.position&&(t.position=l6(e))}function kI(e,t){let a=t;if(e&&e.data){const i=e.data.hName,l=e.data.hChildren,c=e.data.hProperties;if(typeof i=="string")if(a.type==="element")a.tagName=i;else{const u="children"in a?a.children:[a];a={type:"element",tagName:i,properties:{},children:u}}a.type==="element"&&c&&Object.assign(a.properties,nf(c)),"children"in a&&a.children&&l!==null&&l!==void 0&&(a.children=l)}return a}function wI(e,t){const a=t.data||{},i="value"in t&&!(lg.call(a,"hProperties")||lg.call(a,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function SI(e,t){const a=[];let i=-1;for(t&&a.push({type:"text",value:`
147
- `});++i<e.length;)i&&a.push({type:"text",value:`
148
- `}),a.push(e[i]);return t&&e.length>0&&a.push({type:"text",value:`
149
- `}),a}function D1(e){let t=0,a=e.charCodeAt(t);for(;a===9||a===32;)t++,a=e.charCodeAt(t);return e.slice(t)}function U1(e,t){const a=vI(e,t),i=a.one(e,void 0),l=cI(a),c=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return l&&c.children.push({type:"text",value:`
150
- `},l),c}function jI(e,t){return e&&"run"in e?async function(a,i){const l=U1(a,{file:i,...t});await e.run(l,i)}:function(a,i){return U1(a,{file:i,...e||t})}}function z1(e){if(e)throw e}var ah,$1;function CI(){if($1)return ah;$1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=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 g=e.call(h,"constructor"),v=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!g&&!v)return!1;var k;for(k in h);return typeof k>"u"||e.call(h,k)},u=function(h,g){a&&g.name==="__proto__"?a(h,g.name,{enumerable:!0,configurable:!0,value:g.newValue,writable:!0}):h[g.name]=g.newValue},m=function(h,g){if(g==="__proto__")if(e.call(h,g)){if(i)return i(h,g).value}else return;return h[g]};return ah=function p(){var h,g,v,k,w,S,M=arguments[0],C=1,T=arguments.length,I=!1;for(typeof M=="boolean"&&(I=M,M=arguments[1]||{},C=2),(M==null||typeof M!="object"&&typeof M!="function")&&(M={});C<T;++C)if(h=arguments[C],h!=null)for(g in h)v=m(M,g),k=m(h,g),M!==k&&(I&&k&&(c(k)||(w=l(k)))?(w?(w=!1,S=v&&l(v)?v:[]):S=v&&c(v)?v:{},u(M,{name:g,newValue:p(I,S,k)})):typeof k<"u"&&u(M,{name:g,newValue:k}));return M},ah}var NI=CI();const rh=Ag(NI);function og(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 TI(){const e=[],t={run:a,use:i};return t;function a(...l){let c=-1;const u=l.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);m(null,...l);function m(p,...h){const g=e[++c];let v=-1;if(p){u(p);return}for(;++v<l.length;)(h[v]===null||h[v]===void 0)&&(h[v]=l[v]);l=h,g?MI(g,m)(...h):u(null,...h)}}function i(l){if(typeof l!="function")throw new TypeError("Expected `middelware` to be a function, not "+l);return e.push(l),t}}function MI(e,t){let a;return i;function i(...u){const m=e.length>u.length;let p;m&&u.push(l);try{p=e.apply(this,u)}catch(h){const g=h;if(m&&a)throw g;return l(g)}m||(p&&p.then&&typeof p.then=="function"?p.then(c,l):p instanceof Error?l(p):c(p))}function l(u,...m){a||(a=!0,t(u,...m))}function c(u){l(null,u)}}const Wr={basename:AI,dirname:EI,extname:_I,join:RI,sep:"/"};function AI(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Xc(e);let a=0,i=-1,l=e.length,c;if(t===void 0||t.length===0||t.length>e.length){for(;l--;)if(e.codePointAt(l)===47){if(c){a=l+1;break}}else i<0&&(c=!0,i=l+1);return i<0?"":e.slice(a,i)}if(t===e)return"";let u=-1,m=t.length-1;for(;l--;)if(e.codePointAt(l)===47){if(c){a=l+1;break}}else u<0&&(c=!0,u=l+1),m>-1&&(e.codePointAt(l)===t.codePointAt(m--)?m<0&&(i=l):(m=-1,i=u));return a===i?i=u:i<0&&(i=e.length),e.slice(a,i)}function EI(e){if(Xc(e),e.length===0)return".";let t=-1,a=e.length,i;for(;--a;)if(e.codePointAt(a)===47){if(i){t=a;break}}else i||(i=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function _I(e){Xc(e);let t=e.length,a=-1,i=0,l=-1,c=0,u;for(;t--;){const m=e.codePointAt(t);if(m===47){if(u){i=t+1;break}continue}a<0&&(u=!0,a=t+1),m===46?l<0?l=t:c!==1&&(c=1):l>-1&&(c=-1)}return l<0||a<0||c===0||c===1&&l===a-1&&l===i+1?"":e.slice(l,a)}function RI(...e){let t=-1,a;for(;++t<e.length;)Xc(e[t]),e[t]&&(a=a===void 0?e[t]:a+"/"+e[t]);return a===void 0?".":II(a)}function II(e){Xc(e);const t=e.codePointAt(0)===47;let a=LI(e,!t);return a.length===0&&!t&&(a="."),a.length>0&&e.codePointAt(e.length-1)===47&&(a+="/"),t?"/"+a:a}function LI(e,t){let a="",i=0,l=-1,c=0,u=-1,m,p;for(;++u<=e.length;){if(u<e.length)m=e.codePointAt(u);else{if(m===47)break;m=47}if(m===47){if(!(l===u-1||c===1))if(l!==u-1&&c===2){if(a.length<2||i!==2||a.codePointAt(a.length-1)!==46||a.codePointAt(a.length-2)!==46){if(a.length>2){if(p=a.lastIndexOf("/"),p!==a.length-1){p<0?(a="",i=0):(a=a.slice(0,p),i=a.length-1-a.lastIndexOf("/")),l=u,c=0;continue}}else if(a.length>0){a="",i=0,l=u,c=0;continue}}t&&(a=a.length>0?a+"/..":"..",i=2)}else a.length>0?a+="/"+e.slice(l+1,u):a=e.slice(l+1,u),i=u-l-1;l=u,c=0}else m===46&&c>-1?c++:c=-1}return a}function Xc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const OI={cwd:DI};function DI(){return"/"}function cg(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function UI(e){if(typeof e=="string")e=new URL(e);else if(!cg(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 zI(e)}function zI(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const t=e.pathname;let a=-1;for(;++a<t.length;)if(t.codePointAt(a)===37&&t.codePointAt(a+1)===50){const i=t.codePointAt(a+2);if(i===70||i===102){const l=new TypeError("File URL path must not include encoded / characters");throw l.code="ERR_INVALID_FILE_URL_PATH",l}}return decodeURIComponent(t)}const sh=["history","path","basename","stem","extname","dirname"];class ij{constructor(t){let a;t?cg(t)?a={path:t}:typeof t=="string"||$I(t)?a={value:t}:a=t:a={},this.cwd="cwd"in a?"":OI.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<sh.length;){const c=sh[i];c in a&&a[c]!==void 0&&a[c]!==null&&(this[c]=c==="history"?[...a[c]]:a[c])}let l;for(l in a)sh.includes(l)||(this[l]=a[l])}get basename(){return typeof this.path=="string"?Wr.basename(this.path):void 0}set basename(t){lh(t,"basename"),ih(t,"basename"),this.path=Wr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Wr.dirname(this.path):void 0}set dirname(t){P1(this.basename,"dirname"),this.path=Wr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Wr.extname(this.path):void 0}set extname(t){if(ih(t,"extname"),P1(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=Wr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){cg(t)&&(t=UI(t)),lh(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Wr.basename(this.path,this.extname):void 0}set stem(t){lh(t,"stem"),ih(t,"stem"),this.path=Wr.join(this.dirname||"",t+(this.extname||""))}fail(t,a,i){const l=this.message(t,a,i);throw l.fatal=!0,l}info(t,a,i){const l=this.message(t,a,i);return l.fatal=void 0,l}message(t,a,i){const l=new la(t,a,i);return this.path&&(l.name=this.path+":"+l.name,l.file=this.path),l.fatal=!1,this.messages.push(l),l}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function ih(e,t){if(e&&e.includes(Wr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Wr.sep+"`")}function lh(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function P1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function $I(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const PI=(function(e){const i=this.constructor.prototype,l=i[e],c=function(){return l.apply(c,arguments)};return Object.setPrototypeOf(c,i),c}),BI={}.hasOwnProperty;class S0 extends PI{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=TI()}copy(){const t=new S0;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];t.use(...i)}return t.data(rh(!0,{},this.namespace)),t}data(t,a){return typeof t=="string"?arguments.length===2?(uh("data",this.frozen),this.namespace[t]=a,this):BI.call(this.namespace,t)&&this.namespace[t]||void 0:t?(uh("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[a,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const l=a.call(t,...i);typeof l=="function"&&this.transformers.use(l)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const a=pd(t),i=this.parser||this.Parser;return oh("parse",i),i(String(a),a)}process(t,a){const i=this;return this.freeze(),oh("process",this.parser||this.Parser),ch("process",this.compiler||this.Compiler),a?l(void 0,a):new Promise(l);function l(c,u){const m=pd(t),p=i.parse(m);i.run(p,m,function(g,v,k){if(g||!v||!k)return h(g);const w=v,S=i.stringify(w,k);VI(S)?k.value=S:k.result=S,h(g,k)});function h(g,v){g||!v?u(g):c?c(v):a(void 0,v)}}}processSync(t){let a=!1,i;return this.freeze(),oh("processSync",this.parser||this.Parser),ch("processSync",this.compiler||this.Compiler),this.process(t,l),H1("processSync","process",a),i;function l(c,u){a=!0,z1(c),i=u}}run(t,a,i){B1(t),this.freeze();const l=this.transformers;return!i&&typeof a=="function"&&(i=a,a=void 0),i?c(void 0,i):new Promise(c);function c(u,m){const p=pd(a);l.run(t,p,h);function h(g,v,k){const w=v||t;g?m(g):u?u(w):i(void 0,w,k)}}}runSync(t,a){let i=!1,l;return this.run(t,a,c),H1("runSync","run",i),l;function c(u,m){z1(u),l=m,i=!0}}stringify(t,a){this.freeze();const i=pd(a),l=this.compiler||this.Compiler;return ch("stringify",l),B1(t),l(t,i)}use(t,...a){const i=this.attachers,l=this.namespace;if(uh("use",this.frozen),t!=null)if(typeof t=="function")p(t,a);else if(typeof t=="object")Array.isArray(t)?m(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[g,...v]=h;p(g,v)}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");m(h.plugins),h.settings&&(l.settings=rh(!0,l.settings,h.settings))}function m(h){let g=-1;if(h!=null)if(Array.isArray(h))for(;++g<h.length;){const v=h[g];c(v)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function p(h,g){let v=-1,k=-1;for(;++v<i.length;)if(i[v][0]===h){k=v;break}if(k===-1)i.push([h,...g]);else if(g.length>0){let[w,...S]=g;const M=i[k][1];og(M)&&og(w)&&(w=rh(!0,M,w)),i[k]=[h,w,...S]}}}}const HI=new S0().freeze();function oh(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ch(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function uh(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 B1(e){if(!og(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function H1(e,t,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function pd(e){return FI(e)?e:new ij(e)}function FI(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function VI(e){return typeof e=="string"||qI(e)}function qI(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const GI="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",F1=[],V1={allowDangerousHtml:!0},WI=/^(https?|ircs?|mailto|xmpp)$/i,KI=[{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 Zc(e){const t=YI(e),a=QI(e);return XI(t.runSync(t.parse(a),a),e)}function YI(e){const t=e.rehypePlugins||F1,a=e.remarkPlugins||F1,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...V1}:V1;return HI().use(AR).use(a).use(jI,i).use(t)}function QI(e){const t=e.children||"",a=new ij;return typeof t=="string"&&(a.value=t),a}function XI(e,t){const a=t.allowedElements,i=t.allowElement,l=t.components,c=t.disallowedElements,u=t.skipHtml,m=t.unwrapDisallowed,p=t.urlTransform||ZI;for(const g of KI)Object.hasOwn(t,g.from)&&(""+g.from+(g.to?"use `"+g.to+"` instead":"remove it")+GI+g.id,void 0);return w0(e,h),f6(e,{Fragment:r.Fragment,components:l,ignoreInvalidStyle:!0,jsx:r.jsx,jsxs:r.jsxs,passKeys:!0,passNode:!0});function h(g,v,k){if(g.type==="raw"&&k&&typeof v=="number")return u?k.children.splice(v,1):k.children[v]={type:"text",value:g.value},v;if(g.type==="element"){let w;for(w in eh)if(Object.hasOwn(eh,w)&&Object.hasOwn(g.properties,w)){const S=g.properties[w],M=eh[w];(M===null||M.includes(g.tagName))&&(g.properties[w]=p(String(S||""),w,g))}}if(g.type==="element"){let w=a?!a.includes(g.tagName):c?c.includes(g.tagName):!1;if(!w&&i&&typeof v=="number"&&(w=!i(g,v,k)),w&&k&&typeof v=="number")return m&&g.children?k.children.splice(v,1,...g.children):k.children.splice(v,1),v}}}function ZI(e){const t=e.indexOf(":"),a=e.indexOf("?"),i=e.indexOf("#"),l=e.indexOf("/");return t===-1||l!==-1&&t>l||a!==-1&&t>a||i!==-1&&t>i||WI.test(e.slice(0,t))?e:""}function q1(e,t){const a=String(e);if(typeof t!="string")throw new TypeError("Expected character");let i=0,l=a.indexOf(t);for(;l!==-1;)i++,l=a.indexOf(t,l+t.length);return i}function JI(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function eL(e,t,a){const l=Af((a||{}).ignore||[]),c=tL(t);let u=-1;for(;++u<c.length;)sj(e,"text",m);function m(h,g){let v=-1,k;for(;++v<g.length;){const w=g[v],S=k?k.children:void 0;if(l(w,S?S.indexOf(w):void 0,k))return;k=w}if(k)return p(h,g)}function p(h,g){const v=g[g.length-1],k=c[u][0],w=c[u][1];let S=0;const C=v.children.indexOf(h);let T=!1,I=[];k.lastIndex=0;let D=k.exec(h.value);for(;D;){const K=D.index,F={index:D.index,input:D.input,stack:[...g,h]};let E=w(...D,F);if(typeof E=="string"&&(E=E.length>0?{type:"text",value:E}:void 0),E===!1?k.lastIndex=K+1:(S!==K&&I.push({type:"text",value:h.value.slice(S,K)}),Array.isArray(E)?I.push(...E):E&&I.push(E),S=K+D[0].length,T=!0),!k.global)break;D=k.exec(h.value)}return T?(S<h.value.length&&I.push({type:"text",value:h.value.slice(S)}),v.children.splice(C,1,...I)):I=[h],C+I.length}}function tL(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const a=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<a.length;){const l=a[i];t.push([nL(l[0]),aL(l[1])])}return t}function nL(e){return typeof e=="string"?new RegExp(JI(e),"g"):e}function aL(e){return typeof e=="function"?e:function(){return e}}const dh="phrasing",fh=["autolink","link","image","label"];function rL(){return{transforms:[dL],enter:{literalAutolink:iL,literalAutolinkEmail:mh,literalAutolinkHttp:mh,literalAutolinkWww:mh},exit:{literalAutolink:uL,literalAutolinkEmail:cL,literalAutolinkHttp:lL,literalAutolinkWww:oL}}}function sL(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:dh,notInConstruct:fh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:dh,notInConstruct:fh},{character:":",before:"[ps]",after:"\\/",inConstruct:dh,notInConstruct:fh}]}}function iL(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function mh(e){this.config.enter.autolinkProtocol.call(this,e)}function lL(e){this.config.exit.autolinkProtocol.call(this,e)}function oL(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 cL(e){this.config.exit.autolinkEmail.call(this,e)}function uL(e){this.exit(e)}function dL(e){eL(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,fL],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),mL]],{ignore:["link","linkReference"]})}function fL(e,t,a,i,l){let c="";if(!lj(l)||(/^w/i.test(t)&&(a=t+a,t="",c="http://"),!pL(a)))return!1;const u=hL(a+i);if(!u[0])return!1;const m={type:"link",title:null,url:c+t+u[0],children:[{type:"text",value:t+u[0]}]};return u[1]?[m,{type:"text",value:u[1]}]:m}function mL(e,t,a,i){return!lj(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+a,children:[{type:"text",value:t+"@"+a}]}}function pL(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 hL(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let a=t[0],i=a.indexOf(")");const l=q1(e,"(");let c=q1(e,")");for(;i!==-1&&l>c;)e+=a.slice(0,i+1),a=a.slice(i+1),i=a.indexOf(")"),c++;return[e,a]}function lj(e,t){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Ji(a)||Nf(a))&&(!t||a!==47)}oj.peek=jL;function gL(){this.buffer()}function xL(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function yL(){this.buffer()}function vL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function bL(e){const t=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=Or(this.sliceSerialize(e)).toLowerCase(),a.label=t}function kL(e){this.exit(e)}function wL(e){const t=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=Or(this.sliceSerialize(e)).toLowerCase(),a.label=t}function SL(e){this.exit(e)}function jL(){return"["}function oj(e,t,a,i){const l=a.createTracker(i);let c=l.move("[^");const u=a.enter("footnoteReference"),m=a.enter("reference");return c+=l.move(a.safe(a.associationId(e),{after:"]",before:c})),m(),u(),c+=l.move("]"),c}function CL(){return{enter:{gfmFootnoteCallString:gL,gfmFootnoteCall:xL,gfmFootnoteDefinitionLabelString:yL,gfmFootnoteDefinition:vL},exit:{gfmFootnoteCallString:bL,gfmFootnoteCall:kL,gfmFootnoteDefinitionLabelString:wL,gfmFootnoteDefinition:SL}}}function NL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:a,footnoteReference:oj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,l,c,u){const m=c.createTracker(u);let p=m.move("[^");const h=c.enter("footnoteDefinition"),g=c.enter("label");return p+=m.move(c.safe(c.associationId(i),{before:p,after:"]"})),g(),p+=m.move("]:"),i.children&&i.children.length>0&&(m.shift(4),p+=m.move((t?`
151
- `:" ")+c.indentLines(c.containerFlow(i,m.current()),t?cj:TL))),h(),p}}function TL(e,t,a){return t===0?e:cj(e,t,a)}function cj(e,t,a){return(a?"":" ")+e}const ML=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];uj.peek=IL;function AL(){return{canContainEols:["delete"],enter:{strikethrough:_L},exit:{strikethrough:RL}}}function EL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:ML}],handlers:{delete:uj}}}function _L(e){this.enter({type:"delete",children:[]},e)}function RL(e){this.exit(e)}function uj(e,t,a,i){const l=a.createTracker(i),c=a.enter("strikethrough");let u=l.move("~~");return u+=a.containerPhrasing(e,{...l.current(),before:u,after:"~"}),u+=l.move("~~"),c(),u}function IL(){return"~"}function LL(e){return e.length}function OL(e,t){const a=t||{},i=(a.align||[]).concat(),l=a.stringLength||LL,c=[],u=[],m=[],p=[];let h=0,g=-1;for(;++g<e.length;){const M=[],C=[];let T=-1;for(e[g].length>h&&(h=e[g].length);++T<e[g].length;){const I=DL(e[g][T]);if(a.alignDelimiters!==!1){const D=l(I);C[T]=D,(p[T]===void 0||D>p[T])&&(p[T]=D)}M.push(I)}u[g]=M,m[g]=C}let v=-1;if(typeof i=="object"&&"length"in i)for(;++v<h;)c[v]=G1(i[v]);else{const M=G1(i);for(;++v<h;)c[v]=M}v=-1;const k=[],w=[];for(;++v<h;){const M=c[v];let C="",T="";M===99?(C=":",T=":"):M===108?C=":":M===114&&(T=":");let I=a.alignDelimiters===!1?1:Math.max(1,p[v]-C.length-T.length);const D=C+"-".repeat(I)+T;a.alignDelimiters!==!1&&(I=C.length+I+T.length,I>p[v]&&(p[v]=I),w[v]=I),k[v]=D}u.splice(1,0,k),m.splice(1,0,w),g=-1;const S=[];for(;++g<u.length;){const M=u[g],C=m[g];v=-1;const T=[];for(;++v<h;){const I=M[v]||"";let D="",K="";if(a.alignDelimiters!==!1){const F=p[v]-(C[v]||0),E=c[v];E===114?D=" ".repeat(F):E===99?F%2?(D=" ".repeat(F/2+.5),K=" ".repeat(F/2-.5)):(D=" ".repeat(F/2),K=D):K=" ".repeat(F)}a.delimiterStart!==!1&&!v&&T.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&I==="")&&(a.delimiterStart!==!1||v)&&T.push(" "),a.alignDelimiters!==!1&&T.push(D),T.push(I),a.alignDelimiters!==!1&&T.push(K),a.padding!==!1&&T.push(" "),(a.delimiterEnd!==!1||v!==h-1)&&T.push("|")}S.push(a.delimiterEnd===!1?T.join("").replace(/ +$/,""):T.join(""))}return S.join(`
152
- `)}function DL(e){return e==null?"":String(e)}function G1(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 UL(e,t,a,i){const l=a.enter("blockquote"),c=a.createTracker(i);c.move("> "),c.shift(2);const u=a.indentLines(a.containerFlow(e,c.current()),zL);return l(),u}function zL(e,t,a){return">"+(a?"":" ")+e}function $L(e,t){return W1(e,t.inConstruct,!0)&&!W1(e,t.notInConstruct,!1)}function W1(e,t,a){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return a;let i=-1;for(;++i<t.length;)if(e.includes(t[i]))return!0;return!1}function K1(e,t,a,i){let l=-1;for(;++l<a.unsafe.length;)if(a.unsafe[l].character===`
153
- `&&$L(a.stack,a.unsafe[l]))return/[ \t]/.test(i.before)?"":" ";return`\\
154
- `}function PL(e,t){const a=String(e);let i=a.indexOf(t),l=i,c=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===l?++c>u&&(u=c):c=1,l=i+t.length,i=a.indexOf(t,l);return u}function BL(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 HL(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 FL(e,t,a,i){const l=HL(a),c=e.value||"",u=l==="`"?"GraveAccent":"Tilde";if(BL(e,a)){const v=a.enter("codeIndented"),k=a.indentLines(c,VL);return v(),k}const m=a.createTracker(i),p=l.repeat(Math.max(PL(c,l)+1,3)),h=a.enter("codeFenced");let g=m.move(p);if(e.lang){const v=a.enter(`codeFencedLang${u}`);g+=m.move(a.safe(e.lang,{before:g,after:" ",encode:["`"],...m.current()})),v()}if(e.lang&&e.meta){const v=a.enter(`codeFencedMeta${u}`);g+=m.move(" "),g+=m.move(a.safe(e.meta,{before:g,after:`
155
- `,encode:["`"],...m.current()})),v()}return g+=m.move(`
156
- `),c&&(g+=m.move(c+`
157
- `)),g+=m.move(p),h(),g}function VL(e,t,a){return(a?"":" ")+e}function j0(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 qL(e,t,a,i){const l=j0(a),c=l==='"'?"Quote":"Apostrophe",u=a.enter("definition");let m=a.enter("label");const p=a.createTracker(i);let h=p.move("[");return h+=p.move(a.safe(a.associationId(e),{before:h,after:"]",...p.current()})),h+=p.move("]: "),m(),!e.url||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(a.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(m=a.enter("destinationRaw"),h+=p.move(a.safe(e.url,{before:h,after:e.title?" ":`
158
- `,...p.current()}))),m(),e.title&&(m=a.enter(`title${c}`),h+=p.move(" "+l),h+=p.move(a.safe(e.title,{before:h,after:l,...p.current()})),h+=p.move(l),m()),u(),h}function GL(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 Dc(e){return"&#x"+e.toString(16).toUpperCase()+";"}function af(e,t,a){const i=Zl(e),l=Zl(t);return i===void 0?l===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}dj.peek=WL;function dj(e,t,a,i){const l=GL(a),c=a.enter("emphasis"),u=a.createTracker(i),m=u.move(l);let p=u.move(a.containerPhrasing(e,{after:l,before:m,...u.current()}));const h=p.charCodeAt(0),g=af(i.before.charCodeAt(i.before.length-1),h,l);g.inside&&(p=Dc(h)+p.slice(1));const v=p.charCodeAt(p.length-1),k=af(i.after.charCodeAt(0),v,l);k.inside&&(p=p.slice(0,-1)+Dc(v));const w=u.move(l);return c(),a.attentionEncodeSurroundingInfo={after:k.outside,before:g.outside},m+p+w}function WL(e,t,a){return a.options.emphasis||"*"}function KL(e,t){let a=!1;return w0(e,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,ig}),!!((!e.depth||e.depth<3)&&h0(e)&&(t.options.setext||a))}function YL(e,t,a,i){const l=Math.max(Math.min(6,e.depth||1),1),c=a.createTracker(i);if(KL(e,a)){const g=a.enter("headingSetext"),v=a.enter("phrasing"),k=a.containerPhrasing(e,{...c.current(),before:`
159
- `,after:`
160
- `});return v(),g(),k+`
161
- `+(l===1?"=":"-").repeat(k.length-(Math.max(k.lastIndexOf("\r"),k.lastIndexOf(`
162
- `))+1))}const u="#".repeat(l),m=a.enter("headingAtx"),p=a.enter("phrasing");c.move(u+" ");let h=a.containerPhrasing(e,{before:"# ",after:`
163
- `,...c.current()});return/^[\t ]/.test(h)&&(h=Dc(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,a.options.closeAtx&&(h+=" "+u),p(),m(),h}fj.peek=QL;function fj(e){return e.value||""}function QL(){return"<"}mj.peek=XL;function mj(e,t,a,i){const l=j0(a),c=l==='"'?"Quote":"Apostrophe",u=a.enter("image");let m=a.enter("label");const p=a.createTracker(i);let h=p.move("![");return h+=p.move(a.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(a.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(m=a.enter("destinationRaw"),h+=p.move(a.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),m(),e.title&&(m=a.enter(`title${c}`),h+=p.move(" "+l),h+=p.move(a.safe(e.title,{before:h,after:l,...p.current()})),h+=p.move(l),m()),h+=p.move(")"),u(),h}function XL(){return"!"}pj.peek=ZL;function pj(e,t,a,i){const l=e.referenceType,c=a.enter("imageReference");let u=a.enter("label");const m=a.createTracker(i);let p=m.move("![");const h=a.safe(e.alt,{before:p,after:"]",...m.current()});p+=m.move(h+"]["),u();const g=a.stack;a.stack=[],u=a.enter("reference");const v=a.safe(a.associationId(e),{before:p,after:"]",...m.current()});return u(),a.stack=g,c(),l==="full"||!h||h!==v?p+=m.move(v+"]"):l==="shortcut"?p=p.slice(0,-1):p+=m.move("]"),p}function ZL(){return"!"}hj.peek=JL;function hj(e,t,a){let i=e.value||"",l="`",c=-1;for(;new RegExp("(^|[^`])"+l+"([^`]|$)").test(i);)l+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++c<a.unsafe.length;){const u=a.unsafe[c],m=a.compilePattern(u);let p;if(u.atBreak)for(;p=m.exec(i);){let h=p.index;i.charCodeAt(h)===10&&i.charCodeAt(h-1)===13&&h--,i=i.slice(0,h)+" "+i.slice(p.index+1)}}return l+i+l}function JL(){return"`"}function gj(e,t){const a=h0(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(a===e.url||"mailto:"+a===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}xj.peek=e8;function xj(e,t,a,i){const l=j0(a),c=l==='"'?"Quote":"Apostrophe",u=a.createTracker(i);let m,p;if(gj(e,a)){const g=a.stack;a.stack=[],m=a.enter("autolink");let v=u.move("<");return v+=u.move(a.containerPhrasing(e,{before:v,after:">",...u.current()})),v+=u.move(">"),m(),a.stack=g,v}m=a.enter("link"),p=a.enter("label");let h=u.move("[");return h+=u.move(a.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=a.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(a.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(p=a.enter("destinationRaw"),h+=u.move(a.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),p(),e.title&&(p=a.enter(`title${c}`),h+=u.move(" "+l),h+=u.move(a.safe(e.title,{before:h,after:l,...u.current()})),h+=u.move(l),p()),h+=u.move(")"),m(),h}function e8(e,t,a){return gj(e,a)?"<":"["}yj.peek=t8;function yj(e,t,a,i){const l=e.referenceType,c=a.enter("linkReference");let u=a.enter("label");const m=a.createTracker(i);let p=m.move("[");const h=a.containerPhrasing(e,{before:p,after:"]",...m.current()});p+=m.move(h+"]["),u();const g=a.stack;a.stack=[],u=a.enter("reference");const v=a.safe(a.associationId(e),{before:p,after:"]",...m.current()});return u(),a.stack=g,c(),l==="full"||!h||h!==v?p+=m.move(v+"]"):l==="shortcut"?p=p.slice(0,-1):p+=m.move("]"),p}function t8(){return"["}function C0(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 n8(e){const t=C0(e),a=e.options.bulletOther;if(!a)return t==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+a+"`) to be different");return a}function a8(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 vj(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 r8(e,t,a,i){const l=a.enter("list"),c=a.bulletCurrent;let u=e.ordered?a8(a):C0(a);const m=e.ordered?u==="."?")":".":n8(a);let p=t&&a.bulletLastUsed?u===a.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&g&&(!g.children||!g.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(p=!0),vj(a)===u&&g){let v=-1;for(;++v<e.children.length;){const k=e.children[v];if(k&&k.type==="listItem"&&k.children&&k.children[0]&&k.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(u=m),a.bulletCurrent=u;const h=a.containerFlow(e,i);return a.bulletLastUsed=u,a.bulletCurrent=c,l(),h}function s8(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 i8(e,t,a,i){const l=s8(a);let c=a.bulletCurrent||C0(a);t&&t.type==="list"&&t.ordered&&(c=(typeof t.start=="number"&&t.start>-1?t.start:1)+(a.options.incrementListMarker===!1?0:t.children.indexOf(e))+c);let u=c.length+1;(l==="tab"||l==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const m=a.createTracker(i);m.move(c+" ".repeat(u-c.length)),m.shift(u);const p=a.enter("listItem"),h=a.indentLines(a.containerFlow(e,m.current()),g);return p(),h;function g(v,k,w){return k?(w?"":" ".repeat(u))+v:(w?c:c+" ".repeat(u-c.length))+v}}function l8(e,t,a,i){const l=a.enter("paragraph"),c=a.enter("phrasing"),u=a.containerPhrasing(e,i);return c(),l(),u}const o8=Af(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function c8(e,t,a,i){return(e.children.some(function(u){return o8(u)})?a.containerPhrasing:a.containerFlow).call(a,e,i)}function u8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}bj.peek=d8;function bj(e,t,a,i){const l=u8(a),c=a.enter("strong"),u=a.createTracker(i),m=u.move(l+l);let p=u.move(a.containerPhrasing(e,{after:l,before:m,...u.current()}));const h=p.charCodeAt(0),g=af(i.before.charCodeAt(i.before.length-1),h,l);g.inside&&(p=Dc(h)+p.slice(1));const v=p.charCodeAt(p.length-1),k=af(i.after.charCodeAt(0),v,l);k.inside&&(p=p.slice(0,-1)+Dc(v));const w=u.move(l+l);return c(),a.attentionEncodeSurroundingInfo={after:k.outside,before:g.outside},m+p+w}function d8(e,t,a){return a.options.strong||"*"}function f8(e,t,a,i){return a.safe(e.value,i)}function m8(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 p8(e,t,a){const i=(vj(a)+(a.options.ruleSpaces?" ":"")).repeat(m8(a));return a.options.ruleSpaces?i.slice(0,-1):i}const kj={blockquote:UL,break:K1,code:FL,definition:qL,emphasis:dj,hardBreak:K1,heading:YL,html:fj,image:mj,imageReference:pj,inlineCode:hj,link:xj,linkReference:yj,list:r8,listItem:i8,paragraph:l8,root:c8,strong:bj,text:f8,thematicBreak:p8};function h8(){return{enter:{table:g8,tableData:Y1,tableHeader:Y1,tableRow:y8},exit:{codeText:v8,table:x8,tableData:ph,tableHeader:ph,tableRow:ph}}}function g8(e){const t=e._align;this.enter({type:"table",align:t.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function x8(e){this.exit(e),this.data.inTable=void 0}function y8(e){this.enter({type:"tableRow",children:[]},e)}function ph(e){this.exit(e)}function Y1(e){this.enter({type:"tableCell",children:[]},e)}function v8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,b8));const a=this.stack[this.stack.length-1];a.type,a.value=t,this.exit(e)}function b8(e,t){return t==="|"?t:e}function k8(e){const t=e||{},a=t.tableCellPadding,i=t.tablePipeAlign,l=t.stringLength,c=a?" ":"|";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:k,table:u,tableCell:p,tableRow:m}};function u(w,S,M,C){return h(g(w,M,C),w.align)}function m(w,S,M,C){const T=v(w,M,C),I=h([T]);return I.slice(0,I.indexOf(`
165
- `))}function p(w,S,M,C){const T=M.enter("tableCell"),I=M.enter("phrasing"),D=M.containerPhrasing(w,{...C,before:c,after:c});return I(),T(),D}function h(w,S){return OL(w,{align:S,alignDelimiters:i,padding:a,stringLength:l})}function g(w,S,M){const C=w.children;let T=-1;const I=[],D=S.enter("table");for(;++T<C.length;)I[T]=v(C[T],S,M);return D(),I}function v(w,S,M){const C=w.children;let T=-1;const I=[],D=S.enter("tableRow");for(;++T<C.length;)I[T]=p(C[T],w,S,M);return D(),I}function k(w,S,M){let C=kj.inlineCode(w,S,M);return M.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function w8(){return{exit:{taskListCheckValueChecked:Q1,taskListCheckValueUnchecked:Q1,paragraph:j8}}}function S8(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:C8}}}function Q1(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function j8(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const l=t.children;let c=-1,u;for(;++c<l.length;){const m=l[c];if(m.type==="paragraph"){u=m;break}}u===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function C8(e,t,a,i){const l=e.children[0],c=typeof e.checked=="boolean"&&l&&l.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",m=a.createTracker(i);c&&m.move(u);let p=kj.listItem(e,t,a,{...i,...m.current()});return c&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),p;function h(g){return g+u}}function N8(){return[rL(),CL(),AL(),h8(),w8()]}function T8(e){return{extensions:[sL(),NL(e),EL(),k8(e),S8()]}}const M8={tokenize:L8,partial:!0},wj={tokenize:O8,partial:!0},Sj={tokenize:D8,partial:!0},jj={tokenize:U8,partial:!0},A8={tokenize:z8,partial:!0},Cj={name:"wwwAutolink",tokenize:R8,previous:Tj},Nj={name:"protocolAutolink",tokenize:I8,previous:Mj},Cs={name:"emailAutolink",tokenize:_8,previous:Aj},es={};function E8(){return{text:es}}let $i=48;for(;$i<123;)es[$i]=Cs,$i++,$i===58?$i=65:$i===91&&($i=97);es[43]=Cs;es[45]=Cs;es[46]=Cs;es[95]=Cs;es[72]=[Cs,Nj];es[104]=[Cs,Nj];es[87]=[Cs,Cj];es[119]=[Cs,Cj];function _8(e,t,a){const i=this;let l,c;return u;function u(v){return!ug(v)||!Aj.call(i,i.previous)||N0(i.events)?a(v):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),m(v))}function m(v){return ug(v)?(e.consume(v),m):v===64?(e.consume(v),p):a(v)}function p(v){return v===46?e.check(A8,g,h)(v):v===45||v===95||ra(v)?(c=!0,e.consume(v),p):g(v)}function h(v){return e.consume(v),l=!0,p}function g(v){return c&&l&&ma(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(v)):a(v)}}function R8(e,t,a){const i=this;return l;function l(u){return u!==87&&u!==119||!Tj.call(i,i.previous)||N0(i.events)?a(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(M8,e.attempt(wj,e.attempt(Sj,c),a),a)(u))}function c(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function I8(e,t,a){const i=this;let l="",c=!1;return u;function u(v){return(v===72||v===104)&&Mj.call(i,i.previous)&&!N0(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),l+=String.fromCodePoint(v),e.consume(v),m):a(v)}function m(v){if(ma(v)&&l.length<5)return l+=String.fromCodePoint(v),e.consume(v),m;if(v===58){const k=l.toLowerCase();if(k==="http"||k==="https")return e.consume(v),p}return a(v)}function p(v){return v===47?(e.consume(v),c?h:(c=!0,p)):a(v)}function h(v){return v===null||ef(v)||tn(v)||Ji(v)||Nf(v)?a(v):e.attempt(wj,e.attempt(Sj,g),a)(v)}function g(v){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(v)}}function L8(e,t,a){let i=0;return l;function l(u){return(u===87||u===119)&&i<3?(i++,e.consume(u),l):u===46&&i===3?(e.consume(u),c):a(u)}function c(u){return u===null?a(u):t(u)}}function O8(e,t,a){let i,l,c;return u;function u(h){return h===46||h===95?e.check(jj,p,m)(h):h===null||tn(h)||Ji(h)||h!==45&&Nf(h)?p(h):(c=!0,e.consume(h),u)}function m(h){return h===95?i=!0:(l=i,i=void 0),e.consume(h),u}function p(h){return l||i||!c?a(h):t(h)}}function D8(e,t){let a=0,i=0;return l;function l(u){return u===40?(a++,e.consume(u),l):u===41&&i<a?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(jj,t,c)(u):u===null||tn(u)||Ji(u)?t(u):(e.consume(u),l)}function c(u){return u===41&&i++,e.consume(u),l}}function U8(e,t,a){return i;function i(m){return m===33||m===34||m===39||m===41||m===42||m===44||m===46||m===58||m===59||m===63||m===95||m===126?(e.consume(m),i):m===38?(e.consume(m),c):m===93?(e.consume(m),l):m===60||m===null||tn(m)||Ji(m)?t(m):a(m)}function l(m){return m===null||m===40||m===91||tn(m)||Ji(m)?t(m):i(m)}function c(m){return ma(m)?u(m):a(m)}function u(m){return m===59?(e.consume(m),i):ma(m)?(e.consume(m),u):a(m)}}function z8(e,t,a){return i;function i(c){return e.consume(c),l}function l(c){return ra(c)?a(c):t(c)}}function Tj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||tn(e)}function Mj(e){return!ma(e)}function Aj(e){return!(e===47||ug(e))}function ug(e){return e===43||e===45||e===46||e===95||ra(e)}function N0(e){let t=e.length,a=!1;for(;t--;){const i=e[t][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){a=!0;break}if(i._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const $8={tokenize:W8,partial:!0};function P8(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:V8,continuation:{tokenize:q8},exit:G8}},text:{91:{name:"gfmFootnoteCall",tokenize:F8},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:B8,resolveTo:H8}}}}function B8(e,t,a){const i=this;let l=i.events.length;const c=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u;for(;l--;){const p=i.events[l][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 m;function m(p){if(!u||!u._balanced)return a(p);const h=Or(i.sliceSerialize({start:u.end,end:i.now()}));return h.codePointAt(0)!==94||!c.includes(h.slice(1))?a(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function H8(e,t){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const c={type:"gfmFootnoteCallString",start:Object.assign({},l.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)},m=[e[a+1],e[a+2],["enter",i,t],e[a+3],e[a+4],["enter",l,t],["exit",l,t],["enter",c,t],["enter",u,t],["exit",u,t],["exit",c,t],e[e.length-2],e[e.length-1],["exit",i,t]];return e.splice(a,e.length-a+1,...m),e}function F8(e,t,a){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c=0,u;return m;function m(v){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(v),e.exit("gfmFootnoteCallLabelMarker"),p}function p(v){return v!==94?a(v):(e.enter("gfmFootnoteCallMarker"),e.consume(v),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(v){if(c>999||v===93&&!u||v===null||v===91||tn(v))return a(v);if(v===93){e.exit("chunkString");const k=e.exit("gfmFootnoteCallString");return l.includes(Or(i.sliceSerialize(k)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(v),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):a(v)}return tn(v)||(u=!0),c++,e.consume(v),v===92?g:h}function g(v){return v===91||v===92||v===93?(e.consume(v),c++,h):h(v)}}function V8(e,t,a){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c,u=0,m;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",g):a(S)}function g(S){if(u>999||S===93&&!m||S===null||S===91||tn(S))return a(S);if(S===93){e.exit("chunkString");const M=e.exit("gfmFootnoteDefinitionLabelString");return c=Or(i.sliceSerialize(M)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(S),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),k}return tn(S)||(m=!0),u++,e.consume(S),S===92?v:g}function v(S){return S===91||S===92||S===93?(e.consume(S),u++,g):g(S)}function k(S){return S===58?(e.enter("definitionMarker"),e.consume(S),e.exit("definitionMarker"),l.includes(c)||l.push(c),At(e,w,"gfmFootnoteDefinitionWhitespace")):a(S)}function w(S){return t(S)}}function q8(e,t,a){return e.check(Qc,t,e.attempt($8,t,a))}function G8(e){e.exit("gfmFootnoteDefinition")}function W8(e,t,a){const i=this;return At(e,l,"gfmFootnoteDefinitionIndent",5);function l(c){const u=i.events[i.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(c):a(c)}}function K8(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:c,resolveAll:l};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(u,m){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 g={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[p][1].end)},v={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[p][1].start)},k=[["enter",g,m],["enter",u[h][1],m],["exit",u[h][1],m],["enter",v,m]],w=m.parser.constructs.insideSpan.null;w&&Qa(k,k.length,0,Tf(w,u.slice(h+1,p),m)),Qa(k,k.length,0,[["exit",v,m],["enter",u[p][1],m],["exit",u[p][1],m],["exit",g,m]]),Qa(u,h-1,p-h+3,k),p=h+k.length-2;break}}for(p=-1;++p<u.length;)u[p][1].type==="strikethroughSequenceTemporary"&&(u[p][1].type="data");return u}function c(u,m,p){const h=this.previous,g=this.events;let v=0;return k;function k(S){return h===126&&g[g.length-1][1].type!=="characterEscape"?p(S):(u.enter("strikethroughSequenceTemporary"),w(S))}function w(S){const M=Zl(h);if(S===126)return v>1?p(S):(u.consume(S),v++,w);if(v<2&&!a)return p(S);const C=u.exit("strikethroughSequenceTemporary"),T=Zl(S);return C._open=!T||T===2&&!!M,C._close=!M||M===2&&!!T,m(S)}}}class Y8{constructor(){this.map=[]}add(t,a,i){Q8(this,t,a,i)}consume(t){if(this.map.sort(function(c,u){return c[0]-u[0]}),this.map.length===0)return;let a=this.map.length;const i=[];for(;a>0;)a-=1,i.push(t.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),t.length=this.map[a][0];i.push(t.slice()),t.length=0;let l=i.pop();for(;l;){for(const c of l)t.push(c);l=i.pop()}this.map.length=0}}function Q8(e,t,a,i){let l=0;if(!(a===0&&i.length===0)){for(;l<e.map.length;){if(e.map[l][0]===t){e.map[l][1]+=a,e.map[l][2].push(...i);return}l+=1}e.map.push([t,a,i])}}function X8(e,t){let a=!1;const i=[];for(;t<e.length;){const l=e[t];if(a){if(l[0]==="enter")l[1].type==="tableContent"&&i.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(l[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const c=i.length-1;i[c]=i[c]==="left"?"center":"right"}}else if(l[1].type==="tableDelimiterRow")break}else l[0]==="enter"&&l[1].type==="tableDelimiterRow"&&(a=!0);t+=1}return i}function Z8(){return{flow:{null:{name:"table",tokenize:J8,resolveAll:eO}}}}function J8(e,t,a){const i=this;let l=0,c=0,u;return m;function m(O){let U=i.events.length-1;for(;U>-1;){const H=i.events[U][1].type;if(H==="lineEnding"||H==="linePrefix")U--;else break}const _=U>-1?i.events[U][1].type:null,P=_==="tableHead"||_==="tableRow"?E:p;return P===E&&i.parser.lazy[i.now().line]?a(O):P(O)}function p(O){return e.enter("tableHead"),e.enter("tableRow"),h(O)}function h(O){return O===124||(u=!0,c+=1),g(O)}function g(O){return O===null?a(O):Je(O)?c>1?(c=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),w):a(O):jt(O)?At(e,g,"whitespace")(O):(c+=1,u&&(u=!1,l+=1),O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),u=!0,g):(e.enter("data"),v(O)))}function v(O){return O===null||O===124||tn(O)?(e.exit("data"),g(O)):(e.consume(O),O===92?k:v)}function k(O){return O===92||O===124?(e.consume(O),v):v(O)}function w(O){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(O):(e.enter("tableDelimiterRow"),u=!1,jt(O)?At(e,S,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):S(O))}function S(O){return O===45||O===58?C(O):O===124?(u=!0,e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),M):F(O)}function M(O){return jt(O)?At(e,C,"whitespace")(O):C(O)}function C(O){return O===58?(c+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),T):O===45?(c+=1,T(O)):O===null||Je(O)?K(O):F(O)}function T(O){return O===45?(e.enter("tableDelimiterFiller"),I(O)):F(O)}function I(O){return O===45?(e.consume(O),I):O===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),D):(e.exit("tableDelimiterFiller"),D(O))}function D(O){return jt(O)?At(e,K,"whitespace")(O):K(O)}function K(O){return O===124?S(O):O===null||Je(O)?!u||l!==c?F(O):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(O)):F(O)}function F(O){return a(O)}function E(O){return e.enter("tableRow"),B(O)}function B(O){return O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),B):O===null||Je(O)?(e.exit("tableRow"),t(O)):jt(O)?At(e,B,"whitespace")(O):(e.enter("data"),Y(O))}function Y(O){return O===null||O===124||tn(O)?(e.exit("data"),B(O)):(e.consume(O),O===92?V:Y)}function V(O){return O===92||O===124?(e.consume(O),Y):Y(O)}}function eO(e,t){let a=-1,i=!0,l=0,c=[0,0,0,0],u=[0,0,0,0],m=!1,p=0,h,g,v;const k=new Y8;for(;++a<e.length;){const w=e[a],S=w[1];w[0]==="enter"?S.type==="tableHead"?(m=!1,p!==0&&(X1(k,t,p,h,g),g=void 0,p=0),h={type:"table",start:Object.assign({},S.start),end:Object.assign({},S.end)},k.add(a,0,[["enter",h,t]])):S.type==="tableRow"||S.type==="tableDelimiterRow"?(i=!0,v=void 0,c=[0,0,0,0],u=[0,a+1,0,0],m&&(m=!1,g={type:"tableBody",start:Object.assign({},S.start),end:Object.assign({},S.end)},k.add(a,0,[["enter",g,t]])),l=S.type==="tableDelimiterRow"?2:g?3:1):l&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")?(i=!1,u[2]===0&&(c[1]!==0&&(u[0]=u[1],v=hd(k,t,c,l,void 0,v),c=[0,0,0,0]),u[2]=a)):S.type==="tableCellDivider"&&(i?i=!1:(c[1]!==0&&(u[0]=u[1],v=hd(k,t,c,l,void 0,v)),c=u,u=[c[1],a,0,0])):S.type==="tableHead"?(m=!0,p=a):S.type==="tableRow"||S.type==="tableDelimiterRow"?(p=a,c[1]!==0?(u[0]=u[1],v=hd(k,t,c,l,a,v)):u[1]!==0&&(v=hd(k,t,u,l,a,v)),l=0):l&&(S.type==="data"||S.type==="tableDelimiterMarker"||S.type==="tableDelimiterFiller")&&(u[3]=a)}for(p!==0&&X1(k,t,p,h,g),k.consume(t.events),a=-1;++a<t.events.length;){const w=t.events[a];w[0]==="enter"&&w[1].type==="table"&&(w[1]._align=X8(t.events,a))}return e}function hd(e,t,a,i,l,c){const u=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",m="tableContent";a[0]!==0&&(c.end=Object.assign({},Hl(t.events,a[0])),e.add(a[0],0,[["exit",c,t]]));const p=Hl(t.events,a[1]);if(c={type:u,start:Object.assign({},p),end:Object.assign({},p)},e.add(a[1],0,[["enter",c,t]]),a[2]!==0){const h=Hl(t.events,a[2]),g=Hl(t.events,a[3]),v={type:m,start:Object.assign({},h),end:Object.assign({},g)};if(e.add(a[2],0,[["enter",v,t]]),i!==2){const k=t.events[a[2]],w=t.events[a[3]];if(k[1].end=Object.assign({},w[1].end),k[1].type="chunkText",k[1].contentType="text",a[3]>a[2]+1){const S=a[2]+1,M=a[3]-a[2]-1;e.add(S,M,[])}}e.add(a[3]+1,0,[["exit",v,t]])}return l!==void 0&&(c.end=Object.assign({},Hl(t.events,l)),e.add(l,0,[["exit",c,t]]),c=void 0),c}function X1(e,t,a,i,l){const c=[],u=Hl(t.events,a);l&&(l.end=Object.assign({},u),c.push(["exit",l,t])),i.end=Object.assign({},u),c.push(["exit",i,t]),e.add(a+1,0,c)}function Hl(e,t){const a=e[t],i=a[0]==="enter"?"start":"end";return a[1][i]}const tO={name:"tasklistCheck",tokenize:aO};function nO(){return{text:{91:tO}}}function aO(e,t,a){const i=this;return l;function l(p){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?a(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),c)}function c(p){return tn(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):a(p)}function u(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),m):a(p)}function m(p){return Je(p)?t(p):jt(p)?e.check({tokenize:rO},t,a)(p):a(p)}}function rO(e,t,a){return At(e,i,"whitespace");function i(l){return l===null?a(l):t(l)}}function sO(e){return PS([E8(),P8(),K8(e),Z8(),nO()])}const iO={};function Jc(e){const t=this,a=e||iO,i=t.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),c=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),u=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push(sO(a)),c.push(N8()),u.push(T8(a))}const lO="modulepreload",oO=function(e){return"/"+e},Z1={},ln=function(t,a,i){let l=Promise.resolve();if(a&&a.length>0){let p=function(h){return Promise.all(h.map(g=>Promise.resolve(g).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),m=u?.nonce||u?.getAttribute("nonce");l=p(a.map(h=>{if(h=oO(h),h in Z1)return;Z1[h]=!0;const g=h.endsWith(".css"),v=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${v}`))return;const k=document.createElement("link");if(k.rel=g?"stylesheet":lO,g||(k.as="script"),k.crossOrigin="",k.href=h,m&&k.setAttribute("nonce",m),document.head.appendChild(k),g)return new Promise((w,S)=>{k.addEventListener("load",w),k.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${h}`)))})}))}function c(u){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=u,window.dispatchEvent(m),!m.defaultPrevented)throw u}return l.then(u=>{for(const m of u||[])m.status==="rejected"&&c(m.reason);return t().catch(c)})};function T0({language:e,code:t,highlight:a=!0}){const[i,l]=x.useState();return x.useEffect(()=>{if(!a){l(void 0);return}let c=!0;return ln(()=>import("./highlighter-Nvj8c0Yw.js"),[]).then(u=>u.highlightToHtml(t,e)).then(u=>{c&&l(u)}).catch(()=>{c&&l(void 0)}),()=>{c=!1}},[t,e,a]),r.jsxs("div",{className:"code-block my-2 overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800",children:[r.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:[r.jsx("span",{className:"font-mono text-xs lowercase text-gray-500 dark:text-gray-400",children:e||"text"}),r.jsx(io,{text:t,label:f.chat.copyCode})]}),r.jsx("div",{className:"overflow-x-auto bg-white text-[13px] leading-relaxed dark:bg-gray-950",children:i?r.jsx("div",{dangerouslySetInnerHTML:{__html:i}}):r.jsx("pre",{className:"m-0 px-3 py-2.5 font-mono text-gray-800 dark:text-gray-200",children:r.jsx("code",{children:t})})})]})}function cO(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(t=>typeof t=="string").join(""):""}function Ej({children:e,streaming:t}){if(x.isValidElement(e)){const a=e.props,i=/language-([\w+-]+)/.exec(a.className??"")?.[1]??"";return r.jsx(T0,{language:i,code:cO(a.children).replace(/\n$/,""),highlight:!t})}return r.jsx("pre",{children:e})}function _j({node:e,children:t,...a}){return r.jsx("a",{...a,target:"_blank",rel:"noreferrer",children:t})}const uO={pre:e=>r.jsx(Ej,{streaming:!0,children:e.children}),a:_j},dO={pre:e=>r.jsx(Ej,{streaming:!1,children:e.children}),a:_j},_f=x.memo(function({text:t,streaming:a=!1}){return r.jsx(Zc,{remarkPlugins:[Jc],components:a?uO:dO,children:t})});function Ss({src:e,alt:t,className:a}){const[i,l]=x.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"block cursor-zoom-in",onClick:()=>l(!0),children:r.jsx("img",{src:e,alt:t,className:a})}),i&&r.jsx(fO,{src:e,alt:t,onClose:()=>l(!1)})]})}function fO({src:e,alt:t,onClose:a}){return x.useEffect(()=>{const i=l=>{l.key==="Escape"&&a()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[a]),nl.createPortal(r.jsx("div",{className:"anim-fade fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-10",onMouseDown:i=>{i.target===i.currentTarget&&a()},children:r.jsxs("div",{className:"anim-pop relative",children:[r.jsx("button",{type:"button","aria-label":f.common.close,onClick:a,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:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",children:r.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})}),r.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 J1=3;function mO(e){const t=[],a=new Set;for(const i of e.matchAll(/`([^`\n]+)`/g)){const l=i[1].trim();!DA(l)||a.has(l)||(a.add(l),t.push(l))}return t}function pO({path:e}){const t=e.lastIndexOf("/"),a=t>=0?e.slice(0,t+1):"",i=t>=0?e.slice(t+1):e;return r.jsxs("span",{className:"flex min-w-0 items-baseline font-mono text-sm",children:[a&&r.jsx("span",{className:"min-w-0 shrink-[9999] truncate text-gray-400 dark:text-gray-500",children:a}),r.jsx("span",{className:"min-w-0 truncate font-semibold text-gray-800 dark:text-gray-100",children:i})]})}function ek({text:e,workspace:t,statFiles:a,onOpenFile:i}){const l=x.useMemo(()=>{const v=[],k=new Set;for(const w of mO(e)){const S=$A(w,t);S===null||k.has(S)||(k.add(S),v.push(S))}return v},[e,t]),[c,u]=x.useState(null);x.useEffect(()=>{if(u(null),l.length===0)return;let v=!1;return a(l).then(k=>{v||u(l.filter(w=>k.has(w)))}).catch(()=>{}),()=>{v=!0}},[l,a]);const[m,p]=x.useState(!1);if(c===null||c.length===0)return null;const h=m?c:c.slice(0,J1),g=c.length-h.length;return r.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:[r.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:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":!0,className:"shrink-0 text-gray-400",children:r.jsx("path",{d:"M6 3h8l4 4v14H6zM14 3v4h4"})}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:f.chat.filesInMessage(c.length)})]}),r.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[h.map(v=>r.jsxs("button",{type:"button",title:v,onClick:()=>i(v),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:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":!0,className:"shrink-0 text-gray-400",children:r.jsx("path",{d:"M6 3h8l4 4v14H6zM14 3v4h4"})}),r.jsx(pO,{path:v}),r.jsx("span",{className:"min-w-0 flex-1"}),r.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:f.chat.openPreview})]},v)),(g>0||m)&&c.length>J1&&r.jsxs("button",{type:"button",onClick:()=>p(v=>!v),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:[m?f.chat.showLess:f.chat.showMoreFiles(g),r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:`transition-transform duration-200 ${m?"rotate-180":""}`,children:r.jsx("path",{d:"m6 9 6 6 6-6"})})]})]})]})}const hO={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"},tk={running:"text-emerald-500 dark:text-emerald-400",waiting:"text-amber-500 dark:text-amber-400",done:"text-gray-400 dark:text-gray-500",failed:"text-red-500 dark:text-red-400"};function rl({state:e,size:t=13,label:a}){return e==="running"?r.jsx("span",{...a?{title:a,"aria-label":a,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 ${tk.running}`}):r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",...a?{role:"img","aria-label":a}:{"aria-hidden":!0},className:`block shrink-0 ${tk[e]}`,children:[a&&r.jsx("title",{children:a}),r.jsx("path",{d:hO[e]})]})}function Jl({sinceMs:e,offsetMs:t=0}){const[a,i]=x.useState(()=>Date.now());return x.useEffect(()=>{const l=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(l)},[]),e===void 0?r.jsx("span",{className:"animate-pulse",children:"…"}):r.jsx(r.Fragment,{children:z2(Math.max(0,t)+Math.max(0,a-e))})}function gO({item:e}){const[t,a]=x.useState(!1),i=x.useRef(null),l=e.stopReason!==void 0&&e.stopReason!=="completed",c=e.streaming?"running":l?"failed":"done",u=e.streaming?f.chat.workRunning:l?e.stopReason:f.chat.workDone;return r.jsxs("div",{ref:i,children:[r.jsxs("button",{type:"button",onClick:()=>{const m=t;a(p=>!p),m&&requestAnimationFrame(()=>i.current?.scrollIntoView({block:"nearest"}))},"aria-expanded":t,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:[r.jsx(rl,{state:c,label:u}),r.jsx("span",{className:"shrink-0 text-xs text-gray-500 dark:text-gray-400",children:f.chat.thinking}),r.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-500 dark:text-gray-400",children:e.streaming?r.jsx(Jl,{sinceMs:e.startedAtMs}):e.durationMs!==void 0?An(e.durationMs):null}),l&&r.jsxs("span",{className:"font-mono text-xs text-gray-400",children:["[",e.stopReason,"]"]}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx(Yn,{open:t,className:"text-gray-400"})]}),t&&r.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:r.jsx(_f,{text:e.thinking,streaming:e.streaming})})]})}const xO=/\x1b(?:\[[0-9:;<=>?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\^_])/g,yO=/\x1b(?:\[[0-9:;<=>?]*[ -/]*|\][^\x07]*)?$/;function Rj(e){return e.includes("\x1B")?e.replace(xO,"").replace(yO,""):e}function vO({onDecide:e}){const[t,a]=x.useState(!1),i=async l=>{a(!0);try{await e(l)}finally{a(!1)}};return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ve,{size:"sm",variant:"primary",disabled:t,onClick:()=>{i("allow")},children:f.chat.approve}),r.jsx(ve,{size:"sm",disabled:t,onClick:()=>{i("deny")},children:f.chat.deny})]})}function Ij(e){for(let t=e.length-1;t>=0;t--){const a=e[t].kind;if(a==="user_text"||a==="user_image")return t}return 0}function bO(e){let t=0;for(const a of e)(a.kind==="user_text"||a.kind==="user_image")&&(t+=1);return t}function Lj(e,t){try{const a=JSON.parse(e);if(a!==null&&typeof a=="object"){const i=a[t];if(typeof i=="string"&&i.length>0)return i}}catch{}return null}function Oj(e){return Lj(e,"agent_id")}function kO(e){return Lj(e,"description")}function wO(e,t,a){return Dj(e.items.slice(Ij(e.items)),t,{running:a})}function SO(e,t,a,i){const l=e.items,c=l.findIndex(p=>p.kind==="tool_call"&&p.subagentSessionId===i||p.kind==="subagent"&&p.sessionId===i);if(c===-1)return null;let u=0;for(let p=c;p>=0;p--){const h=l[p].kind;if(h==="user_text"||h==="user_image"){u=p;break}}let m=l.length;for(let p=c+1;p<l.length;p++){const h=l[p].kind;if(h==="user_text"||h==="user_image"){m=p;break}}return Dj(l.slice(u,m),t,{running:m===l.length&&a})}function Dj(e,t,a){const i=[{sessionId:t,agentId:null,description:null,running:a.running,depth:0,origin:[],parentId:null}],l=new Set([t]),c=(m,p,h,g,v,k,w)=>{if(l.has(m))return;l.add(m);const S=[...v,m],M=p.firstTsMs??p.firstSeenLocalMs,C=p.firstTsMs!==void 0&&p.lastActivityTsMs!==void 0?Math.max(0,p.lastActivityTsMs-p.firstTsMs):p.firstSeenLocalMs!==void 0&&p.lastActivityLocalMs!==void 0?Math.max(0,p.lastActivityLocalMs-p.firstSeenLocalMs):void 0;i.push({sessionId:m,agentId:p.meta?.agentId??k,description:w,running:h,depth:S.length,origin:S,parentId:g,...M!==void 0?{startedMs:M}:{},...C!==void 0?{elapsedMs:C}:{}}),u(p.items,m,S)},u=(m,p,h)=>{for(const g of m)g.kind==="tool_call"&&g.subagent&&g.subagentSessionId?c(g.subagentSessionId,g.subagent,!g.outputComplete,p,h,Oj(g.argumentsText),kO(g.argumentsText)):g.kind==="subagent"&&c(g.sessionId,g.model,!1,p,h,null,null)};return u(e,t,[]),i}function jO(e){const t=e.items;for(let a=Ij(t);a<t.length;a++){const i=t[a];if(i.kind==="tool_call"&&i.subagent!==void 0||i.kind==="subagent")return!0}return!1}function CO(e,t){if(t.length===0)return null;let a=e;for(const i of t){const l=a.subagents.get(i);if(!l)return null;a=l}return a}const $d=200,mc=46,hh=32,nk=10,gd=6;function NO(e){const t=new Map;for(const g of e){if(g.parentId===null)continue;const v=t.get(g.parentId);v?v.push(g):t.set(g.parentId,[g])}const a=new Map;let i=0;const l=g=>{const v=t.get(g.sessionId)??[];let k;if(v.length===0)k=i++;else{const w=v.map(l);k=(w[0]+w[w.length-1])/2}return a.set(g.sessionId,k),k};for(const g of e)g.parentId===null&&l(g);const c=e.map(g=>({node:g,x:gd+g.depth*($d+hh),y:gd+(a.get(g.sessionId)??0)*(mc+nk)})),u=new Map(c.map(g=>[g.node.sessionId,g])),m=[];for(const g of c){if(g.node.parentId===null)continue;const v=u.get(g.node.parentId);if(!v)continue;const k=v.x+$d,w=v.y+mc/2,S=g.x,M=g.y+mc/2,C=k+hh/2;m.push({fromId:v.node.sessionId,toId:g.node.sessionId,path:w===M?`M ${k} ${w} H ${S}`:`M ${k} ${w} H ${C} V ${M} H ${S}`})}const p=e.reduce((g,v)=>Math.max(g,v.depth),0),h=Math.max(1,i);return{width:gd*2+(p+1)*$d+p*hh,height:gd*2+h*mc+(h-1)*nk,nodes:c,edges:m}}function dg(e,t,a){const i=a.find(c=>c.sessionId===e.sessionId),l=e.agentId??i?.agentId??null;if(l!==null){const c=t.find(u=>u.agentId===l);return c?c.name?.length?c.name:c.agentId:l}return i?.title??null}function fg(e){return e.length>8?e.slice(-8):e}function Uj({sessionId:e,model:t,running:a,ctx:i,agentId:l=null}){const{agents:c}=cn(),{sessions:u}=pi(),m=dg({sessionId:e,agentId:t.meta?.agentId??l},c,u)??f.chat.subagent,p=yE(i.pendingApprovals.keys(),[...i.origin,e]),h=`${f.chat.subagent} ${m}${p?` · ${f.chat.approvalWaiting}`:""}`;return r.jsxs("button",{type:"button","aria-label":h,title:h,onClick:()=>i.onOpenSubagent?.(e,i.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:[r.jsx(Da,{id:t.meta?.agentId??l??e,name:m,size:16}),r.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-gray-700 dark:text-gray-300",children:m}),e&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:fg(e)}),a&&r.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&&r.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500"}),r.jsx("span",{className:"min-w-0 flex-1"})]})}const ak=new Set(["exec_command","input_command","run_subagent","input_subagent"]),rf=new Set(["read_file","edit_file","write_file"]);function zj(e){const t=e.split("/").filter(a=>a.length>0);return t.length<=2?e:`…/${t[t.length-2]}/${t[t.length-1]}`}function TO(e,t){if(e==="exec_command"){const a=sf(t,"cmd");if(a!==null)return`$ ${a.value.replace(/\s+/g," ").trim()}`}if(rf.has(e)){const a=sf(t,"file_path");if(a!==null)return zj(a.value.replace(/\s+/g," ").trim())}return t.replace(/\s+/g," ").trim()}function MO(e,t,a=!0){if(ak.has(e)||rf.has(e)){const i=sf(t,"description");if(i!==null){if(!i.complete&&!a)return null;const l=i.value.replace(/\s+/g," ").trim();if(l)return l}if(ak.has(e))return null}if(rf.has(e)){const i=sf(t,"file_path");if(i!==null){if(!i.complete&&!a)return null;const l=i.value.replace(/\s+/g," ").trim();if(l)return zj(l)}}return null}function AO(e,t){if(!rf.has(e))return null;let a;try{a=JSON.parse(t)}catch{return null}if(a===null||typeof a!="object")return null;const i=a,l=[],c=(u,m)=>{m!==void 0&&(typeof m=="string"&&m.includes(`
166
- `)?l.push(`${u}:
167
- ${m}`):l.push(`${u}: ${typeof m=="string"?m:JSON.stringify(m)}`))};return c("file_path",i.file_path),e==="read_file"?(c("offset",i.offset),c("limit",i.limit)):e==="edit_file"?(c("old_string",i.old_string),c("new_string",i.new_string),i.replace_all===!0&&c("replace_all",!0)):e==="write_file"&&c("content",i.content),l.join(`
168
- `)}function sf(e,t){const a=`"${t}"`,i=e.indexOf(a);if(i===-1)return null;let l=i+a.length;for(;/\s/.test(e[l]??"");)l+=1;if(e[l]!==":")return null;for(l+=1;/\s/.test(e[l]??"");)l+=1;if(e[l]!=='"')return null;l+=1;let c="",u=!1;for(;l<e.length;l+=1){const m=e[l];if(u){c+=m==="n"?`
169
- `:m==="t"?" ":m,u=!1;continue}if(m==="\\"){u=!0;continue}if(m==='"')return{value:c,complete:!0};c+=m}return{value:c,complete:!1}}function EO({item:e,ctx:t}){const[a,i]=x.useState(!1),l=x.useRef(!1),c=x.useRef(null),u=t.pendingApprovals.get(Xl(t.origin,e.toolCallId)),m=TO(e.name,e.argumentsText),p=x.useMemo(()=>Rj(e.output),[e.output]),h=MO(e.name,e.argumentsText,!e.callStreaming),g=e.callComplete&&!e.outputComplete&&!u,v=e.argStartedAtMs!==void 0&&e.callStartedAtMs!==void 0?Math.max(0,e.callStartedAtMs-e.argStartedAtMs):0,k=e.callStopReason!==void 0&&e.callStopReason!=="completed"||e.outputStopReason!==void 0&&e.outputStopReason!=="completed",w=u?"waiting":g||e.callStreaming?"running":k?"failed":"done",S=e.decision?`${e.decision==="allow"?f.chat.decisionAllow:f.chat.decisionDeny} · ${e.decisionSource==="manual"?f.chat.decisionManual:f.chat.decisionAuto}`:null,M=e.decision==="deny"&&e.outputStopReason==="aborted",C=u?f.chat.approvalWaiting:w==="running"?f.chat.workRunning:w==="done"?S??f.chat.workDone:M?S??void 0:e.outputStopReason??e.callStopReason;return r.jsxs("div",{ref:c,children:[r.jsxs("button",{type:"button","aria-expanded":a,onClick:()=>{l.current=!0;const T=a;i(I=>!I),T&&requestAnimationFrame(()=>c.current?.scrollIntoView({block:"nearest"}))},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:[r.jsx(rl,{state:w,label:C}),r.jsx("span",{className:"shrink-0 truncate font-mono text-xs font-semibold text-gray-700 dark:text-gray-300",children:e.name||f.chat.unknownTool}),h&&r.jsx("span",{className:"min-w-0 shrink truncate text-xs text-gray-500 dark:text-gray-400",children:h}),r.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-500 dark:text-gray-400",children:e.durationMs!==void 0?An(e.durationMs):g?r.jsx(Jl,{sinceMs:e.approvalAtMs??e.callStartedAtMs,offsetMs:v}):u?v>0?An(v):null:e.callStreaming?e.argStartedAtMs!==void 0?r.jsx(Jl,{sinceMs:e.argStartedAtMs}):r.jsx("span",{className:"animate-pulse",children:"…"}):null}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx(Yn,{open:a,className:"text-gray-400"})]}),u&&r.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:[r.jsxs("div",{className:"mb-2 flex items-start gap-2 sm:items-center",children:[r.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||f.chat.unknownTool}),r.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:m})]}),(()=>{const T=AO(e.name,e.argumentsText);return T!==null?r.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})(),r.jsx(vO,{onDecide:T=>t.onApprove(e.toolCallId,T,t.origin)})]}),a&&r.jsxs("div",{className:"anim-fade",children:[e.argumentsText&&r.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)&&r.jsxs("pre",{className:"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",children:[p,e.outputStreaming&&r.jsx("span",{className:"animate-pulse",children:"▌"})]}),e.images&&e.images.length>0&&r.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,I)=>r.jsx(Ss,{src:T,alt:f.chat.toolImageAlt,className:"max-h-40 max-w-full rounded-md border border-gray-200 dark:border-gray-700"},I))})]}),e.subagent&&r.jsx("div",{className:"px-3 pb-2 pt-2",children:r.jsx(Uj,{sessionId:e.subagentSessionId??"",model:e.subagent,running:!e.outputComplete,agentId:Oj(e.argumentsText),ctx:t})})]})}function _O(e){const t=e.summaryText;return t?KA(t).trim():""}function lf({state:e,title:t,detail:a,liveSinceMs:i,durationMs:l,children:c}){const[u,m]=x.useState(!1),p=x.useRef(null),h=e==="running",g=c!=null,v=r.jsxs(r.Fragment,{children:[r.jsx(rl,{state:e,size:12}),r.jsx("span",{className:`shrink-0 text-[11px] font-semibold tracking-wide uppercase ${h?"text-emerald-600 dark:text-emerald-400":"text-gray-500 dark:text-gray-400"}`,children:t}),a!==void 0&&r.jsx("span",{title:a,className:"min-w-0 truncate font-mono text-xs text-gray-400",children:a}),h?i!==void 0&&r.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:r.jsx(Jl,{sinceMs:i})}):l!==void 0&&l>0&&r.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:An(l)}),r.jsx("span",{className:"min-w-0 flex-1"}),g&&r.jsx(Yn,{open:u,className:"text-gray-400"})]});return r.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:[g?r.jsx("button",{type:"button","aria-expanded":u,onClick:()=>{const k=u;m(w=>!w),k&&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:v}):r.jsx("div",{className:"flex w-full items-center gap-2 bg-gray-50 px-3 py-2 text-left dark:bg-gray-900",children:v}),g&&u&&r.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 RO({text:e,streaming:t}){return r.jsx("div",{className:"md-body px-3 py-2 text-sm leading-relaxed text-gray-600 dark:text-gray-400",children:r.jsx(_f,{text:e,streaming:t})})}function IO({item:e}){const t=_O(e),i=t!==""||e.running&&e.mode==="summarize"?r.jsx(RO,{text:t,streaming:e.running}):null;if(e.running)return r.jsx(lf,{state:"running",title:f.chat.compactionTitle(e.mode),...e.beginTsMs!==void 0?{liveSinceMs:e.beginTsMs}:{},children:i});const l=e.status==="completed";return r.jsx(lf,{state:l?"done":"failed",title:f.chat.compactionTitle(e.mode),detail:l?void 0:f.chat.compactionFailed(e.status??"failed",e.errorMessage),...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:i})}function LO(e,t){let a=null;for(const i of t)e.startsWith(`mcp__${i}__`)&&(a===null||i.length>a.length)&&(a=i);return a}function OO({outcome:e,tools:t}){const[a,i]=x.useState(!1),l=e.status==="failed",c=l?e.error!==void 0:t.length>0,u=l?f.chat.mcpServerFailed:f.chat.mcpToolsCount(e.tools??0),m=r.jsxs(r.Fragment,{children:[r.jsx(rl,{state:l?"failed":"done",size:11}),r.jsx("code",{className:"shrink-0 font-mono text-xs text-gray-700 dark:text-gray-300",children:e.server}),r.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-gray-400",children:u}),e.durationMs>0&&r.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:An(e.durationMs)}),r.jsx("span",{className:"min-w-0 flex-1"}),c&&r.jsx(Yn,{open:a,size:12,className:"text-gray-400"})]});return c?r.jsxs("div",{children:[r.jsx("button",{type:"button","aria-expanded":a,onClick:()=>i(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:m}),a&&(l?r.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}):r.jsx("ul",{className:"anim-fade pb-1",children:t.map(p=>r.jsxs("li",{className:"flex items-baseline gap-2 py-1 pr-3 pl-8",children:[r.jsx("code",{className:"shrink-0 font-mono text-xs text-gray-700 dark:text-gray-300",children:p.name}),p.description!==void 0&&r.jsx("span",{title:p.description,className:"min-w-0 truncate text-xs text-gray-400 dark:text-gray-500",children:p.description})]},p.name))}))]}):r.jsx("div",{className:"flex w-full items-center gap-2 px-3 py-1.5",children:m})}function DO({item:e}){if(e.running)return r.jsx(lf,{state:"running",title:f.chat.mcpConnectTitle,detail:f.chat.mcpServerList(e.servers),...e.beginTsMs!==void 0?{liveSinceMs:e.beginTsMs}:{}});const t=e.aborted||(e.failed?.length??0)>0,a=e.aborted?f.chat.mcpConnectAborted:f.chat.mcpConnectResult(e.toolCount??0,e.failed??[]),i=e.results??[],l=e.tools??[],c=i.map(u=>u.server);return r.jsx(lf,{state:t?"failed":"done",title:f.chat.mcpConnectTitle,detail:a,...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:i.length>0?i.map(u=>r.jsx(OO,{outcome:u,tools:l.filter(m=>LO(m.name,c)===u.server)},u.server)):void 0})}const M0=-1,Uc="M21 12A9 9 0 1 1 12 3M17 12A5 5 0 1 1 12 7M12 12L15 9V5L18 2V6H22L19 9H15";function xd(e){const t=e.trim();if(t==="")return M0;const a=/^(\d+(?:\.\d+)?)([km])?$/i.exec(t);if(!a)return null;const i=a[2]?.toLowerCase()==="m"?1e6:a[2]?.toLowerCase()==="k"?1e3:1,l=Math.round(Number(a[1])*i);return l>0?l:null}const UO="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 zO({images:e,showFull:t,onExpand:a}){return e.length===0?null:t?r.jsx("div",{className:"mt-1.5 flex max-w-[88%] flex-wrap justify-end gap-1.5 md:max-w-[75%]",children:e.map((i,l)=>r.jsx(Ss,{src:i,alt:f.chat.imageAlt,className:"max-h-40 max-w-full rounded-md"},l))}):r.jsxs("button",{type:"button",onClick:a,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:[r.jsx(Ge,{d:UO,size:12,className:"shrink-0"}),f.chat.goalRoundImages(e.length)]})}function $O({round:e,objective:t,images:a=[]}){const[i,l]=x.useState(!1),c=a.length>0&&(e===1||i);return t!==void 0&&t!==""?r.jsxs("div",{className:"anim-msg my-4 flex flex-col items-end",children:[r.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:r.jsx("p",{className:"wrap-anywhere whitespace-pre-wrap text-base leading-relaxed text-gray-900 dark:text-gray-100",children:t})}),r.jsx(zO,{images:a,showFull:c,onExpand:()=>l(!0)}),r.jsxs("p",{className:"mt-1 flex items-center gap-1.5 px-0.5 text-xs text-gray-400 dark:text-gray-500",children:[r.jsx(Ge,{d:Uc,size:12,className:"shrink-0"}),f.chat.goalRoundBanner(e)]})]}):r.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:[r.jsx(Ge,{d:Uc,className:"text-gray-400 dark:text-gray-500"}),f.chat.goalRoundBanner(e)]})}function PO({goal:e}){const t=e.budget>0&&e.budget!==M0?`${Rt(e.used)}/${Rt(e.budget)}`:Rt(e.used),a=e.status!=="active";return r.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:[r.jsx(Ge,{d:Uc,className:"shrink-0 text-gray-400 dark:text-gray-500"}),r.jsx("span",{className:"min-w-0 flex-1 truncate",title:e.objective,children:e.objective}),r.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:f.chat.goalProgress(e.rounds,t)}),r.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 ${a?e.status==="complete"?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-400":"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-400":"bg-gray-200 text-gray-600 dark:bg-gray-800 dark:text-gray-300"}`,children:f.chat.goalStatus[e.status]})]})}function BO(e){return e.agentName&&e.agentName!==e.agentId?`${e.agentName} (${e.agentId})`:e.agentId}const mg="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 HO({origin:e}){const t=ia(),a=f.chat.handoffFrom(BO(e));if(!e.sessionId)return r.jsx("p",{className:mg,children:a});const i=e.sessionId;return r.jsxs("button",{type:"button",title:f.chat.handoffBack(e.sessionTitle),onClick:()=>t(`/chat/${i}`),className:`${mg} transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200`,children:[a,r.jsx("span",{"aria-hidden":!0,className:"text-gray-400 dark:text-gray-500",children:"→"})]})}function FO({origin:e}){const t=ia(),a=e.sessionId;return r.jsxs("button",{type:"button",title:f.chat.handoffBack(e.sessionTitle),onClick:()=>t(`/chat/${a}`),className:`${mg} transition-colors hover:bg-gray-100 hover:text-gray-800 dark:hover:bg-gray-800 dark:hover:text-gray-200`,children:[f.chat.modelSwitchFrom(e.prevModelId),r.jsx("span",{"aria-hidden":!0,className:"text-gray-400 dark:text-gray-500",children:"→"})]})}function VO({origin:e}){return r.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:[f.chat.scheduledFrom(e.name),e.firedAt&&r.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:Oa(e.firedAt)})]})}const A0="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 qO(e,t,a){return e==="zh"&&a?a:t}function co(e,t){return e==="zh"?t.shortDescriptionZh||t.shortDescription||t.description:t.shortDescription||t.description}function GO(e,t,a){const i=a.trim().toLowerCase();return i?e.filter(l=>l.name.toLowerCase().includes(i)||co(t,l).toLowerCase().includes(i)):e}function WO(e,t){return e.map(a=>({name:a.name,cmd:`/${a.name}`,desc:co(t,a)}))}function rk({names:e}){return r.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:[r.jsx(Ge,{d:A0,className:"text-gray-400 dark:text-gray-500"}),f.chat.skillsBanner(e)]})}const of="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 sk({files:e}){const t=f.chat.attachedFilesBanner(e.map(UE));return r.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:[r.jsx(Ge,{d:of,className:"shrink-0 text-gray-400 dark:text-gray-500"}),r.jsx("span",{className:"min-w-0 truncate",children:t})]})}const KO=QA,YO=JA;function QO(e,t){const a=t.trim().toLowerCase();return a?e.filter(i=>i.agentId.toLowerCase().includes(a)||(i.name??"").toLowerCase().includes(a)):e}function XO({handoffTarget:e,pendingModel:t,canSwitchModel:a,sessionBusy:i}){return e?"handoff":!t||!a?"post":i?"blocked":"model"}function ac({icon:e,value:t,compactValue:a,label:i,display:l="flex"}){return r.jsxs("span",{title:i,"aria-label":i,className:`${l} items-center gap-1`,children:[r.jsx(Ge,{d:e}),a!==void 0&&a!==t?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sm:hidden",children:a}),r.jsx("span",{className:"hidden sm:inline",children:t})]}):t]})}function ZO({stats:e,assistantText:t,cost:a,atMs:i,forkPosition:l,onFork:c}){const{currency:u}=mi(),{locale:m}=Za(),[p,h]=x.useState(!1),[g,v]=x.useState(!1),k=e?.tokensByBucket,w=k?k.cacheRead+k.cacheWrite:0,S=()=>t?.trim()||e===null?t??"":mE(e,{stats:f.chat.statsLabel,input:f.chat.statInput,cached:f.chat.statCached,output:f.chat.statOutput,parenOpen:f.chat.statParenOpen,parenClose:f.chat.statParenClose});return r.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:[r.jsxs("span",{className:"no-scrollbar flex min-w-0 items-center gap-x-2 overflow-x-auto sm:gap-x-3",children:[i!==void 0&&r.jsx("span",{children:P2(i,m)}),e&&k&&r.jsxs(r.Fragment,{children:[r.jsx(ac,{icon:aa.input,value:Rt(w),label:f.chat.statInput}),r.jsx(ac,{icon:aa.output,value:Rt(k.output),label:f.chat.statOutput}),r.jsx(ac,{icon:aa.tps,value:qd(e.outputTps),label:f.chat.statTps,display:"hidden sm:flex"}),a!=null&&r.jsx(ac,{icon:aa.cost,value:Dr(a,u),compactValue:Dr(a,u,{compact:!0}),label:`${f.common.cost}(${u})`}),r.jsx(ac,{icon:aa.elapsed,value:An(e.elapsedDeltaMs),compactValue:An(e.elapsedDeltaMs,{compact:!0}),label:f.chat.statElapsed})]})]}),r.jsx(io,{text:S,label:f.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()&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",disabled:p,title:f.chat.forkSession,"aria-label":f.chat.forkSession,onClick:()=>v(!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:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:p?"animate-pulse":"",children:[r.jsx("circle",{cx:"6",cy:"5",r:"2"}),r.jsx("circle",{cx:"18",cy:"7",r:"2"}),r.jsx("circle",{cx:"6",cy:"19",r:"2"}),r.jsx("path",{d:"M6 7v8M8 11h4a6 6 0 0 0 6-2"})]})}),r.jsx(yn,{open:g,title:f.chat.forkSession,tone:"primary",confirmLabel:f.chat.forkSessionConfirmAction,busy:p,onClose:()=>v(!1),onConfirm:()=>{v(!1),h(!0),c({assistantText:t,...i!==void 0?{atMs:i}:{},...l!==void 0?{position:l}:{}}).finally(()=>h(!1))},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.chat.forkSessionConfirmBody})})]})]})}const JO="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 rc({atMs:e,text:t,align:a="left"}){const{locale:i}=Za();return r.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 ${a==="right"?"justify-end":"justify-start"}`,children:[e!==void 0&&r.jsx("span",{className:"text-[11px] text-gray-400",children:P2(e,i)}),t!==void 0&&r.jsx(io,{text:t,label:f.chat.copyMessage})]})}const e7=2e3;function t7({item:e,ctx:t}){const a=e.gaveUp?"gaveUp":e.retrying?"retried":"waiting",i=a==="waiting"&&e.plannedDelayMs!==void 0&&e.plannedDelayMs>=e7&&e.arrivedAtMs!==void 0?e.arrivedAtMs+e.plannedDelayMs:null,[l,c]=x.useState(()=>Date.now()),[u,m]=x.useState(!1);x.useEffect(()=>{if(i===null||Date.now()>=i)return;const k=setInterval(()=>{c(Date.now()),Date.now()>=i&&clearInterval(k)},250);return()=>clearInterval(k)},[i]);const p=i!==null?i-l:0,h=i!==null&&p>0,g=h?Math.ceil(p/1e3):void 0,v=h&&t.origin.length===0&&(t.onRetryNow!==void 0||t.onGiveUp!==void 0);return r.jsxs("p",{className:"anim-msg my-1 flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-xs text-amber-600 dark:text-amber-500",children:[r.jsx("span",{children:f.chat.reconnect(e.status,a,e.attempt,g)}),v&&r.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[t.onRetryNow&&r.jsx("button",{type:"button",disabled:u,onClick:()=>{m(!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:f.chat.reconnectRetryNow}),t.onGiveUp&&r.jsx("button",{type:"button",disabled:u,onClick:()=>{m(!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:f.chat.reconnectGiveUp})]})]})}function $j({item:e,ctx:t}){switch(e.kind){case"user_text":{const a=pS(e.text);if(a)return r.jsx(HO,{origin:a});const i=gS(e.text);if(i)return r.jsx(FO,{origin:i});const l=xS(e.text),c=l?l.rest:e.text,u=hS(c),m=u?u.rest:c,p=fS(m),{text:h,images:g,files:v}=Jd(p?p.rest:m);return l?r.jsxs(r.Fragment,{children:[p&&r.jsx(rk,{names:p.skills}),r.jsx($O,{round:l.round,objective:h,images:g})]}):r.jsxs(r.Fragment,{children:[u&&r.jsx(VO,{origin:u.origin}),p&&r.jsx(rk,{names:p.skills}),h&&r.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[r.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:r.jsx("p",{className:"wrap-anywhere whitespace-pre-wrap text-base leading-relaxed text-gray-900 dark:text-gray-100",children:h})}),r.jsx(rc,{...e.atMs!==void 0?{atMs:e.atMs}:{},text:h,align:"right"})]}),v.length>0&&r.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[r.jsx(sk,{files:v}),r.jsx(rc,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]}),g.map((k,w)=>r.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[r.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 p-1.5 md:max-w-[75%] dark:bg-gray-800",children:r.jsx(Ss,{src:k,alt:f.chat.imageAlt,className:"max-h-48 max-w-full rounded-md"})}),r.jsx(rc,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]},w))]})}case"user_steering":{const{text:a,images:i,files:l}=Jd(e.text),c=[...i,...e.images??[]];return r.jsxs("div",{className:"anim-msg group my-2 flex flex-col items-end",children:[r.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:[r.jsxs("div",{className:"flex items-start gap-1.5",children:[r.jsx(Ge,{d:JO,className:"mt-1 shrink-0 text-gray-400 dark:text-gray-500"}),r.jsxs("p",{className:"wrap-anywhere whitespace-pre-wrap text-sm leading-relaxed text-gray-800 dark:text-gray-100",children:[r.jsx("span",{className:"mr-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400",children:f.chat.userSteering}),a]})]}),c.length>0&&r.jsx("div",{className:"flex flex-wrap justify-end gap-1.5",children:c.map((u,m)=>r.jsx(Ss,{src:u,alt:f.chat.imageAlt,className:"max-h-28 max-w-full rounded-md"},m))}),l.length>0&&r.jsx("div",{className:"flex justify-end",children:r.jsx(sk,{files:l})})]}),r.jsx(rc,{...e.atMs!==void 0?{atMs:e.atMs}:{},text:a,align:"right"})]})}case"user_image":return r.jsxs("div",{className:"anim-msg group my-4 flex flex-col items-end",children:[r.jsx("div",{className:"max-w-[88%] rounded-lg bg-gray-100 p-1.5 md:max-w-[75%] dark:bg-gray-800",children:r.jsx(Ss,{src:e.imageUrl,alt:f.chat.imageAlt,className:"max-h-48 max-w-full rounded-md"})}),r.jsx(rc,{...e.atMs!==void 0?{atMs:e.atMs}:{},align:"right"})]});case"assistant_text":return r.jsxs("div",{className:"md-body anim-msg my-3 text-base leading-relaxed text-gray-800 dark:text-gray-100",children:[r.jsx(_f,{text:e.text,streaming:e.streaming}),e.streaming&&r.jsx("span",{className:"animate-pulse text-gray-400",children:"▌"}),e.stopReason&&e.stopReason!=="completed"&&r.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&&r.jsx(ek,{text:e.text,workspace:t.workspace??null,statFiles:t.statFiles,onOpenFile:t.onOpenFile})]});case"thinking":return r.jsx(gO,{item:e});case"tool_call":return r.jsx(EO,{item:e,ctx:t});case"subagent":return r.jsx("div",{className:"anim-msg my-2",children:r.jsx(Uj,{sessionId:e.sessionId,model:e.model,running:!1,ctx:t})});case"abort":return r.jsx("p",{className:"anim-msg my-1 font-mono text-xs text-gray-500 dark:text-gray-400",children:f.chat.aborted(e.reason)});case"reconnect":return r.jsx(t7,{item:e,ctx:t});case"compaction":return r.jsx(IO,{item:e});case"mcp_connect":return r.jsx(DO,{item:e});case"task_stats":return r.jsxs(r.Fragment,{children:[t.origin.length===0&&t.onOpenFile&&t.statFiles&&e.assistantText.trim()!==""&&r.jsx(ek,{text:e.assistantText,workspace:t.workspace??null,statFiles:t.statFiles,onOpenFile:t.onOpenFile}),r.jsx(ZO,{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 n7(e){let t=0,a=0,i,l;const c=p=>{p!==void 0&&(i===void 0||p<i)&&(i=p)},u=(p,h)=>{if(h<=0)return;if(p===void 0){a+=h;return}c(p);const g=p+h;(l===void 0||g>l)&&(l=g)};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 m=i!==void 0&&l!==void 0?l-i:0;return{steps:t,durationMs:m+a,...i!==void 0?{startMs:i}:{}}}function a7(e){return e.kind==="thinking"||e.kind==="tool_call"}function r7(e,t){return e.kind==="thinking"?e.streaming:e.kind==="tool_call"?e.callStreaming||e.outputStreaming||e.callComplete&&!e.outputComplete?!0:t.pendingApprovals.has(Xl(t.origin,e.toolCallId)):!1}function s7(e,t){return e.some(a=>a.kind==="tool_call"&&t.pendingApprovals.has(Xl(t.origin,a.toolCallId)))}function i7({items:e,ctx:t,isLast:a}){const i=e.some(S=>r7(S,t)),l=a&&t.taskRunning||i,c=s7(e,t),[u,m]=x.useState(a),p=x.useRef(!1),h=x.useRef(null);x.useEffect(()=>{p.current||m(a)},[a]);const g=u||c,{steps:v,durationMs:k,startMs:w}=n7(e);return r.jsxs("div",{ref:h,className:"anim-msg my-2 overflow-clip rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[r.jsxs("button",{type:"button","data-group-header":!0,"aria-expanded":g,onClick:()=>{p.current=!0;const S=u&&!c;m(M=>!M),S&&requestAnimationFrame(()=>h.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:[r.jsx(rl,{state:l?"running":"done",size:12}),r.jsx("span",{className:`shrink-0 text-[11px] font-semibold uppercase tracking-wide ${l?"text-emerald-600 dark:text-emerald-400":"text-gray-500 dark:text-gray-400"}`,children:l?f.chat.workRunning:f.chat.workDone}),v>0&&r.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 sm:inline",children:f.chat.workGroupSteps(v)}),i?w!==void 0&&r.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:r.jsx(Jl,{sinceMs:w})}):k>0&&r.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400",children:An(k)}),c&&!g&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"hidden shrink-0 rounded bg-amber-100 px-1 text-[10px] font-medium text-amber-700 sm:inline dark:bg-amber-950/50 dark:text-amber-300",children:f.chat.approvalWaiting}),r.jsx("span",{role:"img",title:f.chat.approvalWaiting,"aria-label":f.chat.approvalWaiting,className:"h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500 sm:hidden"})]}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx(Yn,{open:g,className:"text-gray-400"})]}),g&&r.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=>r.jsx($j,{item:S,ctx:t},S.id))})]})}function l7(){let e=!0,t=null,a=null;return{get stick(){return e},wheel(i){i<0&&(e=!1)},touchStart(i){a=i},touchMove(i){a!==null&&i>a&&(e=!1),a=i},touchEnd(){a=null},scrolled(i){const l=i.scrollHeight-i.scrollTop-i.clientHeight,c=t;if(t=i.scrollTop,c===null){e=l<80;return}if(i.scrollTop<c&&l>1){e=!1;return}l<80&&(e=!0)},resume(){e=!0,t=null}}}function yd(e,t){e.scrollTop=e.scrollHeight,t.scrolled({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})}function o7({items:e,ctx:t}){const a=[];let i=[];const l=()=>{i.length>0&&(a.push({type:"group",items:i}),i=[])};for(const h of e)a7(h)?i.push(h):(l(),a.push({type:"single",item:h}));l();const c=(h,g)=>h.type==="group"?r.jsx(i7,{items:h.items,ctx:t,isLast:g===a.length-1},`wg-${h.items[0].id}`):r.jsx($j,{item:h.item,ctx:t},h.item.id),u=[];let m=[];const p=()=>{if(m.length===0)return;const h=m[0].seg,g=h.type==="group"?h.items[0].id:h.item.id,v=m;m=[],u.push(r.jsx("div",{className:"group",children:v.map(k=>c(k.seg,k.i))},`turn-${g}`))};for(let h=0;h<a.length;h++){const g=a[h];if(g.type==="single"&&(g.item.kind==="user_text"||g.item.kind==="user_image")){p(),u.push(t.origin.length===0?r.jsx("div",{"data-outline-anchor":g.item.id,children:c(g,h)},`anchor-${g.item.id}`):c(g,h));continue}m.push({seg:g,i:h}),g.type==="single"&&g.item.kind==="task_stats"&&p()}return p(),r.jsx(r.Fragment,{children:u})}const c7=300;function Pj({items:e,version:t,ctx:a,scrollElRef:i,outline:l,older:c}){const u=x.useRef(null),m=x.useRef(null),p=m.current??=l7(),[h,g]=x.useState(!1),v=x.useRef(!1),k=x.useRef(null),w=()=>{k.current!==null&&(cancelAnimationFrame(k.current),k.current=null),v.current=!1};x.useEffect(()=>()=>w(),[]);const S=x.useRef(null),M=()=>{const E=u.current;g(!v.current&&!p.stick&&E!==null&&E.scrollHeight-E.scrollTop-E.clientHeight>1)},C=x.useRef(c);C.current=c;const T=x.useRef(c?.prependedCount??0),I=x.useRef(0),D=E=>{const B=C.current;!B||!B.hasMore||B.loading||B.error!==null||E.scrollTop<c7&&B.onLoad()},K=()=>{const E=u.current;if(!E)return;const B=S.current;S.current=E.scrollTop,v.current&&B!==null&&E.scrollTop<B-1&&w(),p.scrolled({scrollTop:E.scrollTop,scrollHeight:E.scrollHeight,clientHeight:E.clientHeight}),D(E),M()};x.useLayoutEffect(()=>{const E=u.current,B=c?.prependedCount??0;E&&B>T.current&&!p.stick&&!v.current&&(E.scrollTop+=E.scrollHeight-I.current),T.current=B,E&&(I.current=E.scrollHeight),E&&p.stick&&!v.current&&yd(E,p),M()},[t,p,c?.prependedCount]),x.useEffect(()=>{const E=u.current;if(!E||typeof ResizeObserver>"u")return;const B=new ResizeObserver(()=>{I.current=E.scrollHeight,p.stick&&!v.current&&yd(E,p),M()});return B.observe(E),E.firstElementChild&&B.observe(E.firstElementChild),()=>B.disconnect()},[p]);const F=()=>{const E=u.current;if(!E)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){p.resume(),yd(E,p),M();return}w(),v.current=!0,E.scrollHeight-E.clientHeight-E.scrollTop>3*E.clientHeight&&(E.scrollTop=E.scrollHeight-4*E.clientHeight);let Y=performance.now();const V=O=>{k.current=null;const U=u.current;if(!U||!v.current)return;const _=Math.min(.05,Math.max(.001,(O-Y)/1e3));Y=O;const P=U.scrollHeight-U.clientHeight-U.scrollTop;if(P<=1){v.current=!1,p.resume(),yd(U,p),M();return}const H=Math.max(P*Math.min(1,_*10),3200*_);U.scrollTop+=Math.min(H,P),k.current=requestAnimationFrame(V)};k.current=requestAnimationFrame(V),M()};return r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsx("div",{ref:E=>{u.current=E,i&&(i.current=E)},onScroll:K,onWheel:E=>{p.wheel(E.deltaY),E.deltaY<0&&w(),M()},onTouchStart:E=>{const B=E.touches[0];B&&p.touchStart(B.clientY)},onTouchMove:E=>{const B=E.touches[0];B&&p.touchMove(B.clientY),v.current&&w(),M()},onTouchEnd:()=>p.touchEnd(),className:"anim-fade h-full overflow-y-auto px-4 py-4 md:px-6",children:r.jsxs("div",{className:"mx-auto max-w-3xl",children:[c&&e.length>0&&r.jsx("div",{className:"flex justify-center pb-2",children:c.loading?r.jsxs("span",{className:"flex items-center gap-2 py-1 text-xs text-gray-400 dark:text-gray-500",children:[r.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}),f.chat.loadingEarlier]}):c.error!==null?r.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:f.chat.loadEarlierRetry}):!c.hasMore&&c.prependedCount>0?r.jsx("span",{className:"py-1 text-xs text-gray-400 dark:text-gray-500",children:f.chat.historyBeginning}):null}),e.length===0?r.jsx(Xr,{title:f.chat.emptyStream}):r.jsx(o7,{items:e,ctx:a})]})}),l,h&&r.jsx("button",{type:"button","aria-label":f.chat.jumpToLatest,title:f.chat.jumpToLatest,onClick:F,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:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M12 5v14M6 13l6 6 6-6",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}const u7=128e3;function Bj(e){const t=typeof e=="string"?Number(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:u7}const d7=/[\s"'/]on[a-z]+\s*=/i,f7=/href\s*=/i;function m7(e){if(!e)return null;const t=e.trim();if(!/^<svg[\s>]/i.test(t))return null;const a=t.toLowerCase();return a.includes("<script")||a.includes("foreignobject")||f7.test(t)||d7.test(t)?null:t}const gh=["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"],p7={firecrawl:3,"data-analysis":1,"web-design":2,"penguin-sdk":0};function Hj(e){const t=p7[e];if(t!==void 0)return gh[t];let a=0;for(let i=0;i<e.length;i++)a=a*31+e.charCodeAt(i)>>>0;return gh[a%gh.length]}function Rf({icon:e,size:t=20,className:a=""}){const i=m7(e);return i?r.jsx("span",{"aria-hidden":!0,style:{width:t,height:t},className:`block shrink-0 [&>svg]:block [&>svg]:h-full [&>svg]:w-full ${a}`,dangerouslySetInnerHTML:{__html:i}}):r.jsx(Ge,{d:A0,size:t,className:a})}const ik={viewBox:"-0.76 -0.47 28.6 28.6",path:r.jsxs(r.Fragment,{children:[r.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"}),r.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"}),r.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"}),r.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"}),r.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"}),r.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"})]})},h7={anthropic:{path:r.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:r.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:r.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:r.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:r.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:r.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:r.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:r.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"})},"qwen-token-plan":ik,"qwen-pay-as-you-go":ik,minimax:{path:r.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:r.jsxs(r.Fragment,{children:[r.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"}),r.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"}),r.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:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M12 2.8 20.5 7.4v9.2L12 21.2 3.5 16.6V7.4L12 2.8Z"}),r.jsx("path",{d:"M3.5 7.4 12 12l8.5-4.6M12 12v9.2"})]})}};function eo({provider:e,className:t}){const a=h7[e];if(!a){const i=sS(e);return r.jsxs("svg",{viewBox:"0 0 24 24",className:t,style:{"--tile-fg":i.fg,"--tile-fg-dark":i.fgDark},"aria-hidden":!0,children:[r.jsx("rect",{x:"0",y:"0",width:"24",height:"24",rx:"5",fill:i.bg}),r.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:iS(e)})]})}return r.jsx("svg",{viewBox:a.viewBox??"0 0 24 24",className:t,"aria-hidden":!0,...a.stroke?{fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinejoin:"round"}:{fill:"currentColor"},children:a.path})}var kt="https://openrouter.ai/api/v1",si="https://api.siliconflow.cn/v1",Fl="https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",Vl="https://dashscope.aliyuncs.com/compatible-mode/v1",ws="https://api.fireworks.ai/inference/v1",g7="https://api.minimax.io/v1",fi=[{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:kt},{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:ws},{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:si},{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:Fl},{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:Vl},{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:"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:"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:"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:"custom",label:"Custom",envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL"}];function jn(e,t,a){const i=l=>Math.round(l/7*1e6)/1e6;return $e(i(e),i(t),i(a))}function $e(e,t,a){return{unit:"usd_per_mtok",cache_read:e,cache_write:t,output:a}}var Fj=[{modelId:"deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"deepseek",contextWindow:1e6,pricing:jn(.05,1.5,4.5),supportsVision:!1},{modelId:"deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"deepseek",contextWindow:1e6,pricing:jn(.15,4.5,13.5),supportsVision:!1},{modelId:"anthropic/claude-fable-5",displayName:"Claude Fable 5",provider:"openrouter",contextWindow:1e6,pricing:$e(1,12.5,50),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"anthropic/claude-opus-5",displayName:"Claude Opus 5",provider:"openrouter",contextWindow:1e6,pricing:$e(.5,6.25,25),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"anthropic/claude-opus-4.8",displayName:"Claude Opus 4.8",provider:"openrouter",contextWindow:1e6,pricing:$e(.5,6.25,25),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"anthropic/claude-opus-4.7",displayName:"Claude Opus 4.7",provider:"openrouter",contextWindow:1e6,pricing:$e(.5,6.25,25),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"anthropic/claude-sonnet-5",displayName:"Claude Sonnet 5",provider:"openrouter",contextWindow:1e6,pricing:$e(.2,2.5,10),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"deepseek/deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"openrouter",contextWindow:1e6,pricing:$e(.0157192,.078596,.157192),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"deepseek/deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"openrouter",contextWindow:1e6,pricing:$e(.0168,.0679,.168),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"deepseek/deepseek-v4-pro-0813",displayName:"DeepSeek V4 Pro 0813",provider:"openrouter",contextWindow:1048576,pricing:$e(.022,.66,1.98),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"deepseek/deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"openrouter",contextWindow:1e6,pricing:$e(.022,.66,1.98),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"google/gemini-3.7-flash",displayName:"Gemini 3.7 Flash",provider:"openrouter",contextWindow:1048576,pricing:$e(.0375,.375,1.875),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"google/gemini-3.6-flash",displayName:"Gemini 3.6 Flash",provider:"openrouter",contextWindow:1048576,pricing:$e(.15,1.5,7.5),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"google/gemini-3.5-flash",displayName:"Gemini 3.5 Flash",provider:"openrouter",contextWindow:1048576,pricing:$e(.15,1.5,9),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"google/gemini-3.5-flash-lite",displayName:"Gemini 3.5 Flash-Lite",provider:"openrouter",contextWindow:1048576,pricing:$e(.03,.3,2.5),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"minimax/minimax-m3",displayName:"MiniMax M3",provider:"openrouter",contextWindow:1048576,pricing:$e(.06,.3,1.2),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"moonshotai/kimi-k3",displayName:"Kimi K3",provider:"openrouter",contextWindow:1e6,pricing:$e(.3,3,15),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"moonshotai/kimi-k2.6",displayName:"Kimi K2.6",provider:"openrouter",contextWindow:262144,pricing:$e(.0992,.589,2.48),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"nvidia/nemotron-3-ultra-550b-a55b:free",displayName:"Nemotron 3 Ultra (free)",provider:"openrouter",contextWindow:1e6,pricing:$e(0,0,0),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"openai/gpt-5.6-luna",displayName:"GPT-5.6 Luna",provider:"openrouter",contextWindow:105e4,pricing:$e(.02,.25,1.2),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openai/gpt-5.6-sol",displayName:"GPT-5.6 Sol",provider:"openrouter",contextWindow:105e4,pricing:$e(.25,3.125,15),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openai/gpt-5.6-terra",displayName:"GPT-5.6 Terra",provider:"openrouter",contextWindow:105e4,pricing:$e(.2,2.5,12),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openai/gpt-5.5",displayName:"GPT-5.5",provider:"openrouter",contextWindow:105e4,pricing:$e(.5,5,30),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openai/gpt-5.5-pro",displayName:"GPT-5.5 Pro",provider:"openrouter",contextWindow:105e4,pricing:$e(30,30,180),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openai/gpt-5.4",displayName:"GPT-5.4",provider:"openrouter",contextWindow:105e4,pricing:$e(.25,2.5,15),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openai/gpt-5.4-mini",displayName:"GPT-5.4 mini",provider:"openrouter",contextWindow:4e5,pricing:$e(.075,.75,4.5),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openai/gpt-5.4-nano",displayName:"GPT-5.4 nano",provider:"openrouter",contextWindow:4e5,pricing:$e(.02,.2,1.25),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openai/gpt-5.4-pro",displayName:"GPT-5.4 Pro",provider:"openrouter",contextWindow:105e4,pricing:$e(30,30,180),supportsVision:!0,clientType:"openai-responses",baseUrl:kt},{modelId:"openrouter/free",displayName:"Free Models Router",provider:"openrouter",contextWindow:128e3,pricing:$e(0,0,0),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"qwen/qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"openrouter",contextWindow:1e6,pricing:$e(.25,2.5,6),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"qwen/qwen3.6-35b-a3b",displayName:"Qwen 3.6 35B A3B",provider:"openrouter",contextWindow:262144,pricing:$e(.05,.14,1),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"stepfun/step-3.7-flash",displayName:"Step 3.7 Flash",provider:"openrouter",contextWindow:256e3,pricing:$e(.04,.2,1.15),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"tencent/hy3",displayName:"Hy3",provider:"openrouter",contextWindow:262144,pricing:$e(.033,.132,.528),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"thinkingmachines/inkling",displayName:"Inkling",provider:"openrouter",contextWindow:1e6,pricing:$e(.17,1,4.05),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"x-ai/grok-4.6",displayName:"Grok 4.6",provider:"openrouter",contextWindow:5e5,pricing:$e(.5,2,6),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"x-ai/grok-4.5",displayName:"Grok 4.5",provider:"openrouter",contextWindow:5e5,pricing:$e(.3,2,6),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"xiaomi/mimo-v2.5",displayName:"MiMo-V2.5",provider:"openrouter",contextWindow:1048576,pricing:$e(.0028,.14,.28),supportsVision:!0,clientType:"openai-chat",baseUrl:kt},{modelId:"z-ai/glm-5.3",displayName:"GLM-5.3",provider:"openrouter",contextWindow:1048576,pricing:$e(.26,1.4,4.4),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"z-ai/glm-5.2",displayName:"GLM-5.2",provider:"openrouter",contextWindow:1e6,pricing:$e(.1261,.679,2.134),supportsVision:!1,clientType:"openai-chat",baseUrl:kt},{modelId:"accounts/fireworks/models/deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"fireworks",contextWindow:1e6,pricing:$e(.028,.14,.28),supportsVision:!1,clientType:"openai-chat",baseUrl:ws},{modelId:"accounts/fireworks/models/deepseek-v4-flash",displayName:"DeepSeek V4 Flash",provider:"fireworks",contextWindow:1e6,pricing:$e(.03,.14,.28),supportsVision:!1,clientType:"openai-chat",baseUrl:ws},{modelId:"accounts/fireworks/models/deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"fireworks",contextWindow:1e6,pricing:$e(.15,1.74,3.48),supportsVision:!1,clientType:"openai-chat",baseUrl:ws},{modelId:"accounts/fireworks/models/glm-5p2",displayName:"GLM-5.2",provider:"fireworks",contextWindow:1e6,pricing:$e(.14,1.4,4.4),supportsVision:!1,clientType:"openai-chat",baseUrl:ws},{modelId:"accounts/fireworks/models/inkling",displayName:"Inkling",provider:"fireworks",contextWindow:1e6,pricing:$e(.17,1,4.05),supportsVision:!0,clientType:"openai-chat",baseUrl:ws},{modelId:"accounts/fireworks/models/kimi-k3",displayName:"Kimi K3",provider:"fireworks",contextWindow:1e6,pricing:$e(.3,3,15),supportsVision:!0,clientType:"openai-chat",baseUrl:ws},{modelId:"accounts/fireworks/models/kimi-k2p7-code",displayName:"Kimi K2.7 Code",provider:"fireworks",contextWindow:262144,pricing:$e(.19,.95,4),supportsVision:!0,clientType:"openai-chat",baseUrl:ws},{modelId:"accounts/fireworks/models/minimax-m3",displayName:"MiniMax M3",provider:"fireworks",contextWindow:524288,pricing:$e(.06,.3,1.2),supportsVision:!0,clientType:"openai-chat",baseUrl:ws},{modelId:"deepseek-ai/DeepSeek-V4-Flash",displayName:"DeepSeek V4 Flash",provider:"siliconflow",contextWindow:1e6,pricing:jn(.02,1,2),supportsVision:!1,clientType:"openai-chat",baseUrl:si},{modelId:"deepseek-ai/DeepSeek-V4-Pro",displayName:"DeepSeek V4 Pro",provider:"siliconflow",contextWindow:1e6,pricing:jn(.1,12,24),supportsVision:!1,clientType:"openai-chat",baseUrl:si},{modelId:"meituan-longcat/LongCat-2.0",displayName:"LongCat 2.0",provider:"siliconflow",contextWindow:1e6,pricing:jn(.1,5,20),supportsVision:!1,clientType:"openai-chat",baseUrl:si},{modelId:"moonshotai/Kimi-K2.7-Code",displayName:"Kimi K2.7 Code",provider:"siliconflow",contextWindow:262144,pricing:jn(1.3,6.5,27),supportsVision:!0,clientType:"openai-chat",baseUrl:si},{modelId:"Pro/moonshotai/Kimi-K2.6",displayName:"Kimi K2.6",provider:"siliconflow",contextWindow:262144,pricing:jn(1.1,6.5,27),supportsVision:!0,clientType:"openai-chat",baseUrl:si},{modelId:"Qwen/Qwen3.6-35B-A3B",displayName:"Qwen 3.6 35B A3B",provider:"siliconflow",contextWindow:262144,pricing:jn(1.8,1.8,10.8),supportsVision:!0,clientType:"openai-chat",baseUrl:si},{modelId:"zai-org/GLM-5.2",displayName:"GLM-5.2",provider:"siliconflow",contextWindow:1e6,pricing:jn(2,8,28),supportsVision:!1,clientType:"openai-chat",baseUrl:si},{modelId:"deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"qwen-token-plan",contextWindow:1e6,pricing:jn(.2,1,2),supportsVision:!1,clientType:"openai-chat",baseUrl:Fl},{modelId:"deepseek-v4-pro",displayName:"DeepSeek V4 Pro",provider:"qwen-token-plan",contextWindow:1e6,pricing:jn(1,12,24),supportsVision:!1,clientType:"openai-chat",baseUrl:Fl},{modelId:"glm-5.2",displayName:"GLM-5.2",provider:"qwen-token-plan",contextWindow:1048576,pricing:jn(2,8,28),supportsVision:!1,clientType:"openai-chat",baseUrl:Fl},{modelId:"qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"qwen-token-plan",contextWindow:1e6,pricing:jn(1.5,12,36),supportsVision:!0,clientType:"openai-chat",baseUrl:Fl},{modelId:"qwen3.7-plus",displayName:"Qwen 3.7 Plus",provider:"qwen-token-plan",contextWindow:1e6,pricing:jn(.4,2,8),supportsVision:!0,clientType:"openai-chat",baseUrl:Fl},{modelId:"deepseek-v4-flash-0731",displayName:"DeepSeek V4 Flash 0731",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:jn(.2,1,2),supportsVision:!1,clientType:"openai-chat",baseUrl:Vl},{modelId:"kimi/kimi-k3",displayName:"Kimi K3",provider:"qwen-pay-as-you-go",contextWindow:1048576,pricing:jn(2,20,100),supportsVision:!0,clientType:"openai-chat",baseUrl:Vl},{modelId:"qwen3.8-max",displayName:"Qwen 3.8 Max",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:jn(1.5,12,36),supportsVision:!0,clientType:"openai-chat",baseUrl:Vl},{modelId:"qwen3.7-plus",displayName:"Qwen 3.7 Plus",provider:"qwen-pay-as-you-go",contextWindow:1e6,pricing:jn(.4,2,8),supportsVision:!0,clientType:"openai-chat",baseUrl:Vl},{modelId:"ZHIPU/GLM-5.2",displayName:"GLM-5.2",provider:"qwen-pay-as-you-go",contextWindow:1048576,pricing:jn(2,8,28),supportsVision:!1,clientType:"openai-chat",baseUrl:Vl},{modelId:"MiniMax-M3",displayName:"MiniMax M3",provider:"minimax",contextWindow:1e6,pricing:$e(.06,.3,1.2),supportsVision:!0,clientType:"minimax-m3",baseUrl:g7},{modelId:"gemini-3.7-flash",displayName:"Gemini 3.7 Flash",provider:"google",contextWindow:1048576,pricing:$e(.15,1.5,7.5),supportsVision:!0},{modelId:"gemini-3.6-flash",displayName:"Gemini 3.6 Flash",provider:"google",contextWindow:1048576,pricing:$e(.15,1.5,7.5),supportsVision:!0},{modelId:"gemini-3.5-flash",displayName:"Gemini 3.5 Flash",provider:"google",contextWindow:1048576,pricing:$e(.15,1.5,9),supportsVision:!0},{modelId:"gemini-3.5-flash-lite",displayName:"Gemini 3.5 Flash-Lite",provider:"google",contextWindow:1048576,pricing:$e(.03,.3,2.5),supportsVision:!0},{modelId:"gemini-3.1-flash-lite",displayName:"Gemini 3.1 Flash-Lite",provider:"google",contextWindow:1048576,pricing:$e(.025,.25,1.5),supportsVision:!0},{modelId:"gemini-3.1-pro-preview",displayName:"Gemini 3.1 Pro (Preview)",provider:"google",contextWindow:1048576,pricing:$e(.2,2,12),supportsVision:!0},{modelId:"gemini-3-flash-preview",displayName:"Gemini 3 Flash (Preview)",provider:"google",contextWindow:1048576,pricing:$e(.05,.5,3),supportsVision:!0},{modelId:"claude-fable-5",displayName:"Claude Fable 5",provider:"anthropic",contextWindow:1e6,pricing:$e(1,12.5,50),supportsVision:!0},{modelId:"claude-opus-4-8",displayName:"Claude Opus 4.8",provider:"anthropic",contextWindow:1e6,pricing:$e(.5,6.25,25),supportsVision:!0},{modelId:"claude-opus-4-7",displayName:"Claude Opus 4.7",provider:"anthropic",contextWindow:1e6,pricing:$e(.5,6.25,25),supportsVision:!0},{modelId:"claude-sonnet-5",displayName:"Claude Sonnet 5",provider:"anthropic",contextWindow:1e6,pricing:$e(.2,2.5,10),supportsVision:!0},{modelId:"claude-sonnet-4-6",displayName:"Claude Sonnet 4.6",provider:"anthropic",contextWindow:1e6,pricing:$e(.3,3.75,15),supportsVision:!0},{modelId:"gpt-5.6",displayName:"GPT-5.6 Sol",provider:"openai",contextWindow:105e4,pricing:$e(.5,5,30),supportsVision:!0},{modelId:"gpt-5.6-luna",displayName:"GPT-5.6 Luna",provider:"openai",contextWindow:105e4,pricing:$e(.02,.2,1.2),supportsVision:!0},{modelId:"gpt-5.6-terra",displayName:"GPT-5.6 Terra",provider:"openai",contextWindow:105e4,pricing:$e(.2,2,12),supportsVision:!0},{modelId:"gpt-5.5",displayName:"GPT-5.5",provider:"openai",contextWindow:105e4,pricing:$e(.5,5,30),supportsVision:!0},{modelId:"gpt-5.5-pro",displayName:"GPT-5.5 Pro",provider:"openai",contextWindow:105e4,pricing:$e(30,30,180),supportsVision:!0},{modelId:"gpt-5.4",displayName:"GPT-5.4",provider:"openai",contextWindow:105e4,pricing:$e(.25,2.5,15),supportsVision:!0},{modelId:"gpt-5.4-mini",displayName:"GPT-5.4 mini",provider:"openai",contextWindow:4e5,pricing:$e(.075,.75,4.5),supportsVision:!0},{modelId:"gpt-5.4-nano",displayName:"GPT-5.4 nano",provider:"openai",contextWindow:4e5,pricing:$e(.02,.2,1.25),supportsVision:!0},{modelId:"gpt-5.4-pro",displayName:"GPT-5.4 Pro",provider:"openai",contextWindow:105e4,pricing:$e(30,30,180),supportsVision:!0},{modelId:"glm-5.3",displayName:"GLM-5.3",provider:"zhipu",contextWindow:1e6,pricing:$e(.26,1.4,4.4),supportsVision:!1},{modelId:"glm-5.2",displayName:"GLM-5.2",provider:"zhipu",contextWindow:1e6,pricing:$e(.26,1.4,4.4),supportsVision:!1},{modelId:"glm-5.1",displayName:"GLM-5.1",provider:"zhipu",contextWindow:2e5,pricing:$e(.26,1.4,4.4),supportsVision:!1},{modelId:"glm-5",displayName:"GLM-5",provider:"zhipu",contextWindow:2e5,pricing:$e(.2,1,3.2),supportsVision:!1},{modelId:"kimi-k3",displayName:"Kimi K3",provider:"moonshot",contextWindow:1048576,pricing:jn(2,20,100),supportsVision:!0},{modelId:"kimi-k2.6",displayName:"Kimi K2.6",provider:"moonshot",contextWindow:262144,pricing:jn(1.1,6.5,27),supportsVision:!0},{modelId:"kimi-k2.5",displayName:"Kimi K2.5",provider:"moonshot",contextWindow:262144,pricing:jn(.7,4,21),supportsVision:!0}];function x7(e){if(e!==void 0)return e.trim().toLowerCase()==="openai"?"openai-chat":e}function E0(e,t){return Fj.find(a=>a.provider===e&&a.modelId===t)}function Yr(e){return fi.find(t=>t.id===e)}function y7(e,t){const i=t?.toLowerCase()||e.toLowerCase(),l=c=>({envKey:`${c}_API_KEY`,envBaseUrlKey:`${c}_BASE_URL`});if(i.includes("gemini-3")||i.includes("gemini-embedding"))return l("GEMINI");if(i.includes("claude")&&(i.includes("4-7")||i.includes("4-8")||i.includes("-5")||i.includes("4-6")))return l("ANTHROPIC");if(i.includes("gpt-5.4")||i.includes("gpt-5.5")||i.includes("gpt-5.6"))return l("OPENAI");if(i.includes("glm-5"))return l("ZAI");if(i.includes("kimi-k3")||i.includes("kimi-k2.5")||i.includes("kimi-k2.6"))return l("MOONSHOT");if(i==="minimax-m3"&&e.toLowerCase()==="minimax-m3")return l("MINIMAX");if(i.includes("deepseek-v4"))return l("DEEPSEEK");if(i.includes("ant-messages"))return l("ANTHROPIC");if(i.includes("openai"))return l("OPENAI")}function v7(e,t,a){const i=t?.toLowerCase()||e.toLowerCase();if(i==="minimax-m3")return"openai";if(!(i.includes("gemini-3")||i.includes("gemini-embedding"))){if(i.includes("claude")&&(i.includes("4-6")||i.includes("4-7")||i.includes("4-8")||i.includes("-5")))return a?.startsWith("bedrock://")||e.includes("4-6")?void 0:"anthropic";if(i.includes("gpt-5.4")||i.includes("gpt-5.5")||i.includes("gpt-5.6"))return"openai";if(!i.includes("glm-5")&&!(i.includes("kimi-k3")||i.includes("kimi-k2.5")||i.includes("kimi-k2.6"))&&!i.includes("deepseek-v4")){if(i.includes("ant-messages"))return"anthropic";if(i.includes("openai-responses"))return"openai";if(!(i.includes("openai")&&i.includes("embedding"))&&i.includes("openai"))return"openai"}}}function b7(){return Fj.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 lk(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 a=/^accounts\/([^/]+)\/models\/(.+)$/.exec(t);return a?`https://app.fireworks.ai/models/${a[1]}/${a[2]}`:Yr(e)?.modelsUrl}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 a=/^kimi-k(\d+)\.(\d+)$/.exec(t);return a?`https://platform.kimi.com/docs/pricing/chat-k${a[1]}${a[2]}`:Yr(e)?.modelsUrl}if(e!=="custom")return Yr(e)?.modelsUrl}function _t(e,t){return!!e&&!!t&&e.provider===t.provider&&e.modelId===t.modelId}function Vj(e){return{id:e,label:e,envKey:"OPENAI_API_KEY",envBaseUrlKey:"OPENAI_BASE_URL"}}function qj(e,t){const a=t.trim().toLowerCase();if(!a)return!0;const i=fi.find(l=>l.id===e.provider);return e.modelId.toLowerCase().includes(a)||(e.displayName??"").toLowerCase().includes(a)||e.provider.toLowerCase().includes(a)||(i?.label??"").toLowerCase().includes(a)}function Gj(e,t){const a=t.trim()!=="",i=e.filter(m=>qj(m,t)),l=fi.map(m=>({provider:m,rows:i.filter(p=>p.provider===m.id)})),u=[...new Set(i.map(m=>m.provider).filter(m=>!fi.some(p=>p.id===m)))].sort().map(m=>({provider:Vj(m),rows:i.filter(p=>p.provider===m)}));return[...l,...u].filter(m=>m.rows.length>0||!a&&m.provider.id==="custom")}function k7(e){return Gj(e,"").flatMap(t=>t.rows)}function pg(e){return!!e.credential?.apiKeyMasked}function Wj(e){return e?[e.cacheRead,e.cacheWrite,e.output].every(t=>typeof t=="string"?t.trim()!==""&&Number(t)===0:t===0):!1}function ok(e,{showAll:t,query:a,selected:i,defaultModel:l}){const c=k7(e);return(t||!c.some(pg)?c:c.filter(m=>pg(m)||_t(m,i)||_t(m,l))).filter(m=>qj(m,a))}function _0({open:e,setOpen:t,leading:a,label:i,labelClassName:l="",muted:c=!1,title:u,ariaLabel:m,ariaHaspopup:p="listbox",disabled:h=!1,menuClass:g,children:v}){return r.jsx(Un,{open:e,setOpen:t,menuClass:g,portal:{direction:"down",align:"left"},button:r.jsxs("button",{type:"button",title:u,"aria-label":m,"aria-haspopup":p,"aria-expanded":e,disabled:h,onClick:()=>t(!e),className:`flex w-full items-center gap-2 text-left ${kf} ${wf.sm} disabled:cursor-not-allowed disabled:opacity-60`,children:[a,r.jsx("span",{className:`min-w-0 flex-1 truncate ${c?"text-gray-400":""} ${l}`,children:i}),r.jsx(Ql,{className:"text-gray-400"})]}),children:v})}function wc(e){return e.displayName??e.modelId}const w7="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 R0({items:e,itemKey:t,isCurrent:a,query:i,onQueryChange:l,searchPlaceholder:c,emptyText:u,onPick:m,renderRow:p,footer:h}){const[g,v]=x.useState(-1),k=g>=0&&g<e.length?t(e[g]):null,w=S=>{if(e.length!==0){if(S.key==="ArrowDown"){S.preventDefault(),v(M=>(M+1)%e.length);return}if(S.key==="ArrowUp"){S.preventDefault(),v(M=>M<=0?e.length-1:M-1);return}(S.key==="Enter"&&!S.shiftKey||S.key==="Tab")&&!S.nativeEvent.isComposing&&(S.preventDefault(),m(e[g>=0?g:0]))}};return r.jsxs("div",{className:"contents",onKeyDown:w,children:[r.jsx("div",{className:"border-b border-gray-100 px-2 pb-1.5 pt-0.5 dark:border-gray-800",children:r.jsx("input",{autoFocus:!0,value:i,onChange:S=>{l(S.target.value),v(-1)},placeholder:c,"aria-label":c,...Wc,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"})}),r.jsxs("div",{className:"max-h-56 overflow-y-auto",children:[e.length===0&&r.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:u}),e.map(S=>{const M=t(S),C=a?.(S)??!1;return r.jsxs("button",{type:"button",ref:M===k?T=>T?.scrollIntoView({block:"nearest"}):void 0,onClick:()=>m(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 ${C?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}${M===k?" bg-gray-100 dark:bg-gray-800":""}`,children:[p(S),r.jsx("span",{className:"w-3 shrink-0 text-center text-xs",children:C?"✓":""})]},M)})]}),h]})}function Kj({models:e,value:t,defaultModel:a,onPick:i}){const[l,c]=x.useState(""),[u,m]=x.useState(!1),p=ok(e,{showAll:u,query:l,selected:t,defaultModel:a}),h=u?0:ok(e,{showAll:!0,query:l,selected:t,defaultModel:a}).length-p.length;return r.jsx(R0,{items:p,itemKey:g=>`${g.provider}:${g.modelId}`,isCurrent:g=>_t(g,t),query:l,onQueryChange:c,searchPlaceholder:f.models.searchPlaceholder,emptyText:f.models.noSearchResults,onPick:i,renderRow:g=>r.jsxs(r.Fragment,{children:[r.jsx(eo,{provider:g.provider,className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"min-w-0 flex-1 truncate",children:wc(g)}),Wj(g.pricing)&&r.jsx("span",{className:"shrink-0",children:r.jsx(Cn,{tone:"yellow",children:f.models.freeBadge})}),!pg(g)&&r.jsx("span",{role:"img",title:f.models.noKey,"aria-label":f.models.noKey,className:"shrink-0 text-gray-400 dark:text-gray-500",children:r.jsx(Ge,{d:w7,size:13})}),_t(g,a)&&r.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:f.models.default})]}),...h>0?{footer:r.jsx("div",{className:"border-t border-gray-100 dark:border-gray-800",children:r.jsx("button",{type:"button",onClick:()=>m(!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:f.models.showModelsWithoutKey(h)})})}:{}})}function I0({models:e,value:t,defaultModel:a,onChange:i,disabled:l,variant:c="pill"}){const[u,m]=x.useState(!1),p=e.find(k=>_t(k,t)),h=p?wc(p):t?.modelId??"…",g=r.jsx(eo,{provider:p?.provider??t?.provider??"custom",className:"h-4 w-4 shrink-0"}),v=r.jsx(Kj,{models:e,value:t,...a!==void 0?{defaultModel:a}:{},onPick:k=>{i({provider:k.provider,modelId:k.modelId}),m(!1)}});return c==="form"?r.jsx(_0,{open:u,setOpen:m,leading:g,label:h,title:`${f.chat.chooseModel}:${h}`,ariaLabel:f.chat.chooseModel,ariaHaspopup:"listbox",disabled:l||e.length===0,menuClass:"w-max min-w-56 origin-top-left",children:v}):r.jsx(Un,{open:u,setOpen:m,menuClass:"w-max min-w-56 origin-top-right",portal:{direction:"down",align:"right"},button:r.jsxs("button",{type:"button",title:`${f.chat.chooseModel}:${h}`,"aria-label":f.chat.chooseModel,disabled:l||e.length===0,onClick:()=>m(!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:[g,r.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:h}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",className:"shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),children:v})}const S7=/^[\w-]*$/;function ck(e,t){const a=e.slice(0,t),i=a.lastIndexOf("/");if(i<0||i>0&&!/\s/.test(a[i-1]))return null;const l=a.slice(i+1);if(!S7.test(l))return null;const c=/^[\w-]*/.exec(e.slice(t))[0];return{start:i,end:t+c.length,query:l}}function j7(e,t){const a=e.slice(0,t.start),i=e.slice(t.end),l=a.endsWith(" ")&&i.startsWith(" ")?a+i.slice(1):a+i;return/^\s*$/.test(l)?"":l}const C7=["none","low","medium","high","xhigh","max"],Yj=["low","medium","high","xhigh","max"];function N7(e,t){return e||(t??"medium")}function hg(e,t){return t&&C7.includes(t)?e[t]??t:null}function uk(e,t){return e||t}function T7(e,t,a){const i=e.filter(([l])=>l!=="").map(([l,c])=>({value:l,triggerLabel:l,label:l,description:c}));return a==="none"&&i.push({value:"none",triggerLabel:"none",label:"none",description:t}),i}function M7(e){let t=e.length-1,a=!1;for(;t>=0&&e[t].kind==="compaction";){const i=e[t];!i.running&&i.status==="completed"&&(a=!0),t--}return t<0?!1:!a}function A7(e,t,a){return t!==""&&a===t?!1:M7(e)}function Qj(e){let t=0,a=0;for(const i of e)i.kind!=="compaction"||i.running===!0||(t++,i.status==="completed"&&a++);return{settled:t,completed:a}}function E7(e,t){const a=Qj(e);return a.completed>t.completed?"completed":a.settled>t.settled?"failed":"pending"}function _7(e,t){if(e.phase==="ask")return{act:"wait"};if(e.phase==="settle")return{act:"apply",level:e.level,notice:"none"};const a=E7(t,e.baseline);return a==="pending"?{act:"wait"}:{act:"apply",level:e.level,notice:a==="completed"?"compacted":"compaction-failed"}}function R7(e){const t=e.currentText;return{text:t.trim()?e.recalledText?`${e.recalledText}
170
- ${t}`:t:e.recalledText,dropGoal:e.goalOn&&e.recalledFiles>0}}function Xj(e){if(pS(e)||gS(e))return null;const t=xS(e),a=t?t.rest:e,i=hS(a),l=i?i.rest:a,c=fS(l),{text:u}=Jd(c?c.rest:l);return{body:u.trim(),...t?{goalRound:t.round}:{},scheduled:i!==null}}function I7(e){const t=[],a=i=>{i!==""&&t[t.length-1]!==i&&t.push(i)};for(const i of e)if(i.kind==="user_text"){const l=Xj(i.text);if(!l||l.scheduled||l.goalRound!==void 0&&l.goalRound>1)continue;a(l.body)}else i.kind==="user_steering"&&a(Jd(i.text).text.trim());return t}function L7(e,t,a){if(e.length===0)return null;if(t===null){if(a.trim()!=="")return null;const c=e.length-1,u=e[c];return{nav:{index:c,stash:a,recalled:u},text:u}}if(a!==t.recalled)return null;if(t.index===0)return{nav:t,text:t.recalled};const i=t.index-1,l=e[i];return{nav:{...t,index:i,recalled:l},text:l}}function O7(e,t,a){if(t===null||a!==t.recalled)return null;if(t.index>=e.length-1)return{nav:null,text:t.stash};const i=t.index+1,l=e[i];return{nav:{...t,index:i,recalled:l},text:l}}function D7(e,t){return!e.slice(0,t).includes(`
171
- `)}function U7(e,t){return!e.slice(t).includes(`
172
- `)}function z7(e){if(e.sending)return"disabled";const t=!e.goalOn&&!e.modelAuthDead;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 $7(e,t){return e==="compacting"?!0:e==="running"&&t==="stop"}function L0(e){return e!=null&&e.includes("Files")}function P7(e,t,a){const i=t&&a;switch(e){case"over":return{active:i,claim:i,accept:!1};case"leave":return{active:i,claim:!1,accept:!1};case"drop":return{active:!1,claim:i,accept:i};case"end":return{active:!1,claim:!1,accept:!1}}}function B7(e){const t=[],a=[];for(const i of e)(i.type.startsWith("image/")?t:a).push(i);return{images:t,files:a}}function dk(e){e.defaultPrevented||!L0(e.dataTransfer?.types)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))}function fk(e){e.defaultPrevented||!L0(e.dataTransfer?.types)||e.preventDefault()}const Zj=x.createContext(null);function H7({className:e,children:t}){const[a,i]=x.useState(null);return r.jsx("div",{className:e,ref:i,children:r.jsx(Zj.Provider,{value:a,children:t})})}function F7({onFiles:e}){const t=x.useContext(Zj),[a,i]=x.useState(!1),l=x.useRef(!1),c=x.useRef(e);return x.useEffect(()=>{c.current=e}),x.useEffect(()=>{if(!t)return;const u=k=>k instanceof Node&&t.contains(k),m=(k,w,S)=>{const M=P7(k,L0(w.dataTransfer?.types),S);return l.current!==M.active&&(l.current=M.active,i(M.active)),M.claim&&(w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="copy")),M},p=k=>{m("over",k,u(k.target))},h=k=>{m("leave",k,u(k.relatedTarget))},g=k=>{if(!m("drop",k,u(k.target)).accept||!k.dataTransfer)return;const S=Array.from(k.dataTransfer.files);S.length>0&&c.current(S)},v=k=>{m("end",k,!1)};return window.addEventListener("dragover",p),window.addEventListener("dragleave",h),window.addEventListener("drop",g),window.addEventListener("dragend",v),()=>{window.removeEventListener("dragover",p),window.removeEventListener("dragleave",h),window.removeEventListener("drop",g),window.removeEventListener("dragend",v),l.current=!1,i(!1)}},[t]),!a||!t?null:nl.createPortal(r.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:r.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:[r.jsx(Ge,{d:of,size:28,className:"text-gray-400 dark:text-gray-500"}),r.jsx("p",{className:"text-base font-medium text-gray-800 dark:text-gray-100",children:f.chat.dropFilesTitle}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.chat.dropFilesDesc})]})}),t)}const V7=1024*1024;function mk(e,t){const a=t*V7,i=[],l=[];for(const c of e)c.size>a?l.push(c):i.push(c);return{accepted:i,rejected:l}}const q7=["always-ask","read-only","allow-all","deny-all"],pk={"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 G7({value:e,onChange:t,disabled:a,direction:i="up"}){const[l,c]=x.useState(!1);return r.jsx(Un,{open:l,setOpen:c,menuClass:"w-max",portal:{direction:i,align:"left"},button:r.jsxs("button",{type:"button","aria-label":f.chat.approvalMode,title:`${f.chat.approvalMode}:${f.chat.approvalModeNames[e]??e}`,disabled:a,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:[r.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",children:r.jsx("path",{d:pk[e]})}),r.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:f.chat.approvalModeNames[e]??e}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",className:"shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),children:q7.map(u=>r.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:[r.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:r.jsx("path",{d:pk[u]})}),r.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-nowrap",children:f.chat.approvalModes[u]??u}),r.jsx("span",{className:"w-3 shrink-0 text-center",children:u===e?"✓":""})]},u))})}function W7({agents:e,currentAgentId:t,onPick:a}){const[i,l]=x.useState("");return r.jsx(R0,{items:QO(e,i),itemKey:c=>c.agentId,isCurrent:c=>c.agentId===t,query:i,onQueryChange:l,searchPlaceholder:f.chat.agentSearchPlaceholder,emptyText:f.chat.agentsNoMatch,onPick:a,renderRow:c=>r.jsxs(r.Fragment,{children:[r.jsx(Da,{id:c.agentId,name:pn(c),size:16,className:"shrink-0 rounded"}),r.jsx("span",{className:"shrink-0 font-mono text-gray-800 dark:text-gray-200",children:c.agentId}),c.name&&c.name!==c.agentId&&r.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:c.name})]})})}function hk({panelRef:e,maxHeight:t,title:a,children:i}){return r.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:[r.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:a}),i]})}const K7="M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z";function gk({value:e,onChange:t,disabled:a,direction:i="down"}){const[l,c]=x.useState(!1),u=e===null?"…":hg(f.chat.thinkingLevelNames,e)??"—";return r.jsxs(Un,{open:l,setOpen:c,menuClass:"w-max min-w-36",portal:{direction:i,align:"right"},button:r.jsxs("button",{type:"button",title:`${f.chat.thinkingLevel}:${u}`,"aria-label":f.chat.thinkingLevel,disabled:a||e===null,onClick:()=>c(!l),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:[r.jsx(Ge,{d:K7,size:14,className:"shrink-0"}),r.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:u}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",className:"shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),children:[r.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:f.chat.thinkingLevel}),Yj.map(m=>r.jsxs("button",{type:"button",onClick:()=>{t(m),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 ${m===e?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:f.chat.thinkingLevelMenuName(f.chat.thinkingLevelNames[m]??m,m)}),r.jsx("span",{className:"w-3 shrink-0 text-center",children:m===e?"✓":""})]},m))]})}const Jj="penguin.steerMode";function Y7(){return localStorage.getItem(Jj)==="followup"?"followup":"steer"}const Q7="M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6";function X7({steerMode:e,onChangeSteerMode:t}){const a=(i,l,c)=>r.jsx("button",{type:"button",title:c,"aria-pressed":e===i,onClick:()=>t(i),className:`h-5 rounded px-1.5 text-xs transition-colors duration-150 ${e===i?"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:l});return r.jsxs("div",{className:"flex w-full items-center gap-2 px-3 py-1 text-xs",children:[r.jsx(Ge,{d:Q7,size:14,className:"shrink-0 text-gray-400 dark:text-gray-500"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-600 dark:text-gray-400",children:f.chat.steerModeLabel}),r.jsxs("div",{role:"group","aria-label":f.chat.steerModeLabel,className:"flex shrink-0 items-center gap-0.5",children:[a("steer",f.chat.steerModeSteer,f.chat.steerModeSteerHint),a("followup",f.chat.steerModeFollowUp,f.chat.steerModeFollowUpHint)]})]})}function Z7({skills:e,selected:t,onToggle:a,disabled:i,direction:l="up"}){const{locale:c}=Za(),[u,m]=x.useState(!1),[p,h]=x.useState(""),g=GO(e,c,p);return r.jsxs(Un,{open:u,setOpen:m,menuClass:"w-[26rem]",portal:{direction:l,align:"left"},button:r.jsxs("button",{type:"button","aria-label":f.chat.skillsSelect,title:f.chat.skillsSelect,disabled:i,onClick:()=>{const v=!u;m(v),v&&h("")},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:[r.jsx(Ge,{d:A0,size:14,className:"shrink-0"}),r.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:f.chat.skillsSelect}),t.length>0&&r.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}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",className:"shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M3 4.5l3 3 3-3",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),children:[r.jsx("div",{className:"border-b border-gray-100 px-2 pb-1.5 pt-0.5 dark:border-gray-800",children:r.jsx("input",{autoFocus:!0,value:p,onChange:v=>h(v.target.value),placeholder:f.chat.skillsSearchPlaceholder,"aria-label":f.chat.skillsSearchPlaceholder,...Wc,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"})}),r.jsx("div",{className:"max-h-56 overflow-y-auto",children:e.length===0?r.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:f.chat.skillsEmptyHint}):g.length===0?r.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:f.chat.skillsNoMatch}):g.map(v=>{const k=t.includes(v.name);return r.jsxs("button",{type:"button","aria-pressed":k,onClick:()=>a(v.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 ${k?"font-medium text-gray-900 dark:text-gray-100":"text-gray-600 dark:text-gray-400"}`,children:[r.jsx(Rf,{icon:v.icon,size:14,className:"shrink-0 text-gray-400 dark:text-gray-500"}),r.jsx("span",{className:"shrink-0 font-mono",children:v.name}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:co(c,v)}),r.jsx("span",{className:"w-3 shrink-0 text-center",children:k?"✓":""})]},v.name)})})]})}const J7="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 eD({items:e,footer:t,direction:a="up"}){const[i,l]=x.useState(!1);return r.jsxs(Un,{open:i,setOpen:l,menuClass:"w-72",portal:{direction:a,align:"left"},button:r.jsx("button",{type:"button","aria-label":f.chat.plusMenu,title:f.chat.plusMenu,onClick:()=>l(!i),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:r.jsx(Ge,{d:"M12 5v14M5 12h14",size:15,className:"shrink-0"})}),children:[e.map(c=>r.jsxs("button",{type:"button","aria-pressed":c.active,disabled:c.disabled,onClick:()=>{l(!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:[r.jsx(Ge,{d:c.icon,size:14,className:"shrink-0 text-gray-400 dark:text-gray-500"}),r.jsx("span",{className:"shrink-0",children:c.label}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:c.desc}),r.jsx("span",{className:"w-3 shrink-0 text-center",children:c.active?"✓":""})]},c.key)),t&&r.jsx("div",{className:"mt-1 border-t border-gray-100 pt-1 dark:border-gray-800",children:t})]})}function tD({now:e,window:t,unknown:a=!1}){const i=Bj(t),l=a?0:Math.min(1,e/i),c=a||l<=.8?"text-gray-400 dark:text-gray-500":l>.95?"text-red-500":"text-amber-500",u=5,m=2*Math.PI*u;return r.jsxs("span",{title:a?f.chat.contextUnknown:`${f.chat.contextUsage} ${Math.round(l*100)}%`,className:`flex shrink-0 items-center gap-1 font-mono ${c}`,children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":!0,className:"block shrink-0",children:[r.jsx("circle",{cx:"7",cy:"7",r:u,fill:"none",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"2"}),r.jsx("circle",{cx:"7",cy:"7",r:u,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:`${m*l} ${m}`,transform:"rotate(-90 7 7)"})]}),r.jsxs("span",{className:"hidden @md:inline",children:[a?"—":Rt(e),"/",Rt(i)]})]})}function nD(e){return new Promise(t=>{const a=new FileReader;a.onload=()=>t(typeof a.result=="string"?a.result:null),a.onerror=()=>t(null),a.readAsDataURL(e)})}function aD(e){const t=e.slice(e.indexOf(",")+1).replace(/[=\s]+/g,"");return Math.floor(t.length*3/4)}function xk(e){const t=[],a=e.text.replace(/\s+/g," ").trim();return a&&t.push(a),e.images>0&&t.push(f.chat.imagesInMessage(e.images)),e.files>0&&t.push(f.chat.filesInMessage(e.files)),t.join(" · ")}const rD="M9 14L4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11";function yk({label:e,onRecall:t,disabled:a}){return r.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[r.jsx("p",{className:"min-w-0 truncate text-xs text-gray-400 dark:text-gray-500",children:e}),t&&r.jsx("button",{type:"button","aria-label":f.chat.recallQueued,title:f.chat.recallQueuedTitle,disabled:a,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:r.jsx(Ge,{d:rD,size:13})})]})}function sD(e,t,a){for(const i of t)e.push({type:"image_url",imageUrl:i});for(const i of a)e.push({type:"file",fileName:i.name,dataUrl:i.dataUrl})}function e5({status:e,onSend:t,onSteer:a,steeringDeliveredCount:i,pendingSteering:l=[],onRecallSteering:c,onQueueFollowUp:u,queuedFollowUps:m=0,pendingFollowUps:p=[],onRecallFollowUp:h,onStop:g,onCompact:v,modelRef:k,models:w,onChangeModel:S,onSwitchModel:M,defaultModel:C,thinkingLevel:T,onChangeThinkingLevel:I,turnThinkingLevel:D,onChangeTurnThinkingLevel:K,contextWindow:F,contextNow:E,contextStale:B=!1,vision:Y,approvalMode:V,onChangeApprovalMode:O,modeSaving:U,autoFocus:_,agents:P,currentAgentId:H,skills:G,initialSkills:z,onSkillsChange:J,onHandoff:xe,initialText:me,onTextChange:A,history:R=[],initialHandoffTargetId:q,onHandoffTargetChange:j,initialPendingModelRef:$,onPendingModelChange:ae,modelAuthDead:de=!1,onOpenModels:ye,onRetryModelAuth:Se,onNewSession:ke}){const{locale:ee}=Za(),{uploadLimits:je}=vn(),[Ae,Qe]=x.useState(me??""),We=x.useRef(Ae);We.current=Ae;const[re,ft]=x.useState([]),[ge,dt]=x.useState([]),[It,zt]=x.useState(!1),[nn,un]=x.useState(0),[Wt,Ce]=x.useState(null),[Ke,se]=x.useState(!1),ce=x.useRef(null),[De,Be]=x.useState(!1),Ue=x.useRef(null),W=x.useRef(null),[pe,Ne]=x.useState(),[Re,Pe]=x.useState(null),[Fe,nt]=x.useState(null),[ot,Te]=x.useState(z??[]),[ze,yt]=x.useState(0),ct=x.useRef(null),vt=x.useRef(null),[hn]=x.useState(()=>window.matchMedia("(max-width: 767px)").matches),bt=e==="running",dn=e==="compacting",Qn=Ae.trim().length>0||re.length>0||ge.length>0||Re!==null||Fe!==null||ot.length>0,[Ht,Bn]=x.useState(!1),[Ur,ga]=x.useState(""),[zn,xa]=x.useState(!1),[Hn,ya]=x.useState(""),va=Ht?xd(Ur):null,an=xd(Hn)===null,$t=va!==null&&va!==M0?f.chat.goalBudgetValue(Rt(va)):f.chat.goalBudgetUnlimited,gn=XO({handoffTarget:Re!==null,pendingModel:Fe!==null,canSwitchModel:M!==void 0,sessionBusy:bt||dn}),Xn=!bt&&!dn&&!It&&!de&&(Ht?Ae.trim().length>0&&ge.length===0&&va!==null&&!(zn&&an):Qn),Ja=x.useCallback(ne=>{if(ne){ya(Ur),xa(!0);return}xd(Hn)!==null&&(ga(Hn.trim()),xa(!1))},[Ur,Hn]),Ns=x.useCallback(()=>{xa(!1),ct.current?.focus()},[]),ba=x.useCallback(()=>{xd(Hn)!==null&&(ga(Hn.trim()),xa(!1),ct.current?.focus())},[Hn]),ka=x.useCallback(ne=>{Bn(ne),xa(!1),ya(""),ne&&(ga(""),Pe(null),j?.(null),nt(null),ae?.(null),dt([]))},[j,ae]),[wa,$r]=x.useState(Y7),Sa=ne=>{$r(ne),localStorage.setItem(Jj,ne)},za=wa==="followup"&&u!==void 0,ja=z7({sending:It,goalOn:Ht,modelAuthDead:de,canSteerChannel:a!==void 0,canQueueChannel:u!==void 0,followUpMode:za,stagedRoute:gn,hasHandoffTarget:Re!==null,hasPendingModel:Fe!==null,hasText:Ae.trim().length>0,hasImages:re.length>0,hasFiles:ge.length>0,hasContent:Qn}),$n=bt&&ja==="steer",Ft=bt&&ja==="queue",er=$n||Ft,Nr=ja==="queue"?f.chat.followUpSend:f.chat.steerSend,Vt=$7(e,ja),[Zn,oa]=x.useState(!1),tr=x.useRef(0);x.useEffect(()=>{Zn&&(!bt||(i??0)>tr.current||l.length>0)&&oa(!1)},[Zn,bt,i,l.length]);const[nr,Pr]=x.useState(null),$a=ne=>{const{text:Ee,dropGoal:Ze}=R7({recalledText:ne.text,currentText:ct.current?.value??Ae,recalledFiles:ne.files.length,goalOn:Ht});Qe(Ee),A?.(Ee),yt(Ee.length),ne.images.length>0&&ft(Xe=>[...ne.images,...Xe]),ne.files.length>0&&(Ze&&ka(!1),dt(Xe=>[...ne.files.map(at=>({name:at.fileName,size:aD(at.dataUrl),dataUrl:at.dataUrl})),...Xe])),requestAnimationFrame(()=>{const Xe=ct.current;Xe&&(Xe.focus(),Xe.setSelectionRange(Xe.value.length,Xe.value.length),Xe.scrollTop=Xe.scrollHeight)})},ca=async(ne,Ee)=>{if(!(nr!==null||It)){Pr(ne);try{const Ze=await Ee(ne);Ze&&(oa(!1),$a(Ze))}finally{Pr(null)}}},On=x.useCallback(ne=>{const Ee=ot.includes(ne)?ot.filter(Ze=>Ze!==ne):[...ot,ne];Te(Ee),J?.(Ee)},[ot,J]),bn=x.useRef(null),ar=x.useMemo(()=>{const ne=()=>{const Ee=bn.current,Ze=Ee?j7(We.current,Ee):"";Qe(Ze),A?.(Ze)};return[{cmd:"/compact",desc:f.chat.compact,run:()=>{ne(),v()}},{cmd:"/goal",desc:f.chat.goalModeDesc,run:()=>{ne(),ka(!Ht)}},...M&&w&&w.length>0?[{cmd:"/model",desc:f.chat.switchModel,run:()=>{ne(),se(!0)}}]:[],...xe&&P.length>0?[{cmd:"/agent",desc:f.chat.switchAgent,run:()=>{ne(),Be(!0)}}]:[],...WO(G,ee).map(Ee=>({cmd:Ee.cmd,desc:Ee.desc,run:()=>{ne(),On(Ee.name)}}))]},[v,M,w,P,A,G,ee,On,ka,Ht]),ue=!bt&&!dn&&!Ke&&!De?ck(Ae,ze):null;bn.current=ue;const Me=ue&&ue.start!==Wt?ar.filter(ne=>ne.cmd.startsWith(`/${ue.query}`)):[],et=Me.length>0,it=Me[Math.min(nn,Me.length-1)];x.useEffect(()=>{if(!Ke&&!De)return;const ne=()=>{se(!1),Be(!1),ct.current?.focus()},Ee=Xe=>{const at=Ke?ce.current:Ue.current;at&&!at.contains(Xe.target)&&ne()},Ze=Xe=>{Xe.key==="Escape"&&!Xe.isComposing&&ne()};return window.addEventListener("mousedown",Ee),window.addEventListener("keydown",Ze),()=>{window.removeEventListener("mousedown",Ee),window.removeEventListener("keydown",Ze)}},[Ke,De]);const gt=ne=>{nt(ne),ae?.(ne?{provider:ne.provider,modelId:ne.modelId}:null)},xt=ne=>{if(se(!1),ct.current?.focus(),_t(ne,k)){gt(null);return}gt(ne),Pe(null),j?.(null),Bn(!1)},Zt=ne=>{Be(!1),Pe(ne),j?.(ne.agentId),gt(null),Bn(!1),ct.current?.focus()},Pa=()=>{Re!==null&&(Pe(null),j?.(null)),gt(null)};x.useEffect(()=>{if(!et&&!Ke&&!De)return;const ne=()=>{const Ee=W.current;if(!Ee)return;let Ze=0;for(let at=Ee.parentElement;at;at=at.parentElement)if(getComputedStyle(at).overflowY!=="visible"){Ze=at.getBoundingClientRect().top;break}const Xe=Ee.getBoundingClientRect().top-Ze-14;Ne(Math.max(96,Math.min(320,Math.round(Xe))))};return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[et,Ke,De]);const ua=()=>{const ne=ct.current;ne&&(ne.style.height="auto",ne.style.height=`${Math.min(ne.scrollHeight,176)}px`)};x.useLayoutEffect(ua,[Ae]),x.useEffect(()=>{const ne=vt.current;ne&&Ae!==ne.recalled&&(vt.current=null)},[Ae]),x.useEffect(()=>{const ne=ct.current;if(ne&&ne.value.length>0){const Ee=ne.value.length;ne.setSelectionRange(Ee,Ee),ne.scrollTop=ne.scrollHeight,yt(Ee)}},[]);const Fn=x.useRef(!1);x.useEffect(()=>{if(!Fn.current&&(Fn.current=!0,G.length===0))return;const ne=ot.filter(Ee=>G.some(Ze=>Ze.name===Ee));ne.length!==ot.length&&(Te(ne),J?.(ne))},[G,ot,J]);const Ca=Re!==null||Fe!==null||Ht,xi=x.useRef(!1);x.useEffect(()=>{if(xi.current||!q||P.length===0||(xi.current=!0,Ca))return;const ne=P.find(Ee=>Ee.agentId===q);ne&&Pe(ne)},[P,q,Ca]);const rr=x.useRef(!1);x.useEffect(()=>{if(rr.current||!$||!w||w.length===0||(rr.current=!0,Ca||!M))return;const ne=w.find(Ee=>_t(Ee,$));ne&&!_t(ne,k)&&nt(ne)},[w,$,k,M,Ca]);const Bt=async(ne=t)=>{const Ee=Ae.trim();if(Ht){zt(!0);try{const ea=[{type:"text",text:Kh(ot,Ee)}];for(const ns of re)ea.push({type:"image_url",imageUrl:ns});await t(ea,{budget:va})&&(Qe(""),ft([]),Te([]),ka(!1))}finally{zt(!1),ct.current?.focus()}return}if(gn==="blocked")return;const Ze=gn==="model"?Fe:null,Xe=Ee!==""?Ee:ot.length>0?f.chat.skillsAutoMessage(ot):Ze?f.chat.modelSwitchAutoMessage:Ee,at=Kh(ot,Xe),kn=[];at&&kn.push({type:"text",text:at}),sD(kn,re,ge),zt(!0);try{(Re?await xe(Re,kn):Ze?await M({provider:Ze.provider,modelId:Ze.modelId},kn):await ne(kn,null))&&(Qe(""),ft([]),dt([]),Pe(null),nt(null),Te([]))}finally{zt(!1),ct.current?.focus()}},Ts=async()=>{if(bt){if(Ft){await Bt(u);return}if(!$n)return;const ne=Ae.trim(),Ee=re,Ze=ge.map(at=>({fileName:at.name,dataUrl:at.dataUrl}));zt(!0);let Xe="failed";try{Xe=await a(ne,Ee,Ze),Xe==="queued"&&(tr.current=i??0,oa(!0),Qe(""),ft([]),dt([]))}finally{zt(!1),ct.current?.focus()}Xe==="not_running"&&await Bt(u??t);return}Xn&&await Bt()},ts=ne=>{vt.current=ne.nav,Qe(ne.text),A?.(ne.text),yt(ne.text.length),requestAnimationFrame(()=>{const Ee=ct.current;Ee&&(Ee.setSelectionRange(Ee.value.length,Ee.value.length),Ee.scrollTop=Ee.scrollHeight)})},Ms=ne=>{if(et){if(ne.key==="ArrowDown"){ne.preventDefault(),un(Ee=>(Ee+1)%Me.length);return}if(ne.key==="ArrowUp"){ne.preventDefault(),un(Ee=>(Ee-1+Me.length)%Me.length);return}if((ne.key==="Enter"&&!ne.shiftKey||ne.key==="Tab")&&!ne.nativeEvent.isComposing){ne.preventDefault(),it?.run();return}if(ne.key==="Escape"){Ce(ue?.start??null);return}}if((ne.key==="ArrowUp"||ne.key==="ArrowDown")&&!ne.nativeEvent.isComposing){const Ee=ne.currentTarget.selectionStart??0,Ze=ne.currentTarget.selectionEnd??Ee,Xe=ne.key==="ArrowUp"?D7(Ae,Ee)?L7(R,vt.current,Ae):null:U7(Ae,Ze)?O7(R,vt.current,Ae):null;if(Xe){ne.preventDefault(),ts(Xe);return}}if(ne.key==="Backspace"&&(Re!==null||Fe!==null)&&ne.currentTarget.selectionStart===0&&ne.currentTarget.selectionEnd===0){ne.preventDefault(),Pa();return}ne.key==="Enter"&&!ne.shiftKey&&!ne.nativeEvent.isComposing&&(ne.preventDefault(),Ts())},yi=ne=>{const Ee=[];for(const at of ne)at.type.startsWith("image/")&&Ee.push(at);const{accepted:Ze,rejected:Xe}=mk(Ee,je.imageMaxMb);for(const at of Xe)Ve(f.chat.attachmentTooLarge(at.name,je.imageMaxMb));for(const at of Ze){const kn=new FileReader;kn.onload=()=>{typeof kn.result=="string"&&ft(ea=>[...ea,kn.result])},kn.readAsDataURL(at)}},As=ne=>{const Ee=[];for(const Ze of ne.clipboardData.items)if(Ze.kind==="file"){const Xe=Ze.getAsFile();Xe&&Ee.push(Xe)}Ee.length>0&&(ne.preventDefault(),yi(Ee))},Es=ne=>{ne.target.files&&yi(ne.target.files),ne.target.value=""},Jn=ne=>{if(Ht)return;const{accepted:Ee,rejected:Ze}=mk(ne,je.attachmentMaxMb);for(const Xe of Ze)Ve(f.chat.attachmentTooLarge(Xe.name,je.attachmentMaxMb));Ee.length!==0&&Promise.all(Ee.map(nD)).then(Xe=>{const at=Ee.flatMap((kn,ea)=>Xe[ea]?[{name:kn.name,size:kn.size,dataUrl:Xe[ea]}]:[]);at.length>0&&dt(kn=>[...kn,...at])})},_s=ne=>{ne.target.files&&Jn(ne.target.files),ne.target.value=""},vi=ne=>{const Ee=B7(ne);Ee.images.length>0&&yi(Ee.images),Ee.files.length>0&&(Ht?pa(f.chat.dropFilesGoalHint):Jn(Ee.files))},sr=x.useRef(null),Tr=x.useRef(null);return r.jsxs("div",{className:"relative",ref:W,children:[r.jsx(F7,{onFiles:vi}),et&&r.jsx("div",{style:{maxHeight:pe},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:Me.map((ne,Ee)=>r.jsxs("button",{type:"button",ref:ne===it?Ze=>Ze?.scrollIntoView({block:"nearest"}):void 0,onMouseEnter:()=>un(Ee),onClick:()=>ne.run(),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm ${ne===it?"bg-gray-100 dark:bg-gray-800":""}`,children:[r.jsx("span",{className:"shrink-0 font-mono text-gray-800 dark:text-gray-200",children:ne.cmd}),r.jsx("span",{title:ne.desc,className:"min-w-0 flex-1 truncate text-xs text-gray-500 dark:text-gray-400",children:ne.desc})]},ne.cmd))}),Ke&&w&&r.jsx(hk,{panelRef:ce,maxHeight:pe,title:f.chat.switchModelTitle,children:r.jsx(Kj,{models:w,value:k,...C!==void 0?{defaultModel:C}:{},onPick:xt})}),De&&r.jsx(hk,{panelRef:Ue,maxHeight:pe,title:f.chat.switchAgentTitle,children:r.jsx(W7,{agents:P,...H!==void 0?{currentAgentId:H}:{},onPick:Zt})}),re.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:re.map((ne,Ee)=>r.jsxs("div",{className:"anim-pop relative",children:[r.jsx(Ss,{src:ne,alt:f.chat.imageAlt,className:"h-16 w-16 rounded-md border border-gray-200 object-cover dark:border-gray-700"}),r.jsx("button",{type:"button","aria-label":f.chat.removeImage,onClick:()=>ft(Ze=>Ze.filter((Xe,at)=>at!==Ee)),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:"×"})]},Ee))}),ge.length>0&&r.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:ge.map((ne,Ee)=>r.jsxs("span",{title:ne.name,className:"anim-pop flex max-w-56 items-center gap-1.5 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:[r.jsx(Ge,{d:of,size:13,className:"shrink-0 text-gray-400 dark:text-gray-500"}),r.jsx("span",{className:"min-w-0 truncate",children:ne.name}),r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:_c(ne.size)}),r.jsx("button",{type:"button","aria-label":`${f.chat.removeFile} ${ne.name}`,onClick:()=>dt(Ze=>Ze.filter((Xe,at)=>at!==Ee)),className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]},Ee))}),!Y&&re.length>0&&r.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:f.chat.imagesAsPathHint}),gn==="blocked"&&r.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:f.chat.modelSwitchBusyHint}),l.length>0?r.jsx("div",{className:"anim-fade mb-1",children:l.map((ne,Ee)=>r.jsx(yk,{label:f.chat.steerQueuedItem(xk(ne)),disabled:nr!==null||It,...c&&ne.id?{onRecall:()=>{ca(ne.id,c)}}:{}},ne.id??Ee))}):Zn&&r.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:f.chat.steerQueuedIndicator}),p.length>0?r.jsx("div",{className:"anim-fade mb-1",children:p.map(ne=>r.jsx(yk,{label:f.chat.followUpQueuedItem(xk(ne)),disabled:nr!==null||It,...h?{onRecall:()=>{ca(ne.id,h)}}:{}},ne.id))}):m>0&&r.jsx("p",{className:"anim-fade mb-1 text-xs text-gray-400 dark:text-gray-500",children:f.chat.followUpQueuedChip(m)}),de&&r.jsxs("div",{className:"anim-fade mb-1.5 flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-xs text-gray-600 dark:border-gray-700 dark:bg-gray-800/60 dark:text-gray-300",children:[r.jsx("span",{className:"min-w-0 flex-1 basis-56",children:f.chat.modelAuthDead}),r.jsxs("span",{className:"flex shrink-0 flex-wrap items-center gap-1.5",children:[ye&&r.jsx("button",{type:"button",onClick:ye,className:"shrink-0 rounded-md bg-gray-900 px-2.5 py-1 font-medium text-white transition-colors duration-150 hover:bg-gray-700 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-300",children:f.chat.modelAuthDeadOpenModels}),Se&&r.jsx("button",{type:"button",onClick:Se,className:"shrink-0 rounded-md border border-gray-300 bg-white px-2.5 py-1 font-medium text-gray-700 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-700",children:f.chat.modelAuthDeadRetry}),ke&&r.jsx("button",{type:"button",onClick:ke,className:"shrink-0 rounded-md border border-gray-300 bg-white px-2.5 py-1 font-medium text-gray-700 transition-colors duration-150 hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-700",children:f.chat.modelAuthDeadCta})]})]}),r.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${de?" opacity-50 grayscale":""}`,children:[(Re!==null||Fe!==null||ot.length>0||Ht)&&r.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-1",children:[Ht&&r.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:[r.jsxs("span",{className:"flex shrink-0 items-center gap-1",title:f.chat.goalModeDesc,children:[r.jsx(Ge,{d:Uc,size:13,className:"text-gray-500 dark:text-gray-400"}),r.jsx("span",{children:f.chat.goalMode})]}),r.jsx("span",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px shrink-0 bg-gray-300 dark:bg-gray-600"}),r.jsx(Un,{open:zn,setOpen:Ja,onEscape:Ns,className:"min-w-0",menuClass:"bottom-full left-1/2 -ml-32 mb-2 w-64 max-w-[calc(100vw-2rem)] origin-bottom",button:r.jsxs("button",{type:"button","aria-label":$t,"aria-expanded":zn,onClick:()=>Ja(!zn),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:[r.jsx("span",{className:"truncate",children:$t}),r.jsx("svg",{width:"9",height:"9",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0","aria-hidden":!0,children:r.jsx("path",{d:"M3 4.5l3 3 3-3"})})]}),children:r.jsxs("div",{className:"px-3 py-2",children:[r.jsx("label",{htmlFor:"goal-budget-input",className:"block text-xs font-medium text-gray-700 dark:text-gray-200",children:f.chat.goalBudgetLabel}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[r.jsx("input",{id:"goal-budget-input",autoFocus:!0,value:Hn,onChange:ne=>ya(ne.target.value),onFocus:ne=>ne.currentTarget.select(),onKeyDown:ne=>{ne.key==="Enter"&&(ne.preventDefault(),ne.stopPropagation(),ba())},placeholder:f.chat.goalBudgetPlaceholder,"aria-invalid":an,"aria-describedby":"goal-budget-hint",...Wc,title:an?f.chat.goalBudgetInvalid:f.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 ${an?"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"}`}),r.jsx("button",{type:"button","aria-label":f.chat.goalBudgetSave,title:f.chat.goalBudgetSave,disabled:an,onClick:ba,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:r.jsx(Ge,{d:"M5 12l4 4L19 6",size:14})})]}),r.jsx("p",{id:"goal-budget-hint",className:`mt-1.5 text-[11px] leading-4 ${an?"text-red-500 dark:text-red-400":"text-gray-400 dark:text-gray-500"}`,children:an?f.chat.goalBudgetInvalid:f.chat.goalBudgetHint})]})}),r.jsx("button",{type:"button","aria-label":f.chat.goalRemove,onClick:()=>ka(!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:"×"})]}),Re!==null&&r.jsxs("span",{title:f.chat.handoffTargetTitle(pn(Re)),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:[r.jsx(Da,{id:Re.agentId,name:pn(Re),size:13,className:"shrink-0 rounded-sm"}),r.jsx("span",{className:"truncate",children:Re.agentId}),r.jsx("button",{type:"button","aria-label":f.chat.handoffRemove,onClick:()=>{Pe(null),j?.(null),ct.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:"×"})]}),Fe!==null&&r.jsxs("span",{title:f.chat.modelSwitchTargetTitle(wc(Fe)),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:[r.jsx(eo,{provider:Fe.provider,className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"truncate",children:wc(Fe)}),r.jsx("button",{type:"button","aria-label":f.chat.modelSwitchRemove,onClick:()=>{gt(null),ct.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:"×"})]}),ot.map(ne=>{const Ee=G.find(Ze=>Ze.name===ne);return r.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",...Ee?{title:co(ee,Ee)}:{},children:[r.jsx(Rf,{icon:Ee?.icon,size:13,className:"shrink-0 text-gray-500 dark:text-gray-400"}),r.jsx("span",{className:"truncate",children:ne}),r.jsx("button",{type:"button","aria-label":`${f.chat.skillRemove} ${ne}`,onClick:()=>On(ne),className:"shrink-0 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-200",children:"×"})]},ne)})]}),r.jsx("textarea",{ref:ct,rows:2,value:Ae,autoFocus:_,onChange:ne=>{const Ee=ne.target.value,Ze=ne.target.selectionStart??Ee.length;Qe(Ee),A?.(Ee),yt(Ze),un(0),Ce(Xe=>{if(Xe===null)return null;const at=ck(Ee,Ze);return at&&at.start===Xe?Xe:null})},onSelect:ne=>yt(ne.currentTarget.selectionStart??0),onKeyDown:Ms,onPaste:As,disabled:de,placeholder:de?f.chat.modelAuthDeadPlaceholder:bt&&za?hn?f.chat.followUpPlaceholderShort:f.chat.followUpPlaceholder:bt&&a?hn?f.chat.steerPlaceholderShort:f.chat.steerPlaceholder:hn?f.chat.inputPlaceholderShort:f.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"}),r.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2 text-xs",children:[r.jsxs("div",{className:"no-scrollbar flex min-w-0 flex-1 items-center gap-2 overflow-x-auto",children:[r.jsx("input",{ref:sr,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Es}),r.jsx("input",{ref:Tr,type:"file",multiple:!0,disabled:Ht,className:"hidden",onChange:_s}),r.jsx(eD,{items:[{key:"image",icon:J7,label:f.chat.uploadImage,desc:Y&&!Ht?f.chat.uploadImageDesc:f.chat.imagesAsPathHint,active:re.length>0,onSelect:()=>sr.current?.click()},{key:"file",icon:of,label:f.chat.uploadFile,desc:f.chat.uploadFileDesc,active:ge.length>0,disabled:Ht,onSelect:()=>Tr.current?.click()},{key:"goal",icon:Uc,label:f.chat.goalMode,desc:f.chat.goalModeDesc,active:Ht,disabled:bt||dn||It,onSelect:()=>ka(!Ht)}],footer:r.jsx(X7,{steerMode:wa,onChangeSteerMode:Sa}),direction:w&&S?"down":"up"}),r.jsx(G7,{value:V,onChange:O,disabled:U,direction:w&&S?"down":"up"}),r.jsx(Z7,{skills:G,selected:ot,onToggle:On,disabled:bt||dn||It,direction:w&&S?"down":"up"}),r.jsx("span",{title:f.chat.slashHint,className:"hidden min-w-0 truncate text-gray-300 @lg:block dark:text-gray-600",children:f.chat.slashHint})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[!S&&r.jsx(tD,{now:E,unknown:B,...F!==void 0?{window:F}:{}}),w&&S&&I&&r.jsx(gk,{value:T??null,onChange:I,disabled:It}),!S&&K&&r.jsx(gk,{value:D??"",onChange:K,disabled:It,direction:"up"}),w&&S?r.jsx(I0,{models:w,value:k,...C!==void 0?{defaultModel:C}:{},onChange:S,disabled:It}):r.jsxs("button",{type:"button",title:k?.modelId??"","aria-label":`${f.chat.model} ${k?.modelId??""}`,onClick:()=>pa(f.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:[r.jsx(eo,{provider:k?.provider??"custom",className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"hidden min-w-0 truncate @md:block",children:(()=>{const ne=w?.find(Ee=>_t(Ee,k));return ne?wc(ne):k?.modelId??"…"})()})]}),r.jsx("button",{type:"button",title:Vt?f.chat.stop:bt?Nr:f.chat.send,"aria-label":Vt?f.chat.stop:bt?Nr:f.chat.send,disabled:Vt?!1:bt?!er:!Xn,onClick:()=>Vt?void g():void Ts(),className:Vt?"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:Vt?r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":!0,className:"block",children:r.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"2",fill:"currentColor"})}):r.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:r.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})})})]})]})]})]})}const vk=500,iD=5;function lD(e,t){return e+t+1}function gg(e,t){return e+t>=iD}const t5=20,oD=20;function cD(e,t,a=t5,i=oD){const l=a+1+i;if(e<=l)return{start:0,end:e};if(t===null||t<0||t>=e)return{start:e-l,end:e};const c=Math.min(Math.max(0,t-a),e-l);return{start:c,end:c+l}}const uD=12,n5=5,a5=48;function dD(e,t){return Math.max(n5,Math.min(uD,Math.floor((e-a5)/Math.max(1,t))))}function fD(e){const t=Math.floor((e-a5)/n5);return Math.min(t5,Math.max(0,Math.floor((t-1)/2)))}function mD(e){const t=[];let a=null,i=!1;for(const l of e){if(l.kind==="user_text"||l.kind==="user_image"){let c="";if(l.kind==="user_text"){const u=Xj(l.text);if(!u||u.goalRound!==void 0&&u.goalRound>1){i=!1;continue}c=u.body}i&&a?a.question===""&&c!==""&&(a.question=c):(a={anchorId:l.id,question:c,answer:""},t.push(a)),i=!0;continue}if(i=!1,l.kind==="assistant_text"&&a&&a.answer.length<vk){const c=l.text.trim();c!==""&&(a.answer=(a.answer===""?c:`${a.answer} ${c}`).slice(0,vk))}}return t}function pD(e,t){let a=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 a.length>t&&(a=`${a.slice(0,t).trimEnd()}…`),a}const hD="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",gD=96,xD=1e3,yD=56,vD=48,bk="(hover: hover) and (pointer: fine)";function bD(e,t){const[a,i]=x.useState(()=>window.matchMedia(bk).matches),[l,c]=x.useState({gutterOk:!1,height:0});return x.useEffect(()=>{const u=window.matchMedia(bk),m=p=>i(p.matches);return u.addEventListener("change",m),()=>u.removeEventListener("change",m)},[]),x.useEffect(()=>{const u=e.current;if(!u)return;const m=()=>{const h=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,g=(u.clientWidth-vD*h)/2;c({gutterOk:g>=yD,height:u.clientHeight})};m();const p=new ResizeObserver(m);return p.observe(u),()=>p.disconnect()},[e,t]),{shown:a&&l.gutterOk,height:l.height}}function r5(e,t){const a=e.querySelectorAll("[data-outline-anchor]");if(a.length===0)return null;let i=null,l=null;const c=e.scrollTop+gD;for(const m of a){const p=Number(m.dataset.outlineAnchor);t.has(p)&&(i=p,m.offsetTop<=c&&(l=p))}return e.scrollHeight-e.scrollTop-e.clientHeight<2?i:l}let kk=null,wk;function s5(e,t){const a=e?.querySelector(`[data-outline-anchor="${t}"]`);!e||!a||(e.scrollTo({top:Math.max(0,a.offsetTop-8)}),window.clearTimeout(wk),kk?.classList.remove("outline-flash"),kk=a,a.classList.remove("outline-flash"),a.offsetWidth,a.classList.add("outline-flash"),wk=window.setTimeout(()=>a.classList.remove("outline-flash"),xD))}function Sk({edge:e}){return r.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=>r.jsx("span",{className:"h-[2px] w-[2px] rounded-full bg-gray-300 dark:bg-gray-700"},t))})}function i5(e,t,a,i){return e.answer?pD(e.answer,i):a&&e===t[t.length-1]?f.chat.outlineAnswering:""}function kD({entries:e,turnOffset:t=0,version:a,scrollRef:i,running:l,fit:c}){const[u,m]=x.useState(null),[p,h]=x.useState(null),g=x.useRef(null);if(x.useEffect(()=>{const D=i.current;if(!c.shown||!D||!gg(t,e.length))return;const K=new Set(e.map(Y=>Y.anchorId));let F=null;const E=()=>{F=null;const Y=i.current;Y&&m(r5(Y,K))},B=()=>{F??=requestAnimationFrame(E)};return E(),D.addEventListener("scroll",B,{passive:!0}),()=>{D.removeEventListener("scroll",B),F!==null&&cancelAnimationFrame(F)}},[c.shown,i,e.length,t,a]),!c.shown||!gg(t,e.length))return null;const v=D=>{const K=D.currentTarget.getBoundingClientRect();return K.top+K.height/2-(g.current?.getBoundingClientRect().top??0)},k=fD(c.height),{start:w,end:S}=cD(e.length,e.findIndex(D=>D.anchorId===u),k,k),M=e.slice(w,S),C=dD(c.height,M.length),T=p===null?null:M.find(D=>D.anchorId===p.id)??null,I=T===null?"":i5(T,e,l,160);return r.jsxs("nav",{ref:g,"aria-label":f.chat.outlineTitle,className:"pointer-events-none absolute inset-y-0 left-0 z-10 flex flex-col items-start justify-center",children:[r.jsxs("div",{className:"max-h-full overflow-hidden",children:[(w>0||t>0)&&r.jsx(Sk,{edge:"above"}),M.map((D,K)=>{const F=D.anchorId===u;return r.jsx("button",{type:"button","data-outline-tick":D.anchorId,"aria-current":F||void 0,"aria-label":f.chat.outlineTickLabel(lD(t,w+K),D.question||f.chat.outlineNoText),style:{height:C},onMouseEnter:E=>h({id:D.anchorId,top:v(E)}),onMouseLeave:()=>h(null),onFocus:E=>h({id:D.anchorId,top:v(E)}),onBlur:()=>h(null),onClick:()=>{s5(i.current,D.anchorId),m(D.anchorId)},className:"group/tick pointer-events-auto flex w-10 items-center pl-2.5",children:r.jsx("span",{className:`h-[2px] rounded-full transition-all duration-150 ${F?"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"}`})},D.anchorId)}),S<e.length&&r.jsx(Sk,{edge:"below"})]}),T&&r.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:[r.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||f.chat.outlineNoText}),I!==""&&r.jsx("p",{className:`mt-1 line-clamp-3 text-sm leading-snug text-gray-500 dark:text-gray-400 ${T.answer===""?"animate-pulse":""}`,children:I})]})]})}function wD({entries:e,turnOffset:t=0,scrollRef:a,running:i}){const[l,c]=x.useState(!1),[u,m]=x.useState(null);if(!gg(t,e.length))return null;const p=h=>{h&&a.current&&m(r5(a.current,new Set(e.map(g=>g.anchorId)))),c(h)};return r.jsx(Un,{open:l,setOpen:p,menuClass:"right-0 top-full mt-1 w-72 max-w-[calc(100vw-1.5rem)] origin-top-right",button:r.jsx("button",{type:"button",title:f.chat.outlineTitle,"aria-label":f.chat.outlineTitle,onClick:()=>p(!l),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:r.jsx(Ge,{d:hD,size:15})}),children:r.jsx("div",{className:"max-h-[60vh] overflow-y-auto py-1",children:e.map(h=>{const g=i5(h,e,i,80),v=h.anchorId===u;return r.jsxs("button",{type:"button","data-outline-menu-entry":h.anchorId,"aria-current":v||void 0,onClick:()=>{s5(a.current,h.anchorId),c(!1)},className:`block w-full px-3 py-1.5 text-left transition-colors duration-150 ${v?"bg-gray-100 dark:bg-gray-800":"hover:bg-gray-50 dark:hover:bg-gray-800/60"}`,children:[r.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||f.chat.outlineNoText}),g!==""&&r.jsx("span",{className:`mt-0.5 block truncate text-xs text-gray-500 dark:text-gray-400 ${h.answer===""?"animate-pulse":""}`,children:g})]},h.anchorId)})})})}function l5({className:e}){return r.jsx("img",{src:"/penguin-logo.svg",alt:"","aria-hidden":!0,draggable:!1,className:`select-none ${e??"h-9 w-9 rounded-lg"}`})}const xg=[{id:"webapps",tasks:[{id:"game",skills:["web-design"]},{id:"gamecenter",skills:["web-design"]},{id:"lol",skills:["web-design"]}]},{id:"agents",tasks:[{id:"rag",skills:["penguin-sdk","web-design"]},{id:"agentBenchmarkBuild",skills:[]},{id:"agentOptimization",skills:[]}]}];xg.flatMap(e=>[...e.tasks]);const SD=["always-ask","read-only","allow-all","deny-all"],Qr=(e,t)=>`penguin.chatDraft.${e}.${t}`,o5=(e,t)=>`penguin.chatDraft.session.${e}.${t}`;function jk(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 jD(e){if(!e)return{};try{return c5(JSON.parse(e))}catch{return{}}}function c5(e){if(typeof e!="object"||e===null)return{};const t=e,a={};typeof t.text=="string"&&(a.text=t.text),typeof t.agentId=="string"&&(a.agentId=t.agentId),typeof t.workspace=="string"&&(a.workspace=t.workspace);const i=jk(t.modelRef);i&&(a.modelRef=i),typeof t.handoffAgentId=="string"&&(a.handoffAgentId=t.handoffAgentId);const l=jk(t.switchModelRef);if(l&&(a.switchModelRef=l),Array.isArray(t.skills)){const c=t.skills.filter(u=>typeof u=="string");c.length>0&&(a.skills=c)}return typeof t.approvalMode=="string"&&SD.includes(t.approvalMode)&&(a.approvalMode=t.approvalMode),a}function gi(e,t=localStorage){try{return jD(t.getItem(e))}catch{return{}}}function js(e,t,a=localStorage){try{a.setItem(e,JSON.stringify(t))}catch{}}function zc(e,t=localStorage){try{t.removeItem(e)}catch{}}function u5(e,t,a=localStorage){const i=Qr(e,t),l=gi(i,a);l.modelRef&&js(i,{...l,modelRef:void 0},a)}function CD(e,t,a=localStorage){const i=Qr(e,t),l=gi(i,a);(l.agentId!==void 0||l.workspace!==void 0||l.approvalMode!==void 0)&&js(i,{...l,agentId:void 0,workspace:void 0,approvalMode:void 0},a)}const eu=(e,t)=>`penguin.chatDrafts.${e}.${t}`,ND=50,yg="penguin:draft-flush";function TD(e){if(!e)return[];try{const t=JSON.parse(e);if(!Array.isArray(t))return[];const a=[];for(const i of t){if(typeof i!="object"||i===null)continue;const l=i;typeof l.id!="string"||!l.id.startsWith("draft-")||a.push({id:l.id,savedAt:typeof l.savedAt=="string"?l.savedAt:"",draft:c5(l.draft)})}return a}catch{return[]}}const O0=ao(()=>({cache:new Map})),vg=[];function d5(e){try{return localStorage}catch{return null}}function tu(e,t){const{cache:a}=O0.getState(),i=a.get(e);if(i)return i;const l=d5();let c=vg;if(l)try{c=TD(l.getItem(e))}catch{c=vg}return a.set(e,c),c}function D0(e,t,a){const i=d5();if(i)try{t.length===0?i.removeItem(e):i.setItem(e,JSON.stringify(t))}catch{}O0.setState(l=>({cache:new Map(l.cache).set(e,t)}))}function MD(e,t){return ro(O0,()=>e&&t?tu(eu(e,t)):vg)}const AD=()=>`draft-${crypto.randomUUID().replace(/-/g,"").slice(0,8)}`;function uo(e,t,a){typeof window<"u"&&window.dispatchEvent(new Event(yg));const i=Qr(e,t),l=gi(i,a);if(!l.text||l.text.trim()==="")return null;const c=eu(e,t),u={id:AD(),savedAt:new Date().toISOString(),draft:l};return D0(c,[u,...tu(c)].slice(0,ND)),l.modelRef?js(i,{modelRef:l.modelRef},a):zc(i,a),u.id}function Ck(e,t,a,i){return tu(eu(e,t)).find(l=>l.id===a)??null}function ED(e,t,a,i,l){const c=eu(e,t),u=tu(c);u.some(m=>m.id===a)&&D0(c,u.map(m=>m.id===a?{...m,draft:i}:m))}function f5(e,t,a,i){const l=eu(e,t),c=tu(l);c.some(u=>u.id===a)&&D0(l,c.filter(u=>u.id!==a))}function bg(e){return((e.draft.text??"").split(`
173
- `).map(a=>a.trim()).find(a=>a!=="")??"").slice(0,80)}const $c="penguin:chat-defaults-changed";function _D(e){window.dispatchEvent(new CustomEvent($c,{detail:e}))}function m5(e,t){const a=e.detail;return a&&a.projectId===t?a:null}const p5="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 If({projectId:e,workspace:t,onChange:a,variant:i="pill",trigger:l}){const[c,u]=x.useState(!1),[m,p]=x.useState({right:!1}),h=x.useRef(!1),[g,v]=x.useState(null),[k,w]=x.useState(!1),[S,M]=x.useState(null),[C,T]=x.useState("");x.useEffect(()=>{T(g?.path??"")},[g]);const I=x.useRef(0),D=x.useCallback((H,G)=>{const z=++I.current;w(!0),M(null),L4(e,H).then(J=>{z===I.current&&v(J)}).catch(J=>{z===I.current&&(G?.onError?G.onError():M(Oe(J)))}).finally(()=>{z===I.current&&w(!1)})},[e]),K=H=>{if(H&&!h.current){h.current=!0;const G=t.trim();D(G.startsWith("/")?G:"")}},F=H=>{u(H),K(H)},E=H=>{const G=!c;if(G){const z=H.currentTarget.getBoundingClientRect(),J=parseFloat(getComputedStyle(document.documentElement).fontSize),xe=12,me=Math.min(20*J,window.innerWidth-2*J),A=window.innerWidth-xe-z.left,R=z.right-xe;A>=me?p({right:!1}):R>A?p({right:!0,...R<me?{maxWidth:R}:{}}):p({right:!1,maxWidth:A})}u(G),K(G)},B=()=>{const H=C.trim();if(!H||H===g?.path){T(g?.path??"");return}D(H,{onError:()=>{Ve(f.chat.workspaceDirInvalid),T(g?.path??"")}})},Y=t.trim(),V=Y?Y.split("/").filter(Boolean).pop()??"/":f.chat.workspaceAuto,O=g?.parent??null,U=(g?.entries??[]).filter(H=>!H.name.startsWith(".")),_=H=>r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:`shrink-0 text-gray-400 ${H}`,"aria-hidden":!0,children:r.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-2V7z",strokeWidth:"1.6",strokeLinejoin:"round"})}),P=r.jsxs("div",{className:"space-y-1.5 px-2.5 pb-2.5 pt-2",children:[r.jsxs("div",{className:"rounded-md border border-gray-200 dark:border-gray-800",children:[r.jsxs("div",{className:"flex items-center gap-1.5 border-b border-gray-100 px-1.5 py-1 dark:border-gray-800",children:[r.jsx("input",{value:C,placeholder:"…","aria-label":f.chat.workspace,...Wc,onChange:H=>T(H.target.value),onBlur:B,onKeyDown:H=>{H.key==="Enter"&&!H.nativeEvent.isComposing?(H.preventDefault(),B()):H.key==="Escape"&&T(g?.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"}),r.jsx("button",{type:"button",disabled:!g,onClick:()=>{g&&(a(g.path),u(!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:f.chat.workspaceUseThis})]}),r.jsxs("ul",{className:"max-h-40 overflow-y-auto py-1",children:[O!==null&&r.jsx("li",{children:r.jsxs("button",{type:"button",disabled:k,onClick:()=>D(O),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:["↰ ",f.chat.workspaceUp]})}),U.map(H=>r.jsx("li",{children:r.jsxs("button",{type:"button",disabled:k,onClick:()=>D(H.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:[r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"shrink-0 text-gray-400","aria-hidden":!0,children:r.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-2V7z",strokeWidth:"1.6",strokeLinejoin:"round"})}),r.jsx("span",{className:"min-w-0 flex-1 truncate",title:H.name,children:H.name})]})},H.path)),g&&U.length===0&&r.jsx("li",{className:"px-2.5 py-1.5 text-xs text-gray-400",children:f.chat.workspaceNoSubdirs}),k&&r.jsx("li",{className:"px-2.5 py-1.5 text-xs text-gray-400",children:f.common.loading}),S&&r.jsxs("li",{className:"flex items-center justify-between gap-2 px-2.5 py-1.5 text-xs text-red-500",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",title:S,children:S}),r.jsx("button",{type:"button",disabled:k,onClick:()=>D(""),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:f.common.retry})]})]})]}),Y&&r.jsx("button",{type:"button",onClick:()=>{a(""),u(!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:f.chat.workspaceClear}),r.jsx("p",{className:"px-0.5 text-xs leading-5 text-gray-400 dark:text-gray-500",children:f.chat.workspaceHint})]});return l?r.jsx(Un,{open:c,setOpen:F,portal:{direction:"down",align:"right"},menuClass:"w-64",button:l(c,()=>F(!c)),children:P}):i==="form"?r.jsx(_0,{open:c,setOpen:F,leading:_(""),label:V,...Y?{labelClassName:"font-mono"}:{},title:Y?`${f.chat.workspace}:${Y}`:f.chat.workspaceHint,ariaLabel:f.chat.workspace,ariaHaspopup:"dialog",menuClass:"w-80",children:P}):r.jsx(Un,{open:c,setOpen:u,menuClass:`top-full mt-1 w-80 max-w-[calc(100vw-2rem)] ${m.right?"right-0 origin-top-right":"left-0 origin-top-left"}`,...m.maxWidth!==void 0?{menuStyle:{maxWidth:m.maxWidth}}:{},button:r.jsxs("button",{type:"button",title:Y?`${f.chat.workspace}:${Y}`:f.chat.workspaceHint,"aria-label":f.chat.workspace,onClick:E,className:p5,children:[_("ml-0.5"),r.jsx("span",{className:`min-w-0 truncate ${Y?"font-mono":""}`,children:V}),r.jsx(Yn,{open:c,size:12,className:"shrink-0 text-gray-400"})]}),children:P})}const RD=300;function Nk(e){try{return sessionStorage.getItem(`penguin.chatRouteApplied.${e}`)}catch{return null}}function Tk(e,t){try{sessionStorage.setItem(`penguin.chatRouteApplied.${e}`,t)}catch{}}const ID={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"};function LD({projectId:e,models:t,draftId:a}){const i=ia(),l=ha(),{agents:c,currentAgent:u,setCurrentAgentId:m}=cn(),{add:p}=pi(),h=vn().user?.userId??null,[g]=x.useState(()=>a!==void 0&&(!h||Ck(h,e,a)===null)),[v]=x.useState(()=>h?a!==void 0?Ck(h,e,a)?.draft??{}:gi(Qr(h,e)):{});x.useEffect(()=>{g&&i("/chat/new",{replace:!0})},[g,i]);const[k,w]=x.useState(v.agentId??u?.agentId??null),[S,M]=x.useState(v.workspace??""),[C,T]=x.useState(v.approvalMode??"allow-all"),[I,D]=x.useState(v.modelRef??null),K=x.useRef(v.text??""),F=x.useRef(v.skills??[]),[E,B]=x.useState(null),Y=x.useRef(!1);x.useEffect(()=>{let W=!1;return qw(e).then(pe=>{!W&&!Y.current&&B(pe)}).catch(()=>{!W&&!Y.current&&B({})}),()=>{W=!0}},[e]);const V=x.useRef({agent:!1,workspace:!1,approval:!1}),O=l.state,U=O?.agentId,_=x.useRef(null),P=x.useRef(!1);x.useEffect(()=>{if(c.length===0)return;const W=pe=>!!pe&&c.some(Ne=>Ne.agentId===pe);if(U&&_.current!==l.key&&Nk("agentId")!==l.key&&(_.current=l.key,Tk("agentId",l.key),W(U))){w(U);return}if(E?.agentId!==void 0&&!P.current&&(P.current=!0,_.current===null&&v.agentId===void 0&&!V.current.agent&&W(E.agentId))){w(E.agentId);return}W(k)||w((c.find(pe=>pe.agentId==="default_agent")??c[0])?.agentId??null)},[c,k,l.key,U,E,v.agentId]);const H=O?.workspace,G=x.useRef(null);x.useEffect(()=>{H===void 0||G.current===l.key||Nk("workspace")===l.key||(G.current=l.key,Tk("workspace",l.key),M(H))},[l.key,H]);const z=x.useRef(!1);x.useEffect(()=>{E===null||z.current||(z.current=!0,E.workspace!==void 0&&H===void 0&&v.workspace===void 0&&!V.current.workspace&&M(E.workspace),E.approvalMode!==void 0&&v.approvalMode===void 0&&!V.current.approval&&T(E.approvalMode))},[E,H,v.workspace,v.approvalMode]),x.useEffect(()=>{if(!t||I&&t.models.some(pe=>_t(pe,I)))return;const W=t.models[0];D(t.defaultModel??(W?{provider:W.provider,modelId:W.modelId}:null))},[t,I]);const J=x.useCallback(W=>{if(W.defaults){const pe=W.defaults;Y.current=!0,B(pe),V.current={agent:!1,workspace:!1,approval:!1},M(pe.workspace??""),T(pe.approvalMode??"allow-all"),(Re=>Re!==void 0&&c.some(Pe=>Pe.agentId===Re))(pe.agentId)?w(pe.agentId):c.length>0&&w(u?.agentId??(c.find(Re=>Re.agentId==="default_agent")??c[0])?.agentId??null)}W.defaultModel!==void 0&&D(W.defaultModel)},[c,u]),xe=x.useRef(J);xe.current=J,x.useEffect(()=>{const W=pe=>{const Ne=m5(pe,e);Ne&&xe.current(Ne)};return window.addEventListener($c,W),()=>window.removeEventListener($c,W)},[e]);const[me,A]=x.useState(null);x.useEffect(()=>{if(A(null),!k)return;let W=!1;return el(e,k).then(pe=>{W||A(pe.config.model?.thinkingLevel??"")}).catch(()=>{}),()=>{W=!0}},[e,k]);const R=me===null||E===null?null:N7(me,E.thinkingLevel),q=x.useRef(null);q.current=me;const j=x.useCallback(W=>{if(!k||!W)return;const pe=q.current;A(W),Zi(e,k,{config:{model:{thinkingLevel:W}}}).catch(Ne=>{A(pe),Ve(Oe(Ne))})},[e,k]),[$,ae]=x.useState([]),[de,ye]=x.useState(!1);x.useEffect(()=>{if(ae(pe=>pe.length>0?[]:pe),ye(!1),!k)return;let W=!1;return hf(e,k).then(pe=>{W||ae(pe.skills)}).catch(()=>{}).finally(()=>{W||ye(!0)}),()=>{W=!0}},[e,k]);const Se=x.useRef(null),ke=x.useCallback(()=>{Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null)},[]),ee=x.useCallback(()=>{if(ke(),!h)return;const W={text:K.current,workspace:S,approvalMode:C};k&&(W.agentId=k),I&&(W.modelRef=I),F.current.length>0&&(W.skills=F.current),a!==void 0?ED(h,e,a,W):js(Qr(h,e),W)},[ke,h,e,a,k,S,C,I]),je=x.useRef(ee);x.useEffect(()=>{je.current=ee,ee()},[ee]);const Ae=x.useCallback(W=>{K.current=W,ke(),Se.current=window.setTimeout(()=>{Se.current=null,je.current()},RD)},[ke]),Qe=x.useCallback(W=>{F.current=W,je.current()},[]);x.useEffect(()=>()=>{Se.current!==null&&(window.clearTimeout(Se.current),je.current())},[]),x.useEffect(()=>{const W=()=>{Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null,je.current())};return window.addEventListener(yg,W),()=>window.removeEventListener(yg,W)},[]);const We=x.useCallback(()=>{if(ke(),F.current=[],K.current="",!!h){if(a!==void 0){f5(h,e,a);return}I?js(Qr(h,e),{modelRef:I}):zc(Qr(h,e))}},[ke,h,e,a,I]),re=W=>{V.current.agent=!0,w(W.agentId),m(W.agentId)},ft=x.useCallback(W=>{V.current.workspace=!0,M(W)},[]),ge=x.useCallback(W=>{V.current.approval=!0,T(W)},[]),dt=x.useRef(!1),[It,zt]=x.useState(!1),nn=x.useCallback(async(W,pe=!1,Ne=null)=>{if(!k||dt.current)return!1;dt.current=!0,zt(!0);let Re=null;try{const Pe={approvalMode:C};I&&(Pe.modelId=I.modelId,Pe.provider=I.provider),S.trim()&&(Pe.workspace=S.trim());const Fe=await Dh(e,k,Pe);Re=Fe.session.sessionId;const nt=await fc(Re,{input:W,...Ne?{goal:Ne}:{}});return p(Fe.session),pe||We(),i(`/chat/${nt.sessionId}`,{replace:!0}),!0}catch(Pe){return Re&&Bd(Re).catch(()=>{}),Ve(Oe(Pe,I?{modelId:I.modelId}:{})),!1}finally{dt.current=!1,zt(!1)}},[e,k,C,I,S,p,We,i]),[un,Wt]=x.useState(null),Ce=x.useCallback(async W=>{if(un===null){Wt(W.id);try{const pe=W.skills.filter(Ne=>$.some(Re=>Re.name===Ne));await nn([{type:"text",text:Kh(pe,f.chat.exampleTasks[W.id].prompt)}],!0)}finally{Wt(null)}}},[un,$,nn]),[Ke,se]=x.useState(xg[0].id),ce=c.find(W=>W.agentId===k)??null,De=t?.models.find(W=>_t(W,I)),Be=De?.contextWindow,Ue=De?.vision!==!1;return r.jsxs("div",{className:"anim-fade flex min-h-0 flex-1 flex-col overflow-y-auto px-3 py-6 md:px-4",children:[r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"mx-auto w-full max-w-3xl",children:[r.jsxs("div",{className:"mb-10 text-center",children:[r.jsx(l5,{className:"mx-auto mb-1 h-36 w-36 rounded-3xl"}),r.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-gray-900 dark:text-gray-100",children:f.appName}),r.jsx("p",{className:"mt-2 text-base text-gray-400 dark:text-gray-500",children:f.chat.draftSubtitle}),r.jsx(OD,{})]}),r.jsx(e5,{status:"idle",onSend:(W,pe)=>nn(W,!1,pe),onStop:async()=>{},onCompact:async()=>{},modelRef:I,models:t?.models??[],onChangeModel:D,thinkingLevel:R,onChangeThinkingLevel:j,...t?.defaultModel!==void 0?{defaultModel:t.defaultModel}:{},...Be!==void 0?{contextWindow:Be}:{},contextNow:0,vision:Ue,approvalMode:C,onChangeApprovalMode:ge,modeSaving:!1,autoFocus:!0,agents:c,...k?{currentAgentId:k}:{},skills:$,...v.skills&&v.skills.length>0?{initialSkills:v.skills}:{},onSkillsChange:Qe,initialText:v.text??"",onTextChange:Ae}),r.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[r.jsx(DD,{agents:c,selected:ce,onSelect:re}),r.jsx(If,{projectId:e,workspace:S,onChange:ft})]}),r.jsx("div",{className:"mt-6 space-y-1",children:xg.map(W=>{const pe=W.id===Ke;return r.jsxs("div",{children:[r.jsxs("button",{type:"button","aria-expanded":pe,onClick:()=>se(W.id),className:`flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 ${pe?"bg-gray-100 dark:bg-gray-800/70":"hover:bg-gray-100 dark:hover:bg-gray-800/70"}`,children:[r.jsx("span",{className:"shrink-0 text-brand-500 dark:text-brand-400",children:r.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:r.jsx("path",{d:ID[W.id]})})}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-gray-700 dark:text-gray-300",children:f.chat.exampleFolders[W.id]}),r.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:W.tasks.length}),r.jsx(Yn,{open:pe,size:14,className:"text-gray-400"})]}),pe&&r.jsx("ul",{className:"mt-0.5 space-y-0.5 pl-4",children:W.tasks.map(Ne=>{const Re=f.chat.exampleTasks[Ne.id];return r.jsx("li",{children:r.jsxs("button",{type:"button",title:Re.desc,disabled:un!==null||It||!de||!k||!t,onClick:()=>{Ce(Ne)},className:"flex w-full items-center gap-2 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",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:Re.label}),un===Ne.id&&r.jsx("span",{className:"shrink-0 text-xs text-gray-400",children:f.common.loading})]})},Ne.id)})})]},W.id)})})]}),r.jsx("div",{className:"flex-1"})]})}const Mk="ml-1.5 inline-block align-super text-[10px] leading-4 text-gray-400 dark:text-gray-500";function OD(){const{locale:e}=Za(),{version:t,update:a}=Gg(!0);if(t===null)return null;const i=t.buildDate;return r.jsxs("p",{className:"mt-1.5 text-xs text-gray-400 dark:text-gray-500",children:[`v${t.version}${i!==null?` · ${f.update.lastUpdated(Gd(i,e))}`:""}`,a!==null&&a.updateAvailable&&a.latestVersion!==null&&(a.releaseUrl!==null?r.jsx("a",{href:a.releaseUrl,target:"_blank",rel:"noopener noreferrer",title:f.update.newVersion(a.latestVersion),"aria-label":f.update.newVersion(a.latestVersion),className:`${Mk} hover:underline`,children:f.update.newVersionBadge}):r.jsx("span",{className:Mk,children:f.update.newVersionBadge}))]})}function DD({agents:e,selected:t,onSelect:a}){const[i,l]=x.useState(!1);return r.jsx(Un,{open:i,setOpen:l,menuClass:"left-0 top-full mt-1 w-72 max-w-[calc(100vw-2rem)] origin-top-left",button:r.jsxs("button",{type:"button",title:f.chat.chooseAgent,"aria-label":f.chat.chooseAgent,onClick:()=>l(!i),className:p5,children:[t?r.jsx(Da,{id:t.agentId,name:pn(t),size:16,className:"shrink-0 rounded"}):null,r.jsx("span",{className:"min-w-0 truncate",children:t?pn(t):f.common.loading}),r.jsx(Yn,{open:i,size:12,className:"shrink-0 text-gray-400"})]}),children:r.jsxs("div",{className:"max-h-56 overflow-y-auto",children:[e.length===0&&r.jsx("p",{className:"px-3 py-1.5 text-xs text-gray-400",children:f.common.loading}),e.map(c=>{const u=c.agentId===t?.agentId;return r.jsxs("button",{type:"button","aria-pressed":u,onClick:()=>{a(c),l(!1)},className:"flex w-full items-center gap-2.5 px-3 py-1.5 text-left transition-colors duration-150 hover:bg-gray-100 dark:hover:bg-gray-800",children:[r.jsx(Da,{id:c.agentId,name:pn(c),size:20,className:"shrink-0 rounded"}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.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:pn(c)}),c.description&&r.jsx("span",{className:"block truncate text-[11px] text-gray-400 dark:text-gray-500",children:c.description})]}),r.jsx("span",{className:"w-4 shrink-0 text-center text-xs text-gray-500 dark:text-gray-400",children:u?"✓":""})]},c.agentId)})]})})}function h5(){return{sessionId:null,taskCount:0,sessionCost:null,costUncosted:!1,settledUsd:0,lastLiveUsd:0,liveAtFetchUsd:0,pendingFetchSnapshot:!1,shownUsd:null,shownUncosted:!1}}function UD(e,t,a){e.sessionId===t&&a!==null&&(e.costUncosted=a.hasUncosted,a.cost!=null&&(e.sessionCost=a.cost,e.settledUsd=0,e.pendingFetchSnapshot=!0))}function Ak(e){return e.sessionCost!=null||e.settledUsd>0?(e.sessionCost??0)+e.settledUsd:null}function Ek(e,t,a,i){return t!=null&&(e.shownUsd=t,e.shownUncosted=a),{costText:t!=null?Dr(t,i):null,costUncosted:a}}function zD(e,t){if(t.sessionId!==e.sessionId&&Object.assign(e,h5(),{sessionId:t.sessionId}),t.loading){const m=e.shownUsd??Ak(e),p=e.shownUsd!=null?e.shownUncosted:e.costUncosted;return Ek(e,m,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 m=t.taskOpen?t.liveUsd??0:0;e.liveAtFetchUsd=m,e.lastLiveUsd=m}(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 a=Ak(e),i=t.taskOpen&&t.liveUsd!=null?Math.max(0,t.liveUsd-e.liveAtFetchUsd):null,l=i!=null&&(i>0||a!=null)?(a??0)+i:a;let c;l==null||t.taskOpen&&e.shownUsd!=null&&l<e.shownUsd?c=e.shownUsd:c=l;const u=l==null?e.shownUncosted:e.costUncosted;return Ek(e,c,u,t.currency)}const kg={damping:1,response:.35},_k={damping:.8,response:.3};function $D(e,t,a,i,l){const c=2*Math.PI/i.response,u=c*c,m=2*i.damping*c;let p=e,h=t,g=Math.min(l,64);for(;g>0;){const v=Math.min(g,8)/1e3,k=-u*(p-a)-m*h;h+=k*v,p+=h*v,g-=8}return[p,h]}function Rk(e,t,a){return Math.abs(e-a)<.5&&Math.abs(t)<5}function PD(e,t){let a=e,i=0,l=e,c=kg,u,m=0,p=0;const h=()=>{m&&cancelAnimationFrame(m),m=0,p=0,u=void 0},g=v=>{const k=p?v-p:16;if(p=v,[a,i]=$D(a,i,l,c,k),Rk(a,i,l)){a=l,i=0,m=0,p=0,t(a);const w=u;u=void 0,w?.();return}t(a),m=requestAnimationFrame(g)};return{get value(){return a},get velocity(){return i},animateTo(v,k,w){if(l=v,c=k,w?.velocity!==void 0&&(i=w.velocity),u=w?.onSettle,Rk(a,i,l)){a=l,i=0,t(a);const S=u;u=void 0,S?.();return}m||(m=requestAnimationFrame(g))},stop(){return h(),[a,i]},set(v){h(),a=v,i=0,t(a)},dispose:h}}function BD(e,t=.998){return e/1e3*t/(1-t)}function HD(e,t,a=.55){return e*t*a/(t+a*Math.abs(e))}function FD(e,t){let a=t[0];for(const i of t)Math.abs(i-e)<Math.abs(a-e)&&(a=i);return a}const VD=.92,qD=.6;function GD(){const[e,t]=x.useState(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches);return x.useEffect(()=>{const a=window.matchMedia("(prefers-reduced-motion: reduce)"),i=l=>t(l.matches);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),e}function U0({open:e,snap:t,onSnapChange:a,onClose:i,title:l,children:c}){const[u,m]=x.useState(e),p=x.useRef(null),h=x.useRef(null),g=x.useRef(null),v=x.useRef(0),k=x.useRef(!1),w=x.useRef(!1),S=x.useRef(null),M=x.useRef([]),C=x.useRef({pointerY:0,sheetY:0}),T=x.useRef(e);T.current=e;const I=x.useRef(null),D=GD(),K=x.useCallback(U=>{const _=v.current||1;p.current&&(p.current.style.transform=`translate3d(0, ${U}px, 0)`),h.current&&(h.current.style.opacity=String(Math.min(1,Math.max(0,1-U/_))))},[]),F=x.useCallback(U=>{const _=v.current;return U==="full"?0:_*(1-qD/VD)},[]);x.useEffect(()=>{e&&m(!0)},[e]),x.useLayoutEffect(()=>{if(!u)return;const U=p.current;U&&(v.current=U.offsetHeight,g.current||(g.current=PD(v.current,K),g.current.set(v.current)))},[u,K]),x.useEffect(()=>{if(!u)return;const U=g.current;if(U)if(e){if(w.current=!1,k.current)return;const _=F(t);if(S.current!==null&&Math.abs(S.current-_)<1)return;if(S.current=_,D){U.set(_);return}U.animateTo(_,kg)}else{if(w.current=!0,S.current=v.current,D){m(!1);return}U.animateTo(v.current,kg,{onSettle:()=>m(!1)})}},[u,e,t,D,F]),x.useEffect(()=>{u||(g.current?.dispose(),g.current=null,S.current=null,k.current=!1,w.current=!1)},[u]),x.useEffect(()=>()=>g.current?.dispose(),[]),x.useEffect(()=>{if(!u)return;const U=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=U}},[u]),x.useEffect(()=>{if(!u||!e)return;const U=_=>{_.key==="Escape"&&i()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[u,e,i]),x.useEffect(()=>{if(u)return I.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>I.current?.focus()},[u]),x.useEffect(()=>{if(!u)return;const U=()=>{const _=p.current;if(!_||(v.current=_.offsetHeight,k.current||w.current))return;const P=F(t);S.current=P,g.current?.set(P)};return window.addEventListener("resize",U),()=>window.removeEventListener("resize",U)},[u,t,F]);const E=U=>{if(w.current)return;const _=g.current;if(!_)return;U.currentTarget.setPointerCapture(U.pointerId);const[P]=_.stop();k.current=!0,C.current={pointerY:U.clientY,sheetY:P},M.current=[{y:U.clientY,t:performance.now()}]},B=U=>{if(!k.current)return;const _=g.current;if(!_)return;const P=C.current.sheetY+(U.clientY-C.current.pointerY),H=v.current,G=P<0?-HD(-P,H):Math.min(P,H);_.set(G);const z=performance.now(),J=M.current;for(J.push({y:U.clientY,t:z});J.length>2&&z-J[0].t>100;)J.shift()},Y=U=>{k.current=!1;const _=g.current;if(!_)return;const P=v.current,H=F("half"),G=T.current?_.value+BD(U):P,z=FD(G,[0,H,P]);if(S.current=z,z===P){if(w.current=!0,D){m(!1),i();return}_.animateTo(P,_k,{velocity:U,onSettle:()=>{m(!1),i()}});return}_.animateTo(z,_k,{velocity:U});const J=z===0?"full":"half";J!==t&&a?.(J)},V=()=>{if(!k.current)return;const U=M.current,_=U[U.length-1],P=U[0],H=_&&P?_.t-P.t:0;Y(H>0?(_.y-P.y)/H*1e3:0)},O=()=>{k.current&&Y(0)};return u?r.jsxs("div",{className:"fixed inset-0 z-50",role:"dialog","aria-modal":"true","aria-label":l,children:[r.jsx("div",{ref:h,className:`absolute inset-0 bg-black/45 ${D?"anim-fade":""}`,style:{opacity:0},onPointerDown:()=>i()}),r.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 ${D?"anim-fade":""}`,style:{transform:"translate3d(0, 100%, 0)"},children:[r.jsxs("div",{className:"shrink-0 cursor-grab touch-none select-none active:cursor-grabbing",onPointerDown:E,onPointerMove:B,onPointerUp:V,onPointerCancel:O,onLostPointerCapture:O,children:[r.jsx("div",{className:"mx-auto mt-2 h-1 w-9 rounded-full bg-gray-300 dark:bg-gray-600"}),r.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 pt-1.5",children:[r.jsx("span",{className:"text-base font-semibold",children:l??""}),r.jsx(Wg,{onClose:i,onPointerDown:U=>U.stopPropagation()})]})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain pb-[env(safe-area-inset-bottom)]",children:c})]})]}):null}function Lf(e){return r.jsx("span",{className:"relative",children:r.jsx("input",{type:"file",className:"sr-only",...e})})}const g5=new Set(["text","plaintext","txt"]),WD=new Map(Object.entries({c:()=>ln(()=>import("./c-BIGW1oBm.js"),[]),cpp:()=>ln(()=>import("./cpp-DIPi6g--.js"),__vite__mapDeps([0,1,2])),css:()=>ln(()=>import("./css-CLj8gQPS.js"),[]),diff:()=>ln(()=>import("./diff-D97Zzqfu.js"),[]),go:()=>ln(()=>import("./go-C27-OAKa.js"),[]),html:()=>ln(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),ini:()=>ln(()=>import("./ini-BEwlwnbL.js"),[]),java:()=>ln(()=>import("./java-CylS5w8V.js"),[]),javascript:()=>ln(()=>import("./javascript-wDzz0qaB.js"),[]),json:()=>ln(()=>import("./json-Cp-IABpG.js"),[]),jsx:()=>ln(()=>import("./jsx-g9-lgVsj.js"),[]),log:()=>ln(()=>import("./log-2UxHyX5q.js"),[]),markdown:()=>ln(()=>import("./markdown-Cvjx9yec.js"),[]),php:()=>ln(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([6,3,4,5,7,8,2,9])),python:()=>ln(()=>import("./python-B6aJPvgy.js"),[]),ruby:()=>ln(()=>import("./ruby-B13GW9FM.js"),__vite__mapDeps([10,3,4,5,7,8,2,11,12,13,0,1,14,15])),rust:()=>ln(()=>import("./rust-B1yitclQ.js"),[]),shellscript:()=>ln(()=>import("./shellscript-Yzrsuije.js"),[]),sql:()=>ln(()=>import("./sql-CRqJ_cUM.js"),[]),toml:()=>ln(()=>import("./toml-vGWfd6FD.js"),[]),tsx:()=>ln(()=>import("./tsx-COt5Ahok.js"),[]),typescript:()=>ln(()=>import("./typescript-BPQ3VLAy.js"),[]),xml:()=>ln(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])),yaml:()=>ln(()=>import("./yaml-Buea-lGh.js"),[])})),KD=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"})),YD=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"})),x5="text";function QD(e){return YD.get(e.toLowerCase())??x5}function jP(e){const t=e.trim().toLowerCase();if(!t||g5.has(t))return x5;const a=KD.get(t)??t;return WD.has(a)?a:void 0}function CP(e){return g5.has(e)}const XD=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"]),ZD=new Set(["png","jpg","jpeg","gif","webp","svg"]),JD=new Set(["html","htm"]),vd=256*1024,Ik=64*1024;function Lk(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():e.toLowerCase()}function Ok(e){return e.includes("/")?e.slice(0,e.lastIndexOf("/")):""}const Dk=/^[a-z][a-z0-9+.-]*:/i;function Uk(e,t){const a=t.startsWith("/")||e===""?[]:e.split("/");for(const i of t.split("/"))i===""||i==="."||(i===".."?a.pop():a.push(i));return a.join("/")}const xh="<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 e9(e){return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,t=>t+xh):/<html[^>]*>/i.test(e)?e.replace(/<html[^>]*>/i,t=>t+xh):xh+e}let bd=0;function zk({session:e,openRequest:t,active:a,onPreviewOpen:i}){const{previewIsolated:l}=vn(),[c,u]=x.useState(""),[m,p]=x.useState(null),[h,g]=x.useState(null),[v,k]=x.useState(null),[w,S]=x.useState(!1),[M,C]=x.useState(null),[T,I]=x.useState(0),[D,K]=x.useState(!1),[F,E]=x.useState("rendered"),[B,Y]=x.useState(null),V=x.useRef(l);V.current=l,x.useEffect(()=>{let A=!1;return g(null),Z4(e.sessionId,c).then(R=>{A||p({base:c,res:R})}).catch(R=>{A||g(R instanceof sa?R.message:f.files.loadFailed)}),()=>{A=!0}},[e.sessionId,c,T]);const[O,U]=x.useState(e.sessionId);O!==e.sessionId&&(U(e.sessionId),u(""),k(null),p(null),Y(null),bd++);const _=x.useRef(a);x.useEffect(()=>{a&&!_.current&&I(A=>A+1),_.current=a},[a]);const P=x.useRef(i);P.current=i;const H=x.useCallback(async A=>{P.current?.();const R=A.includes("/")?A.slice(A.lastIndexOf("/")+1):A,q=Lk(R),j=++bd,$=ye=>{j===bd&&k(ye)};if(E("rendered"),Y(null),ZD.has(q)){$({path:A,name:R,kind:"image",nonce:j});return}if(q==="pdf"){$({path:A,name:R,kind:"pdf",nonce:j});return}const ae=JD.has(q),de=q==="md";if(!ae&&!XD.has(q)){$({path:A,name:R,kind:"unsupported",nonce:j});return}if(ae&&V.current){$({path:A,name:R,kind:"html",nonce:j});return}try{const ye=await fetch(ti(e.sessionId,A),{credentials:"same-origin"});if(!ye.ok)throw new Error(String(ye.status));const Se=await ye.text(),ke=Se.length>vd;de&&Se.length>Ik&&j===bd&&E("source"),$({path:A,name:R,kind:ae?"html":de?"md":"text",content:ke?Se.slice(0,vd):Se,truncated:ke,nonce:j})}catch{$({path:A,name:R,kind:"unsupported",nonce:j})}},[e.sessionId]);x.useEffect(()=>{if(v?.kind!=="html"||v.content!==void 0||F!=="source"&&l)return;const A=v.path;let R=!1;return Y(null),(async()=>{try{const q=await fetch(ti(e.sessionId,A),{credentials:"same-origin"});if(!q.ok)throw new Error(String(q.status));const j=await q.text();if(R)return;const $=j.length>vd;k(ae=>ae!==null&&ae.kind==="html"&&ae.path===A&&ae.content===void 0?{...ae,content:$?j.slice(0,vd):j,truncated:$}:ae)}catch{R||Y(f.files.loadFailed)}})(),()=>{R=!0}},[v,F,l,e.sessionId]);const G=x.useRef(null);x.useEffect(()=>{if(!t||G.current===t)return;G.current=t;const A=t.path,R=A.includes("/")?A.slice(0,A.lastIndexOf("/")):"";u(R),I(q=>q+1),H(A)},[t,H]);const z=A=>{S(!0),g(null),(async()=>{try{for(const R of A){const q=await new Promise((j,$)=>{const ae=new FileReader;ae.onload=()=>{const de=ae.result;j(de.slice(de.indexOf(",")+1))},ae.onerror=()=>$(new Error("read failed")),ae.readAsDataURL(R)});await J4(e.sessionId,Ud(c,R.name),q)}Ut(f.files.uploaded),I(R=>R+1)}catch(R){Ve(Oe(R))}finally{S(!1)}})()},J=A=>{const R=A.target.files?[...A.target.files]:[];if(A.target.value="",R.length===0)return;const q=new Set((m?.res.entries??[]).map($=>$.name)),j=R.filter($=>q.has($.name)).map($=>$.name);j.length>0?C({files:R,clashes:j}):z(R)},xe=c===""?[]:c.split("/"),me=h===null&&m!==null&&m.base!==c;return v!==null?r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[r.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:[r.jsxs("button",{type:"button",onClick:()=>{k(null),I(A=>A+1)},title:f.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:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r.jsx("path",{d:"M15 18l-6-6 6-6"})}),f.files.backToList]}),r.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")&&r.jsx("div",{className:"flex shrink-0 rounded-md bg-gray-100 p-0.5 dark:bg-gray-800",children:[["rendered",f.files.htmlRendered],["source",f.files.htmlSource]].map(([A,R])=>r.jsx("button",{type:"button",onClick:()=>E(A),className:`rounded px-2 py-0.5 text-xs transition-colors duration-150 ${F===A?"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:R},A))}),/\.html?$/i.test(v.name)&&r.jsxs("a",{href:Ab(e.sessionId,v.path),target:"_blank",rel:"noopener noreferrer",title:l?void 0:f.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:[f.files.openInNewTab,!l&&r.jsx("span",{"aria-label":f.files.previewNotIsolatedHint,className:"text-amber-600 dark:text-amber-500",children:"⚠"})]}),r.jsx("a",{href:ti(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:f.files.download})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:v.kind==="image"?r.jsx("img",{src:ti(e.sessionId,v.path),alt:v.name,className:"max-w-full rounded-md border border-gray-200 dark:border-gray-800"}):v.kind==="pdf"?r.jsx("iframe",{src:ti(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.kind==="html"&&F==="rendered"?l?r.jsx("iframe",{src:Ab(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?B!==null?r.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:B}):r.jsx(La,{rows:6}):r.jsx("iframe",{srcDoc:e9(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"&&F==="rendered"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"md-body text-base leading-relaxed text-gray-800 dark:text-gray-100",children:r.jsx(Zc,{remarkPlugins:[Jc],components:{img:({src:A,alt:R})=>r.jsx("img",{src:typeof A=="string"&&!Dk.test(A)?ti(e.sessionId,Uk(Ok(v.path),A)):A,alt:R??"",loading:"lazy",className:"max-w-full"}),a:({href:A,children:R})=>{if(typeof A!="string"||A.startsWith("#"))return r.jsx("a",{href:A,children:R});if(Dk.test(A))return r.jsx("a",{href:A,target:"_blank",rel:"noreferrer",children:R});const q=Uk(Ok(v.path),A);return r.jsx("a",{href:ti(e.sessionId,q),onClick:j=>{j.preventDefault(),H(q)},children:R})}},children:v.content??""})}),v.truncated&&r.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["… ",f.files.previewTruncated]})]}):v.kind==="text"||v.kind==="html"||v.kind==="md"?v.content===void 0?B!==null?r.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:B}):r.jsx(La,{rows:6}):r.jsxs(r.Fragment,{children:[r.jsx(T0,{language:QD(Lk(v.name)),code:v.content,highlight:v.content.length<=Ik}),v.truncated&&r.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["… ",f.files.previewTruncated]})]}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:f.files.previewUnsupported})})]}):r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[r.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:[r.jsx("button",{type:"button",disabled:me,onClick:()=>{u("")},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:f.files.root}),xe.map((A,R)=>r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-gray-300 dark:text-gray-700",children:"/"}),r.jsx("button",{type:"button",disabled:me,onClick:()=>u(xe.slice(0,R+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:A})]},R)),r.jsx("span",{className:"flex-1"}),r.jsx(Un,{open:D,setOpen:K,menuClass:"right-0 top-full mt-1 w-max max-w-72 origin-top-right",button:r.jsx(ve,{size:"sm",variant:D?"primary":"ghost",onClick:()=>K(A=>!A),children:f.files.details}),children:r.jsxs("div",{className:"px-3.5 py-2.5",children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.files.workspacePath}),r.jsx("p",{className:"mt-1 break-all font-mono text-xs leading-5",children:e.workspace})]})}),r.jsx(ve,{size:"sm",variant:"ghost",onClick:()=>I(A=>A+1),children:f.files.refresh}),r.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:[r.jsx(Lf,{multiple:!0,onChange:J,disabled:w}),w?f.common.saving:f.files.upload]})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:h?r.jsx("p",{className:"px-3 py-3 text-sm text-red-600 dark:text-red-400",children:h}):m===null?r.jsx(La,{rows:6}):m.res.entries.length===0?r.jsx("p",{className:"px-3 py-3 text-sm text-gray-400",children:f.files.empty}):r.jsx("ul",{"aria-busy":me,className:`divide-y divide-gray-100 dark:divide-gray-800/60 ${me?"opacity-60":""}`,children:m.res.entries.map(A=>r.jsx("li",{children:r.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:[r.jsxs("button",{type:"button",disabled:me,onClick:()=>{const R=Ud(m.base,A.name);A.kind==="dir"?u(R):H(R)},className:"flex min-w-0 flex-1 items-center gap-2 text-left",title:A.name,children:[r.jsx("span",{className:"shrink-0 text-gray-400","aria-hidden":!0,children:A.kind==="dir"?r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:r.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"})}):r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",children:r.jsx("path",{d:"M6 3h8l4 4v14H6zM14 3v4h4"})})}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:A.name})]}),r.jsx("span",{className:"shrink-0 font-mono text-xs text-gray-400 dark:text-gray-500",children:A.kind==="file"?_c(A.sizeBytes):""}),r.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 sm:block dark:text-gray-500",children:A.mtime?Oa(A.mtime):""}),A.kind==="file"&&r.jsx("a",{href:ti(e.sessionId,Ud(m.base,A.name),!0),download:A.name,title:f.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:r.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:r.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M4 21h16"})})})]})},A.name))})}),r.jsx(yn,{open:M!==null,title:f.files.overwriteTitle,tone:"primary",confirmLabel:f.files.upload,onClose:()=>C(null),onConfirm:()=>{M&&z(M.files),C(null)},children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.files.overwriteConfirm(M?.clashes.length??0)}),r.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:(M?.clashes??[]).map(A=>r.jsx("li",{className:"truncate py-0.5 font-mono text-xs",title:A,children:A},A))})]})})]})}function t9(){return r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})}function n9({session:e,panel:t}){return t.isDocked?r.jsxs(r.Fragment,{children:[t.open&&r.jsx("div",{onMouseDown:t.startResize,onDoubleClick:t.resetWidth,title:f.files.resizeHandle,className:`w-1.5 shrink-0 cursor-col-resize transition-colors duration-150 hover:bg-brand-300/50 dark:hover:bg-brand-700/40 ${t.resizing?"bg-brand-400/60":"bg-transparent"}`}),r.jsx("div",{ref:t.panelRef,style:{width:t.open?t.width:0},inert:!t.open,className:`relative flex min-h-0 shrink-0 flex-col overflow-hidden ${t.open?"border-l border-gray-200 dark:border-gray-800":""} ${t.resizing?"pointer-events-none":"transition-[width] duration-200"}`,children:r.jsxs("div",{style:{width:t.width},className:"flex h-full min-h-0 flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-3 pt-2",children:[r.jsx("h4",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:f.files.title}),r.jsx("button",{type:"button",onClick:()=>t.setOpen(!1),title:f.common.close,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:r.jsx(t9,{})})]}),r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(zk,{session:e,openRequest:t.openRequest,active:t.open})})]})})]}):r.jsx(U0,{open:t.open,snap:t.sheetSnap,onSnapChange:t.setSheetSnap,onClose:()=>t.setOpen(!1),title:f.files.title,children:r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(zk,{session:e,openRequest:t.openRequest,active:t.open,onPreviewOpen:()=>t.setSheetSnap("full")})})})})}const Of=320,cf="penguin.panelWidth",a9=["penguin.filesPanelWidth","penguin.subagentsPanelWidth"];function uf(e){return Math.max(Of,Math.min(720,Math.round(e*.5)))}function y5(e){return Math.min(uf(e),Math.max(Of,Math.round(e*.4)))}function r9(){try{const e=Number(localStorage.getItem(cf));if(Number.isFinite(e)&&e>0)return e;let t=null;for(const a of a9){const i=Number(localStorage.getItem(a));Number.isFinite(i)&&i>0&&(t=Math.max(t??0,i)),localStorage.removeItem(a)}return t!==null&&localStorage.setItem(cf,String(Math.round(t))),t}catch{return null}}function s9(){const e=r9();return e===null?y5(window.innerWidth):Math.min(uf(window.innerWidth),Math.max(Of,Math.round(e)))}const Pc=ao(()=>({width:null}));function yh(){const{width:e}=Pc.getState();if(e!==null)return e;const t=s9();return Pc.setState({width:t}),t}function vh(e){e!==Pc.getState().width&&Pc.setState({width:e})}function v5(){const e=ro(Pc,()=>yh()),[t,a]=x.useState(!1),i=x.useRef(null);x.useEffect(()=>{if(!t)return;const u=p=>{const h=i.current?.getBoundingClientRect(),g=h?h.right:window.innerWidth;vh(Math.min(uf(window.innerWidth),Math.max(Of,g-p.clientX)))},m=()=>{a(!1);try{localStorage.setItem(cf,String(Math.round(yh())))}catch{}};return document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",u),window.addEventListener("mouseup",m),()=>{document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",m)}},[t]);const l=x.useCallback(u=>{u.preventDefault(),a(!0)},[]),c=x.useCallback(()=>{vh(y5(window.innerWidth));try{localStorage.removeItem(cf)}catch{}},[]);return x.useEffect(()=>{const u=()=>vh(Math.min(yh(),uf(window.innerWidth)));return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]),{width:e,resizing:t,startResize:l,resetWidth:c,panelRef:i}}const $k="(min-width: 1024px)";function i9(e){const[t,a]=x.useState(!1),[i,l]=x.useState("half"),[c,u]=x.useState(null),m=x.useCallback(k=>{k&&l("half"),a(k)},[]),p=v5(),[h,g]=x.useState(()=>window.matchMedia($k).matches);x.useEffect(()=>{u(null)},[e]),x.useEffect(()=>{const k=window.matchMedia($k),w=S=>g(S.matches);return k.addEventListener("change",w),()=>k.removeEventListener("change",w)},[]);const v=x.useCallback(k=>{l("full"),u({path:k})},[]);return{open:t,setOpen:m,sheetSnap:i,setSheetSnap:l,browsePath:v,openRequest:c,isDocked:h,...p}}function l9({nodes:e,selectedId:t,labelFor:a,onSelect:i}){const l=NO(e);return r.jsx("div",{role:"group","aria-label":f.subagentPanel.topologyLabel,className:"overflow-x-auto",children:r.jsxs("div",{className:"relative",style:{width:l.width,height:l.height},children:[r.jsx("svg",{width:l.width,height:l.height,className:"absolute inset-0 text-gray-300 dark:text-gray-700","aria-hidden":!0,children:l.edges.map(c=>r.jsx("path",{d:c.path,fill:"none",stroke:"currentColor",strokeWidth:"1.5"},`${c.fromId}>${c.toId}`))}),l.nodes.map(({node:c,x:u,y:m})=>{const p=a(c),h=c.sessionId===t,g=c.running?f.subagentPanel.nodeRunning:f.subagentPanel.nodeDone,v=c.description!==null?`${p} · ${g}
174
- ${c.description}`:`${p} · ${g}`;return r.jsxs("button",{type:"button","aria-label":`${p} · ${g}`,"aria-pressed":h,title:v,onClick:()=>i(c),style:{left:u,top:m,width:$d,height:mc},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:[r.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[r.jsx(Da,{id:c.agentId??c.sessionId,name:p,size:18}),r.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&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:r.jsx(Jl,{sinceMs:c.startedMs})}):c.elapsedMs!==void 0&&r.jsx("span",{className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:An(c.elapsedMs)}),r.jsx(rl,{state:c.running?"running":"done",size:10})]}),c.description!==null&&r.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 o9({session:e,model:t,version:a,taskRunning:i,ctx:l,focusRequest:c,taskScope:u}){const{agents:m}=cn(),{sessions:p}=pi(),[h,g]=x.useState(null);x.useEffect(()=>{c&&g({sessionId:c.sessionId,origin:c.origin})},[c]);const v=x.useMemo(()=>(u?SO(t,e.sessionId,i,u.anchorSessionId):null)??wO(t,e.sessionId,i),[t,a,e.sessionId,i,u]),k=v.find(F=>F.depth>0)??null,w=h??(k?{sessionId:k.sessionId,origin:k.origin}:null),S=F=>{if(F.depth===0){const E=m.find(B=>B.agentId===e.agentId);return E?E.name?.length?E.name:E.agentId:e.agentId}return dg(F,m,p)??fg(F.sessionId)},M=w!==null&&w.origin.length===0,C=w?v.find(F=>F.sessionId===w.sessionId)??null:null,T=w&&!M?CO(t,w.origin):null,I=C?S(C):w?dg({sessionId:w.sessionId,agentId:T?.meta?.agentId??null},m,p)??f.chat.subagent:"",D=C?.running??!1,K=w?{...l,origin:w.origin,taskRunning:D}:null;return r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[r.jsxs("div",{className:"shrink-0 border-b border-gray-200 px-3 pb-2 pt-1.5 dark:border-gray-800",children:[r.jsx("p",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:f.subagentPanel.topologyLabel}),v.length>1?r.jsx("div",{className:"max-h-48 overflow-y-auto",children:r.jsx(l9,{nodes:v,selectedId:w?.sessionId??null,labelFor:S,onSelect:F=>g({sessionId:F.sessionId,origin:F.origin})})}):r.jsx("p",{className:"py-1 text-xs text-gray-400 dark:text-gray-500",children:f.subagentPanel.empty})]}),w===null?r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Xr,{title:f.subagentPanel.empty})}):M?r.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4",children:r.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500",children:f.subagentPanel.mainSessionNote})}):T===null?r.jsx("div",{className:"min-h-0 flex-1",children:r.jsx(Xr,{title:f.subagentPanel.empty})}):r.jsxs(r.Fragment,{children:[r.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:[r.jsx(Da,{id:T.meta?.agentId??w.sessionId,name:I,size:16}),r.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-gray-700 dark:text-gray-300",children:I}),r.jsx("span",{title:w.sessionId,className:"shrink-0 font-mono text-[10px] text-gray-400 dark:text-gray-500",children:fg(w.sessionId)}),D&&r.jsx(rl,{state:"running",size:10,label:f.chat.subagentRunning})]}),r.jsx("div",{className:"min-h-0 flex-1",children:K&&r.jsx(Pj,{items:T.items,version:a,ctx:K},w.sessionId)})]})]})}function c9(){return r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})}function u9({session:e,panel:t,model:a,version:i,taskRunning:l,ctx:c}){const u=r.jsx(o9,{session:e,model:a,version:i,taskRunning:l,ctx:c,focusRequest:t.focusRequest,taskScope:t.taskScope},e.sessionId);return t.isDocked?r.jsxs(r.Fragment,{children:[t.open&&r.jsx("div",{onMouseDown:t.startResize,onDoubleClick:t.resetWidth,title:f.files.resizeHandle,className:`w-1.5 shrink-0 cursor-col-resize transition-colors duration-150 hover:bg-brand-300/50 dark:hover:bg-brand-700/40 ${t.resizing?"bg-brand-400/60":"bg-transparent"}`}),r.jsx("div",{ref:t.panelRef,style:{width:t.open?t.width:0},inert:!t.open,className:`relative flex min-h-0 shrink-0 flex-col overflow-hidden ${t.open?"border-l border-gray-200 dark:border-gray-800":""} ${t.resizing?"pointer-events-none":"transition-[width] duration-200"}`,children:r.jsxs("div",{style:{width:t.width},className:"flex h-full min-h-0 flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-3 pt-2",children:[r.jsx("h4",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:f.subagentPanel.title}),r.jsx("button",{type:"button",onClick:()=>t.setOpen(!1),title:f.common.close,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:r.jsx(c9,{})})]}),r.jsx("div",{className:"min-h-0 flex-1",children:u})]})})]}):r.jsx(U0,{open:t.open,snap:t.sheetSnap,onSnapChange:t.setSheetSnap,onClose:()=>t.setOpen(!1),title:f.subagentPanel.title,children:r.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r.jsx("div",{className:"min-h-0 flex-1",children:u})})})}const Pk="(min-width: 1024px)";function d9(){return{sessionId:null,taskCount:0,autoOpenedAt:null}}function f9(e,t){const a=t.sessionId!==e.sessionId,i=!a&&t.taskCount<e.taskCount;return(a||t.taskCount!==e.taskCount)&&(e.sessionId=t.sessionId,e.taskCount=t.taskCount,e.autoOpenedAt=i?t.taskCount:null),t.liveSpawn&&e.autoOpenedAt!==e.taskCount?(e.autoOpenedAt=e.taskCount,"autoOpen"):null}function m9(e){const[t,a]=x.useState(!1),[i,l]=x.useState("half"),[c,u]=x.useState(null),[m,p]=x.useState(null),h=x.useCallback(S=>{S&&(l("half"),p(null)),a(S)},[]),g=v5(),[v,k]=x.useState(()=>window.matchMedia(Pk).matches);x.useEffect(()=>{u(null),p(null)},[e]),x.useEffect(()=>{const S=window.matchMedia(Pk),M=C=>k(C.matches);return S.addEventListener("change",M),()=>S.removeEventListener("change",M)},[]);const w=x.useCallback((S,M)=>{l("full"),p({anchorSessionId:M[0]??S}),u({sessionId:S,origin:M})},[]);return{open:t,setOpen:h,sheetSnap:i,setSheetSnap:l,focusSubagent:w,focusRequest:c,taskScope:m,isDocked:v,...g}}const p9=300;function h9(e){const t=vn().user?.userId??null,a=t&&e?o5(t,e):null,i=x.useMemo(()=>a?gi(a):{},[a]),l=x.useRef(i.text??""),c=x.useRef(i.handoffAgentId??null),u=x.useRef(i.switchModelRef??null),m=x.useRef(i.skills??[]),p=x.useRef(null),h=x.useCallback(()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]),g=x.useCallback(()=>{if(h(),!a)return;const C=l.current,T=c.current,I=u.current,D=m.current;if(!C&&!T&&!I&&D.length===0){zc(a);return}const K={text:C};T&&(K.handoffAgentId=T),I&&(K.switchModelRef=I),D.length>0&&(K.skills=D),js(a,K)},[h,a]);x.useEffect(()=>(l.current=i.text??"",c.current=i.handoffAgentId??null,u.current=i.switchModelRef??null,m.current=i.skills??[],()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null,g())}),[i,g]);const v=x.useCallback(C=>{l.current=C,h(),p.current=window.setTimeout(()=>{p.current=null,g()},p9)},[h,g]),k=x.useCallback(C=>{c.current=C,g()},[g]),w=x.useCallback(C=>{u.current=C,g()},[g]),S=x.useCallback(C=>{m.current=C,g()},[g]),M=x.useCallback(()=>{h(),l.current="",m.current=[],c.current=null,u.current=null,a&&zc(a)},[h,a]);return{initial:i,onTextChange:v,onHandoffTargetChange:k,onPendingModelChange:w,onSkillsChange:S,discard:M}}function bh(e){const t=e.lastIndexOf("-");if(t<=0)return null;const a=Number.parseInt(e.slice(t+1),10);return!Number.isInteger(a)||a<0?null:{epoch:e.slice(0,t),seq:a}}const kh=200,g9=100,x9=1e6;function y9(e){const t=e.now??(()=>Date.now()),a=new Set,i=new Map;let l=ql(a),c=!1,u="buffering",m=[],p=null,h=null,g=0,v=!1,k=[],w=new Map,S=0,M=null,C=null;const T={hasMore:!1,loading:!1,error:null};let I=0;const D=()=>{k=[],w=new Map,S=0,M=null,C=null,T.hasMore=!1,T.loading=!1,T.error=null,I=0},K=_=>{D(),_!==void 0&&(M=_.before??null,C=_.before??null,T.hasMore=_.before!==void 0,I=_.earlierTurns)},F=()=>{i.size!==0&&(i.clear(),e.onPendingChange())},E=(_,P)=>{if(r0(_)&&_.payload.type==="approval_decision"&&i.delete(Xl(_.origin,_.payload.tool_call_id))&&e.onPendingChange(),P&&!Ic(_.payload)&&RE(P,_)){jS(l,_);return}Lc(l,_,t())},B=_=>{switch(_.type){case"approval_request":{const P=_.toolCall.payload.tool_call_id,H={toolCall:_.toolCall};if(_.origin&&(H.origin=_.origin),i.set(Xl(_.origin,P),H),!kE(l,_.origin,P)){const G={..._.toolCall};_.origin&&_.origin.length>0?G.origin=[..._.origin]:delete G.origin,Lc(l,G,t()),e.onModelChange()}e.onPendingChange();return}case"task_state":{p=_.state,e.onTaskState(_.state),e.onQueuedFollowUps?.(_.queued??0),e.onPendingSteering?.(_.pendingSteering??[]),e.onPendingFollowUps?.(_.pendingFollowUps??[]),_.state==="idle"&&(vE(l),F(),e.onModelChange());return}case"resync_required":{Y();return}case"credentials_updated":{l.lastAuthFailureMs=null,e.onModelChange();return}case"hello":return}},Y=async()=>{g+=1,u="buffering",m=[],F(),await O(g,ql(a),{page:{kind:"tail",limit:kh},splice:k.length>0})},V=(_,P)=>{const H=bh(P.cursor);if(!H)return _;const G=h===null?null:bh(h);if(G!==null&&G.epoch!==H.epoch)return _;const z=[],J=[];for(const me of _){const A=me.id===null?null:bh(me.id);A!==null&&A.epoch===H.epoch&&A.seq<=H.seq?(me.kind!=="omni"||!Ic(me.msg.payload))&&z.push(me):J.push(me)}const xe=P.fragments.map(me=>({kind:"omni",msg:me,id:null,seeded:!0}));return[...z,...xe,...J]},O=async(_,P,H={})=>{try{let G=await e.loadMessages(H.page);if(c||_!==g)return;if(H.splice===!0){const q=G.page?.before??null;if(!(G.page!==void 0&&q!==null&&q===C))if(G.page!==void 0&&q===null)K(G.page);else{if(G=await e.loadMessages(),c||_!==g)return;K(void 0)}}else H.page!==void 0?K(G.page):K(void 0);const{messages:z,live:J,serverNowMs:xe}=G;P&&(l=P);const me=l;G.page!==void 0&&s1(me.stats,G.page.prior),i1(me,z,t(),xe??null);const A=_E(z,100),R=J!==void 0?V(m,J):m;m=[];for(let q=0;q<R.length;q+=1){const j=R[q];if(j.kind==="omni"?E(j.msg,A):B(j.ev),c)return;if(_!==g){m.push(...R.slice(q+1).filter($=>$.kind!=="omni"||!$.seeded));return}}u="live",p==="idle"&&Yh(me),v=!1,e.onError(null),e.onLoading(!1),e.onModelChange()}catch(G){if(c||_!==g)return;v=!0,e.onLoading(!1),e.onError(G instanceof Error?G.message:String(G))}};return{get model(){return l},get prefixItems(){return k},get prefixSubagents(){return w},get outlineOffset(){return I},get older(){return T},get pendingApprovals(){return i},load:()=>(g+=1,O(g,void 0,{page:{kind:"tail",limit:kh}})),retry:async()=>{c||!v||(e.onError(null),e.onLoading(!0),g+=1,await O(g,ql(a),{page:{kind:"tail",limit:kh}}))},loadOlder:async()=>{if(c||u!=="live"||v||T.loading||!T.hasMore||M===null)return;const _=g;T.loading=!0,T.error=null,e.onModelChange();try{const P=await e.loadMessages({kind:"before",cursor:M,limit:g9});if(c||_!==g)return;if(P.page===void 0)throw new Error("windowed history not supported");S+=1;const H=ql(a);H.nextItemId=-S*x9,s1(H.stats,P.page.prior),i1(H,P.messages,t(),null),Yh(H),k=[...H.items,...k];const G=new Map(H.subagents);for(const[z,J]of w)G.set(z,J);w=G,M=P.page.before??null,T.hasMore=P.page.before!==void 0,I=P.page.earlierTurns}catch(P){if(c||_!==g)return;T.error=P instanceof Error?P.message:String(P)}finally{!c&&_===g&&(T.loading=!1,e.onModelChange())}},handleOmni:(_,P=null)=>{if(!c){if(P!==null&&(h=P),u==="buffering"){m.push({kind:"omni",msg:_,id:P});return}E(_,null),e.onModelChange()}},handleServer:(_,P=null)=>{if(!c){if(P!==null&&(h=P),_.type==="session_title"){e.onSessionTitle?.(_.sessionId,_.title);return}if(_.type==="session_created"){e.onSessionCreated?.(_.sessionId);return}if(_.type==="goal_started"||_.type==="goal_round"||_.type==="goal_finished"){e.onGoalEvent?.(_);return}if(u==="buffering"){_.type==="task_state"&&(p=_.state,e.onTaskState(_.state),e.onQueuedFollowUps?.(_.queued??0),e.onPendingSteering?.(_.pendingSteering??[]),e.onPendingFollowUps?.(_.pendingFollowUps??[])),m.push({kind:"server",ev:_,id:P});return}B(_)}},markLocalDecision:_=>{bE(l,_)},resolveApproval:_=>{i.delete(_)&&e.onPendingChange()},dispose:()=>{c=!0}}}const v9=120,b9=new Map,k9=[],w9=new Map,S9={hasMore:!1,loading:!1,error:null};function j9(e,t,a,i){const[l,c]=x.useState(0),[u,m]=x.useState(!0),[p,h]=x.useState(t),[g,v]=x.useState(0),[k,w]=x.useState([]),[S,M]=x.useState([]),[C,T]=x.useState(null),[I,D]=x.useState(0),[K,F]=x.useState(null),E=x.useCallback(A=>{F(R=>A.type==="goal_started"?{objective:A.objective,status:"active",budget:A.budget,used:0,rounds:0}:A.type==="goal_round"?{objective:R?.objective??"",status:"active",budget:A.budget,used:A.used,rounds:A.round}:{objective:R?.objective??"",status:A.outcome,budget:R?.budget??-1,used:A.used,rounds:A.rounds})},[]),B=x.useRef(a);B.current=a;const Y=x.useRef(i);Y.current=i;const V=x.useRef(null),O=x.useRef(null);O.current===null&&(O.current=ql());const U=x.useRef(null),_=x.useRef(null),P=x.useRef(0),H=x.useCallback(()=>{if(U.current!==null||_.current!==null)return;const A=()=>{P.current=Date.now(),c(q=>q+1)},R=P.current+v9-Date.now();if(R>0){_.current=window.setTimeout(()=>{_.current=null,A()},R);return}U.current=requestAnimationFrame(()=>{U.current=null,A()})},[]);x.useEffect(()=>{if(!e){V.current?.dispose(),V.current=null,h("idle"),v(0),w([]),M([]),m(!1),T(null),F(null),D($=>$+1),c($=>$+1);return}c($=>$+1),m(!0),T(null),h(t),F(null),v(0),w([]),M([]),D($=>$+1);let A=!1;const R=()=>{D4(e).then($=>{A||!$.goal||$.goal.status!=="active"||F(ae=>ae??$.goal)}).catch(()=>{})},q=y9({loadMessages:$=>Kw(e,$),onTaskState:h,onQueuedFollowUps:v,onPendingSteering:w,onPendingFollowUps:M,onLoading:m,onError:T,onModelChange:H,onPendingChange:()=>D($=>$+1),onSessionTitle:($,ae)=>B.current?.($,ae),onSessionCreated:()=>Y.current?.(),onGoalEvent:E});V.current=q;const j=s3(e,{onOmniMessage:q.handleOmni,onServerEvent:q.handleServer,onOpen:R,onError:$=>{$&&Ld().catch(()=>{})}});return q.load(),()=>{A=!0,q.dispose(),j.close(),U.current!==null&&(cancelAnimationFrame(U.current),U.current=null),_.current!==null&&(window.clearTimeout(_.current),_.current=null)}},[e]);const G=x.useCallback(A=>{V.current?.markLocalDecision(A)},[]),z=x.useCallback(A=>{V.current?.resolveApproval(A)},[]),J=x.useCallback(()=>{V.current?.retry()},[]),xe=x.useCallback(()=>{V.current?.loadOlder()},[]),me=x.useCallback(()=>{const A=V.current?.model;A&&A.lastAuthFailureMs!==null&&(A.lastAuthFailureMs=null,c(R=>R+1))},[]);return{model:V.current?.model??O.current,prefixItems:V.current?.prefixItems??k9,prefixSubagents:V.current?.prefixSubagents??w9,outlineOffset:V.current?.outlineOffset??0,older:V.current?.older??S9,loadOlder:xe,version:l,loading:u,taskState:p,queuedFollowUps:g,pendingSteering:k,pendingFollowUps:S,lastAuthFailureMs:(V.current?.model??O.current).lastAuthFailureMs,dismissModelAuthDead:me,pendingApprovals:V.current?.pendingApprovals??b9,markLocalDecision:G,resolveApproval:z,error:C,retry:J,goal:K}}const sc={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",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",elapsed:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zm0-14v5l3 2",folder:"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",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"},C9=15e3,N9=200;function wh({icon:e,value:t,label:a}){return r.jsxs("span",{title:a,className:"flex shrink-0 items-center gap-1 font-mono text-xs text-gray-500 dark:text-gray-400",children:[r.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:r.jsx("path",{d:e})}),t]})}function T9({sessionId:e}){return r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.chat.sessionIdLabel}),r.jsxs("div",{className:"flex items-start gap-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 break-all font-mono text-xs leading-5",children:e}),r.jsx(io,{text:e,label:f.chat.copySessionId,className:o0})]})]})}function M9({stats:e,taskOpen:t,taskStartLocalMs:a}){const[i,l]=x.useState(()=>Date.now());return x.useEffect(()=>{if(!t)return;l(Date.now());const c=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(c)},[t]),t?r.jsx(r.Fragment,{children:z2(fE(e,t,a,i))}):r.jsx(r.Fragment,{children:An(e.sessionElapsedMs)})}function A9(e,t){const a=e.stats;return{tokensText:Rt(a.sessionTotal+a.subagentTotal),costText:t.costText,costUncosted:t.costUncosted,elapsedNode:r.jsx(M9,{stats:a,taskOpen:e.taskOpen,taskStartLocalMs:e.taskStartLocalMs})}}const Xa="new",E9=e=>e!==null&&e.startsWith("draft-")?e:null,Bk=100;function _9(){const e=ia(),t=ha(),a=x2(),{user:i}=vn(),{currency:l}=mi(),{currentProject:c,currentAgent:u,setCurrentAgentId:m,reloadAgents:p,agents:h}=cn(),g=c?.projectId??null,v=u?.agentId??null,{sessions:k,loading:w,reload:S,add:M,isDeleted:C,replace:T,setStatus:I,setTitle:D}=pi(),K=x.useRef(h5()),F=x.useRef(null),[,E]=x.useState(0),[B,Y]=x.useState(!1),[V,O]=x.useState(!1),[U,_]=x.useState(!1),[P,H]=x.useState(null),[G,z]=x.useState([]),[J,xe]=x.useState(null),[me,A]=x.useState(null),[R,q]=x.useState(null),[j,$]=x.useState(null),ae=a.sessionId??null,de=i9(ae),ye=m9(ae),Se=x.useRef(null),ke=()=>{Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null)};x.useEffect(()=>ke,[]);const ee=(ue,Me)=>{ue.setOpen(!1),ue.open&&ue.isDocked?Se.current=window.setTimeout(()=>{Se.current=null,Me(!0)},N9):Me(!0)},je={...de,setOpen:ue=>{ke(),ue?ee(ye,de.setOpen):de.setOpen(!1)}},Ae={...ye,setOpen:ue=>{ke(),ue?ee(de,ye.setOpen):ye.setOpen(!1)}},Qe=E9(ae),We=ae===Xa||Qe!==null,re=We?null:k.find(ue=>ue.sessionId===ae)??null,ft=re?{provider:re.provider,modelId:re.modelId}:null;Jr(re?re.title??f.chat.defaultSessionTitle:f.nav.chat);const ge=j9(re?.sessionId??null,re?.status??"idle",D,()=>{S()}),{initial:dt,onTextChange:It,onHandoffTargetChange:zt,onPendingModelChange:nn,onSkillsChange:un,discard:Wt}=h9(re?.sessionId??null),Ce=x.useMemo(()=>ge.prefixItems.length>0?[...ge.prefixItems,...ge.model.items]:ge.model.items,[ge.version,ae]),Ke=x.useMemo(()=>I7(Ce),[ge.version,ae]),se=x.useMemo(()=>mD(Ce),[ge.version,ae]),ce=x.useMemo(()=>ge.prefixItems.length>0||ge.prefixSubagents.size>0?{...ge.model,items:[...Ce],subagents:new Map([...ge.prefixSubagents,...ge.model.subagents])}:ge.model,[ge.version,ae]),De=x.useRef(null),Be=bD(De,ge.version),Ue=re?.sessionId??null,W=re?.agentId??null,pe=re?.thinkingLevel??"";x.useEffect(()=>{Ue&&W&&m(W)},[Ue,W,m]),x.useEffect(()=>{We&&(ke(),de.setOpen(!1),ye.setOpen(!1))},[We]);const Ne=x.useRef(d9()),Re=bO(ge.model.items),Pe=ge.taskState!=="idle"&&jO(ge.model);x.useEffect(()=>{f9(Ne.current,{sessionId:Ue,taskCount:Re,liveSpawn:Pe})==="autoOpen"&&ye.isDocked&&!ye.open&&!de.open&&ye.setOpen(!0)},[Ue,Re,Pe]);const[Fe,nt]=x.useState([]);x.useEffect(()=>{if(nt(Me=>Me.length>0?[]:Me),!g||!W)return;let ue=!1;return hf(g,W).then(Me=>{ue||nt(Me.skills)}).catch(()=>{}),()=>{ue=!0}},[g,W]);const[ot,Te]=x.useState("");x.useEffect(()=>{if(Te(""),!g||!W)return;let ue=!1;return el(g,W).then(Me=>{ue||Te(Me.config.model?.thinkingLevel??"")}).catch(()=>{}),()=>{ue=!0}},[g,W]);const[ze,yt]=x.useState(null);x.useEffect(()=>{if(We||!ae||w||k.some(Me=>Me.sessionId===ae))return;if(C(ae)){yt(ae);return}let ue=!1;return Fp(ae).then(Me=>{ue||M(Me.session)},()=>{ue||yt(ae)}),()=>{ue=!0}},[We,ae,w,k,M,C]),x.useEffect(()=>{if(w||We||ae&&k.some(Me=>Me.sessionId===ae)||ae&&ze!==ae)return;const ue=N2(k);e(ue?`/chat/${ue.sessionId}`:`/chat/${Xa}`,{replace:!0})},[w,We,ae,ze,k,e]),x.useEffect(()=>{Ue!==null&&I(Ue,ge.taskState)},[ge.taskState,Ue,I]);const ct=x.useRef({id:Ue,state:"idle"});x.useEffect(()=>{const ue=ct.current,Me=ue.id===Ue;ct.current={id:Ue,state:Me?ge.taskState:"idle"},!(!Me||Ue===null)&&ue.state!=="idle"&&ge.taskState==="idle"&&(S(),p())},[ge.taskState,Ue,S,p]);const vt=re?.lastActiveAt??null;x.useEffect(()=>{Ue===null||vt===null||ge.taskState==="idle"&&F2(g,Ue,vt)},[g,Ue,vt,ge.taskState]);const hn=x.useRef(new Map);x.useEffect(()=>{F.current=null,$(null),hn.current=new Map,z([]),A(null),q(null)},[ae]);const bt=x.useCallback(async ue=>{const Me=re?.sessionId??null,et=hn.current,it=Me===null?[]:ue.filter(xt=>!et.has(xt));if(Me!==null&&it.length>0)for(let xt=0;xt<it.length;xt+=Bk){const Zt=it.slice(xt,xt+Bk),Pa=eT(Me,Zt).then(ua=>new Set(ua.existing)).catch(()=>null);for(const ua of Zt){const Fn=Pa.then(Ca=>Ca?.has(ua)??!1);et.set(ua,Fn),Fn.then(Ca=>{et.get(ua)===Fn&&(Ca?et.set(ua,!0):et.delete(ua))})}}const gt=new Set;return await Promise.all(ue.map(async xt=>{const Zt=et.get(xt);(Zt===!0||Zt instanceof Promise&&await Zt)&&gt.add(xt)})),gt},[re?.sessionId]);x.useEffect(()=>{if(!g||!re||F.current===re.sessionId&&ge.taskState!=="idle"&&!V)return;let ue=!1;return Yw(g,{groupBy:"session",agentId:re.agentId}).then(Me=>{if(ue)return;F.current=re.sessionId;const et=Me.groups.find(it=>it.key===re.sessionId);UD(K.current,re.sessionId,et??null),A(et?{cacheRead:et.cacheRead,cacheWrite:et.cacheWrite,output:et.output}:null),E(it=>it+1)}).catch(()=>{}),()=>{ue=!0}},[g,re,ge.taskState,V]);const dn=x.useRef(Ue);x.useEffect(()=>{dn.current=Ue},[Ue]);const Qn=G.filter(ue=>ue.running).length,Ht=ge.taskState!=="idle"||Qn>0||V&&G.length>0;x.useEffect(()=>{if(!Ue)return;let ue=!1;const Me=()=>{Mb(Ue).then(it=>{ue||z(it.processes)}).catch(()=>{})};if(Me(),!Ht)return()=>{ue=!0};const et=window.setInterval(Me,C9);return()=>{ue=!0,window.clearInterval(et)}},[Ue,ge.taskState,Ht]);const Bn=x.useCallback(async(ue,Me,et)=>{if(!re||J!==null)return;const it=re.sessionId;xe(ue);try{await Me(it,ue)}catch(gt){gt instanceof sa&&et.includes(gt.status)||Ve(Oe(gt))}finally{xe(null),Mb(it).then(gt=>{dn.current===it&&z(gt.processes)}).catch(()=>{})}},[re,J]),Ur=x.useCallback(ue=>Bn(ue,P4,[404]),[Bn]),ga=x.useCallback(ue=>Bn(ue,B4,[404,409]),[Bn]);x.useEffect(()=>{if(!V||!Ue)return;let ue=!1;return Fp(Ue).then(Me=>{ue||q(Me.session.tracePath??null)}).catch(()=>{}),()=>{ue=!0}},[V,Ue]),x.useEffect(()=>{if(!g)return;let ue=!1;return H(null),(async()=>{try{const Me=await Yl(g);if(ue)return;H(Me);const{prefs:et}=await Rg();if(ue||et.credentialGuideSeen)return;const it=Me.models.find(xt=>_t(xt,Me.defaultModel));(!Me.defaultModel||!it?.credential?.apiKeyMasked)&&Y(!0),pf({credentialGuideSeen:!0}).catch(()=>{})}catch{}})(),()=>{ue=!0}},[g]),x.useEffect(()=>{if(!g)return;let ue=!1;const Me=et=>{const it=m5(et,g);!it||it.defaultModel===void 0||(H(null),Yl(g).then(gt=>{ue||H(gt)}).catch(()=>{}))};return window.addEventListener($c,Me),()=>{ue=!0,window.removeEventListener($c,Me)}},[g]);const zn=x.useCallback(async(ue,Me)=>{Me!==ue&&(await S(),e(`/chat/${Me}`,{replace:!0}))},[S,e]),xa=x.useCallback(async(ue,Me)=>{if(!re)return!1;try{const et=await fc(re.sessionId,{input:ue,...Me?{goal:Me}:{},...pe?{thinkingLevel:pe}:{}});return Wt(),await zn(re.sessionId,et.sessionId),!0}catch(et){return Ve(Oe(et,{modelId:re.modelId})),!1}},[re,pe,Wt,zn]),Hn=x.useCallback(async(ue,Me)=>{if(!g||!re)return!1;const et=await Fp(re.sessionId).then(xt=>xt.session.tracePath).catch(()=>{}),it={type:"text",text:YO({sessionId:re.sessionId,...re.title!==void 0?{sessionTitle:re.title}:{},...et!==void 0?{tracePath:et}:{},workspace:re.workspace,prevProvider:re.provider,prevModelId:re.modelId})};let gt=null;try{const xt=await Dh(g,re.agentId,{provider:ue.provider,modelId:ue.modelId,workspace:re.workspace,approvalMode:re.approvalMode});gt=xt.session.sessionId;const Zt=await fc(gt,{input:[it,...Me]});return M(xt.session),Wt(),e(`/chat/${Zt.sessionId}`),!0}catch(xt){return gt&&Bd(gt).catch(()=>{}),Ve(Oe(xt,{modelId:ue.modelId})),!1}},[g,re,M,Wt,e]),ya=x.useCallback(async(ue,Me)=>{if(!g||!u||!re)return!1;const et={type:"text",text:KO({agentId:u.agentId,...u.name!==void 0?{agentName:u.name}:{},sessionId:re.sessionId,workspace:re.workspace,...re.title!==void 0?{sessionTitle:re.title}:{}})};let it=null;try{const gt=await Dh(g,ue.agentId,{approvalMode:re.approvalMode});it=gt.session.sessionId;const xt=await fc(it,{input:[et,...Me]});return M(gt.session),Wt(),e(`/chat/${xt.sessionId}`),!0}catch(gt){return it&&Bd(it).catch(()=>{}),Ve(Oe(gt,P?.defaultModel?{modelId:P.defaultModel.modelId}:{})),!1}},[g,u,re,M,Wt,e,P]),va=x.useCallback(async()=>{re&&await z4(re.sessionId).catch(()=>{})},[re]),zr=x.useCallback(async ue=>{if(!re)return!1;try{const Me=await fc(re.sessionId,{input:ue,queueIfBusy:!0,...pe?{thinkingLevel:pe}:{}});return Wt(),await zn(re.sessionId,Me.sessionId),!0}catch(Me){return Ve(Oe(Me,{modelId:re.modelId})),!1}},[re,pe,Wt,zn]),an=x.useCallback(async(ue,Me=[],et=[])=>{if(!re)return"failed";try{return await H4(re.sessionId,{text:ue,...Me.length>0?{images:Me}:{},...et.length>0?{files:et}:{}}),Wt(),"queued"}catch(it){return it instanceof sa&&it.status===409?"not_running":(Ve(Oe(it,{modelId:re.modelId})),"failed")}},[re,Wt]),$t=x.useCallback(ue=>{re&&Pd(re.sessionId,{thinkingLevel:ue}).then(Me=>T(Me.session)).catch(Me=>{Ve(Oe(Me))})},[re,T]),gn=x.useCallback(async ue=>{if(!re)return null;try{return await F4(re.sessionId,ue)}catch(Me){return Ve(Oe(Me)),null}},[re]),Xn=x.useCallback(async ue=>{if(!re)return null;try{const Me=await V4(re.sessionId,ue);return Me.thinkingLevel&&$t(Me.thinkingLevel),Me}catch(Me){return Ve(Oe(Me)),null}},[re,$t]),Ja=x.useCallback(async(ue,Me,et)=>{if(!re)return;ge.markLocalDecision(ue);const it=Xl(et,ue);try{await U4(re.sessionId,ue,{decision:Me}),ge.resolveApproval(it)}catch(gt){gt instanceof sa&&gt.status===404&&ge.resolveApproval(it)}},[re,ge]),Ns=x.useCallback(ue=>{!re||U||(_(!0),Pd(re.sessionId,{approvalMode:ue}).then(Me=>T(Me.session)).catch(Me=>{Ve(Oe(Me))}).finally(()=>_(!1)))},[re,U,T]),ba=x.useCallback(async()=>{if(!re)return!1;try{const ue=await q4(re.sessionId);return await zn(re.sessionId,ue.sessionId),!0}catch(ue){return Ve(Oe(ue,{modelId:re.modelId})),!1}},[re,zn]),ka=x.useCallback(async()=>{await ba()},[ba]),wa=x.useCallback(ue=>{A7(ge.model.items,uk(pe,ot),ue)?$({phase:"ask",level:ue}):$t(ue)},[ge.model,pe,ot,$t]),$r=x.useCallback(()=>{if(j===null||ge.taskState!=="idle")return;const ue={phase:"compacting",level:j.level,baseline:Qj(ge.model.items)};$(ue),pa(f.chat.thinkingSwitchCompacting),ba().then(Me=>{Me||$(et=>et===ue?{phase:"settle",level:ue.level}:et)})},[j,ge.taskState,ge.model,ba]);x.useEffect(()=>{if(j===null)return;const ue=_7(j,ge.model.items);ue.act!=="wait"&&($(null),$t(ue.level),ue.notice==="compacted"?Ut(f.chat.thinkingSwitchApplied(hg(f.chat.thinkingLevelNames,ue.level)??ue.level)):ue.notice==="compaction-failed"&&Ve(f.chat.thinkingSwitchCompactFailed))},[ge.version,ge.model,j,$t]);const Sa=x.useCallback(()=>{i&&g&&uo(i.userId,g),e(`/chat/${Xa}`)},[i,g,e]),za=x.useCallback(()=>{e("/models")},[e]),ja=x.useCallback(async ue=>{if(re)try{let Me=ue.position;if(Me===void 0){const it=await Kw(re.sessionId),gt=ql();for(const Zt of it.messages)Lc(gt,Zt);Yh(gt);const xt=[...gt.items].reverse().find(Zt=>Zt.kind==="task_stats"&&Zt.assistantText===ue.assistantText&&Zt.atMs===ue.atMs&&Zt.forkPosition!==void 0);Me=xt?.kind==="task_stats"?xt.forkPosition:void 0}if(Me===void 0){Ve(f.chat.forkSessionFailed);return}const et=await O4(re.sessionId,{position:Me});M(et.session),e(`/chat/${et.session.sessionId}`)}catch(Me){Ve(Oe(Me,{modelId:re.modelId}))}},[re,M,e]),$n=P?.models.find(ue=>_t(ue,ft))?.pricing,Ft={pendingApprovals:ge.pendingApprovals,onApprove:Ja,origin:[],taskRunning:ge.taskState!=="idle",taskCost:ue=>r1(ue.tokensByBucket,$n),onRetryNow:()=>{re&&$4(re.sessionId).catch(()=>{})},onGiveUp:()=>{va()},onOpenFile:ue=>{je.setOpen(!0),je.browsePath(ue)},onOpenSubagent:(ue,Me)=>{Ae.setOpen(!0),Ae.focusSubagent(ue,[...Me,ue])},workspace:re?.workspace??null,statFiles:bt,onFork:ja},er=[...ge.pendingApprovals.keys()].some(ue=>!ue.startsWith(" "));if(!g||!v)return r.jsx("div",{className:"p-6",children:r.jsx(mn,{className:"h-6 w-64"})});const Nr=ge.model.taskOpen?r1({cacheRead:ge.model.stats.taskCacheRead,cacheWrite:ge.model.stats.taskCacheWrite,output:ge.model.stats.taskOutput},$n):null,Vt=A9(ge.model,zD(K.current,{sessionId:re?.sessionId??null,taskCount:Re,taskOpen:ge.model.taskOpen,loading:ge.loading,liveUsd:Nr,currency:l})),Zn=me?me.cacheRead+me.cacheWrite:0,oa=me&&Zn>0?`${Math.round(100*me.cacheRead/Zn)}%`:null,tr=P?.models.find(ue=>_t(ue,ft)),nr=tr?.contextWindow,Pr=tr?.vision!==!1,$a=re!==null&&!ge.loading&&!ge.error&&ge.model.items.length===0,ca=P?.updatedAt!==void 0?Date.parse(P.updatedAt):NaN,On=hE(ge.lastAuthFailureMs,Number.isFinite(ca)?ca:null),bn=re&&r.jsx(e5,{status:ge.taskState,modelAuthDead:On,onOpenModels:za,onRetryModelAuth:ge.dismissModelAuthDead,onNewSession:Sa,onSend:xa,onSteer:an,steeringDeliveredCount:ge.model.items.filter(ue=>ue.kind==="user_steering").length,pendingSteering:ge.pendingSteering,onRecallSteering:gn,onQueueFollowUp:zr,queuedFollowUps:ge.queuedFollowUps,pendingFollowUps:ge.pendingFollowUps,onRecallFollowUp:Xn,onStop:va,onCompact:ka,modelRef:ft,...P!==null?{models:P.models}:{},...P?.defaultModel!==void 0?{defaultModel:P.defaultModel}:{},onSwitchModel:Hn,turnThinkingLevel:uk(pe,ot),onChangeTurnThinkingLevel:wa,...nr!==void 0?{contextWindow:nr}:{},contextNow:ge.model.stats.contextNow,contextStale:ge.model.stats.contextStale,vision:Pr,approvalMode:re.approvalMode,onChangeApprovalMode:Ns,modeSaving:U,autoFocus:!0,agents:h,currentAgentId:re.agentId,skills:Fe,...dt.skills&&dt.skills.length>0?{initialSkills:dt.skills}:{},onSkillsChange:un,onHandoff:ya,initialText:dt.text??"",onTextChange:It,history:Ke,...dt.handoffAgentId?{initialHandoffTargetId:dt.handoffAgentId}:{},onHandoffTargetChange:zt,...dt.switchModelRef?{initialPendingModelRef:dt.switchModelRef}:{},onPendingModelChange:nn}),ar=re===null?null:V2(ge.taskState,re.hasTrace,!1);return r.jsxs("div",{className:"flex h-full flex-col bg-white dark:bg-gray-950",children:[re&&r.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:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r.jsx("h1",{className:"flex min-w-0 text-[15px] font-semibold",children:r.jsx(qc,{text:re.title??f.chat.defaultSessionTitle})}),ar==="running"&&r.jsxs("span",{title:Wh(ar),className:"flex shrink-0 items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[r.jsx(oS,{activity:ar}),r.jsx("span",{className:"hidden sm:inline",children:Wh(ar)})]})]}),r.jsxs("button",{type:"button","aria-expanded":Ae.open,onClick:()=>Ae.setOpen(!Ae.open),title:f.chat.openAgents,"aria-label":f.chat.openAgents,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors duration-150 ${Ae.open?"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"}`,children:[r.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":!0,children:[r.jsx("circle",{cx:"5",cy:"12",r:"2.5"}),r.jsx("circle",{cx:"19",cy:"5.5",r:"2.5"}),r.jsx("circle",{cx:"19",cy:"18.5",r:"2.5"}),r.jsx("path",{d:"M7.4 11 16.7 6.6M7.4 13l9.3 4.4"})]}),r.jsx("span",{className:"hidden lg:inline",children:f.chat.openAgents}),er&&r.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-amber-500"})]}),r.jsxs("button",{type:"button","aria-expanded":je.open,onClick:()=>je.setOpen(!je.open),title:f.chat.openWorkspace,"aria-label":f.chat.openWorkspace,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors duration-150 ${je.open?"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"}`,children:[r.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":!0,children:r.jsx("path",{d:sc.folder})}),r.jsx("span",{className:"hidden lg:inline",children:f.chat.openWorkspace})]}),!Be.shown&&r.jsx(wD,{entries:se,turnOffset:ge.outlineOffset,scrollRef:De,running:ge.taskState!=="idle"}),r.jsx(Un,{open:V,setOpen:O,menuClass:"right-0 top-full mt-1 w-96 max-w-[calc(100vw-1.5rem)] origin-top-right",button:r.jsxs("button",{type:"button",title:f.chat.infoPanel,"aria-label":f.chat.infoPanel,"aria-expanded":V,onClick:()=>O(!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:[r.jsxs("span",{className:"hidden items-center gap-3 px-2 sm:flex",children:[r.jsx(wh,{icon:sc.tokens,value:Vt.tokensText,label:`${f.chat.statTokens}(Token)`}),Vt.costText!=null&&r.jsx(wh,{icon:sc.cost,value:`${Vt.costText}${Vt.costUncosted?" *":""}`,label:`${f.common.cost}(${l})${Vt.costUncosted?` · ${f.usage.uncostedNote}`:""}`}),r.jsx(wh,{icon:sc.elapsed,value:Vt.elapsedNode,label:f.chat.statElapsed}),Qn>0&&r.jsxs("span",{title:f.chat.runningServices(Qn),className:"flex shrink-0 items-center gap-1 font-mono text-xs text-emerald-600 dark:text-emerald-400",children:[r.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:r.jsx("path",{d:sc.services})}),Qn]})]}),r.jsx("span",{className:"flex h-7 w-7 items-center justify-center text-gray-500 sm:hidden dark:text-gray-400",children:r.jsxs("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:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 11v5m0-8h.01"})]})})]}),children:r.jsxs("div",{className:"space-y-3 px-3.5 py-2.5 text-sm",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.chat.model}),r.jsxs("p",{className:"truncate text-xs",children:[r.jsx("span",{className:"font-mono",children:re.modelId}),r.jsx("span",{className:"ml-1.5 text-gray-400 dark:text-gray-500",children:Yr(re.provider)?.label??re.provider})]})]}),r.jsx(T9,{sessionId:re.sessionId}),r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.chat.workspace}),r.jsx("p",{className:"break-all font-mono text-xs leading-5",children:re.workspace})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.common.created}),r.jsx("p",{className:"font-mono text-xs",children:Oa(re.createdAt)})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.chat.sessionStats}),r.jsxs("ul",{className:"list-inside list-disc space-y-0.5 font-mono text-xs",children:[r.jsxs("li",{children:[f.chat.statTotalTokens," ",Vt.tokensText,oa!==null&&`${f.chat.statParenOpen}${f.chat.statCacheHit(oa)}${f.chat.statParenClose}`]}),Vt.costText!=null&&r.jsxs("li",{children:[f.common.cost," ",Vt.costText,Vt.costUncosted?" *":""]}),r.jsxs("li",{children:[f.chat.statElapsed," ",Vt.elapsedNode]})]})]}),G.length>0&&r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.chat.processList}),r.jsx("ul",{className:"mt-1 space-y-1.5",children:G.map(ue=>r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{"aria-hidden":!0,className:`h-1.5 w-1.5 shrink-0 rounded-full ${ue.running?"animate-pulse bg-emerald-500":"bg-gray-300 dark:bg-gray-600"}`}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate font-mono text-xs",title:ue.cmd,children:ue.cmd}),r.jsxs("span",{className:"block text-[11px] text-gray-400 dark:text-gray-500",children:[Oa(ue.startedAt),ue.pid!==null&&` · pid ${ue.pid}`]})]}),ue.running?r.jsx("button",{type:"button",disabled:J!==null,onClick:()=>{Ur(ue.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:J===ue.processId?f.common.loading:f.chat.processStop}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"shrink-0 text-[11px] text-gray-400 dark:text-gray-500",children:f.chat.processExited}),r.jsx("button",{type:"button",title:f.chat.processRemoveHint,disabled:J!==null,onClick:()=>{ga(ue.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:J===ue.processId?f.common.loading:f.chat.processRemove})]})]},ue.processId))})]}),R!==null&&r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.chat.traceFile}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("button",{type:"button",title:R,onClick:()=>{O(!1),e(`/traces?agentId=${encodeURIComponent(re.agentId)}&sessionId=${encodeURIComponent(re.sessionId)}`)},className:"max-w-full truncate text-left font-mono text-xs leading-5 text-gray-600 underline decoration-gray-300 underline-offset-2 transition-colors duration-150 hover:text-gray-900 dark:text-gray-300 dark:decoration-gray-600 dark:hover:text-gray-100",children:UA(R)})}),r.jsx(io,{text:R,label:f.chat.copyTracePath,className:o0})]})]})]})})]}),r.jsxs("div",{className:"flex min-h-0 flex-1",children:[r.jsx(H7,{className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:We?r.jsx(LD,{projectId:g,models:P,...Qe!==null?{draftId:Qe}:{}},`draft:${g}:${Qe??t.key}`):r.jsx("div",{className:"anim-fade flex min-h-0 flex-1 flex-col",children:re?ge.error?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6",children:[r.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400",children:[f.chat.historyLoadFailed,":",ge.error]}),r.jsx(ve,{onClick:ge.retry,children:f.common.retry})]}):ge.loading?r.jsxs("div",{className:"space-y-3 p-6",children:[r.jsx(mn,{className:"h-5 w-1/3"}),r.jsx(mn,{className:"h-5 w-2/3"}),r.jsx(mn,{className:"h-5 w-1/2"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"min-h-0 flex-1",children:$a?r.jsx("div",{className:"flex h-full items-center justify-center px-4",children:r.jsx("p",{className:"text-lg font-medium text-gray-400 dark:text-gray-500",children:f.chat.emptyGreeting})}):r.jsx(Pj,{items:Ce,version:ge.version,ctx:Ft,scrollElRef:De,older:{hasMore:ge.older.hasMore,loading:ge.older.loading,error:ge.older.error,prependedCount:ge.prefixItems.length,onLoad:ge.loadOlder},outline:r.jsx(kD,{entries:se,turnOffset:ge.outlineOffset,version:ge.version,scrollRef:De,running:ge.taskState!=="idle",fit:Be})})}),r.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:r.jsxs("div",{className:"mx-auto max-w-3xl",children:[ge.goal&&r.jsx(PO,{goal:ge.goal}),bn]})})]}):w?r.jsx("div",{className:"space-y-3 p-6",children:r.jsx(mn,{className:"h-5 w-1/2"})}):r.jsx(Xr,{title:f.chat.noSessions,action:r.jsx(ve,{onClick:Sa,children:f.nav.newChat})})},re?.sessionId??"empty")}),re&&r.jsx(u9,{session:re,panel:Ae,model:ce,version:ge.version,taskRunning:ge.taskState!=="idle",ctx:Ft}),re&&r.jsx(n9,{session:re,panel:je})]}),r.jsx(Xt,{open:B,title:f.project.noCredentialTitle,onClose:()=>Y(!1),footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:()=>Y(!1),children:f.project.later}),r.jsx(ve,{variant:"primary",onClick:()=>{Y(!1),e("/models")},children:f.project.goToModels})]}),children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.project.noCredentialBody})}),r.jsxs(yn,{open:j?.phase==="ask",title:f.chat.thinkingSwitchTitle,tone:"primary",confirmLabel:f.chat.thinkingSwitchCompactFirst,confirmDisabled:ge.taskState!=="idle",onConfirm:$r,secondaryLabel:f.chat.thinkingSwitchConfirm,onSecondary:()=>{j!==null&&$t(j.level),$(null)},onClose:()=>$(null),children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.chat.thinkingSwitchBody(hg(f.chat.thinkingLevelNames,j?.level)??j?.level??"")}),ge.taskState!=="idle"&&r.jsx("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:f.chat.thinkingSwitchBusyHint})]})]})}const b5=/^[a-z][a-z0-9_]{1,63}$/,Hk=/^[a-z][a-z0-9_]{1,31}$/,R9=/^[a-z0-9_]+$/,I9=64,Fk=4,Vk=16;function k5({open:e,onClose:t,estimatedHeight:a,panelWidth:i}){const l=x.useRef(null),c=x.useRef(null),[u,m]=x.useState(null),p=x.useRef(t);return p.current=t,x.useLayoutEffect(()=>{if(!e||!l.current)return;const h=l.current.getBoundingClientRect(),g=window.innerHeight-h.bottom,v=h.top,k=Math.min(a,window.innerHeight*.7),w=g<k&&v>g,S=i??h.width,M=Math.max(Vk,Math.min(h.left,window.innerWidth-S-Vk));m({topPx:w?void 0:h.bottom+Fk,bottomPx:w?window.innerHeight-h.top+Fk:void 0,left:M,triggerWidth:h.width})},[e,a,i]),x.useEffect(()=>{if(!e)return;const h=w=>{const S=w.target;l.current?.contains(S)||c.current?.contains(S)||p.current()},g=w=>{w.key==="Escape"&&(w.stopPropagation(),p.current())},v=w=>{c.current?.contains(w.target)||p.current()},k=()=>p.current();return window.addEventListener("mousedown",h),window.addEventListener("keydown",g,!0),window.addEventListener("scroll",v,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("mousedown",h),window.removeEventListener("keydown",g,!0),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",k)}},[e]),{triggerRef:l,panelRef:c,position:u}}function L9(e){const t=[];return x.Children.forEach(e,a=>{if(!x.isValidElement(a)||a.type!=="option")return;const i=a.props;t.push({value:i.value!==void 0?String(i.value):"",label:i.children??"",...i.disabled?{disabled:!0}:{}})}),t}const O9=`flex w-full items-center gap-2 text-left ${kf} disabled:cursor-not-allowed disabled:opacity-60`,D9={base:"text-base",sm:"text-xs"};function oi({label:e,hint:t,error:a,required:i,size:l="base",className:c,children:u,value:m,onChange:p,disabled:h}){const g=L9(u),v=String(m??""),k=g.find(F=>F.value===v),w=x.useId(),[S,M]=x.useState(!1),{triggerRef:C,panelRef:T,position:I}=k5({open:S,onClose:()=>M(!1),estimatedHeight:g.length*36+8}),D=F=>{M(!1),p?.({target:{value:F}}),C.current?.focus()},K=r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:C,type:"button",disabled:h,"aria-haspopup":"listbox","aria-expanded":S,"aria-required":i||void 0,"aria-invalid":a?!0:void 0,"aria-describedby":a?w:void 0,onClick:()=>M(F=>!F),className:`${O9} ${wf[l]} ${a?Sf:""} ${c??""}`,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:k?.label??g[0]?.label??""}),r.jsx(Ql,{className:"text-gray-400"})]}),S&&I&&nl.createPortal(r.jsx("div",{ref:T,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:I.left,width:I.triggerWidth,top:I.topPx,bottom:I.bottomPx},children:g.map((F,E)=>r.jsxs("button",{type:"button",role:"option","aria-selected":F.value===v,disabled:F.disabled,onClick:()=>D(F.value),className:`flex items-center ${n0} ${D9[l]} disabled:opacity-50 ${F.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:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:F.label}),F.value===v&&r.jsx(bf,{className:"text-gray-500 dark:text-gray-400"})]},`${F.value}-${E}`))}),document.body)]});return r.jsx(Gc,{label:e,hint:t,error:a,errorId:w,required:i,children:K})}const U9=["always-ask","read-only","allow-all","deny-all"];function z9({open:e,onClose:t,onCreated:a}){const{user:i}=vn(),l=i&&!i.isAdmin?`${i.userId}-`:"",[c,u]=x.useState(""),[m,p]=x.useState(""),[h,g]=x.useState(void 0),[v,k]=x.useState(!1);x.useEffect(()=>{e&&(u(""),p(""),g(void 0))},[e]);const w=async()=>{const S=l+c.trim();if(!c.trim()){g(f.common.requiredField);return}if(!(l?R9.test(c.trim())&&S.length<=I9:b5.test(S))){g(l?f.project.idPrefixHint:f.project.idHint);return}k(!0),g(void 0);try{const C=await u4({projectId:S,...m.trim()?{name:m.trim()}:{}});a(C.project.projectId)}catch(C){g(Oe(C))}finally{k(!1)}};return r.jsx(Xt,{open:e,title:f.project.createTitle,onClose:t,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:t,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:v,onClick:()=>{w()},children:f.common.create})]}),children:r.jsxs("div",{className:"space-y-3",children:[l?r.jsxs("div",{children:[r.jsx(wr,{required:!0,children:f.project.id}),r.jsxs("div",{className:"flex items-stretch",children:[r.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:l}),r.jsx(rt,{size:"sm",className:"rounded-l-none",value:c,invalid:!!h,onChange:S=>{u(S.target.value),g(void 0)},autoFocus:!0})]}),h?r.jsx(Kr,{children:h}):r.jsx(Yd,{children:f.project.idPrefixHint})]}):r.jsx(rt,{label:f.project.id,required:!0,size:"sm",value:c,error:h,onChange:S=>{u(S.target.value),g(void 0)},hint:f.project.idHint,autoFocus:!0}),r.jsx(rt,{label:f.project.name,size:"sm",value:m,onChange:S=>p(S.target.value)})]})})}function $9({open:e,onClose:t}){const{user:a,desktopMode:i}=vn(),{currentProject:l,setCurrentProjectId:c,projects:u,reloadProjects:m}=cn(),[p,h]=x.useState(null),[g,v]=x.useState(""),[k,w]=x.useState(null),[S,M]=x.useState(!1),[C,T]=x.useState(""),[I,D]=x.useState(!1),[K,F]=x.useState(void 0),E=l?.projectId,B=l?.role==="owner",Y=l?Ph(l):"";if(x.useEffect(()=>{!e||!E||(h(null),w(null),M(!1),T(Y),F(void 0),i||Hp(E).then(P=>h(P.members)).catch(P=>w(Oe(P))))},[e,E,i]),!l||!E)return null;const V=async()=>{const P=C.trim();if(!(!P||P===Y||I)){D(!0),F(void 0);try{await d4(E,{name:P}),await m()}catch(H){F(Oe(H))}finally{D(!1)}}},O=async()=>{if(g.trim())try{await m4(E,{userId:g.trim()}),v("");const P=await Hp(E);h(P.members)}catch(P){Ve(Oe(P))}},U=async P=>{try{await p4(E,P);const H=await Hp(E);h(H.members)}catch(H){Ve(Oe(H))}},_=async()=>{try{await f4(E),t();const P=u.find(H=>H.projectId!==E);await m(),P&&c(P.projectId)}catch(P){Ve(Oe(P))}};return r.jsxs(Xt,{open:e,title:f.project.settingsTitle,onClose:t,children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[B?r.jsxs(r.Fragment,{children:[r.jsx(wr,{children:f.project.displayName}),r.jsxs("div",{className:"flex items-stretch gap-2",children:[r.jsx(rt,{size:"sm",className:"min-w-0 flex-1",value:C,invalid:!!K,maxLength:100,onChange:P=>{T(P.target.value),K&&F(void 0)},onKeyDown:P=>{P.key==="Enter"&&V()}}),r.jsx(ve,{size:"sm",disabled:I||!C.trim()||C.trim()===Y,onClick:()=>{V()},children:f.common.save})]}),K!==void 0&&r.jsx(Kr,{children:K})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"mb-1 text-xs font-medium text-gray-500",children:f.project.switcher}),r.jsx("p",{className:"text-sm",children:Y})]}),r.jsx("p",{className:"mt-1 font-mono text-xs text-gray-400",children:E})]}),!i&&r.jsxs("div",{children:[r.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500",children:f.project.members}),k?r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:k}):p===null?r.jsx("p",{className:"text-xs text-gray-400",children:f.common.loading}):r.jsx("div",{className:"overflow-x-auto rounded-md border border-gray-200 dark:border-gray-800",children:r.jsxs("table",{className:"w-full text-xs",children:[r.jsx("thead",{children:r.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:[r.jsx("th",{className:"whitespace-nowrap px-2.5 py-1.5 font-medium",children:f.common.username}),r.jsx("th",{className:"whitespace-nowrap px-2.5 py-1.5 font-medium",children:f.common.role}),r.jsx("th",{className:"w-20 whitespace-nowrap px-2.5 py-1.5 text-right font-medium",children:f.common.actions})]})}),r.jsxs("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[p.map(P=>r.jsxs("tr",{children:[r.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:P.userId}),r.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:r.jsx(Cn,{tone:"gray",children:P.role})}),r.jsx("td",{className:"whitespace-nowrap px-2.5 py-1 text-right",children:B&&P.role!=="owner"&&P.userId!==a?.userId&&r.jsx(ve,{size:"sm",variant:"ghost",onClick:()=>{U(P.userId)},children:f.project.removeMember})})]},P.userId)),B&&r.jsxs("tr",{children:[r.jsx("td",{className:"px-2.5 py-1.5",children:r.jsx(rt,{placeholder:f.common.username,size:"sm",value:g,onChange:P=>v(P.target.value),onKeyDown:P=>{P.key==="Enter"&&O()}})}),r.jsx("td",{className:"whitespace-nowrap px-2.5 py-1.5",children:r.jsx(Cn,{tone:"gray",children:"member"})}),r.jsx("td",{className:"whitespace-nowrap px-2.5 py-1 text-right",children:r.jsx(ve,{size:"sm",disabled:!g.trim(),onClick:()=>{O()},children:f.project.addMember})})]})]})]})})]}),r.jsx(P9,{projectId:E,isOwner:B}),B&&r.jsx("div",{className:"border-t border-gray-100 pt-3 dark:border-gray-800",children:E==="default_project"?r.jsx("p",{className:"text-xs text-gray-400",children:f.project.deleteDefaultForbidden}):u.length<=1?r.jsx("p",{className:"text-xs text-gray-400",children:f.project.deleteLastForbidden}):r.jsx(ve,{size:"sm",variant:"danger",onClick:()=>M(!0),children:f.project.deleteProject})})]}),r.jsx(yn,{open:S,title:f.project.deleteProject,onClose:()=>M(!1),onConfirm:()=>{_()},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.project.deleteConfirm})})]})}function P9({projectId:e,isOwner:t}){const{user:a}=vn(),{agents:i}=cn(),[l,c]=x.useState(null),[u,m]=x.useState(null),[p,h]=x.useState(null),[g,v]=x.useState(!1),[k,w]=x.useState(""),[S,M]=x.useState(""),[C,T]=x.useState(""),[I,D]=x.useState(""),[K,F]=x.useState(null);x.useEffect(()=>{let U=!1;return qw(e).then(_=>{U||(c(_),w(_.agentId??""),M(_.workspace??""),T(_.approvalMode??""),D(_.thinkingLevel??""))}).catch(_=>{U||h(Oe(_))}),Yl(e).then(_=>{U||(m(_),F(_.defaultModel??null))}).catch(_=>{U||h(Oe(_))}),()=>{U=!0}},[e]);const E=l!==null&&(k!==(l.agentId??"")||S.trim()!==(l.workspace??"")||C!==(l.approvalMode??"")||I!==(l.thinkingLevel??"")),B=u!==null&&K!==null&&!_t(u.defaultModel,K),Y=async()=>{if(g||!E&&!B)return;v(!0);let U=null;try{if(E){const _={...k?{agentId:k}:{},...S.trim()?{workspace:S.trim()}:{},...C?{approvalMode:C}:{},...I?{thinkingLevel:I}:{}},P=await h4(e,_);c(P),a&&CD(a.userId,e),U={projectId:e,defaults:P}}if(B&&K){const _=await x4(e,{provider:K.provider,modelId:K.modelId});m(P=>P&&{...P,defaultModel:_.defaultModel}),a&&u5(a.userId,e),U={...U??{projectId:e},defaultModel:_.defaultModel}}U&&Ut(f.common.saved)}catch(_){Ve(Oe(_))}finally{U&&_D(U),v(!1)}},V=l?.agentId?(()=>{const U=i.find(_=>_.agentId===l.agentId);return U?pn(U):l.agentId})():f.project.chatDefaultsNotSet,O=u?.models.find(U=>_t(U,u.defaultModel));return r.jsxs("div",{className:"border-t border-gray-100 pt-3 dark:border-gray-800",children:[r.jsx("p",{className:"text-xs font-medium text-gray-500",children:f.project.chatDefaultsTitle}),r.jsx("p",{className:"mb-2 mt-0.5 text-xs text-gray-400",children:f.project.chatDefaultsHint}),p?r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:p}):l===null||u===null?r.jsx("p",{className:"text-xs text-gray-400",children:f.common.loading}):t?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[r.jsxs(oi,{label:f.project.chatDefaultsAgent,size:"sm",value:k,onChange:U=>w(U.target.value),children:[r.jsx("option",{value:"",children:f.project.chatDefaultsNotSet}),i.map(U=>r.jsx("option",{value:U.agentId,children:pn(U)},U.agentId))]}),r.jsxs(oi,{label:f.chat.approvalMode,size:"sm",value:C,onChange:U=>T(U.target.value),children:[r.jsx("option",{value:"",children:f.project.chatDefaultsApprovalNotSet}),U9.map(U=>r.jsx("option",{value:U,children:f.chat.approvalModeNames[U]??U},U))]}),r.jsxs(oi,{label:f.chat.thinkingLevel,size:"sm",value:I,onChange:U=>D(U.target.value),children:[r.jsx("option",{value:"",children:f.project.chatDefaultsThinkingNotSet}),Yj.map(U=>r.jsx("option",{value:U,children:f.chat.thinkingLevelNames[U]??U},U))]}),r.jsxs("div",{children:[r.jsx(wr,{children:f.chat.model}),u.models.length>0?r.jsxs(r.Fragment,{children:[r.jsx(I0,{models:u.models,value:K,defaultModel:u.defaultModel,onChange:F,disabled:g,variant:"form"}),r.jsx(Yd,{children:f.project.chatDefaultsModelHint})]}):r.jsx("p",{className:"text-xs text-gray-400",children:f.models.empty})]}),r.jsxs("div",{className:"sm:col-span-2",children:[r.jsx(wr,{children:f.chat.workspace}),r.jsx(If,{projectId:e,workspace:S,onChange:M,variant:"form"}),r.jsx(Yd,{children:f.project.chatDefaultsWorkspaceHint})]})]}),r.jsx("div",{className:"mt-3 flex justify-end",children:r.jsx(ve,{size:"sm",disabled:g||!E&&!B,onClick:()=>{Y()},children:f.common.save})})]}):r.jsx("div",{className:"space-y-1 text-sm",children:[[f.project.chatDefaultsAgent,V],[f.chat.workspace,l.workspace??f.chat.workspaceAuto],[f.chat.approvalMode,l.approvalMode?f.chat.approvalModeNames[l.approvalMode]??l.approvalMode:f.project.chatDefaultsApprovalNotSet],[f.chat.thinkingLevel,l.thinkingLevel?f.chat.thinkingLevelNames[l.thinkingLevel]??l.thinkingLevel:f.project.chatDefaultsThinkingNotSet],[f.chat.model,O?O.displayName??O.modelId:f.project.chatDefaultsNotSet]].map(([U,_])=>r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"w-24 shrink-0 text-xs text-gray-500",children:U}),r.jsx("span",{className:"min-w-0 flex-1 break-all",children:_})]},U))})]})}const B9="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",H9="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 ci({label:e,hint:t,error:a,invalid:i,required:l,size:c="base",className:u,...m}){const[p,h]=x.useState(!1),g=p?f.auth.hidePassword:f.auth.showPassword,v=x.useId();return r.jsx(Gc,{label:e,hint:t,error:a,errorId:v,required:l,children:r.jsxs("div",{className:"relative",children:[r.jsx(rt,{...m,required:l,size:c,type:p?"text":"password",invalid:!!a||!!i,"aria-describedby":a?v:void 0,className:`${c==="sm"?"pr-8":"pr-10"} ${u??""}`}),r.jsx("button",{type:"button","aria-label":g,title:g,tabIndex:-1,onClick:()=>h(k=>!k),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 ${c==="sm"?"w-8":"w-10"}`,children:r.jsx("svg",{width:c==="sm"?14:16,height:c==="sm"?14:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r.jsx("path",{d:p?H9:B9})})})]})})}function w5({open:e,onClose:t}){const{refresh:a,sessionVia:i}=vn(),l=i==="desktop",[c,u]=x.useState(""),[m,p]=x.useState(""),[h,g]=x.useState(""),[v,k]=x.useState({}),[w,S]=x.useState(!1),M=()=>k(T=>T.old||T.new||T.confirm?{}:T);x.useEffect(()=>{e&&(u(""),p(""),g(""),k({}))},[e]);const C=async()=>{const T={};if(!l&&!c&&(T.old=f.common.requiredField),m||(T.new=f.common.requiredField),h||(T.confirm=f.common.requiredField),!T.confirm&&m!==h&&(T.confirm=f.account.passwordMismatch),T.old||T.new||T.confirm){k(T);return}S(!0),k({});try{await r4(l?{newPassword:m}:{oldPassword:c,newPassword:m}),await a(),t()}catch(I){I instanceof sa&&I.code==="invalid_password"?k({new:Oe(I)}):k({old:Oe(I)})}finally{S(!1)}};return r.jsx(Xt,{open:e,title:f.account.changePassword,onClose:t,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:t,disabled:w,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:w,onClick:()=>{C()},children:f.common.save})]}),children:r.jsxs("div",{className:"space-y-3",children:[!l&&r.jsx(ci,{label:f.account.oldPassword,required:!0,size:"sm",value:c,onChange:T=>{u(T.target.value),M()},error:v.old,autoComplete:"current-password",hint:f.account.oldPasswordHint,autoFocus:!0}),r.jsx(ci,{label:f.account.newPassword,required:!0,size:"sm",value:m,onChange:T=>{p(T.target.value),M()},error:v.new,autoComplete:"new-password",hint:f.auth.passwordHint,autoFocus:l}),r.jsx(ci,{label:f.account.confirmPassword,required:!0,size:"sm",value:h,onChange:T=>{g(T.target.value),M()},error:v.confirm,autoComplete:"new-password"})]})})}function F9({open:e,onClose:t}){const[a,i]=x.useState(null),[l,c]=x.useState(!0),[u,m]=x.useState(!0),[p,h]=x.useState(""),[g,v]=x.useState(null),[k,w]=x.useState(!1);x.useEffect(()=>{if(!e)return;let C=!1;return i(null),v(null),w(!1),Fw().then(T=>{C||(i(T.settings),c(T.settings.proxyForApp),m(T.settings.proxyForAgent),h(T.settings.proxyUrl??""))}).catch(T=>{C||Ve(Oe(T))}),()=>{C=!0}},[e]);const S=async()=>{if(a===null||k)return;if(l===a.proxyForApp&&u===a.proxyForAgent&&p.trim()===(a.proxyUrl??"")){pa(f.common.noChangesToSave);return}w(!0),v(null);try{await Vw({proxyForApp:l,proxyForAgent:u,proxyUrl:p}),Ut(f.common.saved),t()}catch(T){T instanceof sa&&T.code==="invalid_proxy_url"?v(Oe(T)):Ve(Oe(T))}finally{w(!1)}},M=a!==null;return r.jsx(Xt,{open:e,title:f.settings.proxyDialogTitle,onClose:t,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:t,disabled:k,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:!M||k,onClick:()=>{S()},children:f.common.save})]}),children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("span",{className:"text-sm font-medium",children:f.settings.proxyForApp}),r.jsx(di,{checked:l,onChange:c,disabled:!M})]}),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("span",{className:"text-sm font-medium",children:f.settings.proxyForAgent}),r.jsx(di,{checked:u,onChange:m,disabled:!M})]}),r.jsx(rt,{label:f.settings.proxyAddress,size:"sm",value:p,placeholder:f.settings.proxyAddressPlaceholder,disabled:!M,...g!==null?{error:g}:{},onChange:C=>{h(C.target.value),g!==null&&v(null)}})]})})}function V9({open:e,onClose:t}){const{uploadLimits:a,refresh:i}=vn(),[l,c]=x.useState(null),[u,m]=x.useState(""),[p,h]=x.useState(""),[g,v]=x.useState(null),[k,w]=x.useState(!1);x.useEffect(()=>{if(!e)return;let C=!1;return c(null),v(null),w(!1),Fw().then(T=>{C||(c(T.settings),m(String(T.settings.attachmentMaxMb)),h(String(T.settings.attachmentTotalMb)))}).catch(T=>{C||Ve(Oe(T))}),()=>{C=!0}},[e]);const S=async()=>{if(l===null||k)return;const C=Number(u.trim()),T=Number(p.trim());if(u.trim()===""||p.trim()===""||!Number.isInteger(C)||!Number.isInteger(T)){v(f.errors.byCode.invalid_attachment_limit);return}if(C===l.attachmentMaxMb&&T===l.attachmentTotalMb){pa(f.common.noChangesToSave);return}w(!0),v(null);try{await Vw({attachmentMaxMb:C,attachmentTotalMb:T}),await i().catch(()=>{}),Ut(f.common.saved),t()}catch(I){I instanceof sa&&I.code==="invalid_attachment_limit"?v(Oe(I)):Ve(Oe(I))}finally{w(!1)}},M=l!==null;return r.jsx(Xt,{open:e,title:f.settings.uploadLimitsDialogTitle,onClose:t,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:t,disabled:k,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:!M||k,onClick:()=>{S()},children:f.common.save})]}),children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(rt,{label:f.settings.attachmentMaxMb,size:"sm",type:"number",inputMode:"numeric",min:a.attachmentLimitMinMb,max:a.attachmentLimitMaxMb,value:u,disabled:!M,onChange:C=>{m(C.target.value),g!==null&&v(null)}}),r.jsx(rt,{label:f.settings.attachmentTotalMb,size:"sm",type:"number",inputMode:"numeric",min:a.attachmentLimitMinMb,max:a.attachmentLimitMaxMb,value:p,disabled:!M,...g!==null?{error:g}:{},onChange:C=>{h(C.target.value),g!==null&&v(null)}}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.settings.uploadLimitsHint(a.attachmentLimitMinMb,a.attachmentLimitMaxMb,a.attachmentMaxCount,a.imageMaxMb)})]})})}function q9({open:e,onClose:t,latestVersion:a,releaseUrl:i=null,canUpdate:l,onRunFinished:c}){const[u,m]=x.useState("confirm"),[p,h]=x.useState(null);x.useEffect(()=>{e&&(m("confirm"),h(null))},[e]);const g=()=>{u==="done"&&c?.(),t()},v=async()=>{m("running");try{h(await pT())}catch(w){h({status:"failed",output:Oe(w),needsRestart:!1})}m("done")},k=p===null?null:p.status==="updated"?{text:f.update.updated,className:"text-green-600 dark:text-green-400"}:p.status==="unsupported"?{text:f.update.unsupported,className:"text-amber-600 dark:text-amber-400"}:{text:f.update.failed,className:"text-red-600 dark:text-red-400"};return r.jsx(Xt,{open:e,title:l?f.update.updateNow:a!==null?f.update.newVersion(a):f.update.releaseNotes,onClose:u==="running"?()=>{}:g,footer:u==="done"||!l?r.jsx(ve,{onClick:g,children:f.common.close}):r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:g,disabled:u==="running",children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:u==="running",onClick:()=>{v()},children:u==="running"?f.update.updating:f.update.updateNow})]}),children:u==="done"&&p!==null&&k!==null?r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:`text-sm font-medium ${k.className}`,children:k.text}),p.status==="updated"&&r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:f.update.restartHint}),p.output!==""&&r.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:Rj(p.output)})]}):r.jsxs("div",{className:"space-y-2",children:[a!==null&&r.jsx("p",{className:"text-sm font-medium",children:f.update.newVersion(a)}),i!==null&&r.jsx("p",{children:r.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:f.update.releaseNotes})}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:l?f.update.confirmBody:f.update.adminOnly}),u==="running"&&r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:f.update.updating})]})})}const wg="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z";function G9({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:[r.jsx("circle",{cx:"5",cy:"12",r:"2"}),r.jsx("circle",{cx:"12",cy:"12",r:"2"}),r.jsx("circle",{cx:"19",cy:"12",r:"2"})]})}const qk="M21 21l-4.35-4.35M17 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0z",W9="M21 5h-7M10 5H3M21 12h-9M8 12H3M21 19h-5M12 19H3M14 2v6M8 9v6M16 16v6",K9="M18 6L6 18M6 6l12 12",Y9="application/x-penguin-session-id",Gk="(hover: hover) and (pointer: fine)";function Wk({base:e,size:t=15}){return r.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:[r.jsx("g",{transform:"translate(-1 -1) scale(0.82)",children:r.jsx("path",{d:e})}),r.jsx("path",{d:"M18.5 15.5v6M15.5 18.5h6",strokeWidth:"2"})]})}const Pi="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",kd=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"}`,Kk="px-2.5 pb-0.5 pt-1.5 text-[11px] font-medium text-gray-400 dark:text-gray-500",Q9=e=>`penguin.sidebarCollapsedGroups.${e}`,X9=e=>`penguin.sidebarPinnedGroups.${e}`;function wd(e){if(!e)return new Set;try{const t=JSON.parse(localStorage.getItem(e)??"[]");return new Set(Array.isArray(t)?t.filter(a=>typeof a=="string"):[])}catch{return new Set}}function Yk(e,t){if(e)try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}const Sd=(e,t)=>`${t}\0${e}`,Sh="\0drafts";function Z9({activity:e}){return e===null?r.jsx("span",{"aria-hidden":"true",className:"block h-3 w-3 shrink-0"}):r.jsx(oS,{activity:e})}function Qk({onNavigate:e,onCollapse:t}){const a=ia(),{user:i,logout:l,desktopMode:c,sessionVia:u}=vn(),{mode:m,setMode:p,fontScale:h,setFontScale:g,accent:v,setAccent:k,currency:w,setCurrency:S}=mi(),{lang:M,locale:C,setLang:T}=Za(),{projects:I,currentProject:D,setCurrentProjectId:K,reloadProjects:F,agents:E,currentAgent:B,setCurrentAgentId:Y}=cn(),{sessions:V,byAgent:O,countsByAgent:U,workspaceCountsByAgent:_,isLoadedFor:P,hasMoreFor:H,loadMoreFor:G,loading:z,remove:J,replace:xe,showCliSessions:me,setShowCliSessions:A}=pi(),q=h2("/chat/:sessionId")?.params.sessionId??null,[j,$]=x.useState(!1),[ae,de]=x.useState(!1),[ye,Se]=x.useState(!1),[ke,ee]=x.useState(!1),[je,Ae]=x.useState(!1),[Qe,We]=x.useState(!1),{version:re,update:ft}=Gg(ae),ge=ft?.updateAvailable===!0,dt=ge?ft?.latestVersion??null:null,It=re?.buildDate??null,[zt,nn]=x.useState(!1),un=async()=>{if(!zt){nn(!0);try{const X=p3(await Fb());X.kind==="disabled"?pa(f.update.checkDisabled):X.kind==="failed"?Ve(f.update.checkFailed):X.kind==="found"?Ut(f.update.foundNew(X.latestVersion)):Ut(f.update.upToDate)}catch(X){Ve(Oe(X))}finally{nn(!1)}}},[Wt,Ce]=x.useState(!1),[Ke,se]=x.useState(!1),ce=D?.projectId??null,De=_3(ce),Be=ce===null?null:Q9(ce),Ue=ce===null?null:X9(ce),[W,pe]=x.useState(D3),[Ne,Re]=x.useState(Vh),[Pe,Fe]=x.useState(()=>wd(Be)),[nt,ot]=x.useState(()=>wd(Ue)),[Te,ze]=x.useState(()=>Yb(ce)),[yt,ct]=x.useState(G3),[vt,hn]=x.useState(()=>Yp(ce,Vh())),[bt,dn]=x.useState(()=>Xb(ce)),[Qn,Ht]=x.useState(null),[Bn,Ur]=x.useState(""),[ga,zn]=x.useState(null),[xa,Hn]=x.useState(!1),[ya,va]=x.useState(""),[zr,an]=x.useState(!1),[$t,gn]=x.useState(()=>window.matchMedia(Gk).matches);x.useEffect(()=>{const X=window.matchMedia(Gk),_e=pt=>gn(pt.matches);return X.addEventListener("change",_e),()=>X.removeEventListener("change",_e)},[]);const[Xn,Ja]=x.useState(null),[Ns,ba]=x.useState(null);x.useEffect(()=>{Fe(wd(Be)),ot(wd(Ue)),ze(Yb(ce)),hn(Yp(ce,Ne)),dn(Xb(ce)),Ft(ud)},[Be,Ue,ce]);const[ka,wa]=x.useState(new Set),[$r,Sa]=x.useState(new Set),[za,ja]=x.useState(new Map),[$n,Ft]=x.useState(ud),[er,Nr]=x.useState(null),[Vt,Zn]=x.useState(!1),[oa,tr]=x.useState(null),nr=MD(i?.userId??null,ce),[Pr,$a]=x.useState(null),[ca,On]=x.useState(""),[bn,ar]=x.useState(!1),[ue,Me]=x.useState(null),et=X=>{R2(X),Re(X),hn(Yp(ce,X)),Ft(ud)},it=()=>{const X=!W;U3(X),pe(X)},gt=x.useMemo(()=>q3(T2(V),bt),[V,bt]),xt=x.useMemo(()=>C2(_),[_]),Zt=x.useMemo(()=>Hd(E,X=>X.agentId,nt),[E,nt]),Pa=x.useMemo(()=>Hd(gt,X=>X.key,nt),[gt,nt]),ua=X=>Ne==="agent"?X.agentId:Ac(X.workspace),Fn=X=>{if(Bt)return;const _e=new Set(Pe);_e.has(X)?_e.delete(X):_e.add(X),Fe(_e),Yk(Be,_e)},Ca=X=>{const _e=new Set(nt);_e.has(X)?_e.delete(X):_e.add(X),ot(_e),Yk(Ue,_e)},xi=X=>{const _e=z3(Te,X);ze(_e),Qb(ce,_e)},rr=X=>{W3(X),ct(X)},Bt=ya.trim()!=="",Ts=yt==="manual"&&$t?"manual":"recent",ts=X=>Bt?X.filter(_e=>o3(_e,ya)):X,Ms=()=>{Hn(!1),va("")},yi=(X,_e,pt)=>{if(!Xn)return;const Et=Y3(X,Xn.id,_e,pt);if(Et===X)return;const st=Q3(vt,Et);hn(st),Zb(ce,Ne,st)},As=Bt?nr.filter(X=>bg(X).toLowerCase().includes(ya.trim().toLowerCase())):nr,Es=As.length>0||(Ne==="agent"?Zt.some(X=>ts(O.get(X.agentId)??[]).length>0):Pa.some(X=>ts(X.sessions).length>0)),Jn=(X,_e)=>`${_e}\0${X}`,_s=(X,_e,pt)=>{const Et=Jn(X,_e);Sa(st=>new Set(st).add(Et)),G(pt,_e).finally(()=>{Sa(st=>{const Mt=new Set(st);return Mt.delete(Et),Mt})})},vi=(X,_e,pt)=>{if(Bt)return;const Et=Sd(X,_e),st=!ka.has(Et);if(wa(Mt=>{const xn=new Set(Mt);return st?xn.add(Et):xn.delete(Et),xn}),st){const Mt=pt.filter(xn=>!P(xn,_e));Mt.length>0&&G(Mt,_e)}},sr=x.useRef(null);x.useEffect(()=>{if(!q)return;const X=V.find(Mt=>Mt.sessionId===q);if(!X)return;const _e=Ir(X);if(_e==="active"||_e==="archived")return;const pt=`${Ne}\0${q}`;if(sr.current===pt)return;sr.current=pt;const Et=Ne==="agent"?X.agentId:Ac(X.workspace),st=Sd(Et,_e);wa(Mt=>Mt.has(st)?Mt:new Set(Mt).add(st)),P(X.agentId,_e)||G([X.agentId],_e)},[q,V,Ne,P,G]);const Tr=async X=>{!X.archived&&X.sessionId===q&&wa(_e=>new Set(_e).add(Sd(ua(X),"archived")));try{const _e=await Pd(X.sessionId,{archived:!X.archived});xe(_e.session)}catch{}},ne=async()=>{if(!Pr)return;const X=ca.trim();if(X){ar(!0),Me(null);try{const _e=await Pd(Pr.sessionId,{title:X});xe(_e.session),$a(null)}catch(_e){Me(Oe(_e))}finally{ar(!1)}}},Ee=async()=>{if(!er)return;Zn(!0);const X=er;try{await Bd(X.sessionId),J(X.sessionId),i&&zc(o5(i.userId,X.sessionId));const _e=$3(Te,X.sessionId);_e!==Te&&(ze(_e),Qb(ce,_e)),R3(ce,X.sessionId);const pt=X3(vt,X.sessionId);if(pt!==vt&&(hn(pt),Zb(ce,Ne,pt)),Nr(null),q===X.sessionId){const Et=(O.get(X.agentId)??[]).filter(st=>{const Mt=Ir(st);return st.sessionId!==X.sessionId&&(Mt==="active"||Mt==="schedule")});a(Et[0]?`/chat/${Et[0].sessionId}`:"/chat")}}catch(_e){Ve(Oe(_e))}finally{Zn(!1)}},Ze=X=>{a(X),e?.()},Xe=(X,_e)=>{i&&ce&&uo(i.userId,ce),X&&Y(X);const pt={...X?{agentId:X}:{},..._e!==void 0?{workspace:_e}:{}};a(`/chat/${Xa}`,Object.keys(pt).length>0?{state:pt}:void 0),e?.()},at=()=>{oa&&(i&&ce&&f5(i.userId,ce,oa.id),q===oa.id&&a(`/chat/${Xa}`),tr(null))},kn=(E.find(X=>X.agentId==="default_agent")??E[0])?.agentId,ea=B?.agentId??kn,Na=qb(Ne)==="agent"?f.agent.create:f.chat.newWorkspaceEntity,ns=X=>{X!==bt&&(dn(X),B3(ce,X))},sl=X=>{const _e=H3(bt,X);_e!==bt&&(ns(_e),Ft(pt=>Math.max(pt,gt.length+1)))},nu=x.useMemo(()=>new Set(bt.map(X=>X.path)),[bt]),il=X=>{Ur(bt.find(_e=>_e.path===X)?.alias??""),Ht({path:X})},bi=()=>{Qn&&(ns(F3(bt,Qn.path,Bn)),Ht(null))},au=()=>{ga&&(ns(V3(bt,ga.path)),zn(null))},ta=X=>{F2(ce,X.sessionId,X.lastActiveAt),Y(X.agentId),Ze(`/chat/${X.sessionId}`)},as=x.useMemo(()=>new Map(E.map(X=>[X.agentId,pn(X)])),[E]),ki=(X,_e,pt,Et=!1)=>r.jsx("ul",{className:"space-y-0.5",children:X.map(st=>{const Mt=pt!==void 0&&Xn?.scope===pt.scope?Xn:null,xn=Mt!==null&&Mt.id!==st.sessionId&&Te.has(Mt.id)===Te.has(st.sessionId),ir=pt===void 0?{}:{draggable:!0,onDragStart:Lt=>{Lt.dataTransfer.setData(Y9,st.sessionId),Lt.dataTransfer.effectAllowed="move",Ja({scope:pt.scope,id:st.sessionId})},onDragEnd:()=>{Ja(null),ba(null)},onDragOver:Lt=>{if(!Mt||!xn)return;Lt.preventDefault();const lr=Lt.currentTarget.getBoundingClientRect(),Rs=Lt.clientY-lr.top>lr.height/2;ba(rs=>rs?.id===st.sessionId&&rs.after===Rs?rs:{id:st.sessionId,after:Rs})},onDragLeave:()=>ba(Lt=>Lt?.id===st.sessionId?null:Lt),onDrop:Lt=>{if(!Mt||!xn)return;Lt.preventDefault();const lr=Lt.currentTarget.getBoundingClientRect(),Rs=Lt.clientY-lr.top>lr.height/2,rs=pt.fullRows.filter(Br=>Te.has(Br.sessionId)===Te.has(Mt.id)).map(Br=>Br.sessionId);yi(rs,st.sessionId,Rs),Ja(null),ba(null)},dropEdge:xn&&Ns?.id===st.sessionId?Ns.after?"below":"above":null};return r.jsx(eU,{s:st,active:st.sessionId===q,activity:I3(st,De,q),pinned:Te.has(st.sessionId),canPin:Et,lastActive:j3(st.lastActiveAt,C),..._e?{agentHint:as.get(st.agentId)??st.agentId}:{},...ir,onOpen:ta,onTogglePin:Lt=>xi(Lt.sessionId),onRename:Lt=>{Me(null),On(Lt.title??""),$a(Lt)},onDelete:Lt=>Nr(Lt),onToggleArchive:Lt=>{Tr(Lt)}},st.sessionId)})}),wi=(X,_e,pt,Et,st,Mt)=>{const xn=pt[_e];if(Bt&&xn.length===0)return null;const ir=Bt?xn.length:Math.max(Mt?.[_e]??0,xn.length);if(ir===0)return null;const Lt=!Bt&&xn.length<ir&&st.some(lr=>H(lr,_e));return r.jsx(L2,{label:f.chat.folderGroups[_e](ir),open:Bt||ka.has(Sd(X,_e)),onToggle:()=>vi(X,_e,st),more:Lt,pending:$r.has(Jn(X,_e)),onMore:()=>_s(X,_e,st),children:ki(xn,Et)},_e)},Uf=(X,_e)=>{ja(pt=>{const Et=new Map(pt);return Et.set(X,(pt.get(X)??qi)+qi),Et}),_e.length>0&&_s(X,"active",_e)},ll=(X,_e,pt,Et,st)=>{const Mt=za.get(X)??qi,xn=K3(_e.active,or=>or.sessionId,{pinned:Te,sortMode:Ts,order:vt,recencyOf:or=>or.lastActiveAt}),ir=Bt?xn:xn.slice(0,Mt),Lt=Ts==="manual"&&!Bt?{scope:X,fullRows:xn}:void 0,lr=st("active"),Rs=Math.max(Et?.active??0,_e.active.length),rs=!Bt&&(_e.active.length>Mt||_e.active.length<Rs&&lr.some(or=>H(or,"active"))),Br=Vc.map(or=>wi(X,or,_e,pt,st(or),Et)),Pf=_e.active.length===0&&Br.every(or=>or===null),Bf=$r.has(Jn(X,"active"));return r.jsxs(r.Fragment,{children:[Pf?r.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400 dark:text-gray-600",children:f.chat.noSessions}):ki(ir,pt,Lt,!0),rs&&r.jsx(Wl,{label:f.chat.loadMore,pending:Bf,onClick:()=>Uf(X,lr),className:"mt-0.5"}),Br]})},ol=X=>r.jsx(Wl,{label:f.chat.moreGroups(X-$n),onClick:()=>Ft(_e=>_e+ud),className:"mt-1"}),Si=O3.map(X=>({to:`/${X}`,label:f.nav[X],icon:li[X]})),cl=[{value:"light",label:f.settings.themeLight},{value:"dark",label:f.settings.themeDark},{value:"system",label:f.settings.followSystem}],ru=[{value:"en",label:f.settings.langEn},{value:"zh",label:f.settings.langZh},{value:"system",label:f.settings.followSystem}],zf=[{value:"sm",label:f.settings.fontSmall},{value:"md",label:f.settings.fontMedium},{value:"lg",label:f.settings.fontLarge}],$f=[{value:"USD",label:f.models.currencyUsd},{value:"CNY",label:f.models.currencyCny}];return r.jsxs("div",{className:"flex h-full w-full flex-col",children:[r.jsxs("div",{className:"flex shrink-0 items-center gap-1 px-2 pt-2",children:[t&&r.jsx("button",{type:"button",title:f.nav.collapseSidebar,"aria-label":f.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:r.jsx(Mn,{d:"M15 6l-6 6 6 6M4 4v16",size:18})}),r.jsxs(Un,{open:j,setOpen:$,className:"min-w-0 flex-1",menuClass:"left-0 right-0 top-full mt-1 origin-top",button:r.jsxs("button",{type:"button",onClick:()=>$(!j),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:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:D?Ph(D):f.common.loading}),r.jsx("span",{className:"text-gray-400",children:r.jsx(Ql,{})})]}),children:[I.map(X=>r.jsxs("button",{type:"button",onClick:()=>{K(X.projectId),$(!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 ${X.projectId===D?.projectId?"font-semibold":""}`,children:[r.jsx("span",{className:"truncate",children:Ph(X)}),r.jsx(Cn,{tone:"gray",children:X.role})]},X.projectId)),r.jsxs("div",{className:"mt-1.5 border-t border-gray-100 pt-1.5 dark:border-gray-800",children:[r.jsxs("button",{type:"button",className:Pi,onClick:()=>{$(!1),Se(!0)},children:["+ ",f.project.create]}),D&&r.jsx("button",{type:"button",className:Pi,onClick:()=>{$(!1),ee(!0)},children:f.project.settings})]})]})]}),r.jsx("div",{className:"shrink-0 px-2 pb-2 pt-2",children:r.jsxs("button",{type:"button",onClick:()=>Xe(kn),className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors duration-150 ${q===Xa?"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:[r.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:r.jsx(Mn,{d:wg})}),f.chat.newSessionMenu]})}),r.jsxs("div",{className:"relative min-h-0 flex-1 overflow-y-auto px-2 pb-2",children:[r.jsxs("nav",{className:"space-y-0.5",children:[r.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${W?"grid-rows-[0fr]":"grid-rows-[1fr]"}`,children:r.jsx("div",{className:"overflow-hidden",inert:W,children:r.jsx("div",{className:`space-y-0.5 transition-opacity duration-200 ${W?"opacity-0":"opacity-100"}`,children:Si.map(X=>r.jsxs(Vg,{to:X.to,onClick:()=>e?.(),className:({isActive:_e})=>`flex items-center gap-2 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-200/50 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800/70 dark:hover:text-gray-200"}`,children:[r.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:r.jsx(Mn,{d:X.icon})}),X.label]},X.to))})})}),r.jsx("button",{type:"button",onClick:it,"aria-expanded":!W,"aria-label":W?f.nav.expandGroup:f.nav.collapseGroup,title:W?f.nav.expandGroup:f.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:r.jsx(Ql,{size:12,className:`transition-transform duration-200 ${W?"":"rotate-180"}`})})]}),r.jsxs("div",{className:`mt-3 grid items-center px-1 pt-2 transition-[grid-template-columns] duration-200 ease-out ${xa?"grid-cols-[0fr_1fr]":"grid-cols-[1fr_1fr]"}`,children:[r.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 ${xa?"opacity-0":"opacity-100"}`,children:f.chat.sessionList}),r.jsxs("div",{className:"flex min-w-0 items-center justify-end gap-0.5",children:[xa?r.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:[r.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-gray-400 dark:text-gray-500",children:r.jsx(Mn,{d:qk,size:12})}),r.jsx("input",{autoFocus:!0,value:ya,placeholder:f.chat.searchSessionsPlaceholder,"aria-label":f.chat.searchSessions,...Wc,onChange:X=>va(X.target.value),onKeyDown:X=>{X.key==="Escape"&&(X.stopPropagation(),Ms())},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"}),r.jsx("button",{type:"button",title:f.chat.searchClear,"aria-label":f.chat.searchClear,onClick:Ms,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:r.jsx(Mn,{d:K9,size:11})})]}):r.jsx("button",{type:"button",title:f.chat.searchSessions,"aria-label":f.chat.searchSessions,onClick:()=>Hn(!0),className:kd(!1),children:r.jsx(Mn,{d:qk,size:14})}),r.jsxs(Un,{open:zr,setOpen:an,portal:{direction:"down",align:"right"},menuClass:"w-40",button:r.jsx("button",{type:"button",title:f.chat.listSettings,"aria-label":f.chat.listSettings,"aria-haspopup":"menu","aria-expanded":zr,onClick:()=>an(!zr),className:kd(zr),children:r.jsx(Mn,{d:W9,size:14})}),children:[r.jsx("p",{className:Kk,children:f.chat.groupModeSection}),r.jsx(jd,{icon:Vd.workspace,label:f.chat.groupByWorkspace,checked:Ne==="workspace",onSelect:()=>{et("workspace"),an(!1)}}),r.jsx(jd,{icon:Vd.agent,label:f.chat.groupByAgent,checked:Ne==="agent",onSelect:()=>{et("agent"),an(!1)}}),r.jsx("div",{className:"my-1 border-t border-gray-100 dark:border-gray-800"}),r.jsx("p",{className:Kk,children:f.chat.sortModeSection}),$t&&r.jsx(jd,{icon:Vb.manual,label:f.chat.sortManual,checked:yt==="manual",onSelect:()=>{rr("manual"),an(!1)}}),r.jsx(jd,{icon:Vb.recent,label:f.chat.sortRecent,checked:yt==="recent",onSelect:()=>{rr("recent"),an(!1)}})]}),qb(Ne)==="agent"?r.jsx("button",{type:"button",title:Na,"aria-label":Na,onClick:()=>{a("/agents",{state:{create:!0}}),e?.()},className:kd(!1),children:r.jsx(Wk,{base:li.agents})}):r.jsx(If,{projectId:ce??"",workspace:"",onChange:sl,trigger:(X,_e)=>r.jsx("button",{type:"button",title:Na,"aria-label":Na,"aria-expanded":X,onClick:_e,className:kd(X),children:r.jsx(Wk,{base:Fd})})},ce??"no-project")]})]}),As.length>0&&r.jsxs("div",{className:"pt-2.5",children:[r.jsx(gc,{open:Bt||!Pe.has(Sh),onToggle:()=>Fn(Sh),icon:r.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:r.jsx(Mn,{d:wg,size:14})}),label:f.chat.draftGroup,uppercase:!0,count:As.length}),(Bt||!Pe.has(Sh))&&r.jsx("ul",{className:"space-y-0.5",children:As.map(X=>r.jsx(J9,{entry:X,active:X.id===q,onOpen:()=>Ze(`/chat/${X.id}`),onDelete:()=>tr(X)},X.id))})]}),Ne==="agent"?z&&E.length===0?r.jsx(La,{rows:5}):Zt.slice(0,Bt?Zt.length:$n).map(X=>{const _e=ts(O.get(X.agentId)??[]);if(Bt&&_e.length===0)return null;const pt=Hb(_e),Et=!Bt&&Pe.has(X.agentId),st=nt.has(X.agentId);return r.jsxs("div",{className:"pt-2.5",children:[r.jsx(gc,{open:!Et,onToggle:()=>Fn(X.agentId),icon:r.jsx(Da,{id:X.agentId,name:pn(X),size:18,className:"shrink-0 rounded"}),label:pn(X),uppercase:!0,actions:r.jsxs(r.Fragment,{children:[r.jsx(Xk,{pinned:st,onToggle:()=>Ca(X.agentId)}),r.jsx("button",{type:"button",title:f.chat.newSessionMenu,"aria-label":f.chat.newSessionMenu,onClick:()=>Xe(X.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:r.jsx(Mn,{d:"M12 5v14M5 12h14",size:18})}),r.jsx("button",{type:"button",title:f.agent.settings,onClick:()=>Ze(`/agents/${X.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:r.jsx(Mn,{d:D2,size:16})})]})}),Et?null:ll(X.agentId,pt,!1,U.get(X.agentId),()=>[X.agentId])]},X.agentId)}):null,Ne==="agent"&&!Bt&&Zt.length>$n?ol(Zt.length):null,Ne==="agent"?null:z&&V.length===0?r.jsx(La,{rows:5}):Pa.length===0&&!Bt?r.jsx("p",{className:"px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600",children:f.chat.noSessions}):Pa.slice(0,Bt?Pa.length:$n).map(X=>{const _e=ts(X.sessions);if(Bt&&_e.length===0)return null;const pt=Hb(_e),Et=!Bt&&Pe.has(X.key),st=nt.has(X.key),Mt=xt.get(X.key),xn=[...new Set(X.sessions.map(Lt=>Lt.agentId))],ir=Lt=>[...new Set([...Mt?.agents[Lt]??[],...xn])];return r.jsxs("div",{className:"pt-2.5",children:[r.jsx(gc,{open:!Et,onToggle:()=>Fn(X.key),icon:r.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:r.jsx(Mn,{d:Et?Fd:A2,size:15})}),label:X.temp?f.chat.tempWorkspaces:X.label,count:Bt?pt.active.length:Math.max(Mt?.totals.active??0,pt.active.length),...X.fullPath!==null?{title:X.fullPath}:{},actions:r.jsxs(r.Fragment,{children:[r.jsx(Xk,{pinned:st,onToggle:()=>Ca(X.key)}),r.jsx("button",{type:"button",title:f.chat.newSessionInWorkspace,"aria-label":f.chat.newSessionInWorkspace,onClick:()=>Xe(ea,X.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:r.jsx(Mn,{d:"M12 5v14M5 12h14",size:18})}),nu.has(X.key)&&r.jsx(tU,{onRename:()=>il(X.key),onDelete:()=>zn({path:X.key,label:X.label})})]})}),Et?null:ll(X.key,pt,!0,Mt?.totals,ir)]},X.key)}),Ne==="workspace"&&!Bt&&Pa.length>$n?ol(Pa.length):null,Bt&&!Es&&r.jsx("p",{className:"px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600",children:f.chat.searchNoMatches})]}),r.jsx("div",{className:"shrink-0 border-t border-gray-200 p-2 dark:border-gray-800",children:r.jsxs(Un,{open:ae,setOpen:de,menuClass:"bottom-full left-0 right-0 mb-1 origin-bottom",button:r.jsxs("button",{type:"button",onClick:()=>de(!ae),...dt!==null?{title:f.update.newVersion(dt),"aria-label":`${i?.userId??""} · ${f.update.newVersion(dt)}`}:{},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:[r.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:[(i?.userId??"?").slice(0,1).toUpperCase(),ge&&r.jsx("span",{"aria-hidden":!0,className:"absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-50 bg-[var(--accent-bg)] dark:border-gray-900"})]}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:i?.userId}),i?.isAdmin&&r.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:f.auth.admin})]}),children:[r.jsxs("div",{className:"space-y-2.5 px-3 py-2",children:[r.jsx(Pl,{label:f.settings.theme,children:r.jsx(Wi,{options:cl,value:m,onChange:p})}),r.jsx(Pl,{label:f.settings.fontSize,children:r.jsx(Wi,{options:zf,value:h,onChange:g})}),r.jsx(Pl,{label:f.settings.accent,children:r.jsx(nU,{value:v,onChange:k})}),r.jsx(Pl,{label:f.models.currency,children:r.jsx(Wi,{options:$f,value:w,onChange:S,cols:2})}),r.jsx(Pl,{label:f.settings.language,children:r.jsx(Wi,{options:ru,value:M,onChange:T})}),r.jsx(Pl,{label:f.settings.showCliSessions,children:r.jsx(di,{checked:me,onChange:A})})]}),r.jsxs("div",{className:"mt-1 border-t border-gray-100 pt-1 dark:border-gray-800",children:[L3({desktopMode:c,sessionVia:u})&&r.jsx("button",{type:"button",className:Pi,onClick:()=>{de(!1),Ae(!0)},children:f.account.changePassword}),i?.isAdmin&&r.jsx("button",{type:"button",className:Pi,onClick:()=>{de(!1),Ce(!0)},children:f.settings.proxyMenu}),i?.isAdmin&&r.jsx("button",{type:"button",className:Pi,onClick:()=>{de(!1),se(!0)},children:f.settings.uploadLimitsMenu}),!c&&r.jsxs("button",{type:"button",disabled:zt,onClick:()=>{dt!==null?(de(!1),We(!0)):un()},...It!==null?{title:f.update.lastUpdated(Gd(It,C))}:{},className:`${Pi} flex items-center justify-between gap-2 disabled:cursor-default disabled:opacity-60`,children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[zt&&r.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"}),!zt&&dt!==null&&r.jsx("span",{"aria-hidden":!0,className:"h-2 w-2 shrink-0 rounded-full bg-[var(--accent-bg)]"}),r.jsx("span",{className:"min-w-0 truncate",children:zt?f.update.checking:dt!==null?f.update.newVersion(dt):f.update.checkNow})]}),re!==null&&r.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:`v${re.version}`})]}),i?.isAdmin&&!c&&r.jsx("button",{type:"button",className:Pi,onClick:()=>{de(!1),Ze("/admin/users")},children:f.admin.users}),!c&&r.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:()=>{de(!1),l().then(()=>a("/login"))},children:f.auth.logout})]})]})}),r.jsx(w5,{open:je,onClose:()=>Ae(!1)}),r.jsx(F9,{open:Wt,onClose:()=>Ce(!1)}),r.jsx(V9,{open:Ke,onClose:()=>se(!1)}),r.jsx(q9,{open:Qe,onClose:()=>We(!1),latestVersion:dt,releaseUrl:ft?.releaseUrl??null,canUpdate:i?.isAdmin===!0,onRunFinished:()=>{Fb().catch(()=>{})}}),r.jsx(z9,{open:ye,onClose:()=>Se(!1),onCreated:X=>{Se(!1),F().then(()=>K(X))}}),D&&r.jsx($9,{open:ke,onClose:()=>ee(!1)}),r.jsx(Xt,{open:Pr!==null,title:f.chat.renameSession,onClose:()=>bn?void 0:$a(null),footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:()=>$a(null),disabled:bn,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:bn||!ca.trim(),onClick:()=>{ne()},children:f.common.save})]}),children:r.jsx(rt,{label:f.chat.renameSessionLabel,value:ca,error:ue??void 0,autoFocus:!0,maxLength:120,onChange:X=>{On(X.target.value),ue&&Me(null)},onKeyDown:X=>{X.key==="Enter"&&ca.trim()&&!bn&&ne()}})}),r.jsx(Xt,{open:Qn!==null,title:f.chat.renameWorkspace,onClose:()=>Ht(null),footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:()=>Ht(null),children:f.common.cancel}),r.jsx(ve,{variant:"primary",onClick:bi,children:f.common.save})]}),children:r.jsx(rt,{label:f.chat.renameWorkspaceLabel,hint:f.chat.renameWorkspaceHint,value:Bn,placeholder:Qn?qg(Qn.path):"",autoFocus:!0,maxLength:80,onChange:X=>Ur(X.target.value),onKeyDown:X=>{X.key==="Enter"&&!X.nativeEvent.isComposing&&bi()}})}),r.jsx(yn,{open:er!==null,title:f.chat.deleteSession,confirmLabel:f.common.delete,busy:Vt,onClose:()=>Vt?void 0:Nr(null),onConfirm:()=>{Ee()},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:er?f.chat.deleteSessionConfirm(er.title??f.chat.defaultSessionTitle):""})}),r.jsx(yn,{open:ga!==null,title:f.chat.deleteWorkspace,confirmLabel:f.common.delete,onClose:()=>zn(null),onConfirm:au,children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:ga?f.chat.deleteWorkspaceConfirm(ga.label):""})}),r.jsx(yn,{open:oa!==null,title:f.chat.deleteDraft,confirmLabel:f.common.delete,onClose:()=>tr(null),onConfirm:at,children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:oa?f.chat.deleteDraftConfirm(bg(oa)||f.chat.draftUntitled):""})})]})}function J9({entry:e,active:t,onOpen:a,onDelete:i}){const l=bg(e)||f.chat.draftUntitled;return r.jsx("li",{children:r.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:[r.jsx("button",{type:"button",onClick:a,className:"flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left",children:r.jsx(qc,{scrollReveal:!0,text:l,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"}`})}),r.jsx("div",{className:"flex shrink-0 items-center",children:r.jsx("button",{type:"button",title:f.chat.deleteDraft,"aria-label":f.chat.deleteDraft,onClick:i,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:r.jsx(Mn,{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 Xk({pinned:e,onToggle:t}){return r.jsx("button",{type:"button",title:e?f.nav.unpinGroup:f.nav.pinGroup,"aria-label":f.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:r.jsx(Mn,{d:Zg,size:15})})}function eU({s:e,active:t,activity:a,pinned:i,canPin:l=!1,lastActive:c,agentHint:u,draggable:m=!1,dropEdge:p=null,onDragStart:h,onDragEnd:g,onDragOver:v,onDragLeave:k,onDrop:w,onOpen:S,onTogglePin:M,onRename:C,onDelete:T,onToggleArchive:I}){const D=lA(),K=B=>{D.close(),{pin:M,rename:C,archive:I,delete:T}[B](e)},F=B=>{D.returnFocus()?.focus(),K(B)},E={archived:e.archived,pinned:i};return r.jsxs("li",{className:"relative",...m?{draggable:!0,onDragStart:h,onDragEnd:g,onDragOver:v,onDragLeave:k,onDrop:w}:{},children:[p!==null&&r.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"}`}),r.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 ${m?"cursor-grab ":""}${t?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[r.jsxs("button",{type:"button",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&&r.jsxs("span",{title:u,className:"flex shrink-0 items-center",children:[r.jsx(Da,{id:e.agentId,name:u,size:14,className:"rounded"}),r.jsx("span",{className:"sr-only",children:u})]}),r.jsx(qc,{scrollReveal:!0,text:e.title??f.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"}`}),i&&l&&r.jsxs("span",{title:f.chat.pinnedSession,className:"shrink-0 text-gray-400 dark:text-gray-500",children:[r.jsx(Mn,{d:Zg,size:12}),r.jsx("span",{className:"sr-only",children:f.chat.pinnedSession})]}),r.jsx(Z9,{activity:a}),e.pendingApprovalCount>0&&r.jsx("span",{title:f.chat.pendingApprovals(e.pendingApprovalCount),children:r.jsx(Cn,{tone:"amber",children:e.pendingApprovalCount})})]}),r.jsxs("div",{className:"relative flex h-6 min-w-12 shrink-0 items-center justify-end",children:[r.jsx("div",{className:"peer absolute right-0 top-1/2 flex -translate-y-1/2 items-center",children:r.jsx(mA,{actions:uA,state:E,onRun:K})}),c!==""&&r.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})]}),r.jsx(Un,{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:r.jsx(fA,{actions:dA(l),state:E,onRun:F})})]})]})}function tU({onRename:e,onDelete:t}){const[a,i]=x.useState(!1),l=c=>()=>{i(!1),c()};return r.jsxs(Un,{open:a,setOpen:i,portal:{direction:"down",align:"right"},menuClass:"w-32",className:"shrink-0",button:r.jsx("button",{type:"button",title:f.chat.workspaceMenu,"aria-label":f.chat.workspaceMenu,"aria-haspopup":"menu","aria-expanded":a,onClick:()=>i(!a),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:r.jsx(G9,{size:16})}),children:[r.jsxs("button",{type:"button",className:Jg,onClick:l(e),children:[e0(tS),f.chat.renameWorkspace]}),r.jsxs("button",{type:"button",className:aS,onClick:l(t),children:[r.jsx("span",{className:"shrink-0",children:r.jsx(Mn,{d:nS,size:13})}),f.chat.deleteWorkspace]})]})}function jd({icon:e,label:t,checked:a,onSelect:i}){return r.jsxs("button",{type:"button","aria-pressed":a,onClick:i,className:`${Jg} justify-between`,children:[r.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e0(e),r.jsx("span",{className:"truncate",children:t})]}),a&&r.jsx(bf,{className:"shrink-0 text-gray-500 dark:text-gray-400"})]})}function Pl({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("p",{className:"mb-1 text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e}),t]})}function nU({value:e,onChange:t}){return r.jsx("div",{className:"flex items-center gap-1.5",children:e4.map(a=>r.jsx("button",{type:"button",title:f.settings.accentNames[a.value],"aria-label":f.settings.accentNames[a.value],"aria-pressed":e===a.value,onClick:()=>t(a.value),className:`h-5 w-5 rounded-full border transition-transform duration-150 hover:scale-110 ${e===a.value?"border-gray-500 ring-2 ring-gray-400/50 dark:border-gray-300":"border-transparent"}`,style:{backgroundColor:a.color}},a.value))})}const aU="M8 10h8M8 14h5M21 12a9 9 0 1 1-4.2-7.6L21 4v5h-5",jh=e=>`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 rU({onExpand:e}){const{user:t}=vn(),a=ia(),{agents:i,currentProject:l,setCurrentAgentId:c}=cn(),{sessions:u,loading:m}=pi(),{update:p}=Gg(!1),h=p?.updateAvailable===!0?p.latestVersion??null:null,g=h2("/chat/:sessionId")?.params.sessionId??null,v=g!==null&&g!==Xa,k=x.useMemo(()=>N2(u),[u]),w=()=>{k&&(c(k.agentId),a(`/chat/${k.sessionId}`))},S=()=>{t&&l&&uo(t.userId,l.projectId);const C=(i.find(T=>T.agentId==="default_agent")??i[0])?.agentId;C&&c(C),a(`/chat/${Xa}`,C?{state:{agentId:C}}:void 0)},M=[{to:"/agents",label:f.nav.agents,icon:li.agents},{to:"/skills",label:f.nav.skills,icon:li.skills},{to:"/models",label:f.nav.models,icon:li.models},{to:"/usage",label:f.nav.usage,icon:li.usage},{to:"/traces",label:f.nav.traces,icon:li.traces},{to:"/benchmark",label:f.nav.benchmark,icon:li.benchmark}];return r.jsxs("div",{className:"flex h-full flex-col items-center gap-1 py-2.5",children:[r.jsx("button",{type:"button",title:f.nav.expandSidebar,"aria-label":f.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:r.jsx(Ge,{d:"M9 6l6 6-6 6M20 4v16",size:18})}),r.jsxs("nav",{className:"no-scrollbar mt-1 flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto",children:[r.jsx("button",{type:"button",title:f.nav.lastConversation,"aria-label":f.nav.lastConversation,disabled:!k&&!m,onClick:w,className:k||m?jh(v):"flex h-8 w-8 cursor-not-allowed items-center justify-center rounded-md text-gray-300 dark:text-gray-700",children:r.jsx(Ge,{d:aU,size:18})}),r.jsx("button",{type:"button",title:f.chat.newSessionMenu,"aria-label":f.chat.newSessionMenu,onClick:S,className:jh(g===Xa),children:r.jsx(Ge,{d:wg,size:18})}),M.map(C=>r.jsx(Vg,{to:C.to,title:C.label,"aria-label":C.label,className:({isActive:T})=>jh(T),children:r.jsx(Ge,{d:C.icon,size:18})},C.to))]}),r.jsxs("button",{type:"button",title:[t?.userId??"",f.nav.expandSidebar].concat(h!==null?[f.update.newVersion(h)]:[]).join(" · "),"aria-label":h!==null?`${t?.userId??""} · ${f.update.newVersion(h)}`:t?.userId??f.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(),h!==null&&r.jsx("span",{"aria-hidden":!0,className:"absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-50 bg-[var(--accent-bg)] dark:border-gray-900"})]})]})}function sU(){const{user:e,desktopMode:t}=vn();y3();const[a,i]=x.useState(!1),[l,c]=x.useState(!1),[u,m]=x.useState(null),p=!!e?.passwordIsInitial&&!t;x.useEffect(()=>{if(!p)return;let w=!1;return Rg().then(S=>{w||m(S.prefs.initialPasswordBannerDismissed===!0)}).catch(()=>{w||m(!1)}),()=>{w=!0}},[p]);const h=()=>{m(!0),pf({initialPasswordBannerDismissed:!0}).catch(()=>{})},[g,v]=x.useState(()=>localStorage.getItem("penguin.sidebarCollapsed")==="1"),k=()=>v(w=>{const S=!w;return localStorage.setItem("penguin.sidebarCollapsed",S?"1":"0"),S});return r.jsxs("div",{className:"flex h-full",children:[r.jsx("aside",{className:`hidden shrink-0 border-r border-gray-200 bg-gray-50 md:block dark:border-gray-800 dark:bg-gray-900 ${g?"w-12":"w-64 lg:w-72"}`,children:g?r.jsx(rU,{onExpand:k}):r.jsx(Qk,{onCollapse:k})}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.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:[r.jsx("button",{type:"button","aria-label":f.chat.sessionList,onClick:()=>i(!0),className:"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:r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":!0,children:r.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"})})}),r.jsx("span",{className:"text-sm font-semibold",children:f.appName})]}),p&&u===!1&&r.jsxs("div",{className:"relative flex shrink-0 items-center justify-center gap-3 border-b border-amber-200 bg-amber-50 px-8 py-1.5 text-xs text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-300",children:[r.jsx("span",{children:f.account.initialPasswordBanner}),r.jsx("button",{type:"button",className:"shrink-0 font-medium underline underline-offset-2 hover:text-amber-950 dark:hover:text-amber-100",onClick:()=>c(!0),children:f.account.changeNow}),r.jsx("button",{type:"button","aria-label":f.common.close,title:f.common.close,onClick:h,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:r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M2 2l10 10M12 2L2 12",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),r.jsx("main",{className:"min-h-0 flex-1 overflow-hidden",children:r.jsx(vM,{})})]}),r.jsx(w5,{open:l,onClose:()=>c(!1)}),r.jsx(U2,{open:a,side:"left",title:f.appName,onClose:()=>i(!1),children:r.jsx("div",{className:"h-full bg-gray-50 dark:bg-gray-900",children:r.jsx(Qk,{onNavigate:()=>i(!1)})})})]})}const z0=1440,$0=900,Sg=3,iU=3,Zk=z0/Sg,Jk=$0/iU,Cd=28,Nd=14;function lU(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 oU(e,t){return e.x1-Nd<=t.x2&&e.x2+Nd>=t.x1&&e.y1-Nd<=t.y2&&e.y2+Nd>=t.y1}function cU(e,t,a,i){return{x1:Math.min(e,a),y1:Math.min(t,i),x2:Math.max(e,a),y2:Math.max(t,i)}}const uU=[{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 dU(){const e=lU(12696599),t=[];for(const{cell:a,edge:i}of uU){const l=a%Sg*Zk+Cd,c=Math.floor(a/Sg)*Jk+Cd,u=l+Zk-2*Cd,m=c+Jk-2*Cd,p=[],h=(D,K,F,E)=>{const B=F[0]>0?u-D:F[0]<0?D-l:F[1]>0?m-K:K-c;for(let Y=Math.min(60+e()*150,B);Y>=40;Y/=2){const V=Math.round(D+F[0]*Y),O=Math.round(K+F[1]*Y),U=cU(D,K,V,O);if(p.every((_,P)=>E.has(P)||!oU(U,_)))return p.push(U),[V,O]}return null},g=(D,K,F)=>(F-D)*(.35+e()*.3)>D-K?1:-1,v=(D,K,F,E,B,Y,V)=>{let[O,U]=[D,K],_=F;const P=[`M${Math.round(O)},${Math.round(U)}`],H=[];for(let G=0;G<E;G+=1){const z=G===0?V:new Set([p.length-1]),J=h(O,U,_,z);if(!J)break;[O,U]=J,P.push(`L${O},${U}`),H.push([O,U]),_=_[0]!==0?[0,g(U,c,m)]:[g(O,l,u),0]}return H.length>=2&&t.push({d:P.join(" "),end:H[H.length-1],dur:B,delay:Y}),H},k=.15+e()*.7,w=i==="left"?0:i==="right"?z0:Math.round(l+(u-l)*k),S=i==="top"?0:i==="bottom"?$0:Math.round(c+(m-c)*k),M=i==="left"?[1,0]:i==="right"?[-1,0]:i==="top"?[0,1]:[0,-1],C=12+e()*8,T=e()*3.2,I=v(w,S,M,3+Math.floor(e()*3),C,T,new Set);if(a%2===0&&I.length>=3){const[D,K]=I[1],[F,E]=I[2],B=[-Math.sign(F-D),-Math.sign(E-K)];v(D,K,B,2,C,T+1.4,new Set([1,2]))}}return t}const fU=dU();function mU(){return r.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 ${z0} ${$0}`,preserveAspectRatio:"xMidYMid slice",fill:"none",children:fU.map((e,t)=>r.jsxs("g",{style:{"--trace-dur":`${e.dur.toFixed(1)}s`},children:[r.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`}}),r.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 pU(){Jr(f.auth.login);const{login:e}=vn(),{mode:t,setMode:a}=mi(),{lang:i,setLang:l}=Za(),c=ia(),[u,m]=x.useState(""),[p,h]=x.useState(""),[g,v]=x.useState({}),[k,w]=x.useState(!1),S=()=>v(I=>I.userId||I.password||I.form?{}:I),M=async()=>{const I={};if(u.trim()||(I.userId=f.common.requiredField),p||(I.password=f.common.requiredField),I.userId||I.password){v(I);return}w(!0),v({});try{await e(u.trim(),p),c("/chat",{replace:!0})}catch(D){v({form:Oe(D)})}finally{w(!1)}},C=[{value:"light",label:f.settings.themeLight},{value:"dark",label:f.settings.themeDark},{value:"system",label:f.settings.followSystem}],T=[{value:"en",label:f.settings.langEn},{value:"zh",label:f.settings.langZh},{value:"system",label:f.settings.followSystem}];return r.jsxs("div",{className:"relative flex min-h-full items-center justify-center overflow-hidden p-4",children:[r.jsx(mU,{}),r.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:[r.jsx("div",{"aria-label":f.settings.language,children:r.jsx(Wi,{options:T,value:i,onChange:l})}),r.jsx("div",{"aria-label":f.settings.theme,children:r.jsx(Wi,{options:C,value:t,onChange:a})})]}),r.jsxs("div",{className:"anim-rise relative w-full max-w-sm",children:[r.jsx(l5,{className:"mx-auto mb-3 h-16 w-16 rounded-2xl"}),r.jsx("h1",{className:"mb-6 text-center text-3xl font-semibold tracking-tight",children:f.appName}),r.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-800 dark:bg-gray-900",children:[r.jsxs("form",{className:"space-y-4",onSubmit:I=>{I.preventDefault(),M()},children:[r.jsx(rt,{label:f.common.username,required:!0,value:u,onChange:I=>{m(I.target.value),S()},error:g.userId,autoComplete:"username",autoFocus:!0}),r.jsx(ci,{label:f.auth.password,required:!0,value:p,onChange:I=>{h(I.target.value),S()},error:g.password,autoComplete:"current-password"}),g.form&&r.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:g.form}),r.jsx(ve,{type:"submit",variant:"primary",className:"w-full justify-center py-2.5 text-sm font-semibold",disabled:k,children:f.auth.login})]}),r.jsx("p",{className:"mt-4 text-center text-xs text-gray-400 dark:text-gray-500",children:f.auth.defaultAdminNote}),r.jsx("p",{className:"mt-1.5 text-center text-xs text-gray-400 dark:text-gray-500",children:f.auth.forgotAdminNote})]})]})]})}const ic=100,ai=30,xr=2;function hU({data:e,label:t,className:a=""}){const i=Math.max(1,...e),l=e.length>1?(ic-2*xr)/(e.length-1):0,c=e.map((h,g)=>[xr+g*l,ai-xr-h/i*(ai-2*xr)]),u=`${xr},${ai-xr} ${ic-xr},${ai-xr}`,m=c.length>1?c.map(([h,g])=>`${h},${g}`).join(" "):u,p=c.length>1?`${m} ${ic-xr},${ai-xr} ${xr},${ai-xr}`:null;return r.jsxs("svg",{width:ic,height:ai,viewBox:`0 0 ${ic} ${ai}`,role:"img","aria-label":t,className:`text-emerald-600 dark:text-emerald-500 ${a}`,children:[r.jsx("title",{children:t}),p!==null&&r.jsx("polygon",{points:p,fill:"currentColor",fillOpacity:"0.12"}),r.jsx("polyline",{points:m,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const gU=new Set(["default_agent"]),_r={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",traces:"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",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",kernelUpdate:"M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10"},lc="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 xU(){const e=ia();Jr(f.nav.agents);const{locale:t}=Za(),{user:a}=vn(),{currentProject:i,agents:l,agentsLoading:c,reloadAgents:u,setCurrentAgentId:m}=cn(),[p,h]=x.useState(!1),[g,v]=x.useState(""),[k,w]=x.useState(""),[S,M]=x.useState(""),[C,T]=x.useState(void 0),[I,D]=x.useState(!1),K=()=>{v(""),w(""),M(""),T(void 0),h(!0)},F=ha(),E=F.state?.create===!0;x.useEffect(()=>{E&&(K(),e(F.pathname,{replace:!0}))},[E]);const[B,Y]=x.useState(null),[V,O]=x.useState(null),U=i?.projectId,_=async()=>{if(!U)return;const z=g.trim();if(!z){T(f.common.requiredField);return}if(!b5.test(z)){T(f.agent.idHint);return}D(!0),T(void 0);try{const J={agentId:z};k.trim()&&(J.name=k.trim()),S.trim()&&(J.description=S.trim());const xe=await _4(U,J);h(!1),await u(),m(xe.agent.agentId),e(`/agents/${xe.agent.agentId}`)}catch(J){T(Oe(J))}finally{D(!1)}},P=z=>{a&&U&&uo(a.userId,U),m(z),e(`/chat/${Xa}`,{state:{agentId:z}})},H=(z,J)=>{m(z),e(`/agents/${z}?tab=${J}`)},G=async()=>{if(!(!U||!B)){D(!0),O(null);try{await X4(U,B.agentId),Y(null),await u()}catch(z){O(Oe(z))}finally{D(!1)}}};return r.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:[r.jsxs("div",{className:"mx-auto max-w-5xl",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between gap-2",children:[r.jsx("h1",{className:"text-xl font-semibold",children:f.agent.listTitle}),r.jsx(ve,{variant:"primary",onClick:K,children:f.agent.create})]}),c?r.jsx("div",{className:"space-y-3",children:Array.from({length:4},(z,J)=>r.jsxs(uS,{className:"flex flex-wrap items-center gap-x-6 gap-y-2 px-5 py-4",children:[r.jsxs("div",{className:"min-w-[14rem] flex-1",children:[r.jsx(mn,{className:"h-[18px] w-40"}),r.jsx(mn,{className:"mt-1.5 h-4 w-2/3"}),r.jsx(mn,{className:"mt-1.5 h-4 w-48"})]}),r.jsx(mn,{className:"hidden h-9 w-40 md:block"}),r.jsx(mn,{className:"h-8 w-52"})]},J))}):l.length===0?r.jsx(Xr,{title:f.common.none}):r.jsx("div",{className:"space-y-3",children:l.map(z=>{const J=gU.has(z.agentId);return r.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:[r.jsxs("div",{className:"min-w-[14rem] flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Da,{id:z.agentId,name:pn(z),size:18,className:"shrink-0 rounded"}),r.jsx("span",{className:"min-w-0 truncate text-base font-bold",children:pn(z)}),r.jsx("span",{className:"hidden shrink-0 font-mono text-xs text-gray-400 md:inline dark:text-gray-500",children:z.agentId}),r.jsxs(Cn,{tone:"gray",children:["v",z.version]}),z.kernelOutdated&&r.jsx("button",{type:"button",className:"shrink-0 cursor-pointer text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",title:f.agent.kernelOutdatedHint,"aria-label":f.agent.kernelOutdatedHint,onClick:()=>H(z.agentId,"overview"),children:r.jsx(Ge,{d:_r.kernelUpdate,size:12})})]}),r.jsx("p",{className:"mt-1.5 min-h-4 truncate text-xs text-gray-500 dark:text-gray-400",children:z.description??""}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-x-4 text-xs text-gray-500 dark:text-gray-400",children:[r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",title:f.agent.sessionCount(z.sessionCount),children:[r.jsx(Ge,{d:_r.sessions,size:12}),z.sessionCount]}),r.jsxs("button",{type:"button",className:lc,title:f.agent.toolCount(z.toolCount),"aria-label":f.agent.toolCount(z.toolCount),onClick:()=>H(z.agentId,"tools"),children:[r.jsx(Ge,{d:aa.toolCalls,size:12}),z.toolCount]}),r.jsxs("button",{type:"button",className:lc,title:f.skills.skillCount(z.skillCount),"aria-label":f.skills.skillCount(z.skillCount),onClick:()=>H(z.agentId,"skills"),children:[r.jsx(Ge,{d:_r.skills,size:12}),z.skillCount]}),r.jsxs("button",{type:"button",className:lc,title:f.agent.memoryCount(z.memoryCount),"aria-label":f.agent.memoryCount(z.memoryCount),onClick:()=>H(z.agentId,"memory"),children:[r.jsx(Ge,{d:_r.memory,size:12}),z.memoryCount]}),r.jsxs("button",{type:"button",className:lc,title:f.agent.vaultKeyCount(z.vaultKeyCount),"aria-label":f.agent.vaultKeyCount(z.vaultKeyCount),onClick:()=>H(z.agentId,"vault"),children:[r.jsx(Ge,{d:_r.vaultKeys,size:12}),z.vaultKeyCount]}),r.jsxs("button",{type:"button",className:lc,title:f.agent.scheduleCount(z.scheduleCount),"aria-label":f.agent.scheduleCount(z.scheduleCount),onClick:()=>H(z.agentId,"schedules"),children:[r.jsx(Ge,{d:_r.schedules,size:12}),z.scheduleCount]}),r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",title:`${f.agent.updatedAt} ${z.updatedAt?Oa(z.updatedAt):"—"}`,children:[r.jsx(Ge,{d:aa.elapsed,size:12}),z.updatedAt?S3(z.updatedAt,t):"—"]})]})]}),r.jsx(hU,{data:z.sessionActivity,label:f.agent.activity(z.sessionActivity.length||30),className:"hidden shrink-0 md:block"}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsxs(ve,{size:"sm",variant:"primary",onClick:()=>P(z.agentId),children:[r.jsx(Ge,{d:_r.newChat}),f.chat.newSessionMenu]}),r.jsxs(ve,{size:"sm",onClick:()=>{m(z.agentId),e(`/agents/${z.agentId}`)},children:[r.jsx(Ge,{d:D2}),f.common.settings]}),r.jsx(ve,{size:"icon",title:f.nav.usage,"aria-label":f.nav.usage,onClick:()=>e(`/usage?agentId=${encodeURIComponent(z.agentId)}`),children:r.jsx(Ge,{d:_r.usage,size:15,className:"text-gray-600 dark:text-gray-300"})}),r.jsx(ve,{size:"icon",title:f.nav.traces,"aria-label":f.nav.traces,onClick:()=>e(`/traces?agentId=${encodeURIComponent(z.agentId)}`),children:r.jsx(Ge,{d:_r.traces,size:15,className:"text-gray-600 dark:text-gray-300"})}),J?r.jsx("span",{role:"img",title:f.agent.builtinUndeletable,"aria-label":f.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:r.jsx(Ge,{d:_r.trash,size:15})}):r.jsx(ve,{size:"icon",variant:"danger",title:f.agent.deleteAgent,"aria-label":f.agent.deleteAgent,onClick:()=>Y({agentId:z.agentId,name:pn(z)}),children:r.jsx(Ge,{d:_r.trash,size:15})})]})]},z.agentId)})})]}),r.jsx(Xt,{open:p,title:f.agent.createTitle,onClose:()=>h(!1),footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:()=>h(!1),children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:I,onClick:()=>{_()},children:f.common.create})]}),children:r.jsxs("div",{className:"space-y-3",children:[r.jsx(rt,{label:f.agent.id,required:!0,size:"sm",value:g,onChange:z=>{v(z.target.value),T(void 0)},error:C,hint:f.agent.idHint,autoFocus:!0}),r.jsx(rt,{label:f.common.name,size:"sm",value:k,onChange:z=>w(z.target.value),hint:f.agent.nameHint}),r.jsx(Kn,{label:f.agent.description,size:"sm",rows:3,value:S,onChange:z=>M(z.target.value)})]})}),r.jsxs(yn,{open:B!==null,title:f.agent.deleteAgent,busy:I,onClose:()=>{Y(null),O(null)},onConfirm:()=>{G()},children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:B?f.agent.deleteConfirm(B.name):""}),V&&r.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:V})]})]})}function yU({items:e,active:t,onChange:a}){return r.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(i=>r.jsx("button",{type:"button",role:"tab","aria-selected":i.key===t,onClick:()=>a(i.key),className:`-mb-px whitespace-nowrap border-b-2 px-3 py-2 text-sm transition-colors duration-150 ${i.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:i.label},i.key))})}const vU=288,bU={base:"text-base",sm:"text-xs"},kU={base:"text-xs",sm:"text-[11px]"};function jg({options:e,value:t,onChange:a,placeholder:i,mono:l,label:c,error:u,required:m,fullWidth:p,size:h="base","aria-label":g}){const[v,k]=x.useState(!1),{triggerRef:w,panelRef:S,position:M}=k5({open:v,onClose:()=>k(!1),estimatedHeight:e.length*48+16,panelWidth:vU}),C=t!=null?e.find(D=>D.value===t):void 0,T=x.useId(),I=r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:w,type:"button","aria-label":g,"aria-haspopup":"listbox","aria-expanded":v,"aria-required":m||void 0,"aria-invalid":u?!0:void 0,"aria-describedby":u?T:void 0,onClick:()=>k(D=>!D),className:`flex items-center gap-2 ${kf} ${wf[h]} ${u?Sf:""}`+(p?" w-full justify-between":""),children:[r.jsx("span",{className:`min-w-0 truncate ${l?"font-mono":""}`,children:C?.triggerLabel??i??"—"}),r.jsx(Ql,{className:"text-gray-400"})]}),v&&M&&nl.createPortal(r.jsx("div",{ref:S,role:"listbox",style:{position:"fixed",top:M.topPx,bottom:M.bottomPx,left:M.left,minWidth:M.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(D=>r.jsxs("button",{type:"button",role:"option","aria-selected":D.value===t,onClick:()=>{a(D.value),k(!1)},className:`block ${n0} hover:bg-gray-100 dark:hover:bg-gray-800 ${D.value===t?"bg-gray-100 dark:bg-gray-800":""}`,children:[r.jsxs("span",{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:`${bU[h]} ${D.value===t?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:D.label}),D.value===t&&r.jsx(bf,{className:"text-gray-500 dark:text-gray-400"})]}),r.jsx("span",{className:`mt-0.5 block ${kU[h]} text-gray-500 dark:text-gray-400`,children:D.description})]},D.value))}),document.body)]});return r.jsx(Gc,{label:c,error:u,errorId:T,required:m,children:I})}const wU=/^(www\.)?(github|gitlab|gitee|bitbucket)\.(com|org)$/i;function SU(e){const t=e.trim();if(/^git@[\w.-]+:/.test(t)||/\.git$/i.test(t))return"repoUrl";if(/^https?:\/\//i.test(t)){try{if(wU.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 Ch(e){return`${f.skills.importPromptLead[SU(e)](e)}
175
- ${f.skills.importPromptTail}`}function jU(e,t,a,i){const l=e.current;if(l&&(l.focus(),document.execCommand?.("insertText",!1,i)))return;const c=l?l.selectionStart:t.length,u=l?l.selectionEnd:t.length;a(t.slice(0,c)+i+t.slice(u)),requestAnimationFrame(()=>{if(!l)return;l.focus();const m=c+i.length;l.setSelectionRange(m,m)})}function P0({agentId:e,feature:t,strings:a,canEdit:i,onConfigChanged:l}){const{currentProject:c}=cn(),u=c?.projectId??null,[m,p]=x.useState(null),[h,g]=x.useState(""),[v,k]=x.useState(!1),w=x.useRef(null),{requestSave:S,element:M}=so(),C=x.useCallback(V=>{const O=V[t];p(O),g(O.prompt)},[t]),T=V=>t==="skills"?{config:{skills:V}}:t==="vault"?{config:{vault:V}}:{config:{schedules:V}},I=async V=>{if(u){k(!0);try{const O=await Zi(u,e,T({enabled:V}));C(O.config),Ut(f.common.saved),l?.()}catch(O){Ve(Oe(O))}finally{k(!1)}}},D=async()=>{if(!u)return;const V=t==="skills"?S4:t==="vault"?w4:j4;try{const O=await V(u,e);p(O),g(O.prompt),Ut(f.common.saved),l?.()}catch(O){Ve(Oe(O))}},K=()=>S(()=>{u&&Zi(u,e,T({prompt:h})).then(V=>{C(V.config),Ut(f.common.saved),l?.()}).catch(V=>Ve(Oe(V)))}),F=m!==null&&r.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:[r.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:a.enable}),r.jsx(di,{checked:m.enabled,onChange:V=>{I(V)},disabled:v||!i})]}),E=m?.legacySectionPresent===!0,B=m!==null&&!m.templateHasPlaceholder&&r.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 dark:border-amber-700 dark:bg-amber-950/40",children:[r.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-300",children:E?a.legacyTemplate??a.templateMissing:a.templateMissing}),i&&r.jsx(ve,{size:"sm",className:"shrink-0",onClick:()=>{D()},children:E?a.migrate??a.insertPlaceholder:a.insertPlaceholder})]}),Y=m!==null&&r.jsxs("section",{className:"space-y-2.5 rounded-lg border border-gray-200 p-3.5 dark:border-gray-800",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:a.promptSection}),r.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:a.promptSectionHint})]}),r.jsx(Kn,{ref:w,label:a.promptLabel,mono:!0,size:"sm",rows:12,readOnly:!i,value:h,onChange:V=>g(V.target.value)}),r.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[r.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:f.agent.placeholdersTitle}),r.jsx("ul",{className:"space-y-1",children:a.promptPlaceholders.map(([V,O])=>r.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[r.jsx("button",{type:"button",disabled:!i,onClick:()=>jU(w,h,g,V),title:f.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}),r.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:O})]},V))})]}),i&&r.jsx("div",{className:"flex justify-end",children:r.jsx(ve,{size:"sm",variant:"primary",onClick:K,children:f.common.save})}),M]});return{applyConfig:C,toggleCard:F,alertStrip:B,promptSection:Y}}const CU="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",NU="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 TU({agentId:e,onConfigChanged:t}){const a=ia(),{locale:i}=Za(),l=vn().user?.userId??null,{currentProject:c,agents:u,setCurrentAgentId:m,reloadAgents:p}=cn(),h=c?.projectId??null,{applyConfig:g,toggleCard:v,alertStrip:k,promptSection:w}=P0({agentId:e,feature:"skills",strings:f.skills.injection,canEdit:!0,onConfigChanged:t}),[S,M]=x.useState(null),[C,T]=x.useState(null),[I,D]=x.useState(!1),[K,F]=x.useState(null),[E,B]=x.useState(!1),[Y,V]=x.useState(""),[O,U]=x.useState(!1),[_,P]=x.useState(null),[H,G]=x.useState(null),z=x.useCallback(async()=>{if(!(!h||!e)){M(null),T(null);try{const[ke,ee]=await Promise.all([hf(h,e),el(h,e)]);M(ke.skills),g(ee.config)}catch(ke){T(Oe(ke))}}},[h,e,g]);x.useEffect(()=>{z()},[z]);const J=u.find(ke=>ke.agentId===e),xe=J?pn(J):e,me=async ke=>{if(h)try{const ee=await fetch(iT(h,e,ke));if(!ee.ok){const We=await ee.json().catch(()=>null);throw new sa(ee.status,We?.error?.code??"unknown",We?.error?.message??f.common.unknownError)}const je=/filename\*=UTF-8''([^;]+)/i.exec(ee.headers.get("content-disposition")??"")?.[1],Ae=URL.createObjectURL(await ee.blob()),Qe=document.createElement("a");Qe.href=Ae,Qe.download=je?decodeURIComponent(je):`${ke}.zip`,document.body.appendChild(Qe),Qe.click(),Qe.remove(),URL.revokeObjectURL(Ae)}catch(ee){Ve(Oe(ee))}},A=async()=>{if(!(!h||K===null)){D(!0);try{await Qw(h,e,K),Ut(f.skills.uninstalledToast(K,xe)),await z(),p()}catch(ke){Ve(Oe(ke))}finally{D(!1),F(null)}}},R=()=>{V(""),P(null),G(null),B(!0)},q=Y.trim(),j=Ch(q||f.skills.importSourceToken),$=Qd(),ae=()=>{if(l&&h&&q){uo(l,h);const ke=Qr(l,h);js(ke,{...gi(ke),agentId:e,text:Ch(q),skills:[],handoffAgentId:void 0})}m(e),a(`/chat/${Xa}`,{state:{agentId:e}})},de=async(ke,ee,je)=>{if(h){U(!0),P(null);try{await sT(h,e,{dataBase64:ke,...je?{overwrite:!0}:{}}),G(null),B(!1),Ut(f.skills.importDoneToast),await z(),p()}catch(Ae){if(Ae instanceof sa&&Ae.status===409&&Ae.code==="skill_exists"){const Qe=/:\s*([A-Za-z0-9_-]+)$/.exec(Ae.message)?.[1]??ee;G({dataBase64:ke,name:Qe})}else G(null),P(Oe(Ae))}finally{U(!1)}}},ye=ke=>{const ee=ke.target.files?.[0];if(ke.target.value="",!ee)return;P(null);const je=ee.name.replace(/\.zip$/i,""),Ae=new FileReader;Ae.onload=()=>{const Qe=Ae.result;de(Qe.slice(Qe.indexOf(",")+1),je,!1)},Ae.onerror=()=>P(f.common.unknownError),Ae.readAsDataURL(ee)},Se=ke=>[`v${ke.version}`,ke.updated?Kd(ke.updated,i):null].filter(ee=>ee!==null).join(" · ");return h?r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.skills.agentTabDesc}),r.jsx(ve,{size:"sm",variant:"primary",className:"shrink-0",disabled:S===null,onClick:R,children:f.skills.importSkill})]}),v,k,S===null?r.jsx(La,{rows:4}):S.length===0?r.jsx("p",{className:"py-2 text-xs text-gray-400 dark:text-gray-500",children:f.skills.agentTabEmpty}):r.jsx("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:S.map(ke=>r.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:[r.jsx("span",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${Hj(ke.name)}`,children:r.jsx(Rf,{icon:ke.icon,size:20})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate font-mono text-[13px] font-semibold",title:ke.name,children:ke.name}),r.jsx("p",{className:"mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400",title:ke.description,children:co(i,ke)})]}),r.jsx("span",{className:"hidden shrink-0 text-[11px] text-gray-400 sm:block dark:text-gray-500",title:Se(ke),children:Se(ke)}),r.jsx(ve,{size:"icon",title:f.skills.exportSkill,"aria-label":`${f.skills.exportSkill} ${ke.name}`,disabled:I,onClick:()=>{me(ke.name)},children:r.jsx(O2,{size:14,className:"text-gray-600 dark:text-gray-300"})}),r.jsx(ve,{size:"icon",variant:"danger",title:f.skills.uninstall,"aria-label":`${f.skills.uninstall} ${ke.name}`,disabled:I,onClick:()=>F(ke.name),children:r.jsx(Ge,{d:NU,size:14})})]},ke.name))}),w,r.jsx(Xt,{open:E,title:f.skills.importSkill,onClose:()=>B(!1),widthClass:"sm:max-w-lg",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("section",{children:[r.jsx("p",{className:"text-sm font-medium",children:f.skills.importChatTitle}),r.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:f.skills.importChatWhy}),r.jsxs("div",{className:"mt-2.5 space-y-2.5",children:[r.jsx(rt,{size:"sm",label:f.skills.importSourceLabel,hint:f.skills.importSourceHint,value:Y,onChange:ke=>V(ke.target.value),placeholder:f.skills.importSourcePlaceholder,autoComplete:"off"}),r.jsx(Kn,{label:f.skills.importPromptLabel,size:"sm",rows:5,readOnly:!0,value:j,className:"text-gray-600 dark:text-gray-300"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ve,{size:"sm",disabled:q==="",onClick:()=>$.flash(Ch(q)),children:[r.jsx(Xd,{copied:$.copied,size:12}),f.skills.importCopyPrompt]}),r.jsx(Zd,{copied:$.copied}),r.jsx(ve,{size:"sm",variant:"primary",onClick:ae,children:f.skills.importOpenChat})]})]})]}),r.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[r.jsx("p",{className:"text-sm font-medium",children:f.skills.importUploadTitle}),r.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:f.skills.importUploadDesc}),r.jsxs("label",{className:`${CU} mt-2.5 ${O?"pointer-events-none opacity-60":""}`,children:[r.jsx(Lf,{accept:".zip",disabled:O,onChange:ye}),O?f.skills.importUploading:f.skills.importUploadAction]}),_&&r.jsx("p",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:_})]})]})}),r.jsx(yn,{open:H!==null,title:f.skills.importOverwriteTitle,confirmLabel:f.skills.importOverwriteAction,busy:O,onClose:()=>G(null),onConfirm:()=>{H!==null&&de(H.dataBase64,H.name,!0)},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:H!==null?f.skills.importOverwriteBody(H.name):""})}),r.jsx(yn,{open:K!==null,title:K!==null?f.skills.uninstallConfirmTitle(K):"",busy:I,onClose:()=>F(null),onConfirm:()=>{A()},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:K!==null?f.skills.uninstallConfirmBody(K,xe):""})}),C&&r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:C})]}):null}function MU(e,t=""){const a=`${f.memory.editPromptLead(e)}
176
- ${f.memory.editPromptTail}`,i=t.trim();return i.length>0?`${a}${i}`:a}function AU(e,t){return`${f.memory.addPromptLead[e]}
177
- ${t.trim()}`}function EU(e){return e.replace(/^\ufeff?---\r?\n[\s\S]*?\r?\n---\r?\n?/,"")}const ew="(min-width: 1024px)",_U="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",RU="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z",IU="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",LU="M12 5v14M5 12h14",OU=(e,t,a)=>`penguin.memoryCollapsed.${e}.${t}.${a}`;function tw(e){if(!e)return new Set;try{const t=JSON.parse(localStorage.getItem(e)??"[]");return Array.isArray(t)?new Set(t.filter(a=>typeof a=="string")):new Set}catch{return new Set}}function nw(e,t){if(e)try{localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function DU({agentId:e,onConfigChanged:t}){const a=ia(),{locale:i}=Za(),l=vn().user?.userId??null,{currentProject:c,setCurrentAgentId:u,reloadAgents:m}=cn(),p=c?.projectId??null,[h,g]=x.useState(!0),[v,k]=x.useState(!0),[w,S]=x.useState(""),[M,C]=x.useState(null),[T,I]=x.useState(null),[D,K]=x.useState(!1),F=l&&p?OU(l,p,e):null,[E,B]=x.useState(()=>tw(F)),[Y,V]=x.useState(""),[O,U]=x.useState(""),_=x.useRef(null),P=x.useRef(null),[H,G]=x.useState("main"),{requestSave:z,element:J}=so(),[xe,me]=x.useState(!1),[A,R]=x.useState(null),[q,j]=x.useState(null),[$,ae]=x.useState(""),[de,ye]=x.useState(null),[Se,ke]=x.useState(""),[ee,je]=x.useState(null),[Ae,Qe]=x.useState(()=>window.matchMedia(ew).matches),[We,re]=x.useState("half");x.useEffect(()=>{const Te=window.matchMedia(ew),ze=yt=>Qe(yt.matches);return Te.addEventListener("change",ze),()=>Te.removeEventListener("change",ze)},[]),x.useEffect(()=>{B(tw(F))},[F]);const ft=Te=>{const ze=new Set(E);ze.delete(Te)||ze.add(Te),nw(F,ze),B(ze)},ge=x.useCallback(async()=>{if(!(!p||!e)){C(null),I(null);try{const[Te,ze]=await Promise.all([C4(p,e),el(p,e)]);V(ze.config.memory.prompt),U(ze.config.memory.workspacePrompt),g(Te.enabled),k(Te.templateHasMemory),S(Te.memoryDir);const yt=new Set(Te.scopes.map(ct=>ct.scopeKey));B(ct=>{const vt=new Set([...ct].filter(hn=>yt.has(hn)));return vt.size===ct.size?ct:(nw(F,vt),vt)}),C(await Promise.all(Te.scopes.map(async ct=>{try{return{scope:ct,files:(await T4(p,e,ct.scopeKey)).files}}catch{return{scope:ct,files:[]}}})))}catch(Te){I(Oe(Te))}}},[p,e,F]);x.useEffect(()=>{ge()},[ge]);const dt=async Te=>{if(p){K(!0);try{const ze=await Zi(p,e,{config:{memory:{enabled:Te}}});g(ze.config.memory.enabled),Ut(f.common.saved),t?.()}catch(ze){Ve(Oe(ze))}finally{K(!1)}}},It=async()=>{if(p)try{const Te=await N4(p,e);k(Te.templateHasMemory),Ut(f.memory.insertPlaceholderDone),t?.()}catch(Te){Ve(Oe(Te))}},zt=(Te,ze,yt,ct)=>{const vt=Te.current;if(vt&&(vt.focus(),document.execCommand?.("insertText",!1,ct)))return;const hn=vt?vt.selectionStart:ze.length,bt=vt?vt.selectionEnd:ze.length;yt(ze.slice(0,hn)+ct+ze.slice(bt)),requestAnimationFrame(()=>{if(!vt)return;vt.focus();const dn=hn+ct.length;vt.setSelectionRange(dn,dn)})},nn=()=>z(()=>{p&&Zi(p,e,{config:{memory:{prompt:Y,workspacePrompt:O}}}).then(Te=>{V(Te.config.memory.prompt),U(Te.config.memory.workspacePrompt),Ut(f.common.saved),t?.()}).catch(Te=>Ve(Oe(Te)))}),un=async(Te,ze)=>{if(p)try{const yt=await M4(p,e,Te.scopeKey,ze.name);re("half"),R({scope:Te,file:yt.file,content:yt.content}),me(!0)}catch(yt){Ve(Oe(yt))}},Wt=(Te,ze)=>`${w}/${Te.scopeKey}/${ze.name}`,Ce=(Te,ze)=>{me(!1),ae(""),j({scope:Te,file:ze})},Ke=q?MU(q.file.title,$):"",se=Qd(),ce=(Te,ze)=>{if(!l||!p)return;const yt=Qr(l,p);js(yt,{...gi(yt),agentId:e,text:Te,...ze!==void 0?{workspace:ze}:{},skills:[],handoffAgentId:void 0}),u(e),a(`/chat/${Xa}`,{state:{agentId:e,...ze!==void 0?{workspace:ze}:{}}})},De=()=>{q&&ce(Ke,q.scope.workspacePath)},Be=Te=>{ke(""),ye(Te)},Ue=de?AU(de.kind,Se):"",W=Qd(),pe=()=>{de&&ce(Ue,de.workspacePath)},Ne=async()=>{if(!p||!ee)return;const Te=ee;je(null);try{await A4(p,e,Te.scope.scopeKey,Te.file.name),Ut(f.memory.deleteDone),A&&A.file.name===Te.file.name&&me(!1),await ge(),m()}catch(ze){Ve(Oe(ze))}};if(T)return r.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:T});const Re=Te=>Te.kind==="user"?f.memory.userScope:Te.workspacePath?.split(/[\\/]/).filter(Boolean).at(-1)??Te.scopeKey,Pe=(Te,ze)=>r.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.jsx(ve,{size:"icon",title:f.memory.view,"aria-label":`${f.memory.view} ${ze.title}`,onClick:()=>{un(Te,ze)},children:r.jsx(Ge,{d:_U,size:14,className:"text-gray-600 dark:text-gray-300"})}),r.jsx(ve,{size:"icon",title:f.memory.edit,"aria-label":`${f.memory.edit} ${ze.title}`,onClick:()=>Ce(Te,ze),children:r.jsx(Ge,{d:RU,size:14,className:"text-gray-600 dark:text-gray-300"})}),r.jsx(ve,{size:"icon",variant:"danger",title:f.memory.delete,"aria-label":`${f.memory.delete} ${ze.title}`,onClick:()=>je({scope:Te,file:ze}),children:r.jsx(Ge,{d:IU,size:14})})]}),Fe=(Te,ze)=>r.jsxs("li",{className:"flex items-center gap-3 px-3.5 py-2.5",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate font-mono text-[13px] font-medium text-gray-800 dark:text-gray-200",children:ze.title}),ze.description&&r.jsx("p",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:ze.description})]}),r.jsx("span",{className:"shrink-0 text-xs tabular-nums text-gray-400 dark:text-gray-500",children:ze.updatedAt??Kd(ze.modifiedAt,i)}),Pe(Te,ze)]},ze.name),nt=A&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:A.file.updatedAt??Kd(A.file.modifiedAt,i)}),A.file.description&&r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:A.file.description}),r.jsx("div",{className:"md-body border-t border-gray-100 pt-3 text-sm dark:border-gray-800",children:r.jsx(_f,{text:EU(A.content)})})]}),ot=A&&r.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-gray-200 px-4 py-3 dark:border-gray-800",children:[r.jsx(ve,{size:"sm",onClick:()=>Ce(A.scope,A.file),children:f.memory.edit}),r.jsx(ve,{size:"sm",variant:"danger",onClick:()=>je(A),children:f.memory.delete})]});return r.jsxs("div",{className:"space-y-5",children:[r.jsx("p",{className:"text-xs leading-5 text-gray-500 dark:text-gray-400",children:f.memory.desc}),r.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:[r.jsx("p",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:f.memory.enable}),r.jsx(di,{checked:h,onChange:Te=>{dt(Te)},disabled:D})]}),!v&&r.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-amber-300 bg-amber-50 px-4 py-3 dark:border-amber-700 dark:bg-amber-950/40",children:[r.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-300",children:f.memory.templateMissing}),r.jsx(ve,{size:"sm",onClick:()=>{It()},children:f.memory.insertPlaceholder})]}),M===null?r.jsx(La,{rows:4}):r.jsx("div",{className:h?"space-y-5":"space-y-5 opacity-60",children:M.map(({scope:Te,files:ze})=>{const yt=!E.has(Te.scopeKey);return r.jsxs("section",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800",children:[r.jsxs("div",{className:"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:[r.jsxs("button",{type:"button","aria-expanded":yt,onClick:()=>ft(Te.scopeKey),className:"flex min-w-0 flex-1 items-center gap-2.5 px-3.5 py-2.5 text-left",children:[r.jsx("span",{className:"shrink-0 text-sm font-semibold text-gray-800 dark:text-gray-200",children:Re(Te)}),Te.kind==="workspace"&&Te.workspacePath!==void 0&&r.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-gray-400 dark:text-gray-500",children:Te.workspacePath}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx("span",{className:"shrink-0 text-xs text-gray-400 dark:text-gray-500",children:f.memory.itemCount(ze.length)})]}),r.jsx("span",{className:"shrink-0",children:r.jsxs(ve,{size:"sm",variant:"ghost",onClick:()=>Be(Te),children:[r.jsx(Ge,{d:LU,size:13}),f.memory.add]})}),r.jsx("button",{type:"button","aria-expanded":yt,"aria-label":Re(Te),onClick:()=>ft(Te.scopeKey),className:"shrink-0 p-1.5",children:r.jsx(Yn,{open:yt,className:"text-gray-400"})})]}),r.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${yt?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:r.jsx("div",{className:"overflow-hidden",inert:!yt,children:ze.length===0?r.jsx("p",{className:"px-4 py-4 text-center text-xs text-gray-400 dark:text-gray-500",children:Te.kind==="user"?f.memory.emptyUserScope:f.memory.emptyScope}):r.jsx("ul",{className:"divide-y divide-gray-100 border-t border-gray-200 dark:divide-gray-800 dark:border-gray-800",children:ze.map(ct=>Fe(Te,ct))})})})]},Te.scopeKey)})}),r.jsxs("section",{className:"space-y-2.5 rounded-lg border border-gray-200 p-3.5 dark:border-gray-800",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:f.memory.promptSection}),r.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:f.memory.promptSectionHint})]}),r.jsx(Kn,{ref:_,label:f.memory.promptLabel,mono:!0,size:"sm",rows:12,value:Y,onFocus:()=>G("main"),onChange:Te=>V(Te.target.value)}),r.jsx(Kn,{ref:P,label:f.memory.workspacePromptLabel,mono:!0,size:"sm",rows:6,value:O,onFocus:()=>G("workspace"),onChange:Te=>U(Te.target.value)}),r.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[r.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:f.agent.placeholdersTitle}),r.jsx("ul",{className:"space-y-1",children:f.memory.promptPlaceholders.map(([Te,ze])=>r.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>H==="main"?zt(_,Y,V,Te):zt(P,O,U,Te),title:f.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}),r.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:ze})]},Te))})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx(ve,{size:"sm",variant:"primary",onClick:nn,children:f.common.save})})]}),J,Ae?r.jsx(U2,{open:xe,side:"right",title:A?.file.title??"",onClose:()=>me(!1),widthClass:"max-w-lg",children:A&&r.jsxs("div",{className:"flex h-full flex-col",children:[r.jsx("div",{className:"flex-1 space-y-3 overflow-y-auto px-4 py-3",children:nt}),ot]})}):r.jsx(U0,{open:xe,snap:We,onSnapChange:re,title:A?.file.title??"",onClose:()=>me(!1),children:A&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"space-y-3 px-4 py-3",children:nt}),ot]})}),r.jsx(Xt,{open:q!==null,title:f.memory.editTitle,onClose:()=>j(null),widthClass:"sm:max-w-lg",children:q&&r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.memory.editWhy}),r.jsx("p",{className:"break-all font-mono text-[11px] text-gray-400 dark:text-gray-500",children:Wt(q.scope,q.file)}),r.jsx(Kn,{label:f.memory.editRequirementLabel,size:"sm",rows:2,value:$,onChange:Te=>ae(Te.target.value),placeholder:f.memory.editRequirementPlaceholder}),r.jsx(Kn,{label:f.memory.editPromptLabel,size:"sm",rows:6,readOnly:!0,value:Ke,className:"text-gray-600 dark:text-gray-300"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ve,{size:"sm",onClick:()=>se.flash(Ke),children:[r.jsx(Xd,{copied:se.copied,size:12}),f.memory.editCopyPrompt]}),r.jsx(Zd,{copied:se.copied}),r.jsx(ve,{size:"sm",variant:"primary",onClick:De,children:f.memory.editOpenChat})]})]})}),r.jsx(Xt,{open:de!==null,title:f.memory.addTitle,onClose:()=>ye(null),widthClass:"sm:max-w-lg",children:de&&r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.memory.addWhy}),r.jsx("p",{className:"break-all font-mono text-[11px] text-gray-400 dark:text-gray-500",children:`${w}/${de.scopeKey}`}),r.jsx(Kn,{label:f.memory.addContentLabel,size:"sm",rows:4,value:Se,onChange:Te=>ke(Te.target.value),placeholder:f.memory.addContentPlaceholder}),r.jsx(Kn,{label:f.memory.editPromptLabel,size:"sm",rows:6,readOnly:!0,value:Ue,className:"text-gray-600 dark:text-gray-300"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ve,{size:"sm",disabled:Se.trim()==="",onClick:()=>W.flash(Ue),children:[r.jsx(Xd,{copied:W.copied,size:12}),f.memory.editCopyPrompt]}),r.jsx(Zd,{copied:W.copied}),r.jsx(ve,{size:"sm",variant:"primary",disabled:Se.trim()==="",onClick:pe,children:f.memory.editOpenChat})]})]})}),r.jsx(yn,{open:ee!==null,tone:"danger",title:f.memory.deleteTitle,confirmLabel:f.memory.delete,onClose:()=>je(null),onConfirm:()=>{Ne()},children:r.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:ee?f.memory.deleteConfirm(ee.file.title):""})})]})}const Nh="tools.builtin.";function UU(e){const t=f.agent.kernelFields[e];return t!==void 0?t:e.startsWith(Nh)&&e.length>Nh.length?f.agent.kernelFieldTool(e.slice(Nh.length)):e}const zU=/^[A-Za-z_][A-Za-z0-9_]*$/;function $U({agentId:e,onConfigChanged:t}){const{currentProject:a,reloadAgents:i}=cn(),l=a?.projectId??null,c=a?.role==="owner",{applyConfig:u,toggleCard:m,alertStrip:p,promptSection:h}=P0({agentId:e,feature:"vault",strings:f.vault.injection,canEdit:c,onConfigChanged:t}),[g,v]=x.useState(null),[k,w]=x.useState(null),[S,M]=x.useState(!1),[C,T]=x.useState(!1),[I,D]=x.useState(""),[K,F]=x.useState(""),[E,B]=x.useState({}),Y=()=>B(me=>me.key||me.value?{}:me),[V,O]=x.useState(null),[U,_]=x.useState(null),P=x.useCallback(async()=>{if(!(!l||!e)){v(null),w(null);try{const[me,A]=await Promise.all([b4(l,e),el(l,e)]);v(me.entries),u(A.config)}catch(me){w(Oe(me))}}},[l,e,u]);x.useEffect(()=>{P()},[P]);const H=async me=>{if(!l||!e)return f.common.unknownError;M(!0);try{const A=await k4(l,e,me);return v(A.entries),Ut(f.common.saved),i(),null}catch(A){return Oe(A)}finally{M(!1)}},G=me=>(g??[]).filter(A=>A.key!==me).map(A=>({key:A.key})),z=()=>{D(""),F(""),B({}),T(!0)},J=async()=>{const me=I.trim(),A={};if(me?zU.test(me)||(A.key=f.vault.keyInvalid):A.key=f.common.requiredField,K||(A.value=f.vault.valueRequired),A.key||A.value){B(A);return}if(B({}),U!==me&&(g??[]).some(q=>q.key===me)){_(me);return}_(null);const R=await H({entries:[...G(me),{key:me,value:K}]});if(R!==null){B({key:R});return}T(!1)},xe=async()=>{if(V===null)return;const me=await H({entries:G(V)});me!==null&&Ve(me),O(null)};return l?r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.vault.desc}),!c&&r.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:f.vault.readOnlyHint})]}),m,p,g===null?r.jsx(La,{rows:4}):g.length===0?r.jsx("p",{className:"py-2 text-xs text-gray-400 dark:text-gray-500",children:f.vault.empty}):r.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:r.jsxs("table",{className:"w-full min-w-[420px] text-left text-sm",children:[r.jsx("thead",{children:r.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:[r.jsx("th",{className:"px-3 py-2.5",children:f.vault.key}),r.jsx("th",{className:"px-3 py-2.5",children:f.vault.valueMasked}),r.jsx("th",{className:"px-3 py-2.5"})]})}),r.jsx("tbody",{children:g.map(me=>r.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:[r.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:me.key}),r.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:me.valueMasked}),r.jsx("td",{className:"px-3 py-2 text-right",children:c&&r.jsx(ve,{size:"sm",variant:"ghost",disabled:S,onClick:()=>O(me.key),children:f.vault.remove})})]},me.key))})]})}),c&&g!==null&&r.jsx(ve,{size:"sm",variant:"primary",disabled:S,onClick:z,children:f.vault.add}),h,r.jsx(Xt,{open:C,title:f.vault.addTitle,onClose:()=>T(!1),footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:()=>T(!1),children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:S,onClick:()=>{J()},children:f.vault.add})]}),children:r.jsxs("div",{className:"space-y-3",children:[r.jsx(rt,{size:"sm",label:f.vault.key,required:!0,hint:f.vault.keyHint,error:E.key,value:I,onChange:me=>{D(me.target.value),Y()},className:"font-mono",placeholder:"OPENAI_API_KEY",autoComplete:"off"}),r.jsx(ci,{size:"sm",label:f.vault.value,required:!0,error:E.value,value:K,onChange:me=>{F(me.target.value),Y()},className:"font-mono",autoComplete:"off",onKeyDown:me=>{me.key==="Enter"&&!S&&J()}})]})}),r.jsx(yn,{open:U!==null,title:f.vault.overwriteTitle,tone:"primary",confirmLabel:f.common.save,busy:S,onClose:()=>_(null),onConfirm:()=>{J()},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:U!==null?f.vault.overwriteConfirm(U):""})}),r.jsx(yn,{open:V!==null,title:f.vault.deleteTitle,busy:S,onClose:()=>O(null),onConfirm:()=>{xe()},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:V!==null?f.vault.deleteConfirm(V):""})}),k&&r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:k})]}):null}const PU={active:"green",disabled:"gray",expired:"amber",done:"brand",missed:"amber",invalid:"red"};function aw(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const a=i=>i<10?`0${i}`:`${i}`;return`${t.getFullYear()}-${a(t.getMonth()+1)}-${a(t.getDate())}T${a(t.getHours())}:${a(t.getMinutes())}`}const rw=e=>e.modelId&&e.provider?{provider:e.provider,modelId:e.modelId}:null,BU={editing:null,name:"",prompt:"",enabled:!0,startAt:"",endAt:"",period:"",target:"new",sessionId:"",workspace:"",model:null};function HU(e,t){const a=t.trim().toLowerCase();return a?e.filter(i=>i.sessionId.toLowerCase().includes(a)||(i.title??"").toLowerCase().includes(a)):e}function FU({projectId:e,agentId:t,value:a,onChange:i}){const[l,c]=x.useState(!1),[u,m]=x.useState(""),[p,h]=x.useState(null);x.useEffect(()=>{if(!l||p!==null)return;let k=!1;return Oh(e,t).then(w=>{k||h(w.sessions)}).catch(()=>{k||h([])}),()=>{k=!0}},[l,p,e,t]);const g=p?.find(k=>k.sessionId===a)??null,v=g?g.title??f.chat.defaultSessionTitle:a||f.schedule.chooseSession;return r.jsx(_0,{open:l,setOpen:c,label:v,muted:!a,title:a?`${f.schedule.sessionId}:${a}`:f.schedule.chooseSession,ariaLabel:f.schedule.chooseSession,ariaHaspopup:"listbox",menuClass:"w-80 origin-top-left",children:p===null?r.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:f.common.loading}):p.length===0?r.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:f.schedule.sessionEmpty}):r.jsx(R0,{items:HU(p,u),itemKey:k=>k.sessionId,isCurrent:k=>k.sessionId===a,query:u,onQueryChange:m,searchPlaceholder:f.schedule.sessionSearch,emptyText:f.schedule.sessionNoMatch,onPick:k=>{i(k.sessionId),c(!1)},renderRow:k=>r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-800 dark:text-gray-200",children:k.title??f.chat.defaultSessionTitle}),r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400 dark:text-gray-500",children:k.sessionId.slice(-6)})]})})})}function VU({agentId:e,onConfigChanged:t}){const{currentProject:a,reloadAgents:i}=cn(),l=a?.projectId??null,c=a?.role==="owner",{applyConfig:u,toggleCard:m,alertStrip:p,promptSection:h}=P0({agentId:e,feature:"schedules",strings:f.schedule.injection,canEdit:c,onConfigChanged:t}),[g,v]=x.useState(null),[k,w]=x.useState(null),[S,M]=x.useState(!1),[C,T]=x.useState(null),[I,D]=x.useState(null),[K,F]=x.useState({}),[E,B]=x.useState(null),[Y,V]=x.useState(null),[O,U]=x.useState([]),[_,P]=x.useState(null),H=x.useCallback(async()=>{if(!(!l||!e)){v(null),w(null);try{const[j,$]=await Promise.all([tT(l,e),el(l,e)]);v(j),u($.config)}catch(j){w(Oe(j))}}},[l,e,u]);x.useEffect(()=>{H()},[H]),x.useEffect(()=>{!l||!c||Yl(l).then(j=>{U(j.models),P(j.defaultModel??null)}).catch(()=>{U([]),P(null)})},[l,c]);const G=j=>{F($=>$.name||$.prompt||$.startAt||$.sessionId?{}:$),B($=>$&&null),T($=>$===null?$:{...$,...j})},z=j=>{F({}),B(null),T(j),D(j)},J=async()=>{if(!l||C===null)return;B(null);const j=C.editing??C.name.trim(),$={};if(j||($.name=f.common.requiredField),C.prompt.trim()||($.prompt=f.common.requiredField),C.startAt||($.startAt=f.common.requiredField),C.target==="session"&&!C.sessionId.trim()&&($.sessionId=f.common.requiredField),$.name||$.prompt||$.startAt||$.sessionId){F($);return}if(F({}),C.editing!==null&&JSON.stringify(C)===JSON.stringify(I)){pa(f.common.noChangesToSave);return}const ae={prompt:C.prompt,enabled:C.enabled,startAt:new Date(C.startAt).toISOString(),...C.period.trim()?{period:C.period.trim()}:{},...C.endAt?{endAt:new Date(C.endAt).toISOString()}:{},...C.target==="session"&&C.sessionId.trim()?{sessionId:C.sessionId.trim()}:{},...C.target==="new"&&C.workspace.trim()?{workspace:C.workspace.trim()}:{},...C.target==="new"&&C.model&&!_t(_,C.model)?{modelId:C.model.modelId,provider:C.model.provider}:{}};M(!0);try{C.editing!==null?await Eb(l,e,C.editing,ae):await nT(l,e,{name:j,...ae}),T(null),Ut(f.common.saved),await H(),i()}catch(de){B(Oe(de))}finally{M(!1)}},xe=async j=>{if(!l)return;M(!0);const $=rw(j);try{await Eb(l,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}:{},...$?{modelId:$.modelId,provider:$.provider}:{}}),Ut(f.common.saved),await H()}catch(ae){Ve(Oe(ae))}finally{M(!1)}},me=j=>{z({editing:j.name,name:j.name,prompt:j.prompt,enabled:j.enabled,startAt:aw(j.startAt),endAt:aw(j.endAt),period:j.period??"",target:j.sessionId?"session":"new",sessionId:j.sessionId??"",workspace:j.workspace??"",model:rw(j)??_})},A=async()=>{if(!(!l||Y===null)){M(!0);try{await aT(l,e,Y),C?.editing===Y&&T(null),await H(),i()}catch(j){Ve(Oe(j))}finally{M(!1),V(null)}}};if(!l)return null;const R=g?.schedules??[],q=g?.invalidFiles??[];return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.schedule.desc}),!c&&r.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:f.schedule.readOnlyHint})]}),m,p,g===null?r.jsx(La,{rows:4}):R.length===0?r.jsx("p",{className:"py-2 text-xs text-gray-400 dark:text-gray-500",children:f.schedule.empty}):r.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:r.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[r.jsx("thead",{children:r.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:[r.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:f.common.name}),r.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:f.schedule.colStatus}),r.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:f.schedule.colPeriod}),r.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:f.schedule.colTarget}),r.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:f.schedule.colFireTimes}),r.jsx("th",{className:"whitespace-nowrap px-3 py-2.5",children:f.schedule.colQueued}),c&&r.jsx("th",{className:"px-3 py-2.5"})]})}),r.jsx("tbody",{children:R.map(j=>r.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:[r.jsx("td",{className:"max-w-40 truncate px-3 py-2 font-mono text-xs",title:j.name,children:j.name}),r.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:r.jsx("span",{title:j.invalidReason,children:r.jsx(Cn,{tone:PU[j.status],children:f.schedule.statusNames[j.status]??j.status})})}),r.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:j.period!==void 0?r.jsx("span",{className:"font-mono",children:j.period}):f.schedule.once}),r.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?r.jsx("span",{className:"font-mono",children:j.sessionId}):f.schedule.newSession}),r.jsxs("td",{className:"whitespace-nowrap px-3 py-2 text-xs",children:[r.jsx("span",{className:"block text-gray-600 dark:text-gray-300",children:j.nextFireAt?Oa(j.nextFireAt):"—"}),r.jsx("span",{className:"block text-gray-400 dark:text-gray-500",children:j.lastFiredAt?Oa(j.lastFiredAt):"—"})]}),r.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:j.queued&&r.jsx(Cn,{tone:"brand",children:f.schedule.queued})}),c&&r.jsxs("td",{className:"whitespace-nowrap px-3 py-2 text-right",children:[r.jsx(ve,{size:"sm",variant:"ghost",disabled:S,onClick:()=>{xe(j)},children:j.enabled?f.schedule.disable:f.schedule.enable}),r.jsx(ve,{size:"sm",variant:"ghost",disabled:S,onClick:()=>me(j),children:f.common.edit}),r.jsx(ve,{size:"sm",variant:"ghost",disabled:S,onClick:()=>V(j.name),children:f.common.delete})]})]},j.name))})]})}),q.length>0&&r.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400",children:[r.jsx("p",{className:"font-medium",children:f.schedule.invalidFiles}),r.jsx("ul",{className:"mt-0.5 space-y-0.5 font-mono",children:q.map(j=>r.jsxs("li",{children:[j.name,": ",j.error]},j.name))})]}),c&&g!==null&&r.jsx(ve,{size:"sm",variant:"primary",disabled:S,onClick:()=>z({...BU,model:_}),children:f.schedule.addTitle}),h,r.jsx(Xt,{open:C!==null,title:C?.editing!=null?f.schedule.editTitle(C.editing):f.schedule.addTitle,onClose:()=>T(null),widthClass:"sm:max-w-lg",footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:()=>T(null),children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:S,onClick:()=>{J()},children:C?.editing!=null?f.common.save:f.common.create})]}),children:C!==null&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[r.jsx(rt,{size:"sm",label:f.common.name,required:!0,hint:f.schedule.nameHint,error:K.name,value:C.name,disabled:C.editing!==null,onChange:j=>G({name:j.target.value}),className:"font-mono",placeholder:"daily_report",autoComplete:"off"}),r.jsx(rt,{size:"sm",label:f.schedule.period,value:C.period,onChange:j=>G({period:j.target.value}),className:"font-mono",placeholder:f.schedule.periodPlaceholder,autoComplete:"off"}),r.jsx(rt,{size:"sm",label:f.schedule.startAt,required:!0,type:"datetime-local",error:K.startAt,value:C.startAt,onChange:j=>G({startAt:j.target.value}),className:"font-mono"}),r.jsx(rt,{size:"sm",label:f.schedule.endAt,type:"datetime-local",value:C.endAt,onChange:j=>G({endAt:j.target.value}),className:"font-mono"}),r.jsxs(oi,{size:"sm",label:f.schedule.target,value:C.target,onChange:j=>G({target:j.target.value}),children:[r.jsx("option",{value:"new",children:f.schedule.targetNew}),r.jsx("option",{value:"session",children:f.schedule.targetSession})]}),C.target==="session"?r.jsxs("div",{children:[r.jsx(wr,{required:!0,children:f.schedule.sessionId}),l&&r.jsx(FU,{projectId:l,agentId:e,value:C.sessionId,onChange:j=>G({sessionId:j})}),K.sessionId&&r.jsx(Kr,{children:K.sessionId})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx(wr,{children:f.schedule.model}),O.length>0?r.jsx(I0,{models:O,value:C.model,..._?{defaultModel:_}:{},onChange:j=>G({model:j}),disabled:S,variant:"form"}):r.jsx("p",{className:"text-xs text-gray-400",children:f.schedule.modelDefault})]}),r.jsxs("div",{children:[r.jsx(wr,{children:f.schedule.workspace}),r.jsx(If,{projectId:l??"",workspace:C.workspace,onChange:j=>G({workspace:j}),variant:"form"})]})]})]}),r.jsx(Kn,{label:f.schedule.prompt,required:!0,size:"sm",rows:4,error:K.prompt,value:C.prompt,onChange:j=>G({prompt:j.target.value})}),r.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-600 dark:text-gray-300",children:[r.jsx("input",{type:"checkbox",checked:C.enabled,onChange:j=>G({enabled:j.target.checked})}),f.schedule.enabled]}),E&&r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:E})]})}),r.jsx(yn,{open:Y!==null,title:f.schedule.deleteTitle,busy:S,onClose:()=>V(null),onConfirm:()=>{A()},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:Y!==null?f.schedule.deleteConfirm(Y):""})}),k&&r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:k})]})}const qU=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,Qi={connectTimeoutMs:1e4,timeoutMs:12e4,maxOutputLength:16e3},GU=new Set(["transport","command","args","env","cwd","url","headers","connectTimeoutMs","timeoutMs","maxOutputLength"]);function WU(){return{name:"",transport:"http",command:"",argsText:"",envText:"",cwd:"",url:"",headersText:"",connectTimeoutMs:String(Qi.connectTimeoutMs),timeoutMs:String(Qi.timeoutMs),maxOutputLength:String(Qi.maxOutputLength),extras:{}}}function sw(e,t){return e===null||typeof e!="object"?"":Object.entries(e).map(([a,i])=>`${a}${t}${String(i)}`).join(`
178
- `)}function S5(e){const t=e.config;return t.transport==="http"||t.transport==="sse"||t.transport==="stdio"?t.transport:typeof t.url=="string"?"http":"stdio"}function KU(e){const t=e.config,a=S5(e),i={};for(const[l,c]of Object.entries(t))GU.has(l)||(i[l]=c);return{name:e.name,transport:a,command:typeof t.command=="string"?t.command:"",argsText:Array.isArray(t.args)?t.args.map(l=>String(l)).join(`
179
- `):"",envText:sw(t.env,"="),cwd:typeof t.cwd=="string"?t.cwd:"",url:typeof t.url=="string"?t.url:"",headersText:sw(t.headers,": "),connectTimeoutMs:String(typeof t.connectTimeoutMs=="number"?t.connectTimeoutMs:Qi.connectTimeoutMs),timeoutMs:String(typeof t.timeoutMs=="number"?t.timeoutMs:Qi.timeoutMs),maxOutputLength:String(typeof t.maxOutputLength=="number"?t.maxOutputLength:Qi.maxOutputLength),extras:i}}function iw(e,t){const a={},i=e.split(`
180
- `);for(const[l,c]of i.entries()){const u=c.trim();if(u==="")continue;const m=u.indexOf(t),p=m>=0?u.slice(0,m).trim():"";if(m<0||p==="")return{ok:!1,line:l+1};a[p]=u.slice(m+1).trim()}return{ok:!0,map:a}}function YU(e){const t=e.trim();if(t==="")return{ok:!0,value:void 0};const a=Number(t);return!Number.isInteger(a)||a<=0?{ok:!1,error:{code:"number"}}:{ok:!0,value:a}}function lw(e){const t={},a=e.name.trim();a===""?t.name={code:"required"}:qU.test(a)||(t.name={code:"name_charset"});const i={...e.extras,transport:e.transport};if(e.transport==="stdio"){const l=e.command.trim();l===""?t.command={code:"required"}:i.command=l;const c=e.argsText.split(`
181
- `).map(p=>p.trim()).filter(p=>p!=="");c.length>0&&(i.args=c);const u=iw(e.envText,"=");u.ok?Object.keys(u.map).length>0&&(i.env=u.map):t.env={code:"kv_line",line:u.line};const m=e.cwd.trim();m!==""&&(i.cwd=m)}else{const l=e.url.trim();if(l==="")t.url={code:"required"};else try{const u=new URL(l);u.protocol!=="http:"&&u.protocol!=="https:"?t.url={code:"url_invalid"}:i.url=l}catch{t.url={code:"url_invalid"}}const c=iw(e.headersText,":");c.ok?Object.keys(c.map).length>0&&(i.headers=c.map):t.headers={code:"kv_line",line:c.line}}for(const l of["connectTimeoutMs","timeoutMs","maxOutputLength"]){const c=YU(e[l]);c.ok?c.value!==void 0&&c.value!==Qi[l]&&(i[l]=c.value):t[l]=c.error}return Object.keys(t).length>0?{ok:!1,errors:t}:{ok:!0,server:{name:a,config:i}}}function ri(e){if(e)switch(e.code){case"required":return f.common.requiredField;case"name_charset":return f.agent.mcpNameInvalid;case"url_invalid":return f.agent.mcpUrlInvalid;case"kv_line":return f.agent.mcpLineInvalid(e.line??1);case"number":return f.agent.mcpNumberInvalid;case"duplicate":return f.agent.mcpDuplicateName}}function QU(e){const t=e.config;if(typeof t.url=="string")return t.url;const a=typeof t.command=="string"?t.command:"",i=Array.isArray(t.args)?t.args.map(l=>String(l)).join(" "):"";return i?`${a} ${i}`:a}function XU({result:e}){return e===void 0?null:e==="pending"?r.jsx("span",{className:"text-[11px] whitespace-nowrap text-gray-400",children:f.agent.mcpTestPending}):e.ok?r.jsx("span",{className:"text-[11px] font-medium whitespace-nowrap text-emerald-600 dark:text-emerald-400",children:f.agent.mcpTestBadge(e.tools?.length??0,e.latencyMs)}):r.jsx("span",{title:e.error,className:"text-[11px] font-medium whitespace-nowrap text-red-600 dark:text-red-400",children:f.agent.mcpTestBadgeFail})}function ZU({agentId:e,initial:t}){const{currentProject:a}=cn(),i=a?.projectId??null,[l,c]=x.useState(t),[u,m]=x.useState(!1),[p,h]=x.useState(null),[g,v]=x.useState(null),[k,w]=x.useState({}),[S,M]=x.useState(null),[C,T]=x.useState(null),[I,D]=x.useState(!1),[K,F]=x.useState(!1),[E,B]=x.useState(!1),[Y,V]=x.useState(new Map),O=[{value:"http",label:"http"},{value:"stdio",label:"stdio"},{value:"sse",label:"sse"}],U={http:f.agent.mcpTransportHttp,stdio:f.agent.mcpTransportStdio,sse:f.agent.mcpTransportSse},_=async j=>{if(!i||!e)return f.common.unknownError;m(!0);try{const $=await Zi(i,e,{config:{mcpServers:j}});return c($.config.mcpServers),Ut(f.common.saved),null}catch($){return Oe($)}finally{m(!1)}},P=()=>{h(WU()),v(null),w({}),M(null)},H=j=>{const $=l[j];$&&(h(KU($)),v(j),w({}),M(null))},G=()=>{h(null),v(null)},z=j=>{h($=>$&&{...$,...j}),w({}),M(null)},J=async()=>{if(!p||!i)return;const j=lw(p);if(!j.ok){w(j.errors);return}D(!0);try{const $=await Tb(i,e,j.server);$.ok?Ut(f.agent.mcpTestOk($.tools?.length??0,$.latencyMs)):Ve(f.agent.mcpTestFail($.error??f.common.unknownError))}catch($){Ve(f.agent.mcpTestFail(Oe($)))}finally{D(!1)}},xe=async()=>{if(i){B(!0);try{for(const j of l){V(ae=>new Map(ae).set(j.name,"pending"));let $;try{$=await Tb(i,e,j)}catch(ae){$={ok:!1,error:Oe(ae)}}V(ae=>new Map(ae).set(j.name,$))}}finally{B(!1)}}},me=async()=>{if(!p)return;const j=lw(p);if(!j.ok){w(j.errors);return}if(l.some((ye,Se)=>Se!==g&&ye.name===j.server.name)){w({name:{code:"duplicate"}});return}const ae=g===null?[...l,j.server]:l.map((ye,Se)=>Se===g?j.server:ye),de=await _(ae);if(de!==null){M(de);return}G()},A=async()=>{if(C===null)return;const j=await _(l.filter(($,ae)=>ae!==C));j!==null&&Ve(j),T(null)};if(!i)return null;const R=p!==null&&(p.transport==="stdio"?p.command.trim()!=="":p.url.trim()!==""),q=Y.size>0;return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"mb-1 text-xs font-medium text-gray-500",children:f.agent.mcpServers}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.agent.mcpDesc})]}),l.length===0?r.jsx("p",{className:"py-2 text-xs text-gray-400 dark:text-gray-500",children:f.agent.mcpEmpty}):r.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:r.jsxs("table",{className:"w-full min-w-[520px] text-left text-sm",children:[r.jsx("thead",{children:r.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:[r.jsx("th",{className:"px-3 py-2.5",children:f.agent.mcpName}),r.jsx("th",{className:"px-3 py-2.5",children:f.agent.mcpTransport}),r.jsx("th",{className:"px-3 py-2.5",children:f.agent.mcpTarget}),q&&r.jsx("th",{className:"px-3 py-2.5"}),r.jsx("th",{className:"px-3 py-1 text-right font-normal whitespace-nowrap",children:r.jsx(ve,{size:"sm",variant:"ghost",disabled:u||E,onClick:()=>F(!0),children:E?f.agent.mcpTestPending:f.agent.mcpTest})})]})}),r.jsx("tbody",{children:l.map((j,$)=>r.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:[r.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:j.name}),r.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:S5(j)}),r.jsx("td",{className:"max-w-[360px] truncate px-3 py-2 font-mono text-xs text-gray-500 dark:text-gray-400",children:QU(j)}),q&&r.jsx("td",{className:"px-3 py-2 text-right",children:r.jsx(XU,{result:Y.get(j.name)})}),r.jsxs("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:[r.jsx(ve,{size:"sm",variant:"ghost",disabled:u,onClick:()=>H($),children:f.common.edit}),r.jsx(ve,{size:"sm",variant:"ghost",disabled:u,onClick:()=>T($),children:f.agent.mcpRemove})]})]},j.name))})]})}),r.jsx(ve,{size:"sm",variant:"primary",disabled:u,onClick:P,children:f.agent.mcpAdd}),r.jsx(Xt,{open:p!==null,title:g===null?f.agent.mcpAdd:f.agent.mcpEditTitle,onClose:G,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:G,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:u,onClick:()=>{me()},children:f.common.save})]}),children:p&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Wi,{options:O,value:p.transport,onChange:j=>z({transport:j})}),r.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:U[p.transport]})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.jsx(ve,{size:"sm",disabled:I||u||!R,onClick:()=>{J()},children:I?f.agent.mcpTesting:f.agent.mcpTest})}),r.jsx(rt,{size:"sm",label:f.agent.mcpName,required:!0,hint:f.agent.mcpNameHint,error:ri(k.name),value:p.name,onChange:j=>z({name:j.target.value}),className:"font-mono",placeholder:"filesystem",autoComplete:"off"}),p.transport==="stdio"?r.jsxs(r.Fragment,{children:[r.jsx(rt,{size:"sm",label:f.agent.mcpCommand,required:!0,error:ri(k.command),value:p.command,onChange:j=>z({command:j.target.value}),className:"font-mono",placeholder:"npx",autoComplete:"off"}),r.jsx(Kn,{size:"sm",mono:!0,label:f.agent.mcpArgs,hint:f.agent.mcpArgsHint,rows:3,value:p.argsText,onChange:j=>z({argsText:j.target.value}),placeholder:`-y
182
- @modelcontextprotocol/server-filesystem
183
- .`}),r.jsx(Kn,{size:"sm",mono:!0,label:f.agent.mcpEnv,hint:f.agent.mcpEnvHint,error:ri(k.env),rows:2,value:p.envText,onChange:j=>z({envText:j.target.value}),placeholder:"API_TOKEN=..."}),r.jsx(rt,{size:"sm",label:f.agent.mcpCwd,hint:f.agent.mcpCwdHint,value:p.cwd,onChange:j=>z({cwd:j.target.value}),className:"font-mono",autoComplete:"off"})]}):r.jsxs(r.Fragment,{children:[r.jsx(rt,{size:"sm",label:f.agent.mcpUrl,required:!0,error:ri(k.url),value:p.url,onChange:j=>z({url:j.target.value}),className:"font-mono",placeholder:"https://example.com/mcp",autoComplete:"off"}),r.jsx(Kn,{size:"sm",mono:!0,label:f.agent.mcpHeaders,hint:f.agent.mcpHeadersHint,error:ri(k.headers),rows:2,value:p.headersText,onChange:j=>z({headersText:j.target.value}),placeholder:"Authorization: Bearer ..."})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(rt,{size:"sm",label:f.agent.mcpConnectTimeout,error:ri(k.connectTimeoutMs),value:p.connectTimeoutMs,inputMode:"numeric",onChange:j=>z({connectTimeoutMs:j.target.value}),className:"font-mono",autoComplete:"off"}),r.jsx(rt,{size:"sm",label:f.agent.toolTimeout,error:ri(k.timeoutMs),value:p.timeoutMs,inputMode:"numeric",onChange:j=>z({timeoutMs:j.target.value}),className:"font-mono",autoComplete:"off"}),r.jsx(rt,{size:"sm",label:f.agent.toolMaxOutput,error:ri(k.maxOutputLength),value:p.maxOutputLength,inputMode:"numeric",onChange:j=>z({maxOutputLength:j.target.value}),className:"font-mono",autoComplete:"off"})]}),r.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:f.agent.mcpBudgetsHint}),S&&r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:S})]})}),r.jsx(Xt,{open:K,title:f.agent.mcpTest,onClose:()=>F(!1),footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:()=>F(!1),children:f.common.cancel}),r.jsx(ve,{variant:"primary",onClick:()=>{F(!1),xe()},children:f.agent.mcpTestAllStart})]}),children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.agent.mcpTestAllConfirm(l.length)})}),r.jsx(yn,{open:C!==null,title:f.agent.mcpDeleteTitle,busy:u,onClose:()=>T(null),onConfirm:()=>{A()},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:C!==null?f.agent.mcpDeleteConfirm(l[C]?.name??""):""})})]})}function JU(e){return e.filter(([t])=>t!=="").map(([t,a])=>({value:t,triggerLabel:t,label:t,description:a}))}function oc(e){const t=e.trim();if(!t)return;const a=Number(t);return Number.isFinite(a)?a:void 0}function Vi(e){return e===void 0?"":String(e)}function ez(e,t,a){return t.some(i=>i.key===e)?e:a}function tz(){const e=[{key:"overview",label:f.agent.tabOverview},{key:"prompt",label:f.agent.tabPrompt},{key:"runtime",label:f.agent.tabRuntime},{key:"tools",label:f.agent.tabTools},{key:"skills",label:f.agent.tabSkills},{key:"memory",label:f.agent.tabMemory},{key:"vault",label:f.agent.tabVault},{key:"schedules",label:f.agent.tabSchedules}],t=ia(),i=x2().agentId??"";Jr(f.agent.settings);const{currentProject:l,reloadAgents:c}=cn(),u=l?.projectId??null,[m,p]=x.useState(null),[h,g]=vf(),[v,k]=x.useState(()=>ez(h.get("tab"),e,"overview")),w=x.useCallback(E=>{k(E),g(B=>{const Y=new URLSearchParams(B);return Y.set("tab",E),Y},{replace:!0})},[g]),[S,M]=x.useState(null),C=x.useCallback(E=>{!u||!i||(E?.keepStale||p(null),M(null),el(u,i).then(p).catch(B=>M(Oe(B))))},[u,i]);x.useEffect(()=>{C()},[C]);const T=x.useCallback(()=>C({keepStale:!0}),[C]),I=x.useCallback(E=>{Ut(f.agent.importDone(E)),C(),c()},[C,c]),D=x.useCallback(()=>{Ut(f.agent.resetConfigDone),C(),c()},[C,c]),K=x.useCallback(()=>{C({keepStale:!0}),c()},[C,c]),F=x.useCallback(async E=>{if(!(!u||!i))try{const B=await Zi(u,i,E);p(B),Ut(f.common.saved),(E.config?.name!==void 0||E.config?.description!==void 0||E.config?.toolsBuiltin!==void 0)&&c()}catch(B){Ve(Oe(B))}},[u,i,c]);return u?S&&!m?r.jsx("p",{className:"p-6 text-sm text-red-600 dark:text-red-400",children:S}):m?r.jsx("div",{className:"no-scrollbar relative h-full overflow-y-auto p-4 md:p-6",children:r.jsxs("div",{className:"mx-auto max-w-3xl",children:[r.jsxs(ve,{variant:"ghost",size:"sm",onClick:()=>t("/agents"),className:"-ml-2 mb-3 text-gray-500 dark:text-gray-400",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"M15 18l-6-6 6-6"}),r.jsx("path",{d:"M9 12h12"})]}),f.agent.backToList]}),r.jsx("h1",{className:"mb-1 text-xl font-semibold",children:m.config.name??i}),r.jsx("p",{className:"mb-4 font-mono text-xs text-gray-400",children:i}),r.jsx(yU,{items:e,active:v,onChange:w}),r.jsxs("div",{className:"py-4",children:[v==="overview"&&r.jsx(az,{data:m,agentId:i,onSave:F,onImported:I,onConfigReset:D,onKernelUpdated:K}),v==="prompt"&&r.jsx(rz,{data:m,onSave:F}),v==="memory"&&r.jsx(DU,{agentId:i,onConfigChanged:T}),v==="runtime"&&r.jsx(sz,{data:m,onSave:F}),v==="tools"&&r.jsxs("div",{className:"space-y-8",children:[r.jsx(iz,{data:m,onSave:F}),r.jsx(ZU,{agentId:i,initial:m.config.mcpServers})]}),v==="skills"&&r.jsx(TU,{agentId:i,onConfigChanged:T}),v==="vault"&&r.jsx($U,{agentId:i,onConfigChanged:T}),v==="schedules"&&r.jsx(VU,{agentId:i,onConfigChanged:T})]})]})}):r.jsxs("div",{className:"space-y-3 p-6",children:[r.jsx(mn,{className:"h-6 w-64"}),r.jsx(mn,{className:"h-32 w-full"})]}):null}const ow="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",nz="M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10";function az({data:e,agentId:t,onSave:a,onImported:i,onConfigReset:l,onKernelUpdated:c}){const{currentProject:u}=cn(),m=u?.projectId??null,p=u?.role==="owner",[h,g]=x.useState(e.config.name??""),[v,k]=x.useState(e.config.description??""),[w,S]=x.useState(!1),[M,C]=x.useState(null),[T,I]=x.useState(null),[D,K]=x.useState(!1),[F,E]=x.useState(!1),[B,Y]=x.useState(!1),[V,O]=x.useState(!1),[U,_]=x.useState(null),{requestSave:P,element:H}=so(),G=async()=>{if(m){E(!0);try{await R4(m,t),K(!1),l()}catch(A){Ve(Oe(A))}finally{E(!1)}}},z=async()=>{if(m){O(!0);try{const A=await I4(m,t);Y(!1),_(A),Ut(f.agent.kernelUpdateDone(A.kernelVersion,A.advanced.length)),c()}catch(A){Ve(Oe(A))}finally{O(!1)}}},J=()=>{const A={};if(h.trim()!==(e.config.name??"")&&(A.name=h.trim()),v.trim()!==(e.config.description??"")&&(A.description=v.trim()),Object.keys(A).length===0){pa(f.common.noChangesToSave);return}P(()=>{a({config:A})})},xe=async(A,R)=>{if(m){S(!0),C(null);try{const q=await fT(m,t,{dataBase64:A,...R?{confirm:!0}:{}});I(null),i(q.version)}catch(q){q instanceof sa&&q.status===409&&q.code==="version_conflict"?I(A):(I(null),C(Oe(q)))}finally{S(!1)}}},me=A=>{const R=A.target.files?.[0];if(A.target.value="",!R)return;C(null);const q=new FileReader;q.onload=()=>{const j=q.result;xe(j.slice(j.indexOf(",")+1),!1)},q.onerror=()=>C(f.common.unknownError),q.readAsDataURL(R)};return r.jsxs("div",{className:"space-y-4",children:[r.jsx(rt,{size:"sm",label:f.common.name,value:h,onChange:A=>g(A.target.value)}),r.jsx(Kn,{label:f.agent.description,size:"sm",rows:3,value:v,onChange:A=>k(A.target.value)}),r.jsx(ve,{size:"sm",variant:"primary",onClick:J,children:f.common.save}),H,r.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[r.jsx("p",{className:"text-sm font-medium",children:f.agent.stateTitle}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m&&r.jsx("a",{href:dT(m,t),download:!0,className:ow,children:f.agent.exportSnapshot}),p&&r.jsxs("label",{className:`${ow} ${w?"pointer-events-none opacity-60":""}`,children:[r.jsx(Lf,{accept:".tar.gz,.tgz",disabled:w,onChange:me}),w?f.agent.importing:f.agent.importSnapshot]})]})]}),r.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:f.agent.transferDesc}),r.jsxs("div",{className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.agent.stateVersion}),r.jsxs("p",{className:"mt-0.5 font-mono text-sm font-semibold",children:["v",e.config.version]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:f.agent.stateDir}),r.jsxs("div",{className:"flex items-start gap-1.5",children:[r.jsx("span",{title:e.stateDir,className:"min-w-0 flex-1 break-all font-mono text-xs leading-5",children:e.stateDir}),r.jsx(io,{text:e.stateDir,label:f.agent.copyStateDir,className:o0})]})]})]}),M&&r.jsx("p",{className:"mt-1.5 text-xs text-red-600 dark:text-red-400",children:M})]}),r.jsxs("section",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[r.jsx("p",{className:"text-sm font-medium",children:f.agent.kernelTitle}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.jsx(ve,{size:"sm",disabled:V||!e.config.kernelOutdated,onClick:()=>Y(!0),children:f.agent.kernelUpdateAction}),r.jsx(ve,{size:"sm",variant:"danger",disabled:F,onClick:()=>K(!0),children:f.agent.resetConfigAction})]})]}),r.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?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.agent.kernelCurrent}),r.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelVersion??f.agent.kernelLegacy}),r.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",f.agent.kernelLatest]}),r.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelLatest}),r.jsx("span",{role:"img",title:f.agent.kernelOutdatedHint,"aria-label":f.agent.kernelOutdatedHint,className:"self-center text-gray-500 dark:text-gray-400",children:r.jsx(Ge,{d:nz,size:12})})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-mono font-semibold",children:e.config.kernelVersion}),r.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",f.agent.kernelUpToDate]})]})}),U!==null&&U.kept.length>0&&r.jsxs("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:[f.agent.kernelUpdateKeptIntro,U.kept.map(UU).join(f.agent.kernelListSeparator)]})]}),r.jsx(yn,{open:T!==null,title:f.agent.importConflictTitle,busy:w,onClose:()=>I(null),onConfirm:()=>{T!==null&&xe(T,!0)},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.agent.importConflictBody})}),r.jsx(yn,{open:B,title:f.agent.kernelUpdateTitle,busy:V,tone:"primary",onClose:()=>Y(!1),onConfirm:()=>{z()},confirmLabel:f.agent.kernelUpdateAction,children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.agent.kernelUpdateConfirmBody})}),r.jsx(yn,{open:D,title:f.agent.resetConfigTitle,busy:F,onClose:()=>K(!1),onConfirm:()=>{G()},confirmLabel:f.agent.resetConfigAction,children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.agent.resetConfigConfirmBody})})]})}function rz({data:e,onSave:t}){const[a,i]=x.useState(e.agentsMd),[l,c]=x.useState(e.config.systemPrompt),u=x.useRef(null),{requestSave:m,element:p}=so(),h=()=>{const v={};if(a!==e.agentsMd&&(v.agentsMd=a),l!==e.config.systemPrompt&&(v.config={systemPrompt:l}),v.agentsMd===void 0&&v.config===void 0){pa(f.common.noChangesToSave);return}m(()=>{t(v)})},g=v=>{const k=u.current;if(k&&(k.focus(),document.execCommand?.("insertText",!1,v)))return;const w=k?k.selectionStart:l.length,S=k?k.selectionEnd:l.length;c(l.slice(0,w)+v+l.slice(S)),requestAnimationFrame(()=>{if(!k)return;k.focus();const M=w+v.length;k.setSelectionRange(M,M)})};return r.jsxs("div",{className:"space-y-4",children:[r.jsx(Kn,{label:f.agent.agentsMd,mono:!0,size:"sm",rows:14,value:a,onChange:v=>i(v.target.value)}),r.jsx(Kn,{ref:u,label:f.agent.systemPrompt,mono:!0,size:"sm",rows:12,value:l,onChange:v=>c(v.target.value)}),r.jsxs("div",{className:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-800 dark:bg-gray-900",children:[r.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:f.agent.placeholdersTitle}),r.jsx("ul",{className:"space-y-1",children:f.agent.placeholders.map(([v,k])=>r.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[r.jsx("button",{type:"button",onClick:()=>g(v),title:f.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:v}),r.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:k})]},v))})]}),r.jsx(ve,{size:"sm",variant:"primary",onClick:h,children:f.common.save}),p]})}function sz({data:e,onSave:t}){const a=e.config,[i,l]=x.useState(Vi(a.maxTurns)),[c,u]=x.useState(Vi(a.model?.maxTokens)),[m,p]=x.useState(a.model?.thinkingLevel??""),[h,g]=x.useState(Vi(a.model?.timeoutMs)),[v,k]=x.useState(Vi(a.compaction?.maxContextLength)),[w,S]=x.useState(Vi(a.compaction?.maxSessionTurns)),[M,C]=x.useState(a.compaction?.mode??""),[T,I]=x.useState(a.compaction?.prompt??""),[D,K]=x.useState({}),F=()=>K(U=>U.maxTurns||U.timeoutMs?{}:U),{requestSave:E,element:B}=so(),Y=()=>{K({});const U={},_=oc(i);if(_!==void 0&&_!==a.maxTurns){if(_<=0&&_!==-1){K({maxTurns:f.agent.maxTurnsInvalid});return}U.maxTurns=_}const P={},H=oc(c);H!==void 0&&H!==a.model?.maxTokens&&(P.maxTokens=H),m&&m!==(a.model?.thinkingLevel??"")&&(P.thinkingLevel=m);const G=oc(h);if(G!==void 0&&G!==a.model?.timeoutMs){if(G<=0&&G!==-1){K({timeoutMs:f.agent.timeoutInvalid});return}P.timeoutMs=G}Object.keys(P).length>0&&(U.model=P);const z={},J=oc(v);J!==void 0&&J!==a.compaction?.maxContextLength&&(z.maxContextLength=J);const xe=oc(w);if(xe!==void 0&&xe!==a.compaction?.maxSessionTurns&&(z.maxSessionTurns=xe),M&&M!==(a.compaction?.mode??"")&&(z.mode=M),T!==(a.compaction?.prompt??"")&&(z.prompt=T),Object.keys(z).length>0&&(U.compaction=z),Object.keys(U).length===0){pa(f.common.noChangesToSave);return}E(()=>{t({config:U})})},V=T7(f.agent.thinkingLevelOptions,f.agent.thinkingLevelNoneKept,a.model?.thinkingLevel),O=JU(f.agent.compactionModeOptions);return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[r.jsx("div",{className:"p-3",children:r.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[r.jsx(rt,{label:f.agent.maxTurns,size:"sm",value:i,error:D.maxTurns,onChange:U=>{l(U.target.value),F()},inputMode:"numeric",className:"font-mono"}),r.jsx(rt,{label:f.agent.maxTokens,size:"sm",value:c,onChange:U=>u(U.target.value),inputMode:"numeric",className:"font-mono"}),r.jsx(jg,{label:f.agent.thinkingLevel,fullWidth:!0,size:"sm",placeholder:f.agent.defaultValue,value:m,onChange:p,options:V}),r.jsx(rt,{label:f.agent.timeoutMs,hint:f.agent.timeoutMsHint,size:"sm",value:h,error:D.timeoutMs,onChange:U=>{g(U.target.value),F()},inputMode:"numeric",className:"font-mono"})]})}),r.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:f.agent.compaction}),r.jsx("div",{className:"p-3",children:r.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-3",children:[r.jsx(rt,{label:f.agent.maxContextLength,hint:f.agent.maxContextLengthHint,size:"sm",value:v,onChange:U=>k(U.target.value),inputMode:"numeric",className:"font-mono"}),r.jsx(rt,{label:f.agent.maxSessionTurns,hint:f.agent.maxSessionTurnsHint,size:"sm",value:w,onChange:U=>S(U.target.value),inputMode:"numeric",className:"font-mono"}),r.jsx(jg,{label:f.agent.compactionMode,fullWidth:!0,size:"sm",placeholder:f.agent.defaultValue,value:M,onChange:C,options:O})]})}),r.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:f.agent.compactionPrompt}),r.jsx("div",{className:"p-3",children:r.jsx(Kn,{"aria-label":f.agent.compactionPrompt,mono:!0,size:"sm",rows:4,value:T,onChange:U=>I(U.target.value)})})]}),r.jsx(ve,{size:"sm",variant:"primary",onClick:Y,children:f.common.save}),B]})}function iz({data:e,onSave:t}){const a=[{value:"r",triggerLabel:"r",label:f.agent.permissionReadLabel,description:f.agent.permissionReadDescription},{value:"rw",triggerLabel:"rw",label:f.agent.permissionReadWriteLabel,description:f.agent.permissionReadWriteDescription}],[i,l]=x.useState(()=>e.config.toolsBuiltin.map(k=>({base:{...k},timeoutMs:Vi(k.timeoutMs),maxOutputLength:Vi(k.maxOutputLength)}))),[c,u]=x.useState({}),{requestSave:m,element:p}=so(),h=(k,w)=>{l(S=>S.map((M,C)=>C===k?{...M,...w}:M)),u(S=>{const M=`${k}-timeoutMs`,C=`${k}-maxOutputLength`;if(!S[M]&&!S[C])return S;const T={...S};return delete T[M],delete T[C],T})},g=()=>{const k={},w=[];for(const[C,T]of i.entries()){const I={...T.base};delete I.timeoutMs,delete I.maxOutputLength;const D=T.timeoutMs.trim();if(D){const E=Number(D);!Number.isInteger(E)||E<=0&&E!==-1?k[`${C}-timeoutMs`]=f.agent.toolFieldInvalid(T.base.name,"timeoutMs"):I.timeoutMs=E}const K=T.maxOutputLength.trim();if(K){const E=Number(K);!Number.isInteger(E)||E<=0&&E!==-1?k[`${C}-maxOutputLength`]=f.agent.toolFieldInvalid(T.base.name,"maxOutputLength"):I.maxOutputLength=E}const F=e.config.toolsBuiltin[C];I.call_description===!0&&F?.call_description===void 0&&delete I.call_description,w.push(I)}if(Object.keys(k).length>0){u(k);return}u({});const S=e.config.toolsBuiltin;if(!(w.length!==S.length||w.some((C,T)=>{const I=S[T];return C.permission!==I.permission||C.timeoutMs!==I.timeoutMs||C.maxOutputLength!==I.maxOutputLength||C.call_description!==I.call_description}))){pa(f.common.noChangesToSave);return}m(()=>{t({config:{toolsBuiltin:w}})})},v=k=>{const w=k.parameters?.properties;return w!=null&&w.description!==void 0};return r.jsxs("div",{className:"space-y-4",children:[r.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:r.jsxs("table",{className:"w-full min-w-[640px] text-left text-sm",children:[r.jsx("thead",{children:r.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:[r.jsx("th",{className:"px-3 py-2",children:f.common.name}),r.jsx("th",{className:"px-3 py-2",children:f.agent.toolPermission}),r.jsx("th",{className:"px-3 py-2",children:f.agent.toolTimeout}),r.jsx("th",{className:"px-3 py-2",children:f.agent.toolMaxOutput}),r.jsx("th",{className:"px-3 py-2",children:f.agent.toolCallDescription})]})}),r.jsx("tbody",{children:i.map((k,w)=>r.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800/60",children:[r.jsx("td",{className:"px-3 py-2 align-top font-mono text-xs",children:k.base.name}),r.jsx("td",{className:"px-3 py-2 align-top",children:r.jsx(jg,{mono:!0,size:"sm","aria-label":f.agent.toolPermission,placeholder:f.agent.defaultValue,options:a,value:k.base.permission,onChange:S=>h(w,{base:{...k.base,permission:S}})})}),r.jsx("td",{className:"px-3 py-2 align-top",children:r.jsx(rt,{size:"sm",value:k.timeoutMs,error:c[`${w}-timeoutMs`],inputMode:"numeric",className:"font-mono",onChange:S=>h(w,{timeoutMs:S.target.value})})}),r.jsx("td",{className:"px-3 py-2 align-top",children:r.jsx(rt,{size:"sm",value:k.maxOutputLength,error:c[`${w}-maxOutputLength`],inputMode:"numeric",className:"font-mono",onChange:S=>h(w,{maxOutputLength:S.target.value})})}),r.jsx("td",{className:"px-3 py-2 align-top",children:v(k.base)?r.jsx(di,{checked:k.base.call_description!==!1,onChange:S=>h(w,{base:{...k.base,call_description:S}}),"aria-label":`${k.base.name} ${f.agent.toolCallDescription}`}):r.jsx("span",{className:"text-xs text-gray-300 dark:text-gray-600",children:"—"})})]},k.base.name))})]})}),r.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:f.agent.callDescriptionHint}),r.jsx(ve,{size:"sm",variant:"primary",onClick:g,children:f.common.save}),p]})}const lz="M22 2 11 13M22 2 15 22 11 13 2 9 22 2",oz="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3",cz="M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10";function uz(e,t,a,i){return e.filter(l=>{const c=t.get(l)?.get(a);return c!==void 0&&c<i})}function dz(){Jr(f.nav.skills);const e=ia(),{locale:t}=Za(),a=vn().user?.userId??null,{currentProject:i,agents:l,currentAgent:c,setCurrentAgentId:u}=cn(),m=i?.projectId??null,[p,h]=x.useState(null),[g,v]=x.useState(null),[k,w]=x.useState(new Map),[S,M]=x.useState(new Set);x.useEffect(()=>{let E=!1;return v(null),rT().then(B=>{E||h(B.groups)}).catch(B=>{E||v(Oe(B))}),()=>{E=!0}},[]);const C=l.map(E=>E.agentId).join(",");x.useEffect(()=>{if(w(new Map),!m||C==="")return;let E=!1;const B=C.split(",");return Promise.all(B.map(async Y=>{try{const V=await hf(m,Y);return[Y,new Map(V.skills.map(O=>[O.name,O.version]))]}catch{return[Y,new Map]}})).then(Y=>{E||w(V=>{const O=new Map(Y);for(const[U,_]of V)O.set(U,_);return O})}),()=>{E=!0}},[m,C]);const T=(E,B,Y)=>w(V=>{const O=new Map(V),U=new Map(O.get(E)??[]);return Y!==void 0?U.set(B,Y):U.delete(B),O.set(E,U),O}),I=(E,B)=>w(Y=>new Map(Y).set(E,new Map(B.map(V=>[V.name,V.version])))),D=async(E,B,Y,V)=>{if(!m)return;const O=k.get(E)?.get(B);T(E,B,Y?V:void 0);const U=l.find(P=>P.agentId===E),_=U?pn(U):E;try{if(Y){const P=await _b(m,E,[B]);I(E,P.skills),Ut(f.skills.installedToast(B,_))}else await Qw(m,E,B),Ut(f.skills.uninstalledToast(B,_))}catch(P){if(!Y&&P instanceof sa&&P.status===404)return;T(E,B,O),Ve(Oe(P))}},K=async(E,B)=>{if(!m||B.length===0)return;const V=(await Promise.allSettled(B.map(async O=>{const U=await _b(m,O,[E]);I(O,U.skills)}))).find(O=>O.status==="rejected");V?Ve(Oe(V.reason)):Ut(f.skills.updatedToast(E,B.length))},F=E=>{const B=c?.agentId;if(B){if(a&&m){uo(a,m);const Y=Qr(a,m);js(Y,{...gi(Y),agentId:B,text:f.skills.quickInvokeText(E),skills:[E],handoffAgentId:void 0})}u(B),e(`/chat/${Xa}`,{state:{agentId:B}})}};return r.jsx("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:r.jsxs("div",{className:"mx-auto max-w-5xl",children:[r.jsx("h1",{className:"text-xl font-semibold",children:f.skills.pageTitle}),r.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:f.skills.pageDesc}),g?r.jsxs("div",{className:"mt-6 flex items-center gap-3",children:[r.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:g}),r.jsx(ve,{size:"sm",onClick:()=>window.location.reload(),children:f.common.retry})]}):p===null?r.jsx("div",{className:"mt-6 grid gap-2.5 sm:grid-cols-2",children:Array.from({length:4},(E,B)=>r.jsxs(uS,{className:"p-4",children:[r.jsx(mn,{className:"h-4 w-32"}),r.jsx(mn,{className:"mt-2 h-4 w-3/4"}),r.jsx(mn,{className:"mt-3 h-6 w-36"})]},B))}):r.jsx("div",{className:"mt-6 space-y-3",children:p.map(E=>{const B=!S.has(E.id);return r.jsxs("section",{className:"overflow-hidden rounded-md bg-white dark:bg-gray-900",children:[r.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(Y=>{const V=new Set(Y);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:[r.jsx("span",{className:"min-w-0 truncate text-sm font-semibold",children:qO(t,E.title,E.titleZh)}),r.jsx("span",{className:"shrink-0 whitespace-nowrap font-mono text-xs text-gray-400",children:f.skills.skillCount(E.skills.length)}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx(Yn,{open:B,className:"text-gray-400"})]}),r.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${B?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:r.jsx("div",{className:"overflow-hidden",inert:!B,children:r.jsx("div",{className:`grid gap-2.5 p-2.5 transition-opacity duration-200 sm:grid-cols-2 ${B?"opacity-100":"opacity-0"}`,children:E.skills.map(Y=>r.jsx(fz,{skill:Y,installed:k,onQuickInvoke:F,onToggleInstall:D,onUpdateOutdated:K},Y.name))})})})]},E.id)})})]})})}function fz({skill:e,installed:t,onQuickInvoke:a,onToggleInstall:i,onUpdateOutdated:l}){const{locale:c}=Za(),{agents:u,currentAgent:m}=cn(),[p,h]=x.useState(!1),[g,v]=x.useState(null),[k,w]=x.useState(!1),[S,M]=x.useState(null),C=async()=>{g&&(w(!0),await l(e.name,g),w(!1),v(null))},T=S!==null?u.find(V=>V.agentId===S):void 0,I=T?pn(T):void 0;let D=0;for(const V of t.values())V.has(e.name)&&(D+=1);const K=uz(u.map(V=>V.agentId),t,e.name,e.version),F=m!==null&&(t.get(m.agentId)?.has(e.name)??!1),E=co(c,e),B=e.description,Y=[`v${e.version}`,e.updated?Kd(e.updated,c):null,f.skills.usedByAgents(D)].filter(V=>V!==null).join(" · ");return r.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:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${Hj(e.name)}`,children:r.jsx(Rf,{icon:e.icon,size:20})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate font-mono text-[13px] font-semibold",title:e.name,children:e.name}),r.jsx("p",{className:"mt-0.5 truncate text-xs leading-5 text-gray-500 dark:text-gray-400",title:B,children:E})]})]}),r.jsx("p",{className:"mt-2.5 truncate text-[11px] text-gray-400 dark:text-gray-500",title:Y,children:Y})]}),r.jsxs("div",{className:"flex shrink-0 items-center justify-center gap-1.5",children:[K.length>0&&r.jsx(ve,{size:"sm",variant:"secondary",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${f.skills.updateOutdated(K.length)} ${e.name}`,title:f.skills.updateOutdated(K.length),onClick:()=>v(K),children:r.jsx(Ge,{d:cz,size:13})}),r.jsx(ve,{size:"sm",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${f.skills.quickInvoke} ${e.name}`,title:F?f.skills.quickInvoke:f.skills.quickInvokeNeedsInstall,disabled:!F,onClick:()=>a(e.name),children:r.jsx(Ge,{d:lz,size:15})}),r.jsx(ve,{size:"sm",className:"h-8 w-8 shrink-0 justify-center p-0","aria-label":`${f.skills.manageInstall} ${e.name}`,title:f.skills.manageInstall,onClick:()=>h(!0),children:r.jsx(Ge,{d:oz,size:15})})]}),p&&r.jsx(Xt,{open:!0,title:f.skills.manageInstallTitle(e.name),onClose:()=>h(!1),children:r.jsxs("div",{className:"space-y-0.5",children:[u.length===0&&r.jsx("p",{className:"py-1.5 text-xs text-gray-400",children:f.common.loading}),u.map(V=>r.jsx(mz,{agentId:V.agentId,name:pn(V),installed:t.get(V.agentId)?.has(e.name)??!1,outdated:K.includes(V.agentId),onToggle:O=>{O?i(V.agentId,e.name,!0,e.version):M(V.agentId)},onUpdate:()=>v([V.agentId])},V.agentId))]})}),g&&r.jsx(yn,{open:!0,title:f.skills.updateConfirmTitle(e.name),tone:"primary",confirmLabel:f.skills.updateAction,busy:k,onClose:()=>v(null),onConfirm:()=>{C()},children:r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.skills.updateConfirmWarning(e.name)}),r.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:g.map(V=>{const O=t.get(V)?.get(e.name),U=u.find(_=>_.agentId===V);return r.jsxs("li",{className:"flex items-center justify-between gap-3 px-3 py-1.5 text-xs",children:[r.jsx("span",{className:"min-w-0 truncate",children:U?pn(U):V}),r.jsxs("span",{className:"shrink-0 font-mono text-gray-500 dark:text-gray-400",children:["v",O??"?"," → v",e.version]})]},V)})})]})}),S!==null&&r.jsx(yn,{open:!0,title:f.skills.uninstallConfirmTitle(e.name),confirmLabel:f.skills.uninstall,onClose:()=>M(null),onConfirm:()=>{const V=S;M(null),i(V,e.name,!1,e.version)},children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.skills.uninstallConfirmBody(e.name,I??S)})})]})}function mz({agentId:e,name:t,installed:a,outdated:i,onToggle:l,onUpdate:c}){return r.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:[r.jsx(Da,{id:e,name:t,size:22,className:"shrink-0 rounded"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",title:e,children:t}),a&&i&&r.jsx(ve,{size:"sm",variant:"secondary",className:"shrink-0","aria-label":`${f.skills.updateAction} ${e}`,onClick:c,children:f.skills.updateAction}),a?r.jsxs(ve,{size:"sm",variant:"ghost",className:"group shrink-0","aria-label":`${f.skills.uninstall} ${e}`,onClick:()=>l(!1),children:[r.jsx("span",{className:"group-hover:hidden",children:f.skills.installed}),r.jsx("span",{className:"hidden text-red-600 group-hover:inline dark:text-red-400",children:f.skills.uninstall})]}):r.jsx(ve,{size:"sm",className:"shrink-0","aria-label":`${f.skills.install} ${e}`,onClick:()=>l(!0),children:f.skills.install})]})}function j5(e,t){const a=t.trim().toLowerCase();if(a.includes("ant-messages"))return"/v1/messages";if(a.includes("openai-responses"))return"/responses";if(a.includes("openai"))return"/chat/completions";if(a.includes("claude"))return"/v1/messages";if(a.includes("gemini"))return"/v1beta/models";if(a.includes("gpt")||a.includes("minimax"))return"/responses";if(a!=="")return"/chat/completions";switch(e){case"anthropic":return"/v1/messages";case"openai":return"/responses";case"minimax":return"/responses";case"google":return"/v1beta/models";default:return"/chat/completions"}}const C5=["openai-responses","ant-messages","openai-chat"],B0="openai-chat";function N5(e){const t=e.trim().toLowerCase();return t===""||t==="openai"||C5.includes(t)}function pz(e){const t=e.trim().toLowerCase();return t===""?null:t==="openai-responses"||t==="ant-messages"?t:"openai-chat"}function hz(e){let t=0;for(const a of e)t+=a.codePointAt(0)>11903?2:1;return t}function gz(e){try{const t=new URL(e.trim());return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function Bc(e){return e==="custom"||Yr(e)===void 0}function T5(e,t){const a=t.trim();return a!==""||!Bc(e)?a:B0}function xz(e,t,a){return e==="save"&&Bc(t)&&a.trim()===""}function yz(e,t){const a=t.trim();return a!==""?a:Bc(e)?B0:void 0}function vz({value:e,path:t,detecting:a,tone:i,onPick:l}){const[c,u]=x.useState(!1),m=e===null?f.models.protocolUnset:f.models.protocolNames[e]??e;return r.jsx(Un,{open:c,setOpen:u,className:"flex",menuClass:"w-72 max-w-[calc(100vw-2rem)] origin-top-right",portal:{direction:"down",align:"right"},button:r.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":c,"aria-label":`${f.models.protocol}: ${m}`,title:f.models.protocolTriggerTitle(m),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 "+(i==="warn"?"text-amber-600 hover:text-amber-700 dark:text-amber-500 dark:hover:text-amber-400":"text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"),children:[r.jsx("span",{className:"truncate",children:t}),a?r.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"}):r.jsx(Ql,{size:10})]}),children:r.jsx("div",{role:"menu",children:C5.map(p=>{const h=p===e;return r.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":h,onClick:()=>{u(!1),l(p)},className:`block ${n0} hover:bg-gray-100 dark:hover:bg-gray-800 ${h?"bg-gray-100 dark:bg-gray-800":""}`,children:[r.jsxs("span",{className:"flex items-center justify-between gap-2",children:[r.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:f.models.protocolNames[p]??p}),h&&r.jsx(bf,{className:"text-gray-500 dark:text-gray-400"})]}),r.jsx("span",{className:"mt-0.5 block font-mono text-[11px] text-gray-500 dark:text-gray-500",children:j5("custom",p)})]},p)})})})}function Th(){return new Set(["deepseek"])}function bz(e,t,a){return a||e.has(t)}function kz(e,t){const a=new Set(e);return a.has(t)?a.delete(t):a.add(t),a}const M5=e=>`penguin.modelsExpandedGroups.${e}`;function wz(e){return JSON.stringify([...e])}function Sz(e){if(e===null)return null;try{const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(a=>typeof a=="string")):null}catch{return null}}function cw(e,t=localStorage){if(e===null)return Th();try{return Sz(t.getItem(M5(e)))??Th()}catch{return Th()}}function jz(e,t,a=localStorage){if(e!==null)try{a.setItem(M5(e),wz(t))}catch{}}function A5(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 Cz(e){return{provider:e.provider,modelId:e.model_id,original:null,...A5(e),maxTokens:"",fastMode:!1,originalBaseUrl:"",apiKeyInput:"",clearApiKey:!1}}function Nz(e,t=b7()){const a=(m,p)=>`${m}\0${p}`,i=new Map(e.map((m,p)=>[a(m.provider,m.modelId),p])),l=[...e];let c=0,u=0;for(const m of t){const p=i.get(a(m.provider,m.model_id));if(p===void 0){l.push(Cz(m)),c+=1;continue}const h=l[p],g=A5(m);Object.keys(g).some(k=>h[k]!==g[k])&&(l[p]={...h,...g},u+=1)}return{rows:l,added:c,updated:u}}function Tz(e){return e<1e3?"green":e<=3e3?"yellow":"red"}function Mz(e){return e>=40?"green":e>=15?"yellow":"red"}const E5={USD:"$",CNY:"¥"};function uw(e){return Number.isFinite(e)?String(Math.round(e*1e6)/1e6):"0"}function Cg(e){return Number.isFinite(e)?String(Math.round(e*1e4)/1e4):"0"}function Mh(e,t){const a=Number(e||"0"),i=t==="CNY"?a*_g:a;return`${E5[t]}${Cg(i)}`}function Bl(e,t){const a=e.trim();if(!a)return"";const i=Number(a);return Number.isFinite(i)?Cg(t==="CNY"?i*_g:i):a}function Ah(e,t){const a=e.trim();if(!a)return"";const i=Number(a);return Number.isFinite(i)?uw(t==="CNY"?i/_g:i):a}const Az="M12 5v14M5 12h14",Ez="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",_z="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3",Rz="M12 14l3.5-3.5M20.49 17A10 10 0 1 0 3.5 17",Iz="M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM12 7v5l3.5 2",Lz="M13 2 3 14h9l-1 8 10-12h-9l1-8Z",dw={green:"text-green-600 dark:text-green-400",yellow:"text-amber-600 dark:text-amber-400",red:"text-red-600 dark:text-red-400"},fw=(e,t)=>`${e}\0${t}`,Eh=128e3;function mw(e){return e.replace(/[^\d]/g,"")}function Oz(e){const t=e.replace(/[^\d.]/g,""),a=t.indexOf(".");return a===-1?t:t.slice(0,a+1)+t.slice(a+1).replace(/\./g,"")}function pw(e,t){return e!=="custom"||t.trim()!==""&&N5(t)?t:"openai-chat"}function vr(e){return{provider:e.provider,modelId:e.modelId}}function Dz(e){const{editing:t,ref:a,action:i,defaultModel:l,visionModel:c}=e,u=t===null,m=!u&&!_t(t,a)?t:null,p=h=>_t(h,m)?a:h;return{defaultModel:i==="setDefault"||u&&!l?a:p(l),visionModel:i==="setVisionModel"?a:p(c)}}function Uz(e){return e.original!==null&&E0(e.original.provider,e.original.modelId)!==void 0}function zz(e){return!e.clearApiKey&&(!!e.apiKeyInput.trim()||!!e.credential?.apiKeyMasked)}function hw(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.credential&&(t.credential=e.credential),t}function $z(e){const t=v7(e.modelId.trim(),T5(e.provider,e.clientType)||void 0,e.baseUrl.trim()||void 0);return{protocol:t,show:t!==void 0||e.fastMode}}function Pz(e){const t=e.vision&&e.fastMode;return{show:e.vision||e.fastMode,cellClass:t?void 0:"col-span-2"}}function Bz(e){const t={provider:e.provider,modelId:e.modelId};e.original&&!_t(e.original,vr(e))&&(t.renamedFrom=e.original),e.displayName?.trim()&&(t.displayName=e.displayName.trim());const a=Number(e.contextWindow.trim());e.contextWindow.trim()&&Number.isFinite(a)&&(t.contextWindow=a);const i=T5(e.provider,e.clientType);i&&(t.clientType=i),e.vision||(t.vision=!1);const l=Number(e.maxTokens.trim());e.maxTokens.trim()&&Number.isFinite(l)&&l>0&&(t.maxTokens=l),e.fastMode&&(t.fastMode=!0);const c=Number(e.cacheRead.trim()),u=Number(e.cacheWrite.trim()),m=Number(e.output.trim());e.cacheRead.trim()&&e.cacheWrite.trim()&&e.output.trim()&&Number.isFinite(c)&&Number.isFinite(u)&&Number.isFinite(m)&&(t.pricing={cacheRead:c,cacheWrite:u,output:m}),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}function Hz(){Jr(f.models.title);const{currentProject:e}=cn(),t=e?.projectId??null,a=e?.role==="owner",i=vn().user?.userId??null,[l,c]=x.useState(new Map),[u,m]=x.useState(null),[p,h]=x.useState(null),[g,v]=x.useState(null),[k,w]=x.useState(void 0),[S,M]=x.useState(void 0),[C,T]=x.useState(null),[I,D]=x.useState(null),[K,F]=x.useState(""),[E,B]=x.useState(()=>cw(t));x.useEffect(()=>{B(cw(t))},[t]);const[Y,V]=x.useState(null),[O,U]=x.useState(!1),[_,P]=x.useState(""),[H,G]=x.useState(null),[z,J]=x.useState(null),[xe,me]=x.useState(!1),{currency:A}=mi(),R=x.useCallback(async()=>{if(t){v(null),J(null),c(new Map);try{const ee=await Yl(t);v(ee.models.map(hw)),w(ee.defaultModel),M(ee.visionModel)}catch(ee){J(Oe(ee))}}},[t]);x.useEffect(()=>{R()},[R]);const q=async(ee,je,Ae,Qe)=>{if(!t)return!1;me(!0);const We=Ae&&ee.some(re=>_t(vr(re),Ae)&&re.vision)?Ae:void 0;try{const re={models:ee.map(Bz)};je&&(re.defaultModel=je),We&&(re.visionModel=We);const ft=await g4(t,re);return v(ft.models.map(hw)),w(ft.defaultModel),M(ft.visionModel),i&&ft.defaultModel&&!_t(ft.defaultModel,k)&&u5(i,t),Ut(Qe??f.common.saved),!0}catch(re){return v(ee),je!==void 0&&w(je),We!==void 0&&M(We),Ve(Oe(re)),!1}finally{me(!1)}},j=x.useMemo(()=>g?Gj(g,K):[],[g,K]),$=K.trim()!=="",ae=async()=>{if(!g)return;const ee=Nz(g);if(ee.added===0&&ee.updated===0){pa(f.models.syncUpToDate);return}await q(ee.rows,k,S,f.models.syncDone(ee.added,ee.updated))},de=async ee=>{if(!t||!g)return;const je=g.filter(Ae=>Ae.provider===ee);h(ee);try{for(const Ae of je){const Qe=fw(Ae.provider,Ae.modelId);c(We=>new Map(We).set(Qe,"pending"));try{const We=await Gw(t,{provider:Ae.provider,modelId:Ae.modelId,speed:!0});c(re=>new Map(re).set(Qe,We))}catch(We){c(re=>new Map(re).set(Qe,{ok:!1,message:Oe(We)}))}}}finally{h(null)}},ye=()=>{const ee=_.trim();if(!/^[a-z0-9][a-z0-9_-]{0,31}$/.test(ee)){G(f.models.groupNameInvalid);return}if(fi.some(je=>je.id===ee)||g?.some(je=>je.provider===ee)){G(f.models.groupNameExists);return}U(!1),P(""),D(ee)},Se=C!==null?g?.find(ee=>_t(vr(ee),C)):void 0;if(!t)return null;const ke=ee=>{if($)return;const je=kz(E,ee);B(je),jz(t,je)};return r.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:[r.jsxs("div",{className:"mx-auto max-w-5xl",children:[r.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-xl font-semibold",children:f.models.title}),!a&&r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.models.readOnlyHint})]}),r.jsxs("div",{className:"flex min-w-0 max-w-full grow items-center gap-2 sm:grow-0",children:[r.jsx("div",{className:"min-w-0 flex-1 sm:w-56 sm:flex-none",children:r.jsx(rt,{size:"sm",value:K,onChange:ee=>F(ee.target.value),placeholder:f.models.searchPlaceholder})}),a&&r.jsx(ve,{size:"sm",onClick:()=>{ae()},disabled:xe||g===null,title:f.models.syncCatalogHint,children:f.models.syncCatalog})]})]}),g===null?r.jsx(La,{rows:4}):g.length===0?r.jsx(Xr,{title:f.models.empty,action:a&&r.jsx(ve,{onClick:()=>D("custom"),children:f.models.addCustom})}):j.length===0?r.jsx(Xr,{title:f.models.noSearchResults}):r.jsxs("div",{className:"space-y-3",children:[j.map(ee=>{const je=bz(E,ee.provider.id,$);return r.jsxs("section",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[r.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:[r.jsxs("button",{type:"button","aria-expanded":je,onClick:()=>ke(ee.provider.id),className:"flex min-w-0 flex-1 items-center gap-2.5 px-3 py-2.5 text-left",children:[r.jsx(eo,{provider:ee.provider.id,className:"h-5 w-5 shrink-0 text-gray-700 dark:text-gray-300"}),r.jsx("span",{className:"min-w-0 truncate text-sm font-semibold",children:ee.provider.label}),r.jsx("span",{className:"shrink-0 whitespace-nowrap font-mono text-xs text-gray-400",children:f.models.modelCount(ee.rows.length)})]}),a&&r.jsxs(ve,{size:"sm",variant:"ghost",className:"shrink-0",disabled:xe,"aria-label":`${f.models.addToGroup} ${ee.provider.label}`,title:f.models.addToGroup,onClick:()=>D(ee.provider.id),children:[r.jsx(Ge,{d:Az,size:13}),r.jsx("span",{className:"hidden @3xl:inline",children:f.models.addToGroup})]}),a&&ee.provider.id!=="custom"&&r.jsxs(ve,{size:"sm",variant:"ghost",className:"shrink-0",disabled:xe,"aria-label":`${f.models.groupApiKey} ${ee.provider.label}`,title:f.models.groupApiKey,onClick:()=>V(ee.provider.id),children:[r.jsx(Ge,{d:Ez,size:13}),r.jsx("span",{className:"hidden @3xl:inline",children:f.models.groupApiKey})]}),a&&r.jsxs(ve,{size:"sm",variant:"ghost",className:"shrink-0",disabled:xe||p!==null,"aria-label":`${f.models.speedTest} ${ee.provider.label}`,title:p===ee.provider.id?f.models.speedPending:f.models.speedTest,onClick:()=>m(ee.provider.id),children:[r.jsx(Ge,{d:Rz,size:13}),r.jsx("span",{className:"hidden @3xl:inline",children:p===ee.provider.id?f.models.speedPending:f.models.speedTest})]}),ee.provider.apiKeyUrl&&r.jsxs("a",{href:ee.provider.apiKeyUrl,target:"_blank",rel:"noreferrer noopener","aria-label":`${f.models.getApiKey} ${ee.provider.label}`,title:f.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:[r.jsx(Ge,{d:_z,size:13,className:"@4xl:hidden"}),r.jsxs("span",{className:"hidden @4xl:inline",children:[f.models.getApiKey," ↗"]})]}),r.jsx("button",{type:"button","aria-expanded":je,"aria-label":ee.provider.label,onClick:()=>ke(ee.provider.id),className:"shrink-0 p-1.5",children:r.jsx(Yn,{open:je,className:"text-gray-400"})})]}),r.jsx("div",{className:`grid transition-[grid-template-rows] duration-200 ease-out ${je?"grid-rows-[1fr]":"grid-rows-[0fr]"}`,children:r.jsx("div",{className:"overflow-hidden",inert:!je,children:r.jsx("div",{className:`grid 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 ${je?"opacity-100":"opacity-0"}`,children:ee.rows.length===0?r.jsx("p",{className:"col-span-full py-1 text-center text-xs text-gray-400 dark:text-gray-500",children:f.models.groupEmptyHint}):ee.rows.map(Ae=>r.jsx(Fz,{row:Ae,currency:A,isDefault:_t(vr(Ae),k),isVisionModel:_t(vr(Ae),S),speed:l.get(fw(Ae.provider,Ae.modelId)),onOpen:()=>T(vr(Ae))},`${Ae.provider}:${Ae.modelId}`))})})})]},ee.provider.id)}),a&&K.trim()===""&&r.jsxs("button",{type:"button",onClick:()=>{P(""),G(null),U(!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:["+ ",f.models.addGroup]})]}),z&&r.jsx("p",{className:"mt-3 text-xs text-red-600 dark:text-red-400",children:z})]}),g&&Y&&r.jsx(Wz,{provider:fi.find(ee=>ee.id===Y)??Vj(Y),count:g.filter(ee=>ee.provider===Y).length,onClose:()=>V(null),onSubmit:ee=>{const je=Y;V(null);const Ae=g.filter(We=>We.provider===je);if(Ae.length===0)return;const Qe=g.map(We=>We.provider===je?{...We,apiKeyInput:ee,clearApiKey:!1}:We);q(Qe,k,S,f.models.groupKeyApplied(Ae.length))}}),u!==null&&r.jsxs(Xt,{open:!0,title:f.models.speedTestTitle,onClose:()=>m(null),children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:f.models.speedTestConfirm(g?.filter(ee=>ee.provider===u).length??0)}),r.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[r.jsx(ve,{onClick:()=>m(null),children:f.common.cancel}),r.jsx(ve,{variant:"primary",onClick:()=>{const ee=u;m(null),ee&&de(ee)},children:f.models.speedTestStart})]})]}),O&&r.jsxs(Xt,{open:!0,title:f.models.addGroupTitle,onClose:()=>U(!1),widthClass:"sm:max-w-sm",footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:()=>U(!1),children:f.common.cancel}),r.jsx(ve,{variant:"primary",onClick:ye,children:f.common.confirm})]}),children:[r.jsxs("label",{className:"block",children:[r.jsx(rt,{size:"sm",label:f.models.groupNameLabel,required:!0,value:_,invalid:!!H,onChange:ee=>{P(ee.target.value),G(null)},onKeyDown:ee=>{ee.key==="Enter"&&ye()},placeholder:f.models.groupNameHint,className:"font-mono",autoFocus:!0}),H&&r.jsx(Kr,{children:H})]}),r.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.models.addGroupDesc})]}),g&&(I!==null||Se)&&r.jsx(Gz,{projectId:t,row:I!==null?null:Se??null,addProvider:I??"custom",existingRefs:g.map(vr),currency:A,canEdit:a,isDefault:Se!==void 0&&_t(vr(Se),k),isVisionModel:Se!==void 0&&_t(vr(Se),S),onClose:()=>{T(null),D(null)},onSubmit:(ee,je)=>{const Ae=I!==null;if(T(null),D(null),je==="remove"){const re=ee.original;q(g.filter(ft=>!_t(vr(ft),re)),_t(re,k)?void 0:k,_t(re,S)?void 0:S);return}const Qe=Ae?[...g,ee]:g.map(re=>_t(vr(re),C)?ee:re),We=Dz({editing:Ae?null:C,ref:vr(ee),action:je,defaultModel:k,visionModel:S});q(Qe,We.defaultModel,We.visionModel)}})]})}function Fz({row:e,currency:t,isDefault:a,isVisionModel:i,speed:l,onOpen:c}){const u=e.cacheRead||e.cacheWrite||e.output,m=[e.contextWindow?Rt(Number(e.contextWindow)):null,u?`${Mh(e.cacheRead,t)} / ${Mh(e.cacheWrite,t)} / ${Mh(e.output,t)}`:null,e.credential?.apiKeyMasked&&!e.clearApiKey?e.credential.apiKeyMasked:zz(e)?f.models.keyConfigured:f.models.noKey].filter(h=>h!==null),p=l==="pending"?r.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:f.models.speedPending}):l?l.ok?r.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] font-medium",children:[l.ttftMs!==void 0&&r.jsxs("span",{className:`flex items-center gap-0.5 ${dw[Tz(l.ttftMs)]}`,title:f.models.ttftTitle,children:[r.jsx(Ge,{d:Iz,size:11}),Math.round(l.ttftMs),"ms"]}),l.tps!==void 0&&r.jsxs("span",{className:`flex items-center gap-0.5 ${dw[Mz(l.tps)]}`,title:f.models.tpsTitle,children:[r.jsx(Ge,{d:Lz,size:11}),l.tps," tok/s"]})]}):r.jsx("span",{className:"shrink-0 text-[11px] font-medium text-red-600 dark:text-red-400",title:l.message,children:f.models.speedFailed}):null;return r.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:[r.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsx("span",{className:"text-sm font-medium",children:e.displayName??e.modelId}),a&&r.jsx(Cn,{tone:"brand",children:f.models.default}),Wj(e)&&r.jsx(Cn,{tone:"yellow",children:f.models.freeBadge}),e.vision&&r.jsx(Cn,{tone:"green",children:f.models.visionBadge}),i&&r.jsx(Cn,{tone:"amber",children:f.models.visionModelBadge}),e.fastMode&&r.jsx(Cn,{tone:"amber",children:f.models.fastModeBadge})]}),e.displayName!==void 0&&r.jsx("span",{className:"truncate font-mono text-[11px] text-gray-500 dark:text-gray-400",children:e.modelId}),r.jsxs("span",{className:"flex w-full items-center gap-1.5",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-gray-400 dark:text-gray-500",children:m.join(" · ")}),p]})]})}const Vz={save:()=>f.models.confirmSaveTitle,setDefault:()=>f.models.confirmDefaultTitle,setVisionModel:()=>f.models.confirmVisionModelTitle,remove:()=>f.models.confirmDeleteTitle},qz={save:e=>f.models.confirmSave(e),setDefault:e=>f.models.confirmDefault(e),setVisionModel:e=>f.models.confirmVisionModel(e),remove:e=>f.models.confirmDelete(e)};function Gz({projectId:e,row:t,addProvider:a,existingRefs:i,currency:l,canEdit:c,isDefault:u,isVisionModel:m,onClose:p,onSubmit:h}){const[g,v]=x.useState(()=>{if(t)return{...t,cacheRead:Bl(t.cacheRead,l),cacheWrite:Bl(t.cacheWrite,l),output:Bl(t.output,l)};const Ce=Yr(a),Ke=Ce!==void 0&&Ce.id!=="custom"&&Ce.gatewayBaseUrl===void 0;return{provider:a,modelId:"",original:null,vision:!Bc(a),contextWindow:"",maxTokens:"",fastMode:!1,clientType:Ke||Bc(a)?"":"openai-chat",cacheRead:"",cacheWrite:"",output:"",baseUrl:Ce?.gatewayBaseUrl??"",originalBaseUrl:"",apiKeyInput:"",clearApiKey:!1}}),[k,w]=x.useState({}),[S,M]=x.useState(!1),[C,T]=x.useState(null),[I,D]=x.useState(!1),[K,F]=x.useState(!1),[E,B]=x.useState(!1),Y=x.useRef(0),V=x.useRef(null),[O,U]=x.useState(!1),_=x.useRef(null),P=t===null,H=t!==null&&Uz(t),{protocol:G,show:z}=$z(g),J=!H,{show:xe,cellClass:me}=Pz({vision:J,fastMode:z}),A=Ce=>{v(Ke=>({...Ke,...Ce})),w(Ke=>{const se={...Ke};for(const ce of Object.keys(Ce))delete se[ce];return se})},R=async()=>{M(!0);try{const Ce=g.apiKeyInput.trim(),Ke=g.baseUrl.trim(),se={provider:g.provider,modelId:g.modelId.trim(),baseUrl:Ke||null};Ce?se.apiKey=Ce:g.clearApiKey&&(se.clearApiKey=!0),g.clientType.trim()&&(se.clientType=g.clientType.trim()),se.fastMode=g.fastMode;const ce=await Gw(e,se);ce.ok?Ut(f.models.testOk(ce.latencyMs??0)):Ve(f.models.testFailed(ce.message??""))}catch(Ce){Ve(f.models.testFailed(Oe(Ce)))}finally{M(!1)}},q=async Ce=>{const Ke=()=>{B(!0),Ce==="save"?pa(f.models.detectFellBack):Ve(f.models.detectFailedBody)},se=g.baseUrl.trim();if(!gz(se))return Ke(),null;const ce=++Y.current;F(!0),B(!1);try{const De={baseUrl:se},Be=g.apiKeyInput.trim();Be?De.apiKey=Be:g.clearApiKey&&(De.clearApiKey=!0);const Ue=g.modelId.trim();Ue&&(De.provider=g.provider,De.modelId=Ue);const W=await y4(e,De);return ce!==Y.current?null:W.detected?(A({clientType:W.detected}),W.detected):(Ke(),null)}catch{return ce===Y.current&&Ke(),null}finally{ce===Y.current&&F(!1)}},j=Ce=>{if(V.current)return V.current;const Ke=q(Ce).finally(()=>{V.current=null});return V.current=Ke,Ke},$=async()=>{const Ce=await j("manual");Ce!==null&&Ut(f.models.detectedProtocol(f.models.protocolNames[Ce]??Ce))},ae=async()=>{if(_.current)return;const Ce=g.modelId.trim();if(!Ce){Ve(f.models.detectVisionNeedsId);return}U(!0);const Ke=(async()=>{try{const se={provider:g.provider,modelId:Ce},ce=g.apiKeyInput.trim();ce?se.apiKey=ce:g.clearApiKey&&(se.clearApiKey=!0);const De=g.baseUrl.trim();se.baseUrl=De||null,g.clientType.trim()&&(se.clientType=g.clientType.trim());const Be=await v4(e,se);Be.outcome==="supported"?(A({vision:!0}),Ut(f.models.detectVisionOk)):Be.outcome==="unsupported"?(A({vision:!1}),pa(f.models.detectVisionNo)):Ve(f.models.detectFailedBody)}catch{Ve(f.models.detectFailedBody)}finally{U(!1)}})();_.current=Ke.finally(()=>{_.current=null}),await _.current},de=Ce=>{Y.current++,F(!1),B(!1),A({clientType:Ce})},ye=g.clientType.trim().toLowerCase().includes("openai")||g.provider==="custom"||Yr(g.provider)===void 0,Se=!H&&ye,ke=g.provider==="custom"||Yr(g.provider)===void 0,ee=ke&&N5(g.clientType)&&!H,je=ee&&c,Ae=j5(g.provider,g.clientType),Qe=pz(g.clientType),We=je&&Qe===null?f.models.protocolUnset:Ae,re=()=>{const Ce=g.modelId.trim(),Ke={provider:g.provider,modelId:Ce},se=g.baseUrl.trim(),ce={};Ce?!_t(Ke,g.original)&&i.some(pe=>_t(pe,Ke))&&(ce.modelId=f.models.modelIdExists):ce.modelId=f.common.requiredField,Se&&!se&&(ce.baseUrl=f.models.baseUrlRequired);const De=[["cacheRead",g.cacheRead.trim()],["cacheWrite",g.cacheWrite.trim()],["output",g.output.trim()]],Be=De.filter(([,pe])=>pe!=="").length;for(const[pe,Ne]of De)Ne===""&&Be>0?ce[pe]=f.models.pricingAllOrNone:Ne!==""&&!Number.isFinite(Number(Ne))&&(ce[pe]=f.models.pricingInvalid);const Ue=g.contextWindow.trim();Ue&&!Number.isFinite(Number(Ue))&&(ce.contextWindow=f.models.contextWindowInvalid);const W=g.maxTokens.trim();return W&&!(Number.isInteger(Number(W))&&Number(W)>0)&&(ce.maxTokens=f.models.maxTokensInvalid),Object.keys(ce).length>0?(w(ce),null):(w({}),{...g,modelId:Ce,contextWindow:!H&&!Ue?String(Eh):g.contextWindow,cacheRead:Ah(g.cacheRead,l),cacheWrite:Ah(g.cacheWrite,l),output:Ah(g.output,l)})},ft=async Ce=>{const Ke=re();if(Ke){if(xz(Ce,Ke.provider,Ke.clientType)){const se=await j("save");h({...Ke,clientType:se??B0},Ce);return}h(Ke,Ce)}},ge=Yr(g.provider),dt=y7(g.modelId.trim(),yz(g.provider,g.clientType))?.envKey,It=ge!==void 0&&ge.id!=="custom"&&ge.gatewayBaseUrl===void 0,zt=It&&!g.clientType.trim()&&g.modelId.trim()!==""&&dt===void 0,nn=r.jsxs(r.Fragment,{children:[r.jsxs("label",{className:"block",children:[r.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[r.jsxs("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:[f.models.modelId,r.jsx("span",{className:"ml-0.5 text-red-500 dark:text-red-400","aria-hidden":!0,children:"*"})]}),r.jsx("span",{className:"flex shrink-0 items-baseline gap-2.5",children:ge?.modelsUrl&&r.jsxs("a",{href:ge.modelsUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[f.models.getModelIds," ↗"]})})]}),r.jsx(rt,{size:"sm",required:!0,value:g.modelId,disabled:!c,invalid:!!k.modelId,onChange:Ce=>A({modelId:Ce.target.value}),className:"font-mono",autoFocus:P,placeholder:f.models.modelIdHint}),k.modelId&&r.jsx(Kr,{children:k.modelId})]}),zt&&r.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-3 rounded-md border border-amber-200 bg-amber-50 px-2.5 py-2 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-300",children:[r.jsx("span",{children:f.models.autoRouteNone}),r.jsx(ve,{size:"sm",className:"shrink-0",onClick:()=>A({provider:"custom",clientType:pw("custom",g.clientType)}),children:f.models.useCustomGroup})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsx(rt,{size:"sm",label:f.models.displayName,value:g.displayName??"",disabled:!c,onChange:Ce=>A({displayName:Ce.target.value}),placeholder:f.models.displayNameHint}),r.jsxs(oi,{size:"sm",label:f.models.providerGroup,value:g.provider,disabled:!c,onChange:Ce=>{const Ke=Ce.target.value;A({provider:Ke,clientType:pw(Ke,g.clientType)})},children:[fi.map(Ce=>r.jsx("option",{value:Ce.id,children:Ce.label},Ce.id)),[...new Set(i.map(Ce=>Ce.provider).concat(g.provider))].filter(Ce=>!fi.some(Ke=>Ke.id===Ce)).sort().map(Ce=>r.jsx("option",{value:Ce,children:Ce},Ce))]})]})]}),un=g.credential?.apiKeyMasked?f.models.apiKeyKeepHint:dt?f.models.apiKeyEnvHint(dt):f.models.apiKeyKeepHint,Wt=!g.credential?.apiKeyMasked&&dt&&dt===ge?.envKey?f.models.providerEnvNotes[g.provider]:void 0;return r.jsxs(Xt,{open:!0,title:P?It?f.models.addTitleVendor:ke?f.models.addTitleCustom:f.models.addTitle:f.models.editTitle,onClose:p,widthClass:"sm:max-w-lg",footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:p,children:f.common.cancel}),c&&r.jsx(ve,{variant:"primary",disabled:K,onClick:()=>{if(!re())return;if(P||t===null){ft("save");return}const Ce={...t,cacheRead:Bl(t.cacheRead,l),cacheWrite:Bl(t.cacheWrite,l),output:Bl(t.output,l)};if(JSON.stringify(g)===JSON.stringify(Ce)){pa(f.common.noChangesToSave);return}T("save")},children:K?f.models.detecting:f.common.confirm})]}),children:[r.jsxs("div",{className:"space-y-3",children:[!P&&r.jsxs("div",{className:"flex items-center gap-2.5 rounded-md bg-gray-50 px-3 py-2 dark:bg-gray-800/60",children:[r.jsx(eo,{provider:g.provider,className:"h-6 w-6 shrink-0 text-gray-700 dark:text-gray-300"}),r.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[r.jsxs("span",{className:"flex flex-wrap items-center gap-1.5 text-sm font-medium",children:[g.displayName??g.modelId,u&&r.jsx(Cn,{tone:"brand",children:f.models.default}),g.vision&&r.jsx(Cn,{tone:"green",children:f.models.visionBadge}),m&&r.jsx(Cn,{tone:"amber",children:f.models.visionModelBadge})]}),g.displayName!==void 0&&r.jsx("span",{className:"truncate font-mono text-xs text-gray-500 dark:text-gray-400",children:g.modelId})]}),t&&lk(t.provider,t.modelId)&&r.jsxs("a",{href:lk(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:[f.models.homepage,r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"shrink-0",children:r.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3"})})]})]}),P&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:It&&ge?f.models.vendorProtocolHint(ge.label):ke?f.models.addProtocolHintDetect:f.models.addProtocolHint}),nn]}),c&&r.jsx("div",{className:"space-y-1.5",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx(ve,{size:"sm",disabled:S||!g.modelId.trim(),onClick:()=>{R()},children:S?f.models.testing:f.models.testConnection}),!P&&!u&&r.jsx(ve,{size:"sm",onClick:()=>T("setDefault"),children:f.models.setDefault}),!P&&g.vision&&!m&&r.jsx(ve,{size:"sm",title:f.models.visionModelHint,onClick:()=>T("setVisionModel"),children:f.models.setVisionModel}),!P&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"min-w-0 flex-1"}),r.jsx(ve,{size:"sm",variant:"danger",onClick:()=>T("remove"),children:f.models.remove})]})]})}),r.jsxs("div",{className:"block",children:[r.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[r.jsx("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:f.models.apiKey}),ge?.apiKeyUrl&&r.jsxs("a",{href:ge.apiKeyUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-xs text-brand-600 underline-offset-2 hover:underline dark:text-brand-300",children:[f.models.getApiKey," ↗"]})]}),r.jsx(ci,{size:"sm",value:g.apiKeyInput,disabled:!c,onChange:Ce=>A({apiKeyInput:Ce.target.value,clearApiKey:!1}),className:"font-mono",autoComplete:"off",autoFocus:!P,placeholder:un})]}),Wt&&r.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:Wt}),g.credential?.apiKeyMasked&&!g.apiKeyInput&&r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[r.jsx("span",{className:"font-mono",children:g.credential.apiKeyMasked}),g.credential.createdAt&&r.jsxs("span",{className:"text-gray-400",children:[f.common.created," ",Oa(g.credential.createdAt)]}),c&&r.jsxs("label",{className:"flex items-center gap-1.5",children:[r.jsx("input",{type:"checkbox",checked:g.clearApiKey,onChange:Ce=>A({clearApiKey:Ce.target.checked})}),f.models.clearApiKey]})]}),r.jsxs("div",{className:"block",children:[je?r.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[r.jsxs("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:[f.models.baseUrl,Se&&r.jsx("span",{className:"ml-0.5 text-red-500 dark:text-red-400","aria-hidden":!0,children:"*"})]}),r.jsxs("button",{type:"button",disabled:K,onClick:()=>{$()},title:f.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:[K&&r.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"}),K?f.models.detecting:f.models.detectProtocol]})]}):r.jsx(wr,{required:Se,children:f.models.baseUrl}),r.jsxs("div",{className:"relative",children:[r.jsx(rt,{size:"sm","aria-label":f.models.baseUrl,required:Se,value:g.baseUrl,disabled:!c,invalid:!!k.baseUrl,onChange:Ce=>{B(!1),A({baseUrl:Ce.target.value})},className:"font-mono",style:{paddingRight:`calc(${hz(We)}ch + ${je?"2.25rem":"1.25rem"})`},title:f.models.baseUrlSuffixTitle,placeholder:H?f.models.baseUrlHint:"https://…"}),je?r.jsx("div",{className:"absolute inset-y-0 right-1 flex items-center",children:r.jsx(vz,{value:Qe,path:We,detecting:K,tone:E?"warn":null,onPick:de})}):r.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center font-mono text-xs text-gray-400",children:Ae})]}),k.baseUrl&&r.jsx(Kr,{children:k.baseUrl})]}),r.jsxs("div",{className:"grid grid-cols-2 items-start gap-2",children:[r.jsxs("label",{className:"block",children:[r.jsx(wr,{children:f.models.contextWindow}),r.jsxs("span",{className:"relative block",children:[r.jsx(rt,{size:"sm",value:g.contextWindow,inputMode:"numeric",disabled:!c,invalid:!!k.contextWindow,onChange:Ce=>A({contextWindow:mw(Ce.target.value)}),className:"pr-12 font-mono",title:H?f.models.contextWindowHint:f.models.contextWindowDefaultHint(Eh),placeholder:H?f.models.contextWindowHint:f.models.contextWindowDefaultHint(Eh)}),r.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:f.models.tokenUnit})]}),k.contextWindow&&r.jsx(Kr,{children:k.contextWindow})]}),r.jsxs("label",{className:"block",children:[r.jsx(wr,{children:f.models.maxTokens}),r.jsxs("span",{className:"relative block",children:[r.jsx(rt,{size:"sm",value:g.maxTokens,inputMode:"numeric",disabled:!c,invalid:!!k.maxTokens,onChange:Ce=>A({maxTokens:mw(Ce.target.value)}),className:"pr-12 font-mono",title:f.models.maxTokensTitle,placeholder:f.models.maxTokensHint}),r.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:f.models.tokenUnit})]}),k.maxTokens&&r.jsx(Kr,{children:k.maxTokens})]})]}),r.jsx("div",{className:"grid grid-cols-3 items-start gap-2",children:[["cacheRead",f.models.priceCacheRead,g.cacheRead],["cacheWrite",f.models.priceCacheWrite,g.cacheWrite],["output",f.models.priceOutput,g.output]].map(([Ce,Ke,se])=>r.jsxs("label",{className:"block",children:[r.jsx(wr,{children:Ke}),r.jsxs("span",{className:"relative block",children:[r.jsx("span",{className:"pointer-events-none absolute inset-y-0 left-2 flex items-center text-xs text-gray-400",children:E5[l]}),r.jsx(rt,{size:"sm",value:se,inputMode:"decimal",disabled:!c,invalid:!!k[Ce],onChange:ce=>A({[Ce]:Oz(ce.target.value)}),className:"pl-4 pr-11 text-right font-mono"}),r.jsx("span",{className:"pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400",children:f.models.priceUnitShort})]}),k[Ce]&&r.jsx(Kr,{children:k[Ce]})]},Ce))}),!P&&nn,!P&&!H&&!ee&&g.clientType&&x7(g.clientType)!=="openai-chat"&&r.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:f.models.clientTypeLocked(g.clientType)}),xe&&r.jsxs("div",{className:"grid grid-cols-2 items-start gap-2",children:[J&&r.jsxs("div",{className:me,children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[r.jsxs("label",{className:`inline-flex items-center gap-2 ${c?"cursor-pointer":"cursor-not-allowed"}`,children:[r.jsx("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:f.models.vision}),r.jsx(di,{checked:g.vision,disabled:!c,onChange:Ce=>A({vision:Ce}),"aria-label":f.models.vision})]}),c&&r.jsxs("button",{type:"button",disabled:O,onClick:()=>{ae()},title:f.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:[O&&r.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"}),O?f.models.detectingVision:f.models.detectVision]})]}),!g.vision&&r.jsx("p",{className:"mt-1 text-xs text-gray-400 dark:text-gray-500",children:f.models.visionOffProxyHint})]}),z&&r.jsxs("div",{className:me,children:[r.jsxs("label",{className:`inline-flex items-center gap-2 ${c?"cursor-pointer":"cursor-not-allowed"}`,title:f.models.fastModeHint,children:[r.jsx("span",{className:"text-xs font-semibold text-gray-600 dark:text-gray-400",children:f.models.fastMode}),r.jsx(di,{checked:g.fastMode,disabled:!c,onChange:Ce=>{Ce?D(!0):A({fastMode:!1})},"aria-label":f.models.fastMode})]}),g.fastMode&&r.jsx("p",{className:"mt-1 text-xs text-gray-400 dark:text-gray-500",children:f.models.fastModeHint}),g.fastMode&&G===void 0&&r.jsx("p",{className:"mt-1 text-xs text-amber-600 dark:text-amber-500",children:f.models.fastModeUnsupported})]})]})]}),I&&r.jsxs(yn,{open:!0,title:f.models.fastModeConfirmTitle,tone:"danger",onClose:()=>D(!1),onConfirm:()=>{D(!1),A({fastMode:!0})},children:[r.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:f.models.fastModeConfirmBody}),G==="anthropic"&&r.jsx("p",{className:"mt-2 text-sm text-gray-700 dark:text-gray-300",children:f.models.fastModeConfirmPreview})]}),C&&r.jsx(yn,{open:!0,title:Vz[C](),tone:C==="remove"?"danger":"primary",onClose:()=>T(null),onConfirm:()=>{const Ce=C;T(null),ft(Ce)},children:r.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:qz[C](g.displayName??g.modelId)})})]})}function Wz({provider:e,count:t,onClose:a,onSubmit:i}){const[l,c]=x.useState("");return r.jsx(Xt,{open:!0,title:f.models.groupApiKeyTitle(e.label),onClose:a,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:a,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:!l.trim(),onClick:()=>i(l.trim()),children:f.common.confirm})]}),children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(rt,{size:"sm",label:f.models.apiKey,required:!0,type:"password",value:l,onChange:u=>c(u.target.value),className:"font-mono",autoComplete:"off",autoFocus:!0,placeholder:f.models.apiKeyEnvHint(e.envKey)}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.models.groupApiKeyHint(t)}),f.models.providerEnvNotes[e.id]&&r.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:f.models.providerEnvNotes[e.id]}),e.apiKeyUrl&&r.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:[f.models.getApiKey," ↗"]})]})})}const pc=200,Xi=46,df=8,Sc=10,Kz=22;function _5(e,t,a){return R5(e,0,t,a)}function R5(e,t,a,i){const l=Math.max(0,i-Xi-df),c=pc-Sc-Kz,u=e>0?l/e:l,m=a-t;return{n:e,min:t,max:a,w:i,innerW:l,innerH:c,step:u,x:p=>Xi+u*p+u/2,y:p=>Sc+c*(1-(m>0?(p-t)/m:0))}}function Yz(e,t){return t.map((a,i)=>`${i===0?"M":"L"}${e.x(i)},${e.y(a)}`).join(" ")}function Qz(e,t){const a=t.length;if(a===0)return"";const i=e.y(0),l=[];for(let c=0;c<a;c++)l.push(`${c===0?"M":"L"}${e.x(c)},${e.y(t[c])}`);return l.push(`L${e.x(a-1)},${i}`),l.push(`L${e.x(0)},${i}`),l.push("Z"),l.join(" ")}function Xz(e){return e<=0?[]:e===1?[0]:e===2?[0,1]:[0,Math.floor((e-1)/2),e-1]}const Zz=40;function Jz(e,t){if(e<=0)return[];const a=t>0?Math.max(1,Math.ceil(Zz/t)):e,i=[];for(let l=0;l<e;l+=a)i.push(l);return i}function e$(e,t){return t>0?e/t:1}const Td=12;function t$(e,t,a,i,l){let c=e+Td;c+a>l.right&&(c=e-Td-a);let u=t+Td;return u+i>l.bottom&&(u=t-Td-i),{left:Math.max(l.left,Math.min(c,l.right-a)),top:Math.max(0,Math.min(u,l.bottom-i))}}const _h=25,n$=8;function a$(e,t){const a=Math.max(0,e-Xi-df),i=2*_h*t;return i<=a?{barW:_h,chartW:e,scroll:!1}:{barW:_h,chartW:Xi+i+df,scroll:!0}}function r$(e,t,a){const i=e.length;if(i===0)return[];if(t<=i*a)return e.map(()=>t/i);const l=new Set;for(;;){const c=t-l.size*a,u=e.reduce((h,g,v)=>l.has(v)?h:h+g,0),m=h=>u>0?e[h]/u*c:c/(i-l.size),p=e.findIndex((h,g)=>!l.has(g)&&m(g)<a);if(p<0)return e.map((h,g)=>l.has(g)?a:m(g));l.add(p)}}const s$=["output","cacheWrite","cacheRead"];function i$(e,t){const a=s$.map(p=>({key:p,value:t[p]})).filter(p=>p.value>0);if(a.length===0)return[];const i=[];let l=0;for(const p of a){const h=e.y(l);l+=p.value;const g=e.y(l);i.push({y:g,h:h-g})}const c=e.y(0),u=r$(i.map(p=>p.h),c-e.y(l),n$);let m=c;return a.map((p,h)=>{const g=u[h],v={key:p.key,value:p.value,y:i[h].y,h:i[h].h,hitY:m-g,hitH:g};return m-=g,v})}const I5=Math.PI*2,ff=e=>Math.round(e*100)/100;function Md(e,t,a,i){const l=i-Math.PI/2;return[ff(e+a*Math.cos(l)),ff(t+a*Math.sin(l))]}function l$(e,t,a,i,l){if(l-i>=I5-1e-9){const[g,v]=Md(e,t,a,0),[k,w]=Md(e,t,a,Math.PI);return`M${g},${v} A${a},${a} 0 1 1 ${k},${w} A${a},${a} 0 1 1 ${g},${v} Z`}const[c,u]=Md(e,t,a,i),[m,p]=Md(e,t,a,l),h=l-i>Math.PI?1:0;return`M${ff(e)},${ff(t)} L${c},${u} A${a},${a} 0 ${h} 1 ${m},${p} Z`}function o$(e,t,a,i){const l=e.reduce((m,p)=>m+Math.max(0,p),0);if(l<=0)return[];const c=[];let u=0;return e.forEach((m,p)=>{if(m<=0)return;const h=m/l,g=u+h*I5;c.push({index:p,value:m,frac:h,start:u,end:g,path:l$(t,a,i,u,g)}),u=g}),c}function H0(){const e=x.useRef(null),[t,a]=x.useState(0);return x.useLayoutEffect(()=>{const i=e.current;if(!i)return;const l=()=>a(Math.floor(i.getBoundingClientRect().width));l();const c=new ResizeObserver(l);return c.observe(i),()=>c.disconnect()},[]),[e,t]}function F0({geom:e,fmtY:t,dates:a,hover:i,onHover:l,bubble:c,hitLayer:u,labels:m,yTicks:p,hoverLine:h=!0,scrollToEnd:g=!1,children:v}){const{x:k,y:w,w:S,innerH:M,step:C,min:T,max:I}=e,D=p??[0,.25,.5,.75,1].map(_=>T+(I-T)*_),K=m??Xz(a.length),F=x.useRef(null);x.useLayoutEffect(()=>{const _=F.current;!g||!_||(_.scrollLeft=_.scrollWidth-_.clientWidth)},[g,S,a.length]);const E=x.useRef(null),B=x.useRef(null),Y=x.useRef(null),V=x.useRef(0),O=()=>{const _=B.current,P=E.current,H=F.current,G=Y.current;if(!_||!P||!H||!G)return;const z=P.getBoundingClientRect(),J=t$(G.cx-z.left,G.cy-z.top,_.offsetWidth,_.offsetHeight,{left:H.scrollLeft,right:H.scrollLeft+H.clientWidth,bottom:pc});_.style.left=`${J.left}px`,_.style.top=`${J.top}px`,_.style.visibility="visible"},U=()=>{V.current||(V.current=requestAnimationFrame(()=>{V.current=0,O()}))};return x.useEffect(()=>()=>cancelAnimationFrame(V.current),[]),x.useLayoutEffect(O,[c,i]),r.jsxs("div",{ref:F,className:"relative overflow-x-auto",children:[r.jsxs("svg",{ref:E,viewBox:`0 0 ${S} ${pc}`,width:S,height:pc,className:"text-gray-600 dark:text-gray-400",role:"img",onMouseLeave:()=>{l(null),Y.current=null},onMouseMove:_=>{Y.current={cx:_.clientX,cy:_.clientY},U()},children:[D.map((_,P)=>r.jsxs("g",{children:[r.jsx("line",{x1:Xi,x2:S-df,y1:w(_),y2:w(_),className:"stroke-gray-200 dark:stroke-gray-800",strokeWidth:1}),r.jsx("text",{x:Xi-6,y:w(_)+3,textAnchor:"end",className:"fill-gray-400 dark:fill-gray-500",fontSize:9,children:t(_)})]},P)),h&&i!==null&&a[i]&&r.jsx("line",{x1:k(i),x2:k(i),y1:Sc,y2:Sc+M,className:"stroke-gray-300 dark:stroke-gray-700",strokeWidth:1}),v,K.map(_=>{const P=a[_];return P?r.jsx("text",{x:k(_),y:pc-6,textAnchor:"middle",className:"fill-gray-400 dark:fill-gray-500",fontSize:9,children:P.slice(5)},_):null}),u??a.map((_,P)=>r.jsx("rect",{x:Xi+C*P,y:Sc,width:C,height:M,fill:"transparent",className:"cursor-crosshair",onMouseEnter:()=>l(P)},`hit-${P}`))]}),c&&i!==null&&a[i]&&r.jsx("div",{ref:B,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(i)})]})}function c$({points:e,currency:t="USD"}){const[a,i]=x.useState(null),[l,c]=H0(),u=e.map(g=>g.cost??0),m=Math.max(1e-9,...u),p=_5(e.length,m,c),h=e.map(g=>g.date);return r.jsx("div",{ref:l,children:c>0&&r.jsx(F0,{geom:p,fmtY:g=>Dr(g,t),dates:h,hover:a,onHover:i,bubble:g=>{const v=e[g];return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-gray-400",children:v.date}),r.jsx("p",{className:"font-mono",children:Dr(v.cost,t)})]})},children:r.jsxs("g",{children:[r.jsx("path",{d:Qz(p,u),className:"fill-current",stroke:"none",opacity:a!==null?.06:.1}),r.jsx("path",{d:Yz(p,u),fill:"none",stroke:"currentColor",strokeWidth:2,opacity:a!==null?.35:1}),e.map((g,v)=>r.jsx("circle",{cx:p.x(v),cy:p.y(g.cost??0),r:a===v?4:2.5,className:"fill-current",opacity:a!==null&&a!==v?.25:1},g.date))]})})})}const jc={cacheRead:"#7dd3fc",cacheWrite:"#0ea5e9",output:"#0369a1"},gw=[{fill:"fill-violet-500 dark:fill-violet-400",swatch:"bg-violet-500 dark:bg-violet-400"},{fill:"fill-sky-500 dark:fill-sky-400",swatch:"bg-sky-500 dark:bg-sky-400"},{fill:"fill-amber-500 dark:fill-amber-400",swatch:"bg-amber-500 dark:bg-amber-400"},{fill:"fill-rose-500 dark:fill-rose-400",swatch:"bg-rose-500 dark:bg-rose-400"},{fill:"fill-emerald-500 dark:fill-emerald-400",swatch:"bg-emerald-500 dark:bg-emerald-400"},{fill:"fill-cyan-500 dark:fill-cyan-400",swatch:"bg-cyan-500 dark:bg-cyan-400"},{fill:"fill-fuchsia-500 dark:fill-fuchsia-400",swatch:"bg-fuchsia-500 dark:bg-fuchsia-400"}];function xw(e){return gw[e%gw.length]}const yw=[{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 L5(e){return yw[e%yw.length]}function Df({text:e}){return r.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:e??f.usage.empty})}function u$(e){return e==="cacheRead"?f.usage.colCacheRead:e==="cacheWrite"?f.usage.colCacheWrite:f.usage.colOutput}const O5="opacity-25",Ad=160,d$=75;function f$({data:e}){const[t,a]=x.useState(null),i=e.reduce((p,h)=>p+h.requests,0);if(e.length===0||i<=0)return r.jsx(Df,{});const l=[...e].sort((p,h)=>h.requests-p.requests),c=o$(l.map(p=>p.requests),Ad/2,Ad/2,d$),u=p=>`${Math.round(p/i*100)}%`,m=p=>t!==null&&t!==p?O5:"";return r.jsxs("div",{className:"flex items-center gap-3",onMouseLeave:()=>a(null),children:[r.jsx("svg",{viewBox:`0 0 ${Ad} ${Ad}`,className:"h-40 w-40 shrink-0",role:"img","aria-label":f.usage.chartAgentCalls,children:c.map(p=>{const h=l[p.index];return r.jsx("path",{d:p.path,onMouseEnter:()=>a(p.index),className:`cursor-pointer ${xw(p.index).fill} transition-opacity duration-150 ${m(p.index)}`,children:r.jsx("title",{children:`${h.agentId} · ${h.requests} ${f.usage.requests} · ${u(h.requests)}`})},h.agentId)})}),r.jsx("ul",{className:"flex max-h-40 min-w-0 flex-1 flex-col gap-1 overflow-y-auto",children:l.map((p,h)=>r.jsxs("li",{onMouseEnter:()=>a(p.requests>0?h:null),title:`${p.agentId} · ${p.requests} ${f.usage.requests} · ${Rt(p.total)}`,className:`flex cursor-pointer items-center gap-1.5 text-[10px] transition-opacity duration-150 ${m(h)}`,children:[r.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-sm ${xw(h).swatch}`}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-gray-500 dark:text-gray-400",children:p.agentId}),r.jsx("span",{className:"shrink-0 font-mono tabular-nums text-gray-500 dark:text-gray-400",children:p.requests}),r.jsx("span",{className:"w-8 shrink-0 text-right font-mono tabular-nums text-gray-400 dark:text-gray-500",children:u(p.requests)})]},p.agentId))})]})}function m$({dimmed:e,onEnter:t,title:a,label:i,value:l,children:c}){return r.jsxs("div",{onMouseEnter:t,className:`flex cursor-pointer items-center gap-2 transition-opacity duration-150 ${e?O5:""}`,title:a,children:[r.jsx("span",{className:"w-24 shrink-0 truncate font-mono text-[10px] text-gray-500 dark:text-gray-400",children:i}),c,r.jsx("span",{className:"w-10 shrink-0 text-right font-mono text-[10px] tabular-nums text-gray-500 dark:text-gray-400",children:l})]})}function p$(e){return E0(e.provider,e.modelId)?.displayName??e.modelId}function h$(e){const t=[`${e.completed}/${e.total}`];e.failed>0&&t.push(`failed ${e.failed}`),e.timeout>0&&t.push(`timeout ${e.timeout}`),e.malformed>0&&t.push(`malformed ${e.malformed}`),e.aborted>0&&t.push(`${f.usage.successAborted} ${e.aborted}`);const a=Yr(e.provider)?.label??e.provider;return`${e.modelId} · ${a} · ${t.join(" · ")}`}function g$({data:e}){const[t,a]=x.useState(null);return e.length===0?r.jsx(Df,{}):r.jsx("div",{className:"flex flex-col gap-1.5",onMouseLeave:()=>a(null),children:e.map((i,l)=>{const c=e$(i.completed,i.total),u=Math.round(c*100);return r.jsx(m$,{dimmed:t!==null&&t!==l,onEnter:()=>a(l),title:h$(i),label:p$(i),value:`${u}%`,children:r.jsx("div",{className:"h-3 min-w-0 flex-1 overflow-hidden rounded-sm bg-gray-200 dark:bg-gray-800",children:r.jsx("div",{className:"h-full rounded-sm bg-sky-500 dark:bg-sky-400",style:{width:`${c*100}%`}})})},`${i.provider}:${i.modelId}`)})})}function x$({trend:e,legend:t}){const[a,i]=x.useState(null),[l,c]=H0();if(e.length===0)return r.jsx(Df,{});const u=e.map(M=>M.cacheRead+M.cacheWrite+M.output),m=Math.max(1,...u),{barW:p,chartW:h,scroll:g}=a$(c,e.length),v=_5(e.length,m,h),k=e.map(M=>M.date),w=e.map(M=>i$(v,M)),S=(M,C)=>a!==null&&!(a.i===M&&a.key===C)||t!=null&&t!==C;return r.jsx("div",{ref:l,children:c>0&&r.jsx(F0,{geom:v,fmtY:M=>Rt(Math.round(M)),dates:k,hover:a?.i??null,labels:Jz(e.length,v.step),hoverLine:!1,scrollToEnd:g,onHover:M=>{M===null&&i(null)},bubble:M=>{const C=e[M],T=a?.key;if(!T)return null;const I=T==="cacheRead"?$2(C.cacheRead,C.cacheWrite):null;return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-gray-400",children:C.date}),r.jsxs("p",{className:"font-mono",children:[u$(T)," ",Rt(C[T])]}),I!==null&&r.jsxs("p",{className:"font-mono",children:[f.traces.hitRate," ",Kg(I)]})]})},hitLayer:e.map((M,C)=>w[C].map(T=>r.jsx("rect",{x:v.x(C)-p/2,y:T.hitY,width:p,height:T.hitH,fill:"transparent",className:"cursor-pointer",onMouseEnter:()=>i({i:C,key:T.key}),onMouseLeave:()=>i(null)},`hit-${M.date}-${T.key}`))),children:e.map((M,C)=>w[C].map(T=>r.jsx("rect",{x:v.x(C)-p/2,y:T.y,width:p,height:T.h,fill:jc[T.key],className:"transition-opacity duration-150",opacity:S(C,T.key)?.2:1},`${M.date}-${T.key}`)))})})}function y$({active:e,onHover:t}){const a=[["cacheRead",f.usage.colCacheRead],["cacheWrite",f.usage.colCacheWrite],["output",f.usage.colOutput]];return r.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:a.map(([i,l])=>r.jsxs("button",{type:"button",onMouseEnter:()=>t?.(i),onMouseLeave:()=>t?.(null),className:`flex items-center gap-1 text-[10px] text-gray-500 transition-opacity duration-150 dark:text-gray-400 ${e!=null&&e!==i?"opacity-30":""}`,children:[r.jsx("span",{className:"inline-block h-2 w-3 rounded-sm",style:{backgroundColor:jc[i]}}),l]},i))})}function v$(e){return e==="unexpected"?f.usage.errorsUnexpected:f.usage.errorsExpected}function b$(e){return e==="unexpected"?"unexpected":"expected"}const k$={environment:"env"};function vw(e,t){return`[${k$[e]??e}] ${t}`}function Ed({label:e,value:t,alert:a,muted:i}){const l=a?"text-rose-600 dark:text-rose-400":i?"text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100";return r.jsxs("div",{className:"flex items-baseline gap-1.5",children:[r.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e}),r.jsx("span",{className:`font-mono text-sm font-semibold tabular-nums ${l}`,children:t})]})}function _d({children:e,className:t=""}){return r.jsx("th",{className:`py-1.5 pr-2 font-medium ${t}`,children:e})}function w$({errors:e,projectId:t,filters:a}){const{total:i,unexpected:l,topCode:c,recent:u}=e,m=Math.max(1,u.length),[p,h]=x.useState(0),[g,v]=x.useState(u),[k,w]=x.useState(i),[S,M]=x.useState(null),[C,T]=x.useState(!1);x.useEffect(()=>h(0),[u]),x.useEffect(()=>{if(p===0){v(u),w(i),M(null);return}let E=!1;return T(!0),M(null),Q4(t,{offset:p*m,limit:m,...a}).then(B=>{E||(v(B.items),w(B.total))}).catch(B=>{E||M(Oe(B))}).finally(()=>{E||T(!1)}),()=>{E=!0}},[p,m,t,a,u,i]);const I=Math.max(1,Math.ceil(k/m)),[D,K]=x.useState(new Set);x.useEffect(()=>K(new Set),[g]);const F=E=>K(B=>{const Y=new Set(B);return Y.has(E)?Y.delete(E):Y.add(E),Y});return r.jsxs("div",{children:[r.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1.5",children:[r.jsx(Ed,{label:f.usage.errorsTotal,value:String(i)}),r.jsx(Ed,{label:f.usage.errorsUnexpected,value:String(l),alert:l>0,muted:l===0}),r.jsx(Ed,{label:f.usage.errorsExpected,value:String(i-l),muted:!0}),c&&r.jsx(Ed,{label:f.usage.errorsTopCode,value:`${vw(c.source,c.code)} ×${c.count}`})]}),g.length===0?r.jsx(Df,{text:f.usage.errorsEmpty}):r.jsx("div",{className:"mt-2.5 max-h-72 overflow-y-auto border-t border-gray-200 dark:border-gray-800",children:r.jsxs("table",{className:"w-full table-fixed text-xs",children:[r.jsx("thead",{className:"sticky top-0 bg-white text-left text-gray-400 dark:bg-gray-900 dark:text-gray-500",children:r.jsxs("tr",{children:[r.jsx(_d,{className:"w-32",children:f.common.time}),r.jsx(_d,{className:"w-72",children:f.usage.errorsColCode}),r.jsx(_d,{className:"w-20",children:f.usage.errorsColKind}),r.jsx(_d,{children:f.usage.errorsColMessage})]})}),r.jsx("tbody",{children:g.map((E,B)=>{const Y=b$(E.kind);return r.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-800/60",children:[r.jsx("td",{className:"py-1.5 pr-2 align-top font-mono tabular-nums text-gray-400",children:Oa(E.ts)}),r.jsx("td",{className:"py-1.5 pr-2 align-top font-mono text-gray-500 dark:text-gray-400",children:r.jsx("span",{className:"block break-words",children:vw(E.source,E.code)})}),r.jsx("td",{className:"py-1.5 pr-2 align-top",children:r.jsx(Cn,{tone:Y==="unexpected"?"red":"gray",children:v$(Y)})}),r.jsx("td",{className:"py-1.5 align-top text-gray-500 dark:text-gray-400",children:r.jsx("button",{type:"button",title:E.message,onClick:()=>F(B),className:`block w-full cursor-pointer text-left transition-colors hover:text-gray-700 dark:hover:text-gray-300 ${D.has(B)?"whitespace-pre-wrap break-words":"truncate"}`,children:E.message})})]},`${E.ts}-${B}`)})})]})}),(I>1||p>0)&&r.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 text-xs text-gray-500 dark:text-gray-400",children:[S!==null&&r.jsx("span",{className:"mr-auto text-rose-500",children:S}),r.jsx("span",{className:"tabular-nums",children:f.usage.errorsPageOf(p+1,I,k)}),r.jsx(bw,{label:f.usage.errorsNewer,disabled:p===0||C,onClick:()=>h(E=>Math.max(0,E-1))}),r.jsx(bw,{label:f.usage.errorsOlder,disabled:p+1>=I||C,onClick:()=>h(E=>E+1)})]})]})}function bw({label:e,disabled:t,onClick:a}){return r.jsx("button",{type:"button",disabled:t,onClick:a,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 kw(e){const t=a=>a<10?`0${a}`:`${a}`;return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`}function Rh({label:e,value:t,muted:a,sup:i}){const l=a?"text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100";return r.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[r.jsxs("span",{className:"shrink-0 text-xs text-gray-500 dark:text-gray-400",children:[e,i&&r.jsx("sup",{className:"ml-px",children:"*"})]}),r.jsx("span",{className:`min-w-0 truncate font-mono text-sm font-semibold tabular-nums ${l}`,children:t})]})}function Ih({title:e,bucket:t,currency:a}){return r.jsxs("div",{className:"rounded-md border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900",children:[r.jsx("p",{className:"mb-1.5 text-xs font-medium text-gray-500 dark:text-gray-400",children:e}),r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Rh,{label:f.usage.tokens,value:Rt(t.total)}),r.jsx(Rh,{label:f.usage.requests,value:String(t.requests),muted:!0}),r.jsx(Rh,{label:f.common.cost,value:Dr(t.cost,a),sup:t.hasUncosted})]})]})}function cc({title:e,extra:t,children:a}){return r.jsxs("div",{className:"rounded-md border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900",children:[r.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-x-2 gap-y-1",children:[r.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:e}),t]}),a]})}function S$(){Jr(f.usage.title);const{currency:e}=mi(),{currentProject:t}=cn(),a=t?.projectId??null,[i]=vf(),l=i.get("agentId"),[c,u]=x.useState(l??""),[m,p]=x.useState(null);x.useEffect(()=>{u(l??"")},[l]);const[h,g]=x.useState(()=>{const O=new Date;return O.setDate(O.getDate()-29),kw(O)}),[v,k]=x.useState(()=>kw(new Date)),[w,S]=x.useState(null),[M,C]=x.useState(null),[T,I]=x.useState(null),D=x.useCallback(async()=>{if(a){C(null);try{const O=await Yw(a,{from:h,to:v,groupBy:"date",...c?{agentId:c}:{},...m?{provider:m.provider,modelId:m.modelId}:{}});S(O)}catch(O){C(Oe(O))}}},[a,h,v,c,m?.provider,m?.modelId]);x.useEffect(()=>{S(null),D()},[D]);const K=x.useMemo(()=>({from:h,to:v,...c?{agentId:c}:{}}),[h,v,c]);if(!a)return null;const F=w?.models??[],E=m?F.findIndex(O=>O.provider===m.provider&&O.modelId===m.modelId):-1,B=E>=0?String(E):"",Y=w?.summary,V=(Y?.today.hasUncosted??!1)||(Y?.last7d.hasUncosted??!1)||(Y?.total.hasUncosted??!1);return r.jsx("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:r.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsx("h1",{className:"text-xl font-semibold",children:f.usage.title}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("div",{className:"w-32",children:r.jsxs(oi,{size:"sm",value:c,onChange:O=>u(O.target.value),children:[r.jsx("option",{value:"",children:f.usage.filterAllAgents}),c&&!(w?.agentIds??[]).includes(c)&&r.jsx("option",{value:c,children:c}),(w?.agentIds??[]).map(O=>r.jsx("option",{value:O,children:O},O))]})}),r.jsx("div",{className:"w-32",children:r.jsxs(oi,{size:"sm",value:B,onChange:O=>{const U=O.target.value;p(U===""?null:F[Number(U)]??null)},children:[r.jsx("option",{value:"",children:f.usage.filterAllModels}),F.map((O,U)=>r.jsx("option",{value:String(U),children:E0(O.provider,O.modelId)?.displayName??O.modelId},`${O.provider}:${O.modelId}`))]})}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(rt,{size:"sm",type:"date","aria-label":f.usage.from,value:h,onChange:O=>g(O.target.value)}),r.jsx("span",{className:"shrink-0 text-gray-400","aria-hidden":!0,children:"–"}),r.jsx(rt,{size:"sm",type:"date","aria-label":f.usage.to,value:v,onChange:O=>k(O.target.value)})]})]})]}),w?r.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[r.jsx(Ih,{title:f.usage.today,bucket:w.summary.today,currency:e}),r.jsx(Ih,{title:f.usage.last7d,bucket:w.summary.last7d,currency:e}),r.jsx(Ih,{title:f.usage.total,bucket:w.summary.total,currency:e})]}):r.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[r.jsx(mn,{className:"h-24"}),r.jsx(mn,{className:"h-24"}),r.jsx(mn,{className:"h-24"})]}),w?r.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[r.jsx(cc,{title:f.usage.chartAgentCalls,children:r.jsx(f$,{data:w.byAgent})}),r.jsx(cc,{title:f.usage.chartSuccessRate,children:r.jsx(g$,{data:w.success})}),r.jsx(cc,{title:f.usage.chartTokenTrend,extra:r.jsx(y$,{active:T,onHover:I}),children:r.jsx(x$,{trend:w.trend,legend:T})}),r.jsx(cc,{title:f.usage.chartCostTrend,children:r.jsx(c$,{points:w.trend,currency:e})})]}):r.jsx(mn,{className:"h-64"}),w&&r.jsx(cc,{title:f.usage.errors,children:r.jsx(w$,{errors:w.errors,projectId:a,filters:K})}),V&&r.jsx("p",{className:"text-xs text-gray-400",children:f.usage.uncostedNote}),M&&r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:M})]})})}function j$({cacheRead:e,cacheWrite:t,output:a,max:i,size:l=44}){const c=e+t+a,u=Math.max(2,Math.round(l*.16)),m=l/2,p=(l-u)/2,h=2*Math.PI*p,g=Math.max(i,c,1),v=i>0?c/i:0,k=v>.95?"text-red-500":v>.8?"text-amber-500":"text-gray-300 dark:text-gray-700",w=[{key:"cacheRead",value:e,color:jc.cacheRead,label:f.usage.colCacheRead},{key:"cacheWrite",value:t,color:jc.cacheWrite,label:f.usage.colCacheWrite},{key:"output",value:a,color:jc.output,label:f.usage.colOutput}],S=`${f.chat.contextUsage} ${Rt(c)}/${Rt(i)}`+w.map(C=>` · ${C.label} ${Rt(C.value)}`).join("");let M=0;return r.jsxs("svg",{width:l,height:l,viewBox:`0 0 ${l} ${l}`,className:`block shrink-0 ${k}`,role:"img","aria-label":S,children:[r.jsx("title",{children:S}),r.jsx("circle",{cx:m,cy:m,r:p,fill:"none",stroke:"currentColor",strokeOpacity:.35,strokeWidth:u}),w.map(C=>{if(C.value<=0)return null;const T=C.value/g*h,I=-(M/g)*h;return M+=C.value,r.jsx("circle",{cx:m,cy:m,r:p,fill:"none",stroke:C.color,strokeWidth:u,strokeDasharray:`${T} ${h}`,strokeDashoffset:I,transform:`rotate(-90 ${m} ${m})`},C.key)})]})}const Ya={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"},mf="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",Ng="truncate font-mono text-[11px]",ww=.25,Tg=24,C$=1/Tg,bs=(e,t,a)=>Math.min(a,Math.max(t,e));function N$(e){return e==="thinking"?Ya.thinking:e==="text"?Ya.text:Ya.toolgen}function T$(e){return e==="thinking"?f.traces.kindThinking:e==="text"?f.traces.kindModelReply:f.traces.kindToolGen}function M$(e){return e==="thinking"?"thinking":e==="text"?"text":"toolgen"}function Bi(e){if(e===void 0)return null;const t=Date.parse(e);return Number.isFinite(t)?t:null}function A$(e,t,a){const i=new Map,l=u=>{let m=i.get(u);return m||(m={segs:[],spans:[],others:[]},i.set(u,m)),m};for(const u of e){const m=Bi(u.startTs),p=Bi(u.endTs);m===null||p===null||l(u.taskIndex).segs.push({kind:u.kind,...u.name!==void 0?{name:u.name}:{},ts:u.endTs,startMs:m,endMs:p})}for(const u of t){const m=Bi(u.callTs);m!==null&&l(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:m,approvalMs:Bi(u.approvalTs),outputMs:Bi(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 a){const m=Bi(u.startTs),p=Bi(u.endTs);m===null||p===null||l(u.taskIndex).others.push({key:u.key,name:u.name,ts:u.endTs,startMs:m,endMs:p,failed:u.failed===!0})}const c=[];for(const[u,{segs:m,spans:p,others:h}]of[...i.entries()].sort((g,v)=>g[0]-v[0])){if(m.length===0&&p.length===0&&h.length===0)continue;const g=[...m.map(C=>C.startMs),...p.map(C=>C.callMs),...h.map(C=>C.startMs)],v=[...m.map(C=>C.endMs),...p.map(C=>C.outputMs??C.approvalMs??C.callMs),...h.map(C=>C.endMs)],k=Math.min(...g),w=Math.max(...v,...g),S=Math.max(1,w-k);p.sort((C,T)=>C.callMs-T.callMs),h.sort((C,T)=>C.startMs-T.startMs);const M=[...new Set(p.map(C=>C.name))];c.push({taskIndex:u,segs:m,spans:p,others:h,t0:k,total:S,toolNames:M})}return c}function Mg({children:e}){return r.jsx("div",{className:"relative h-4 min-w-0 flex-1 overflow-hidden bg-gray-100 dark:bg-gray-800/60",children:e})}function E$({label:e,children:t}){return r.jsxs("div",{className:"flex items-center",children:[r.jsx("span",{className:`${mf} text-gray-400 dark:text-gray-500`,title:e,children:r.jsx("span",{className:Ng,children:e})}),r.jsx(Mg,{children:t})]})}function _$({total:e}){const t=[0,.25,.5,.75,1];return r.jsxs("div",{className:"flex items-center",children:[r.jsx("span",{className:mf}),r.jsx("div",{className:"relative h-4 min-w-0 flex-1",children:t.map((a,i)=>r.jsx("span",{className:`absolute top-0 font-mono text-[11px] text-gray-400 dark:text-gray-500 ${i===0?"":i===t.length-1?"-translate-x-full":"-translate-x-1/2"}`,style:{left:`${a*100}%`},children:An(a*e)},i))})]})}function R$({segments:e,toolSpans:t,otherSpans:a=[],highlight:i,onHighlight:l,onJump:c,hideTaskLabel:u=!1}){const m=x.useMemo(()=>A$(e,t,a),[e,t,a]),{firstBarKeyByTs:p,barKeys:h}=x.useMemo(()=>{const j=new Map,$=new Set,ae=(de,ye)=>{$.add(ye),j.has(de)||j.set(de,ye)};for(const de of m){de.segs.forEach((ye,Se)=>ae(ye.ts,`s-${de.taskIndex}-${Se}`));for(const ye of de.spans)ye.approvalMs!==null&&ye.approvalMs>ye.callMs&&ae(ye.approvalTsRaw??ye.callTs,`w-${ye.toolCallId}`),ye.approvalMs===null&&ye.outputMs===null?ae(ye.callTs,`p-${ye.toolCallId}`):ae(ye.outputTsRaw??ye.callTs,`e-${ye.toolCallId}`);for(const ye of de.others)ae(ye.ts,`o-${ye.key}`)}return{firstBarKeyByTs:j,barKeys:$}},[m]),[g,v]=x.useState(null),[k,w]=x.useState(1),[S,M]=x.useState({left:0,width:1}),C=x.useRef(null),T=x.useRef(null),I=x.useRef(S);I.current=S;const D=x.useRef(k);D.current=k;const K=x.useRef(null),F=x.useRef(null),E=x.useCallback(()=>{const j=C.current;if(!j)return;const $=j.scrollWidth||1;M({left:j.scrollLeft/$,width:Math.min(1,j.clientWidth/$)})},[]);if(x.useLayoutEffect(()=>{const j=C.current;if(j){if(K.current){const $=j.scrollWidth-j.clientWidth;j.scrollLeft=bs(K.current(j),0,Math.max(0,$)),K.current=null}E()}},[k,m,E]),x.useLayoutEffect(()=>{const j=C.current;if(!j||typeof ResizeObserver>"u")return;const $=new ResizeObserver(()=>E());return $.observe(j),()=>$.disconnect()},[E]),x.useLayoutEffect(()=>()=>F.current?.(),[]),m.length===0)return r.jsx("p",{className:"text-xs text-gray-400",children:f.common.none});const B=i?.ts,Y=i?.key,V=(j,$)=>l?.($?{ts:$,key:j}:null),O=()=>l?.(null),U=Y??(B!==void 0?p.get(B):void 0),_=U!==void 0&&h.has(U)?U:void 0,P=_!==void 0,H=j=>_===j,G=(j,$)=>g!==null&&!$||P&&!j?"opacity-15":"",z=(j,$,ae,de)=>{const ye=bs((j-ae)/de*100,0,100),Se=bs(($-j)/de*100,0,100-ye);return ye>=100?{left:"100%",width:"0%",marginLeft:"-2px"}:{left:`${ye}%`,width:`${Se}%`}},J=[{key:"thinking",className:Ya.thinking,label:f.traces.kindThinking},{key:"text",className:Ya.text,label:f.traces.kindModelReply},{key:"toolgen",className:Ya.toolgen,label:f.traces.kindToolGen},{key:"approvalWait",className:Ya.approvalWait,label:f.traces.legendApprovalWait},{key:"exec",className:Ya.exec,label:f.traces.legendToolExec},{key:"other",className:Ya.other,label:f.traces.legendOther}],xe=(j,$)=>{const ae=bs($,C$,1),de=bs(1/ae,ww,Tg),ye=bs(j,0,1-ae);K.current=Se=>ye*Se.scrollWidth,w(de)},me=j=>{j.preventDefault();const $=T.current,ae=C.current;if(!$||!ae)return;const de=$.getBoundingClientRect().width||1,ye=j.clientX,Se=ae.scrollLeft,ke=Math.max(0,ae.scrollWidth-ae.clientWidth),ee=Ae=>{const Qe=(Ae.clientX-ye)/de;ae.scrollLeft=bs(Se+Qe*ae.scrollWidth,0,ke),E()},je=()=>{window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",je),window.removeEventListener("pointercancel",je),F.current=null};window.addEventListener("pointermove",ee),window.addEventListener("pointerup",je),window.addEventListener("pointercancel",je),F.current=je},A=j=>$=>{$.preventDefault(),$.stopPropagation();const ae=T.current;if(!ae)return;const de=ae.getBoundingClientRect(),ye=ke=>{const ee=bs((ke.clientX-de.left)/(de.width||1),0,1),je=I.current;if(j==="right")xe(je.left,ee-je.left);else{const Ae=je.left+je.width;xe(ee,Ae-ee)}},Se=()=>{window.removeEventListener("pointermove",ye),window.removeEventListener("pointerup",Se),window.removeEventListener("pointercancel",Se),F.current=null};window.addEventListener("pointermove",ye),window.addEventListener("pointerup",Se),window.addEventListener("pointercancel",Se),F.current=Se},R=()=>{K.current=()=>0,w(1)},q=j=>{const $=C.current,ae=bs(D.current*j,ww,Tg);if(ae!==D.current){if($){const de=$.clientWidth/2,ye=($.scrollLeft+de)/($.scrollWidth||1);K.current=Se=>ye*Se.scrollWidth-de}w(ae)}};return r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{ref:C,className:"no-scrollbar overflow-x-auto overflow-y-hidden",children:r.jsx("div",{className:"space-y-4",style:{width:`${k*100}%`},children:m.map(j=>r.jsxs("div",{className:"space-y-1",children:[!u&&r.jsxs("div",{className:"flex items-center gap-2 pl-[5.5rem]",children:[r.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:f.traces.task(j.taskIndex+1)}),r.jsx("span",{className:"font-mono text-[11px] text-gray-400",children:An(j.total)})]}),r.jsx(E$,{label:f.traces.laneLLM,children:j.segs.map(($,ae)=>{const de=M$($.kind),ye=g===null||g===de,Se=`s-${j.taskIndex}-${ae}`,ke=H(Se);return r.jsx("span",{onMouseEnter:()=>V(Se,$.ts),onMouseLeave:O,onClick:()=>c?.($.ts),title:`${T$($.kind)}${$.name?` ${$.name}`:""} · ${An($.endMs-$.startMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${N$($.kind)} ${G(ke,ye)}`,style:z($.startMs,$.endMs,j.t0,j.total)},ae)})}),j.spans.map($=>{const ae=$.approvalMs??$.callMs,de=$.outputMs===null,ye=$.outputMs??j.t0+j.total,Se=$.approvalTsRaw??$.callTs,ke=$.outputTsRaw??$.callTs;return r.jsxs("div",{className:"flex items-center",children:[r.jsx("span",{className:`${mf} text-gray-500 dark:text-gray-400`,title:$.name,children:r.jsx("span",{className:Ng,children:$.name})}),r.jsxs(Mg,{children:[$.approvalMs!==null&&$.approvalMs>$.callMs&&r.jsx("span",{onMouseEnter:()=>V(`w-${$.toolCallId}`,Se),onMouseLeave:O,onClick:()=>c?.(Se),title:`${$.name} · ${f.traces.legendApprovalWait}${$.decision?` (${$.decision})`:""} · ${An($.approvalMs-$.callMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${Ya.approvalWait} ${G(H(`w-${$.toolCallId}`),g===null||g==="approvalWait")}`,style:z($.callMs,$.approvalMs,j.t0,j.total)}),$.approvalMs===null&&de?(()=>{const ee=G(H(`p-${$.toolCallId}`),g===null||g==="approvalWait");return r.jsx("span",{onMouseEnter:()=>V(`p-${$.toolCallId}`,$.callTs),onMouseLeave:O,onClick:()=>c?.($.callTs),title:`${$.name} · ${f.traces.legendApprovalWait} · ${f.traces.inProgress}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${Ya.approvalWait} ${ee||"animate-pulse"}`,style:z($.callMs,ye,j.t0,j.total)})})():(()=>{const ee=G(H(`e-${$.toolCallId}`),g===null||g==="exec"),je=de&&!ee;return r.jsx("span",{onMouseEnter:()=>V(`e-${$.toolCallId}`,ke),onMouseLeave:O,onClick:()=>c?.(ke),title:`${$.name} · ${f.traces.legendToolExec} · ${de?f.traces.inProgress:An(ye-ae)}${$.failed?` · ${$.status}`:""}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${Ya.exec} ${$.failed?"ring-1 ring-red-500":""} ${je?"animate-pulse opacity-70":ee}`,style:z(ae,ye,j.t0,j.total)})})()]})]},$.toolCallId)}),j.others.map($=>{const ae=G(H(`o-${$.key}`),g===null||g==="other");return r.jsxs("div",{className:"flex items-center",children:[r.jsx("span",{className:`${mf} text-gray-500 dark:text-gray-400`,title:$.name,children:r.jsx("span",{className:Ng,children:$.name})}),r.jsx(Mg,{children:r.jsx("span",{onMouseEnter:()=>V(`o-${$.key}`,$.ts),onMouseLeave:O,onClick:()=>c?.($.ts),title:`${$.name} · ${f.traces.legendOther} · ${An($.endMs-$.startMs)}`,className:`absolute inset-y-0 min-w-[2px] cursor-pointer ${Ya.other} ${$.failed?"ring-1 ring-red-500":""} ${ae}`,style:z($.startMs,$.endMs,j.t0,j.total)})})]},$.key)}),r.jsx(_$,{total:j.total})]},j.taskIndex))})}),r.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:J.map(j=>r.jsxs("button",{type:"button",onMouseEnter:()=>v(j.key),onMouseLeave:()=>v(null),className:`flex items-center gap-1 px-1 font-mono text-[11px] text-gray-500 transition-opacity duration-150 dark:text-gray-400 ${g!==null&&g!==j.key?"opacity-30":""}`,children:[r.jsx("span",{className:`inline-block h-2 w-3 rounded-sm ${j.className}`}),j.label]},j.key))}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:f.traces.zoom}),r.jsx("button",{type:"button","aria-label":f.traces.zoomOut,title:f.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:r.jsx("span",{className:"text-[11px] leading-none",children:"−"})}),r.jsx("div",{ref:T,onDoubleClick:R,title:f.traces.zoomReset,className:"relative h-3 min-w-0 flex-1 rounded bg-gray-100 dark:bg-gray-800",children:r.jsxs("div",{role:"scrollbar","aria-label":f.traces.zoom,onPointerDown:me,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:[r.jsx("span",{onPointerDown:A("left"),className:"h-full w-1.5 shrink-0 cursor-ew-resize rounded-l bg-gray-500/80 dark:bg-gray-400/80"}),r.jsx("span",{onPointerDown:A("right"),className:"h-full w-1.5 shrink-0 cursor-ew-resize rounded-r bg-gray-500/80 dark:bg-gray-400/80"})]})}),r.jsx("button",{type:"button","aria-label":f.traces.zoomIn,title:f.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:r.jsx("span",{className:"text-[11px] leading-none",children:"+"})}),r.jsxs("span",{className:"w-9 shrink-0 text-right font-mono text-[11px] tabular-nums text-gray-400",children:[k.toFixed(2),"×"]})]}),l&&r.jsx("p",{className:"text-[11px] text-gray-400 dark:text-gray-600",children:f.traces.linkHint})]})}function I$(e){return e==="session_meta"?"brand":e==="model_msg"?"gray":"amber"}const L$={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"},O$="M12 8v5m0 3h.01M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z";function D$({type:e}){return r.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:r.jsx("path",{d:L$[e]??O$})})}function U$(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 a=String(t.output??"").slice(0,120);return Array.isArray(t.images)&&t.images.length>0?`[image] ${a}`:a}case"token_usage":{const a=t.request,i=t.session;return`request.total=${a?.total??0} session.total=${i?.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 i=(Array.isArray(t.results)?t.results:[]).map(l=>`${String(l.server)}:${String(l.status)}(${String(l.duration_ms)}ms)`);return[String(t.status??""),i.join(" ")].filter(Boolean).join(" · ")}case"tool_list_ready":return Array.isArray(t.tools)?f.traces.toolDefs(t.tools.length):"";case"abort":return t.reason!=null?String(t.reason):"";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 z$(e){const t=e.payload;return t.stop_reason??t.status}const hc="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 $$({p:e}){const t=e.request??{},a=e.session??{},i=(l,c)=>r.jsxs("tr",{children:[r.jsx("td",{className:"pr-3 text-gray-400",children:l}),r.jsx("td",{className:"pr-3 text-right font-mono",children:Rt(c.cache_read??0)}),r.jsx("td",{className:"pr-3 text-right font-mono",children:Rt(c.cache_write??0)}),r.jsx("td",{className:"pr-3 text-right font-mono",children:Rt(c.output??0)}),r.jsx("td",{className:"text-right font-mono",children:Rt(c.total??0)})]});return r.jsxs("table",{className:"text-xs",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-gray-400",children:[r.jsx("th",{}),r.jsx("th",{className:"pr-3 text-right font-normal",children:"cacheRead"}),r.jsx("th",{className:"pr-3 text-right font-normal",children:"cacheWrite"}),r.jsx("th",{className:"pr-3 text-right font-normal",children:"output"}),r.jsx("th",{className:"text-right font-normal",children:"total"})]})}),r.jsxs("tbody",{children:[i("request",t),i("session",a)]})]})}const D5="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 P$({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??"")]],a=String(e.system_prompt??"");return r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5 text-xs",children:t.map(([i,l])=>r.jsxs(x.Fragment,{children:[r.jsx("dt",{className:"text-gray-400",children:i}),r.jsx("dd",{className:"min-w-0 break-all font-mono text-gray-700 dark:text-gray-300",children:l||"—"})]},i))}),a.trim()&&r.jsxs("details",{children:[r.jsx("summary",{className:D5,children:f.traces.systemPrompt}),r.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:r.jsx(Zc,{remarkPlugins:[Jc],children:a})})]})]})}function B$({schema:e}){const t=e.properties!==null&&typeof e.properties=="object"?e.properties:null;if(!t||Object.keys(t).length===0)return r.jsx("pre",{className:`${hc} mt-1`,children:JSON.stringify(e,null,2)});const a=new Set(Array.isArray(e.required)?e.required.map(String):[]),i=l=>{if(Array.isArray(l.enum))return l.enum.map(String).join(" | ");const c=typeof l.type=="string"?l.type:"object";if(c==="array"){const u=l.items;return`${u!==null&&typeof u=="object"?i(u):"unknown"}[]`}return c};return r.jsx("table",{className:"mt-1 w-full text-xs",children:r.jsx("tbody",{children:Object.entries(t).map(([l,c])=>r.jsxs("tr",{className:"align-top",children:[r.jsxs("td",{className:"whitespace-nowrap pr-3 font-mono text-gray-700 dark:text-gray-300",children:[l,a.has(l)&&r.jsx("span",{className:"ml-0.5 text-red-500",children:"*"})]}),r.jsx("td",{className:"whitespace-nowrap pr-3 font-mono text-gray-400 dark:text-gray-500",children:i(c)}),r.jsx("td",{className:"text-gray-500 dark:text-gray-400",children:typeof c.description=="string"?c.description:""})]},l))})})}function H$({p:e}){const t=Array.isArray(e.tools)?e.tools:[];return t.length===0?r.jsx("p",{className:"text-xs text-gray-400",children:"—"}):r.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((a,i)=>r.jsxs("li",{className:"px-2.5 py-1.5 text-xs",children:[r.jsx("span",{className:"font-mono font-semibold text-gray-700 dark:text-gray-300",children:a.name??"—"}),a.description&&r.jsx("p",{className:"mt-0.5 text-gray-500 dark:text-gray-400",children:a.description}),a.parameters!==null&&typeof a.parameters=="object"&&r.jsxs("details",{className:"mt-1",children:[r.jsx("summary",{className:D5,children:f.traces.toolParams}),r.jsx(B$,{schema:a.parameters})]})]},i))})}function F$({msg:e}){const t=e.payload;if(e.type==="session_meta")return r.jsx(P$,{p:t});if(t.type==="tool_list_ready")return r.jsx(H$,{p:t});switch(t.type){case"text":case"thinking":{const a=String(t.text??t.thinking??"");return a.trim()?r.jsx("div",{className:"md-body text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:r.jsx(Zc,{remarkPlugins:[Jc],children:a})}):r.jsx("p",{className:"text-xs text-gray-400",children:"—"})}case"image_url":return r.jsx(Ss,{src:String(t.image_url??""),alt:"trace",className:"max-h-48 max-w-full rounded-md"});case"inline_data":return r.jsx(Ss,{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 r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("p",{className:"font-mono text-xs font-semibold text-gray-700 dark:text-gray-300",children:String(t.name??"")}),r.jsx("pre",{className:hc,children:String(t.arguments??"")})]});case"tool_call_output":{const a=Array.isArray(t.images)?t.images:[];return a.length===0?r.jsx("pre",{className:hc,children:String(t.output??"")}):r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("pre",{className:hc,children:String(t.output??"")}),r.jsx("div",{className:"flex flex-wrap gap-2",children:a.map((i,l)=>r.jsx(Ss,{src:i,alt:"trace",className:"max-h-48 max-w-full rounded-md"},l))})]})}case"token_usage":return r.jsx($$,{p:t});default:return r.jsx("pre",{className:hc,children:JSON.stringify(t,null,2)})}}function V$({msg:e,rowKey:t,matched:a,onHighlight:i}){const[l,c]=x.useState(!1),u=e.payload.type??e.type,m=z$(e);return r.jsxs("li",{"data-trace-row":t,children:[r.jsxs("button",{type:"button",onClick:()=>c(p=>!p),onMouseEnter:()=>i?.({ts:e.timestamp,rowKey:t}),onMouseLeave:()=>i?.(null),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left transition-colors duration-150 ${a?"bg-amber-50 dark:bg-amber-950/40":"hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,children:[r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400",children:C3(e.timestamp)}),r.jsx(D$,{type:u}),r.jsx(Cn,{tone:I$(e.type),children:u}),e.origin&&e.origin.length>0&&r.jsx(Cn,{tone:"brand",children:"origin"}),r.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-gray-500 dark:text-gray-400",children:U$(e)})]}),l&&r.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:[r.jsx(F$,{msg:e}),m&&r.jsx("div",{className:"mt-1.5 flex justify-end",children:r.jsx(Cn,{tone:MA(m),children:m})})]})]})}function q$(e){return e?.compaction!==!0?null:f.chat.compactionTitle(e.compactionMode??"summarize")}const Sw=()=>({cacheRead:0,cacheWrite:0,output:0}),G$=2500,jw=(e,t)=>`${e}-${t}`;function ks({label:e,value:t}){return r.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-0.5",children:[r.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:e}),r.jsx("span",{className:"truncate font-mono text-sm font-semibold tabular-nums",children:t})]})}const U5=e=>e.cacheRead+e.cacheWrite,z5=e=>$2(e.cacheRead,e.cacheWrite),$5="flex shrink-0 items-center font-mono text-[11px] tabular-nums text-gray-500 dark:text-gray-400";function uc({icon:e,value:t,label:a}){return r.jsxs("span",{title:a,"aria-label":a,className:`${$5} gap-1`,children:[r.jsx(Ge,{d:e,className:"text-gray-400"}),t]})}function W$({buckets:e}){const t=U5(e),a=`${f.traces.cacheHit} ${Rt(e.cacheRead)} · ${f.traces.hitRate} ${Kg(z5(e))}`;return r.jsxs("span",{"aria-label":`${f.traces.taskInput} ${Rt(t)} · ${a}`,className:$5,children:[r.jsxs("span",{title:f.traces.taskInput,className:"flex items-center gap-1",children:[r.jsx(Ge,{d:aa.input,className:"text-gray-400"}),Rt(t)]}),r.jsxs("span",{title:a,className:"ml-1 flex items-center gap-0.5 text-gray-400",children:[r.jsx("span",{children:"("}),r.jsx(Ge,{d:aa.cacheHit}),r.jsx("span",{children:Rt(e.cacheRead)}),r.jsx("span",{children:")"})]})]})}function K$({projectId:e,agentId:t,sessionId:a,index:i,highlight:l,onHighlight:c}){const{currency:u}=mi(),[m,p]=x.useState(null),[h,g]=x.useState([]),[v,k]=x.useState(0),[w,S]=x.useState(0),[M,C]=x.useState(null),[T,I]=x.useState(null),[D,K]=x.useState(new Set),[F,E]=x.useState(null),B=x.useRef(null),Y=x.useRef(null);x.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[]),x.useEffect(()=>{p(null),g([]),I(null),K(new Set),E(null);let R=!1;return Promise.all([W4(e,t,a,i),G4(e,t,a,i,0,1e3),Yl(e).catch(()=>null)]).then(([q,j,$])=>{R||(p(q),g(j.events),k(j.offset),S(j.total),C($))}).catch(q=>{R||I(Oe(q))}),()=>{R=!0}},[e,t,a,i]);const V=x.useMemo(()=>{const R=h.find(j=>j.type==="session_meta"),q=R?R.payload:void 0;if(!(!q?.model_id||!q.provider))return M?.models.find(j=>j.modelId===q.model_id&&j.provider===q.provider)?.pricing},[h,M]),O=R=>V?(R.cacheRead*V.cacheRead+R.cacheWrite*V.cacheWrite+R.output*V.output)/1e6:null,U=x.useMemo(()=>{const R=h.find(q=>q.type==="session_meta");return Bj(R?R.payload.model_context_window:void 0)},[h]),{tasks:_,global:P,statsByTask:H,globalLlmMs:G}=x.useMemo(()=>{const R={buckets:Sw(),toolCalls:0},q=new Map;if(!m)return{tasks:[],global:R,statsByTask:q,globalLlmMs:0};const j=new Map;for(const ee of m.tasks){const je=Date.parse(ee.startTs),Ae=Date.parse(ee.endTs);Number.isFinite(je)&&Number.isFinite(Ae)&&j.set(ee.taskIndex,{min:je,max:Ae})}const $=new Map,ae=ee=>{let je=$.get(ee);if(!je){const Ae=j.get(ee);je={taskIndex:ee,segments:[],spans:[],otherSpans:[],messages:[],toolCalls:0,durationMs:Ae?Math.max(0,Ae.max-Ae.min):0},$.set(ee,je)}return je};for(const ee of m.tasks)ae(ee.taskIndex);for(const ee of m.modelSegments)ae(ee.taskIndex).segments.push(ee);for(const ee of m.toolSpans){const je=ae(ee.taskIndex);je.spans.push(ee),je.toolCalls+=1}for(const ee of m.otherSpans??[])ae(ee.taskIndex).otherSpans.push(ee);const de=ee=>{for(const je of m.tasks)if(ee>=je.messageFrom&&ee<=je.messageTo)return je.taskIndex;return null};for(let ee=0;ee<h.length;ee++){const je=h[ee];if(je.origin&&je.origin.length>0)continue;const Ae=de(v+ee);Ae!==null&&ae(Ae).messages.push(je)}R.toolCalls=m.toolSpans.length;const ye=new Map(m.tasks.map(ee=>[ee.taskIndex,ee]));for(const ee of m.tasks)R.buckets.cacheRead+=ee.tokens.cacheRead,R.buckets.cacheWrite+=ee.tokens.cacheWrite,R.buckets.output+=ee.tokens.output;const Se=m.tasks.reduce((ee,je)=>ee+je.llmMs,0);return{tasks:[...$.values()].sort((ee,je)=>ee.taskIndex-je.taskIndex),global:R,statsByTask:ye,globalLlmMs:Se}},[m,h,v]);if(T)return r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:T});if(!m)return r.jsx(mn,{className:"h-40"});const z=m.elapsedMs,J=R=>K(q=>{const j=new Set(q);return j.has(R)?j.delete(R):j.add(R),j}),xe=R=>{for(const q of _){const j=q.messages.findIndex($=>$.timestamp===R);if(j>=0)return jw(q.taskIndex,j)}return null},me=l?.rowKey??(l?.ts!==void 0?xe(l.ts):null),A=R=>{const q=xe(R);q!==null&&(E(q),requestAnimationFrame(()=>{B.current?.querySelector(`[data-trace-row="${q}"]`)?.scrollIntoView({block:"center",behavior:"smooth"})}),Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>E(null),G$))};return r.jsxs("div",{ref:B,className:"space-y-4",children:[r.jsxs("div",{className:"rounded-md border border-gray-200 p-3 dark:border-gray-800",children:[r.jsx("p",{className:"mb-2 text-xs font-semibold text-gray-500",children:f.traces.globalSummary}),r.jsxs("div",{className:"grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-3",children:[r.jsxs("div",{children:[r.jsx(ks,{label:f.traces.tasksLabel,value:String(m.tasks.length)}),r.jsx(ks,{label:f.traces.toolCalls,value:String(P.toolCalls)}),r.jsx(ks,{label:f.traces.compactions,value:String(m.compactionCount)})]}),r.jsxs("div",{children:[r.jsx(ks,{label:f.chat.statInput,value:Rt(U5(P.buckets))}),r.jsx(ks,{label:f.traces.cacheHit,value:`${Rt(P.buckets.cacheRead)} · ${Kg(z5(P.buckets))}`}),r.jsx(ks,{label:f.chat.statOutput,value:Rt(P.buckets.output)})]}),r.jsxs("div",{children:[r.jsx(ks,{label:f.common.cost,value:Dr(O(P.buckets),u)}),r.jsx(ks,{label:f.chat.statElapsed,value:An(Math.max(0,z))}),r.jsx(ks,{label:f.chat.statTps,value:qd(qh(P.buckets.output,G))})]})]})]}),_.map(R=>{const q=!D.has(R.taskIndex),j=H.get(R.taskIndex),$=j?.context,ae=j?.tokens??Sw(),de=q$(j);return r.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-800",children:[r.jsxs("button",{type:"button",onClick:()=>J(R.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:[r.jsx(Yn,{open:q,size:13,className:"text-gray-400"}),r.jsx("span",{className:"shrink-0 text-sm font-semibold",children:f.traces.task(R.taskIndex+1)}),de!==null&&r.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:de}),r.jsx("span",{className:"min-w-0 flex-1"}),r.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-1",children:[r.jsx(uc,{icon:aa.toolCalls,value:String(R.toolCalls),label:f.traces.toolCalls}),r.jsx(W$,{buckets:ae}),r.jsx(uc,{icon:aa.output,value:Rt(ae.output),label:f.traces.taskOutput}),r.jsx(uc,{icon:aa.cost,value:Dr(O(ae),u),label:`${f.common.cost}(${u})`}),r.jsx(uc,{icon:aa.elapsed,value:An(R.durationMs),label:f.chat.statElapsed}),r.jsx(uc,{icon:aa.tps,value:qd(qh(ae.output,j?.llmMs??0)),label:f.chat.statTps})]}),$&&r.jsx(j$,{cacheRead:$.cacheRead,cacheWrite:$.cacheWrite,output:$.output,max:U,size:22})]}),q&&r.jsxs("div",{className:"space-y-3 p-3",children:[(R.segments.length>0||R.spans.length>0||R.otherSpans.length>0)&&r.jsxs("div",{className:"rounded-md border border-gray-100 p-2 dark:border-gray-800/60",children:[r.jsx("p",{className:"mb-1.5 text-[11px] font-medium text-gray-500",children:f.traces.timeline}),r.jsx(R$,{segments:R.segments,toolSpans:R.spans,otherSpans:R.otherSpans,highlight:l,onHighlight:c,onJump:A,hideTaskLabel:!0})]}),r.jsxs("div",{children:[r.jsxs("p",{className:"mb-1.5 text-[11px] font-medium text-gray-500",children:[f.traces.messages,"(",R.messages.length,")"]}),R.messages.length===0?r.jsx("p",{className:"text-xs text-gray-400",children:f.common.none}):r.jsx("ul",{className:"divide-y divide-gray-100 rounded-md border border-gray-200 dark:divide-gray-800/60 dark:border-gray-800",children:R.messages.map((ye,Se)=>{const ke=jw(R.taskIndex,Se);return r.jsx(V$,{msg:ye,rowKey:ke,matched:ke===me||ke===F,onHighlight:ee=>c(ee)},Se)})})]})]})]},R.taskIndex)}),h.length<w&&r.jsx("p",{className:"text-xs text-gray-400",children:f.traces.truncatedNote(h.length,w)})]})}const Cc=20,dc=15;function P5(e){if(e.sessions)return e.sessions.map(a=>({sessionId:a.sessionId,...a.title!==void 0?{title:a.title}:{},category:a.category,workspace:a.workspace,files:[...a.files].sort((i,l)=>l.index-i.index)}));const t=new Map;for(const a of e.dates)for(const i of a.sessions){const l=t.get(i.sessionId)??[];for(const c of i.files)l.push({index:c.index,date:a.date,sizeBytes:c.sizeBytes});t.set(i.sessionId,l)}return[...t.entries()].sort((a,i)=>i[0].localeCompare(a[0])).map(([a,i])=>({sessionId:a,category:"active",workspace:"",files:i.sort((l,c)=>c.index-l.index)}))}function Cw(e){const t={active:[],subagent:[],schedule:[],archived:[]};for(const a of e)t[a.category].push(a);return t}const yr=(e,t)=>`${e}\0${t}`;function Y$(e,t=!1){const[a,i]=x.useState(new Map),[l,c]=x.useState(new Map),[u,m]=x.useState(new Map),[p,h]=x.useState(new Map),[g,v]=x.useState(new Map),[k,w]=x.useState(new Set),S=x.useRef(0),M=x.useRef(new Set),C=x.useRef(l);C.current=l;const T=x.useRef(u);T.current=u,x.useEffect(()=>{S.current+=1,M.current.clear();const O=new Map;C.current=O,i(new Map),c(O),m(new Map),h(new Map),v(new Map),w(new Set)},[e,t]);const I=x.useCallback(async(O,U,_,P)=>{const H=await Ww(O,U,{offset:P,limit:Cc+1,category:_,...t?{cli:!0}:{}}),G=Bh(P5(H),Cc);return{agentId:U,category:_,items:G.items.map(z=>({...z,agentId:U})),hasMore:G.hasMore,...H.counts!==void 0?{counts:H.counts}:{},...H.workspaceCounts!==void 0?{workspaceCounts:H.workspaceCounts}:{}}},[t]),D=x.useCallback((O,U)=>{i(_=>{const P=new Map(_);if(U!==void 0)for(const[H,G]of _)G.agentId===U&&P.delete(H);for(const H of O)for(const G of H.items)P.set(G.sessionId,G);return P}),c(_=>{const P=new Map(_);if(U!==void 0)for(const H of _.keys())H.startsWith(`${U}\0`)&&P.delete(H);for(const H of O){const G=yr(H.agentId,H.category);P.set(G,{hasMore:H.hasMore,fetched:(U===void 0?_.get(G)?.fetched??0:0)+H.items.length})}return P});for(const _ of O)_.counts&&m(P=>new Map(P).set(_.agentId,_.counts)),_.workspaceCounts&&h(P=>new Map(P).set(_.agentId,_.workspaceCounts))},[]),K=x.useCallback(O=>{if(!e)return;const U=[...new Set(O)].filter(P=>{const H=yr(P,"active");return!C.current.has(H)&&!M.current.has(H)});if(U.length===0)return;const _=S.current;for(const P of U)M.current.add(yr(P,"active"));w(P=>{const H=new Set(P);for(const G of U)H.add(yr(G,"active"));return H}),v(P=>{if(!U.some(G=>P.has(G)))return P;const H=new Map(P);for(const G of U)H.delete(G);return H}),Promise.all(U.map(async P=>{try{return await I(e,P,"active",0)}catch(H){return _===S.current&&v(G=>new Map(G).set(P,Oe(H))),null}})).then(P=>{for(const H of U)M.current.delete(yr(H,"active"));w(H=>{const G=new Set(H);for(const z of U)G.delete(yr(z,"active"));return G}),_===S.current&&D(P.filter(H=>H!==null))})},[e,I,D]),F=x.useCallback(async(O,U)=>{if(!e)return;const _=[...new Set(O)].filter(G=>{const z=C.current.get(yr(G,U));return z===void 0?(T.current.get(G)?.[U]??0)>0:z.hasMore});if(_.length===0)return;const P=S.current,H=await Promise.all(_.map(async G=>{const z=C.current.get(yr(G,U))?.fetched??0;try{return await I(e,G,U,z)}catch{return null}}));P===S.current&&D(H.filter(G=>G!==null))},[e,I,D]),E=x.useCallback(async O=>{if(!e)return;const U=["active",...Vc.filter(H=>C.current.has(yr(O,H)))],_=S.current,P=await Promise.all(U.map(async H=>{try{return await I(e,O,H,0)}catch{return null}}));_===S.current&&D(P.filter(H=>H!==null),O)},[e,I,D]),B=x.useCallback((O,U)=>l.has(yr(O,U)),[l]),Y=x.useCallback((O,U)=>k.has(yr(O,U)),[k]),V=x.useCallback((O,U)=>{const _=l.get(yr(O,U));return _!==void 0?_.hasMore:(u.get(O)?.[U]??0)>0},[l,u]);return x.useMemo(()=>{const O=new Map;for(const _ of a.values()){const P=O.get(_.agentId);P?P.push(_):O.set(_.agentId,[_])}for(const _ of O.values())_.sort((P,H)=>H.sessionId.localeCompare(P.sessionId));const U=[...O.values()].flat();return{rowsByAgent:O,allRows:U,countsByAgent:u,workspaceCountsByAgent:p,errorByAgent:g,isLoadedFor:B,isPendingFor:Y,hasMoreFor:V,ensureFirstFor:K,loadMoreFor:F,refreshAgent:E}},[a,u,p,g,B,Y,V,K,F,E])}const Q$=14*1024*1024,Lh=10,Nw=(e,t)=>`${t}\0${e}`;function X$(){Jr(f.traces.title);const{currentProject:e,agents:t,agentsLoading:a}=cn(),{byAgent:i,showCliSessions:l}=pi(),c=e?.projectId??null,u=Y$(c,l),[m]=vf(),p=m.get("agentId"),h=m.get("sessionId"),[g,v]=x.useState(Vh),k=p!==null?"agent":g,[w,S]=x.useState(null),[M,C]=x.useState(null),[T,I]=x.useState(dc),[D,K]=x.useState(new Map),[F,E]=x.useState(null),[B,Y]=x.useState(new Set),[V,O]=x.useState(new Set),[U,_]=x.useState(new Set),[P,H]=x.useState(!1),[G,z]=x.useState(""),[J,xe]=x.useState(null),[me,A]=x.useState(!1),[R,q]=x.useState(null),j=x.useRef(null),$=W=>{R2(W),v(W),I(dc)};x.useEffect(()=>{S(null),C(null),I(dc),K(new Map),E(null),Y(new Set),O(new Set)},[c]),x.useEffect(()=>{q(null)},[w,M]),x.useEffect(()=>{A(!1)},[w]);const ae=x.useMemo(()=>{const W=new Map;for(const pe of i.values())for(const Ne of pe)Ne.title!==void 0&&W.set(Ne.sessionId,Ne.title);return W},[i]),de=x.useCallback((W,pe)=>ae.get(W)??pe??f.chat.defaultSessionTitle,[ae]),ye=x.useMemo(()=>new Map(t.map(W=>[W.agentId,pn(W)])),[t]),Se=x.useMemo(()=>Hd(t,W=>W.agentId,new Set(p===null?[]:[p])),[t,p]),ke=x.useMemo(()=>{if(F!==null)return F;const W=p??Se[0]?.agentId;return new Set(W===void 0?[]:[W])},[F,p,Se]),ee=W=>{const pe=new Set(ke);pe.has(W)?pe.delete(W):pe.add(W),E(pe)},je=W=>{Y(pe=>{const Ne=new Set(pe);return Ne.has(W)?Ne.delete(W):Ne.add(W),Ne})},Ae=u.ensureFirstFor;x.useEffect(()=>{if(!c||k!=="agent")return;const W=Se.slice(0,T).map(pe=>pe.agentId).filter(pe=>ke.has(pe));W.length>0&&Ae(W)},[c,k,Se,T,ke,Ae]),x.useEffect(()=>{!c||k!=="workspace"||t.length===0||Ae(t.map(W=>W.agentId))},[c,k,t,Ae]);const Qe=x.useMemo(()=>T2(u.allRows.map(W=>({...W,createdAt:W.sessionId}))),[u.allRows]),We=x.useMemo(()=>C2(u.workspaceCountsByAgent),[u.workspaceCountsByAgent]),re=x.useCallback(W=>{S({agentId:W.agentId,sessionId:W.sessionId,...W.title!==void 0?{title:W.title}:{},files:W.files}),C(W.files[0]?.index??null)},[]),ft=x.useCallback((W,pe)=>{c&&Ww(c,W).then(Ne=>{const Re=P5(Ne).find(Pe=>Pe.sessionId===pe);Re&&re({...Re,agentId:W})}).catch(()=>{})},[c,re]),ge=x.useRef(!1);x.useEffect(()=>{if(ge.current||!h||!p||!u.isLoadedFor(p,"active"))return;ge.current=!0;const W=u.rowsByAgent.get(p)?.find(pe=>pe.sessionId===h);W?re(W):ft(p,h)},[u,h,p,re,ft]),x.useEffect(()=>{const W=j.current;if(W===null)return;const pe=u.rowsByAgent.get(W.agentId);if(pe===void 0)return;j.current=null;const Ne=pe.find(Re=>Re.sessionId===W.sessionId);Ne?re(Ne):ft(W.agentId,W.sessionId)},[u,re,ft]);const dt=async(W,pe)=>{if(c){xe(W);try{const Ne=await Y4(c,W,{dataBase64:pe});j.current={agentId:W,sessionId:Ne.sessionId},ke.has(W)||ee(W),await u.refreshAgent(W)}catch(Ne){Ve(Oe(Ne))}finally{xe(null)}}},It=W=>{const pe=G,Ne=W.target.files?.[0];if(W.target.value="",!Ne||pe==="")return;if(Ne.size>Q$){Ve(f.traces.fileTooLarge);return}H(!1);const Re=new FileReader;Re.onload=()=>{const Pe=Re.result;dt(pe,Pe.slice(Pe.indexOf(",")+1))},Re.onerror=()=>Ve(f.common.unknownError),Re.readAsDataURL(Ne)},zt=()=>{z(p??Se[0]?.agentId??""),H(!0)},nn=(W,pe)=>`${pe}\0${W}`,un=(W,pe,Ne)=>{const Re=nn(W,pe);_(Pe=>new Set(Pe).add(Re)),u.loadMoreFor(Ne,pe).finally(()=>{_(Pe=>{const Fe=new Set(Pe);return Fe.delete(Re),Fe})})},Wt=(W,pe,Ne)=>{const Re=Nw(W,pe),Pe=!V.has(Re);if(O(Fe=>{const nt=new Set(Fe);return Pe?nt.add(Re):nt.delete(Re),nt}),Pe){const Fe=Ne.filter(nt=>!u.isLoadedFor(nt,pe));Fe.length>0&&u.loadMoreFor(Fe,pe)}},Ce=(W,pe)=>r.jsx("ul",{className:"space-y-0.5",children:W.map(Ne=>{const Re=w?.sessionId===Ne.sessionId,Pe=ye.get(Ne.agentId)??Ne.agentId;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>re(Ne),className:`flex w-full items-center gap-1.5 rounded-md px-2.5 py-1.5 text-left transition-colors duration-150 ${Re?"bg-gray-200/70 dark:bg-gray-800":"hover:bg-gray-200/50 dark:hover:bg-gray-800/70"}`,children:[pe&&r.jsxs("span",{title:Pe,className:"flex shrink-0 items-center",children:[r.jsx(Da,{id:Ne.agentId,name:Pe,size:14,className:"rounded"}),r.jsx("span",{className:"sr-only",children:Pe})]}),r.jsx(qc,{text:de(Ne.sessionId,Ne.title),className:`min-w-0 flex-1 text-sm ${Re?"font-medium text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`}),r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400",children:Ne.files.length})]})},Ne.sessionId)})}),Ke=(W,pe,Ne,Re,Pe,Fe)=>{const nt=Ne[pe],ot=Math.max(Fe?.[pe]??0,nt.length);if(ot===0)return null;const Te=nt.length<ot&&Pe.some(ze=>u.hasMoreFor(ze,pe));return r.jsx(L2,{label:f.chat.folderGroups[pe](ot),open:V.has(Nw(W,pe)),onToggle:()=>Wt(W,pe,Pe),more:Te,pending:U.has(nn(W,pe)),onMore:()=>un(W,pe,Pe),children:Ce(nt,Re)},pe)},se=(W,pe)=>{K(Ne=>{const Re=new Map(Ne);return Re.set(W,(Ne.get(W)??Cc)+Cc),Re}),pe.length>0&&un(W,"active",pe)},ce=(W,pe,Ne,Re,Pe,Fe)=>{const nt=Cw(pe),ot=D.get(W)??Cc,Te=nt.active.slice(0,ot),ze=Pe("active"),yt=Math.max(Re?.active??0,nt.active.length),ct=nt.active.length>ot||nt.active.length<yt&&ze.some(dn=>u.hasMoreFor(dn,"active")),vt=Vc.map(dn=>Ke(W,dn,nt,Ne,Pe(dn),Re)),hn=nt.active.length===0&&vt.every(dn=>dn===null),bt=U.has(nn(W,"active"));return r.jsxs(r.Fragment,{children:[hn?r.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400 dark:text-gray-600",children:Fe}):Ce(Te,Ne),ct&&r.jsx(Wl,{label:f.chat.loadMore,pending:bt,onClick:()=>se(W,ze),className:"mt-0.5"}),vt]})};if(!c)return null;const De=w===null?null:w.files.find(W=>W.index===M)??w.files[0]??null,Be=w===null||me?null:w.files.slice(0,Lh),Ue=u.allRows.length===0&&t.some(W=>u.isPendingFor(W.agentId,"active"));return r.jsxs("div",{className:"flex h-full flex-col md:flex-row",children:[r.jsxs("aside",{className:"relative 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:[r.jsxs("div",{className:"flex items-center justify-between px-3 pb-1",children:[r.jsx("p",{className:"text-xs font-bold uppercase tracking-wide text-gray-500",children:f.traces.title}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[e?.role==="owner"&&r.jsx("button",{type:"button",title:J!==null?f.traces.importing:f.traces.importTrace,"aria-label":J!==null?f.traces.importing:f.traces.importTrace,disabled:J!==null,onClick:zt,className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 hover:bg-gray-200/50 hover:text-gray-700 disabled:opacity-60 dark:text-gray-500 dark:hover:bg-gray-800/70 dark:hover:text-gray-300",children:r.jsx(Gb,{size:14})}),p===null&&r.jsx(k3,{value:g,onChange:$})]})]}),a||k==="workspace"&&Ue?r.jsx(La,{rows:4}):k==="agent"?r.jsxs(r.Fragment,{children:[Se.slice(0,T).map(W=>{const pe=ke.has(W.agentId),Ne=pn(W),Re=u.errorByAgent.get(W.agentId),Pe=u.isLoadedFor(W.agentId,"active");return r.jsxs("div",{className:"pt-2.5",children:[r.jsx(gc,{open:pe,onToggle:()=>ee(W.agentId),icon:r.jsx(Da,{id:W.agentId,name:Ne,size:18,className:"shrink-0 rounded"}),label:Ne,uppercase:!0}),pe&&r.jsxs("div",{className:"anim-fade",children:[Re!==void 0&&r.jsx("p",{className:"px-2.5 py-1 text-xs text-red-500",children:Re}),!Pe&&Re===void 0&&r.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400",children:f.common.loading}),Pe&&ce(W.agentId,u.rowsByAgent.get(W.agentId)??[],!1,u.countsByAgent.get(W.agentId),()=>[W.agentId],f.traces.empty)]})]},W.agentId)}),Se.length>T&&r.jsx(Wl,{label:f.chat.moreGroups(Se.length-T),onClick:()=>I(W=>W+dc),className:"mt-1"})]}):Qe.length===0?r.jsx("p",{className:"px-2.5 pt-3 text-xs text-gray-400 dark:text-gray-600",children:f.chat.noSessions}):r.jsxs(r.Fragment,{children:[Qe.slice(0,T).map(W=>{const pe=B.has(W.key),Ne=Cw(W.sessions),Re=We.get(W.key),Pe=[...new Set(W.sessions.map(nt=>nt.agentId))],Fe=nt=>[...new Set([...Re?.agents[nt]??[],...Pe])];return r.jsxs("div",{className:"pt-2.5",children:[r.jsx(gc,{open:!pe,onToggle:()=>je(W.key),icon:r.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:r.jsx(Mn,{d:pe?Fd:A2,size:15})}),label:W.temp?f.chat.tempWorkspaces:W.label,count:Math.max(Re?.totals.active??0,Ne.active.length),...W.fullPath!==null?{title:W.fullPath}:{}}),pe?null:ce(W.key,W.sessions,!0,Re?.totals,Fe,f.chat.noSessions)]},W.key)}),Qe.length>T&&r.jsx(Wl,{label:f.chat.moreGroups(Qe.length-T),onClick:()=>I(W=>W+dc),className:"mt-1"})]})]}),r.jsx("section",{className:"min-w-0 flex-1 overflow-y-auto p-3 md:p-4",children:w&&De?r.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("p",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:de(w.sessionId,w.title)}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[r.jsx("span",{className:"mr-1 text-xs text-gray-400",children:f.traces.filesTitle}),(Be??w.files).map(W=>r.jsxs("button",{type:"button",onClick:()=>C(W.index),title:`${W.date} · ${_c(W.sizeBytes)}`,className:`rounded-md border px-2 py-0.5 font-mono text-xs transition-colors duration-150 ${W.index===De.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(W.index).padStart(3,"0")]},W.index)),Be!==null&&w.files.length>Lh&&r.jsxs("button",{type:"button",title:f.chat.loadMore,"aria-label":f.chat.loadMore,onClick:()=>A(!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:["+",w.files.length-Lh]})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs("p",{className:"min-w-0 flex-1 truncate font-mono text-xs text-gray-400",children:[De.date," · ",_c(De.sizeBytes)]}),r.jsxs("a",{href:K4(c,w.agentId,w.sessionId,De.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:[r.jsx(O2,{size:12}),f.traces.exportFile]})]}),r.jsx(K$,{projectId:c,agentId:w.agentId,sessionId:w.sessionId,index:De.index,highlight:R,onHighlight:q})]}):r.jsx(Xr,{title:f.traces.selectSession})}),r.jsx(Xt,{open:P,title:f.traces.importTrace,onClose:()=>H(!1),children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(oi,{label:f.traces.importAgent,value:G,onChange:W=>z(W.target.value),children:t.map(W=>r.jsx("option",{value:W.agentId,children:pn(W)},W.agentId))}),r.jsx("div",{className:"flex justify-end",children:r.jsxs("label",{className:"inline-flex cursor-pointer items-center justify-center gap-1 rounded-md border border-[var(--accent-bg)] bg-[var(--accent-bg)] px-3 py-1.5 text-sm font-medium text-[var(--accent-fg)] transition-opacity hover:opacity-90",children:[r.jsx(Lf,{accept:".jsonl",onChange:It}),r.jsx(Gb,{size:14}),f.traces.importPickFile]})})]})})]})}function B5(e){return e.map(t=>typeof t.score=="number"&&Number.isFinite(t.score)?t.score:null)}const Rd=0,Id=100,Tw=10,Z$=[1,2,2.5,5,10,20];function J$(e){const t=e.filter(g=>g!==null&&g>=Rd&&g<=Id);if(t.length===0)return{min:Rd,max:Id,ticks:[0,20,40,60,80,100]};const a=Math.min(...t),i=Math.max(...t),l=Math.max(Rd,a-Tw),c=Math.min(Id,i+Tw),u=Z$.find(g=>(c-l)/g<=5),m=Math.max(Rd,Math.floor(l/u)*u),p=Math.min(Id,Math.ceil(c/u)*u),h=Array.from({length:Math.round((p-m)/u)+1},(g,v)=>m+v*u);return{min:m,max:p,ticks:h}}function eP(e){const t=[];let a=[];return e.forEach((i,l)=>{if(i===null){a.length>0&&t.push(a),a=[];return}a.push({index:l,value:i})}),a.length>0&&t.push(a),t}function tP(e){const t=new Map;e.forEach((i,l)=>{const c=i.modelId!==void 0&&i.modelId!=="",u=c?`${i.modelId}\0${i.thinkingLevel??""}`:"";let m=t.get(u);m||(m={key:u,...c&&i.modelId!==void 0?{modelId:i.modelId}:{},...c&&i.thinkingLevel!==void 0?{thinkingLevel:i.thinkingLevel}:{},indices:[]},t.set(u,m)),m.indices.push(l)});const a=[...t.values()];return[...a.filter(i=>i.key!==""),...a.filter(i=>i.key==="")]}function nP(e,t){const a=new Set(t.indices);return B5(e).map((i,l)=>a.has(l)?i:null)}const aP=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"]),rP=new Set(["png","jpg","jpeg","gif","webp"]),Mw=/^[a-z][a-z0-9+.-]*:/i,sP=64*1024;function H5(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():e.toLowerCase()}function Aw(e){return e.includes("/")?e.slice(0,e.lastIndexOf("/")):""}function Ew(e,t){const a=t.startsWith("/")||e===""?[]:e.split("/");for(const i of t.split("/"))i===""||i==="."||(i===".."?a.pop():a.push(i));return a.join("/")}function iP(e){const t=H5(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 _w({projectId:e,agentId:t,benchmarkId:a,caseSummary:i,material:l,label:c,hiddenLabel:u,defaultOpen:m=!1,autoPreviewReadme:p=!1,onPreview:h}){const[g,v]=x.useState(m),[k,w]=x.useState(""),[S,M]=x.useState(null),[C,T]=x.useState(null),I=x.useRef(!1);x.useEffect(()=>{if(!g)return;M(null),T(null);let F=!1;return cT(e,t,a,i.id,k,l).then(E=>{if(!F&&(M({base:k,res:E}),p&&k===""&&!I.current)){I.current=!0;const B=E.entries.find(Y=>Y.kind==="file"&&Y.name.toLowerCase()==="readme.md");B&&h(l,B.name)}}).catch(E=>{F||T(Oe(E))}),()=>{F=!0}},[e,t,a,i.id,l,p,h,g,k]);const D=k===""?[]:k.split("/"),K=F=>{if(S===null)return;const E=Ud(S.base,F.name);if(F.kind==="dir"){w(E);return}h(l,E)};return r.jsxs("div",{className:"border-b border-gray-200 last:border-b-0 dark:border-gray-800",children:[r.jsxs("button",{type:"button","aria-expanded":g,onClick:()=>v(F=>!F),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:[r.jsx("span",{className:"text-xs text-gray-400",children:g?"▾":"▸"}),r.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:c}),u&&r.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})]}),g&&r.jsxs("div",{children:[D.length>0&&r.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:[r.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}),D.map((F,E)=>r.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[r.jsx("span",{className:"text-gray-300 dark:text-gray-700",children:"/"}),r.jsx("button",{type:"button",onClick:()=>w(D.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:F})]},`${F}-${E}`))]}),C&&r.jsx("p",{className:"px-6 py-2 text-xs text-red-500",children:C}),!S&&!C&&r.jsx(La,{rows:3}),S?.res.entries.length===0&&r.jsx("p",{className:"px-6 py-2 text-xs text-gray-400",children:f.files.empty}),S?.res.entries.map(F=>r.jsxs("button",{type:"button",onClick:()=>K(F),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:[r.jsx("span",{className:"text-sm text-gray-400",children:F.kind==="dir"?"▸":"·"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:F.name}),F.kind==="file"&&r.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:_c(F.sizeBytes)})]},`${F.kind}/${F.name}`))]})]})}function lP({projectId:e,agentId:t,benchmarkId:a,caseSummary:i}){const[l,c]=x.useState(null),u=x.useRef(0),m=x.useCallback((k,w,S)=>uT(e,t,a,i.id,w,k,S),[e,t,a,i.id]),p=x.useCallback(async(k,w)=>{const S=++u.current,M=w.includes("/")?w.slice(w.lastIndexOf("/")+1):w,C=H5(M);if(rP.has(C)){c({material:k,path:w,name:M,kind:"image"});return}if(C==="pdf"){c({material:k,path:w,name:M,kind:"pdf"});return}const T=C==="md";if(!aP.has(C)){c({material:k,path:w,name:M,kind:"unsupported"});return}c({material:k,path:w,name:M,kind:T?"md":"text",loading:!0});try{const I=await fetch(m(k,w,{preview:!0}),{credentials:"same-origin"});if(!I.ok)throw new Error(String(I.status));const D=await I.text();if(S!==u.current)return;c({material:k,path:w,name:M,kind:T?"md":"text",content:D,truncated:I.headers.get("x-content-truncated")==="1"})}catch(I){if(S!==u.current)return;c({material:k,path:w,name:M,kind:T?"md":"text",error:Oe(I)})}},[m]),h=l?m(l.material,l.path,{download:!0}):null,g=l?.material==="rubric"?f.benchmark.rubric:f.benchmark.taskMaterials,v={img:({src:k,alt:w})=>r.jsx("img",{src:typeof k=="string"&&!Mw.test(k)?m(l?.material??"statement",Ew(Aw(l?.path??""),k)):k,alt:w??"",loading:"lazy",className:"max-w-full"}),a:({href:k,children:w})=>{if(typeof k!="string"||k.startsWith("#"))return r.jsx("a",{href:k,children:w});if(Mw.test(k))return r.jsx("a",{href:k,target:"_blank",rel:"noreferrer",children:w});const S=Ew(Aw(l?.path??""),k),M=l?.material??"statement";return r.jsx("a",{href:m(M,S),onClick:C=>{C.preventDefault(),p(M,S)},children:w})}};return r.jsxs("div",{className:"grid min-h-[58vh] overflow-hidden rounded-md border border-gray-200 md:grid-cols-[240px_minmax(0,1fr)] dark:border-gray-800",children:[r.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:r.jsxs("div",{className:"max-h-44 overflow-y-auto md:max-h-[53vh]",children:[r.jsx(_w,{projectId:e,agentId:t,benchmarkId:a,caseSummary:i,material:"statement",label:f.benchmark.taskMaterials,defaultOpen:!0,autoPreviewReadme:!0,onPreview:p}),r.jsx(_w,{projectId:e,agentId:t,benchmarkId:a,caseSummary:i,material:"rubric",label:f.benchmark.rubric,hiddenLabel:f.benchmark.agentHidden,defaultOpen:!0,onPreview:p})]})}),r.jsxs("section",{className:"min-w-0",children:[r.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:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("p",{className:"truncate font-mono text-xs text-gray-500",children:l?`${g} / ${l.path}`:i.id})}),h&&l&&r.jsx("a",{href:h,download:l.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:f.files.download})]}),r.jsx("div",{className:"max-h-[52vh] min-h-[52vh] overflow-auto p-3",children:l?l.loading?r.jsx(La,{rows:8}):l.error?r.jsx("p",{className:"text-sm text-red-500",children:l.error}):l.kind==="image"?r.jsx("img",{src:m(l.material,l.path),alt:l.name,loading:"lazy",className:"max-w-full rounded-md border border-gray-200 dark:border-gray-800"}):l.kind==="pdf"?r.jsx("iframe",{src:m(l.material,l.path),title:l.name,className:"h-[50vh] w-full rounded-md border border-gray-200 dark:border-gray-800"}):l.kind==="md"?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"md-body text-sm text-gray-800 dark:text-gray-100",children:r.jsx(Zc,{remarkPlugins:[Jc],components:v,children:l.content??""})}),l.truncated&&r.jsx("p",{className:"mt-2 text-xs text-gray-400",children:f.files.previewTruncated})]}):l.kind==="text"?r.jsxs(r.Fragment,{children:[r.jsx(T0,{language:iP(l.name),code:l.content??"",highlight:(l.content?.length??0)<=sP}),l.truncated&&r.jsx("p",{className:"mt-2 text-xs text-gray-400",children:f.files.previewTruncated})]}):r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:f.files.previewUnsupported}):r.jsx("p",{className:"text-sm text-gray-400",children:f.benchmark.caseFileUnavailable})})]})]})}function oP({projectId:e,agentId:t,name:a,defaultOpen:i,selection:l,onSelect:c}){const[u,m]=x.useState(i),[p,h]=x.useState(null),[g,v]=x.useState(null);return x.useEffect(()=>{!u||p||lT(e,t).then(k=>h(k.benchmarks)).catch(k=>v(Oe(k)))},[u,p,e,t]),r.jsxs("li",{className:"pt-2.5",children:[r.jsx("div",{className:"flex items-center px-1 pb-0.5",children:r.jsxs("button",{type:"button",onClick:()=>m(k=>!k),"aria-label":u?f.nav.collapseGroup:f.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:[r.jsx(Da,{id:t,name:a,size:18,className:"shrink-0 rounded"}),r.jsx("span",{className:"min-w-0 truncate text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:a}),r.jsx(Yn,{open:u,size:12,className:"text-gray-400"}),r.jsx("span",{className:"min-w-0 flex-1"})]})}),u&&r.jsxs("div",{className:"anim-fade",children:[g&&r.jsx("p",{className:"px-2.5 py-1 text-xs text-red-500",children:g}),!p&&!g&&r.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400",children:f.common.loading}),p&&p.length===0&&r.jsx("p",{className:"px-2.5 py-1 text-xs text-gray-400 dark:text-gray-600",children:f.benchmark.emptyAgent}),r.jsx("ul",{className:"space-y-0.5",children:p?.map(k=>{const w=l?.agentId===t&&l.benchmark.id===k.id;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>c({agentId:t,benchmark:k}),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:[r.jsx(qc,{text:k.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"}`}),r.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-400",children:k.caseCount})]})},k.id)})})]})]})}function cP({evaluations:e,series:t}){const[a,i]=x.useState(null),[l,c]=H0(),u=B5(e),m=J$(u),p=R5(e.length,m.min,m.max,c),h=e.map(g=>Oa(g.time));return r.jsx("div",{ref:l,children:c>0&&r.jsx(F0,{geom:p,fmtY:Ec,dates:h,hover:a,onHover:i,yTicks:m.ticks,bubble:g=>{const v=e[g],k=u[g]??null;return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-gray-400",children:Oa(v.time)}),r.jsxs("p",{className:"font-mono",children:[k===null?"—":Ec(k),v.version!==void 0&&r.jsxs("span",{className:"ml-1.5 text-gray-400",children:["v",v.version]})]}),r.jsxs("p",{className:"font-mono text-gray-400",children:[v.modelId," · ",v.thinkingLevel]})]})},children:t.map((g,v)=>{const k=eP(nP(e,g));return r.jsx("g",{className:g.modelId?L5(v).text:"text-gray-400 dark:text-gray-500",children:k.map((w,S)=>{const M=w.map((C,T)=>`${T===0?"M":"L"}${p.x(C.index)},${p.y(C.value)}`).join(" ");return r.jsxs("g",{children:[w.length>1&&r.jsx("path",{d:M,fill:"none",stroke:"currentColor",strokeWidth:2,opacity:a!==null?.35:1}),w.map(C=>r.jsx("circle",{cx:p.x(C.index),cy:p.y(C.value),r:a===C.index?4:2.5,className:"fill-current",opacity:a!==null&&a!==C.index?.25:1},C.index))]},S)})},g.key===""?"unlabeled":g.key)})})})}function uP({evaluations:e}){const t=tP(e),a=i=>i.modelId?i.thinkingLevel?`${i.modelId} · ${i.thinkingLevel}`:i.modelId:f.benchmark.legendUnlabeled;return r.jsxs("div",{children:[r.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:f.benchmark.trendTitle(f.benchmark.colScore)}),t.length>=2&&r.jsx("div",{className:"mb-1.5 flex flex-wrap items-center gap-x-3 gap-y-1",children:t.map((i,l)=>r.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[r.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-sm ${i.modelId?L5(l).swatch:"bg-gray-400 dark:bg-gray-500"}`}),r.jsx("span",{className:"font-mono",children:a(i)})]},i.key===""?"unlabeled":i.key))}),r.jsx(cP,{evaluations:e,series:t})]})}const Hi="px-3 py-2";function dP({agentId:e,evaluation:t,caseTitles:a,onOpenCase:i,currency:l}){const[c,u]=x.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsxs("tr",{onClick:()=>u(m=>!m),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:[r.jsx("td",{className:Hi,children:r.jsxs("span",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Yn,{open:c,size:12,className:"text-gray-400"}),Oa(t.time)]})}),r.jsx("td",{className:`${Hi} font-mono text-xs text-gray-500 dark:text-gray-400`,children:t.version!==void 0?`v${t.version}`:"—"}),r.jsx("td",{className:`${Hi} max-w-40 truncate font-mono text-xs text-gray-500 dark:text-gray-400`,title:t.provider,children:t.modelId}),r.jsx("td",{className:`${Hi} font-mono text-xs text-gray-500 dark:text-gray-400`,children:t.thinkingLevel}),r.jsx("td",{className:`${Hi} font-mono text-xs font-semibold tabular-nums`,children:Ec(t.score)}),r.jsx("td",{className:`${Hi} font-mono text-xs tabular-nums text-gray-500 dark:text-gray-400`,children:Dr(t.cost,l)}),r.jsx("td",{className:`${Hi} font-mono text-xs tabular-nums text-gray-500 dark:text-gray-400`,children:t.durationMs!==void 0?An(t.durationMs):"—"})]}),c&&r.jsx("tr",{className:"border-b border-gray-100 last:border-b-0 dark:border-gray-800/60",children:r.jsxs("td",{colSpan:7,className:"bg-gray-50/80 px-3 py-2 dark:bg-gray-950/40",children:[(t.summaryTitle||t.summary)&&r.jsxs("div",{className:"mb-2",children:[t.summaryTitle?r.jsx("p",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:t.summaryTitle}):r.jsx("p",{className:"text-xs font-semibold text-gray-500",children:f.benchmark.summaryLabel}),t.summary&&r.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-xs text-gray-600 dark:text-gray-300",children:t.summary})]}),r.jsxs("table",{className:"w-full text-left",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-xs text-gray-500",children:[r.jsx("th",{className:"px-2 py-1 font-medium",children:f.benchmark.colCase}),r.jsx("th",{className:"px-2 py-1 font-medium",children:f.benchmark.colScore}),r.jsx("th",{className:"px-2 py-1 font-medium",children:f.common.cost}),r.jsx("th",{className:"px-2 py-1 font-medium",children:f.benchmark.colDuration}),r.jsx("th",{className:"px-2 py-1 font-medium",children:f.benchmark.colSession})]})}),r.jsx("tbody",{children:t.cases.map(m=>r.jsx(mP,{agentId:e,caseScore:m,title:a.get(m.case),onOpenCase:a.has(m.case)?i:void 0,currency:l},m.case))})]})]})})]})}function fP({agentId:e,sessionId:t}){return t?r.jsx(Fg,{to:`/traces?agentId=${encodeURIComponent(e)}&sessionId=${encodeURIComponent(t)}`,className:"font-mono text-gray-600 underline decoration-gray-300 underline-offset-2 hover:text-gray-900 dark:text-gray-300 dark:decoration-gray-600 dark:hover:text-gray-100",title:t,children:t}):r.jsx("span",{className:"text-gray-400",children:"—"})}function mP({agentId:e,caseScore:t,title:a,onOpenCase:i,currency:l}){const[c,u]=x.useState(!1),m=t.runs;return r.jsxs(r.Fragment,{children:[r.jsxs("tr",{onClick:()=>u(p=>!p),className:"cursor-pointer text-xs transition-colors duration-150 hover:bg-gray-100/70 dark:hover:bg-gray-800/40",children:[r.jsx("td",{className:"px-2 py-1",children:r.jsxs("span",{className:"flex items-start gap-1.5",children:[r.jsx(Yn,{open:c,size:12,className:"text-gray-400"}),r.jsxs("span",{className:"min-w-0",children:[i?r.jsx("button",{type:"button",className:"block text-left font-medium text-gray-800 hover:underline dark:text-gray-200",onClick:p=>{p.stopPropagation(),i(t.case)},children:a??t.case}):r.jsx("span",{className:"block font-medium text-gray-800 dark:text-gray-200",children:a??t.case}),a&&a!==t.case&&r.jsx("span",{className:"block font-mono text-[11px] text-gray-400",children:t.case})]})]})}),r.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:Ec(t.score)}),r.jsx("td",{className:"px-2 py-1 font-mono tabular-nums text-gray-500 dark:text-gray-400",children:Dr(t.cost,l)}),r.jsx("td",{className:"px-2 py-1 font-mono tabular-nums text-gray-500 dark:text-gray-400",children:t.durationMs!==void 0?An(t.durationMs):"—"}),r.jsx("td",{className:"px-2 py-1",children:r.jsx("span",{className:"text-gray-400",children:"—"})})]}),c&&m.map((p,h)=>r.jsxs("tr",{className:"text-xs text-gray-500 dark:text-gray-400",children:[r.jsxs("td",{className:"py-1 pl-7 pr-2 font-mono",children:[f.benchmark.colRun," #",h+1]}),r.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:Ec(p.score)}),r.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:Dr(p.cost,l)}),r.jsx("td",{className:"px-2 py-1 font-mono tabular-nums",children:p.durationMs!==void 0?An(p.durationMs):"—"}),r.jsx("td",{className:"px-2 py-1",children:r.jsx(fP,{agentId:e,...p.sessionId?{sessionId:p.sessionId}:{}})})]},h))]})}function pP({cases:e,error:t,onOpenCase:a}){return r.jsxs("div",{children:[r.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:f.benchmark.cases}),r.jsxs("div",{className:"overflow-hidden rounded-md border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[t&&r.jsx("p",{className:"px-3 py-2 text-xs text-red-500",children:t}),!e&&!t&&r.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:f.common.loading}),e?.map(i=>r.jsxs("button",{type:"button",onClick:()=>a(i.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:[r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium text-gray-800 dark:text-gray-200",children:i.title}),r.jsx("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:i.id})]}),r.jsx("span",{className:"shrink-0 rounded-md px-2.5 py-1 text-xs font-medium text-gray-600 dark:text-gray-300",children:f.benchmark.viewCase})]},i.id))]})]})}function hP(){Jr(f.benchmark.title);const{currentProject:e,agents:t,agentsLoading:a}=cn(),{currency:i}=mi(),l=e?.projectId??null,[c]=vf(),u=c.get("agentId"),[m,p]=x.useState(null),[h,g]=x.useState(null),[v,k]=x.useState(null),[w,S]=x.useState(null);if(x.useEffect(()=>{p(null)},[l]),x.useEffect(()=>{if(g(null),k(null),S(null),!l||!m)return;let D=!1;return oT(l,m.agentId,m.benchmark.id).then(K=>{D||g(K.cases)}).catch(K=>{D||k(Oe(K))}),()=>{D=!0}},[l,m]),!l)return null;const M=m?.benchmark??null,C=M?[...M.evaluations]:[],T=new Map(h?.map(D=>[D.id,D.title])??[]),I=h?.find(D=>D.id===w)??null;return r.jsxs("div",{className:"flex h-full flex-col md:flex-row",children:[r.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:[r.jsx("p",{className:"px-3 pb-1 text-xs font-bold uppercase tracking-wide text-gray-500",children:f.benchmark.title}),a?r.jsx(La,{rows:4}):r.jsx("ul",{children:t.map(D=>r.jsx(oP,{projectId:l,agentId:D.agentId,name:pn(D),defaultOpen:u===null||u===D.agentId,selection:m,onSelect:p},D.agentId))})]}),r.jsx("section",{className:"min-w-0 flex-1 overflow-y-auto p-3 md:p-4",children:m&&M?r.jsxs("div",{className:"mx-auto max-w-4xl space-y-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[r.jsx("h1",{className:"min-w-0 truncate text-lg font-semibold",children:M.title}),r.jsx("span",{className:"text-xs text-gray-500",children:f.benchmark.caseCount(M.caseCount)})]}),M.description&&r.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:M.description})]}),r.jsx(pP,{cases:h,error:v,onOpenCase:S}),C.length===0?r.jsx(Xr,{title:f.benchmark.noEvaluations}):r.jsxs(r.Fragment,{children:[r.jsx(uP,{evaluations:C}),r.jsxs("div",{children:[r.jsx("p",{className:"mb-1 text-xs font-semibold text-gray-500",children:f.benchmark.evaluations}),r.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:r.jsxs("table",{className:"w-full min-w-[720px] text-left text-sm",children:[r.jsx("thead",{children:r.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:[r.jsx("th",{className:"px-3 py-2.5",children:f.common.time}),r.jsx("th",{className:"px-3 py-2.5",children:f.benchmark.colVersion}),r.jsx("th",{className:"px-3 py-2.5",children:f.benchmark.colModel}),r.jsx("th",{className:"px-3 py-2.5",children:f.benchmark.colThinkingLevel}),r.jsx("th",{className:"px-3 py-2.5",children:f.benchmark.colScore}),r.jsx("th",{className:"px-3 py-2.5",children:f.common.cost}),r.jsx("th",{className:"px-3 py-2.5",children:f.benchmark.colDuration})]})}),r.jsx("tbody",{children:[...C].reverse().map((D,K)=>r.jsx(dP,{agentId:m.agentId,evaluation:D,caseTitles:T,onOpenCase:S,currency:i},K))})]})})]})]}),I&&r.jsx(Xt,{open:!0,title:I.title,widthClass:"sm:max-w-6xl",onClose:()=>S(null),children:r.jsx(lP,{projectId:l,agentId:m.agentId,benchmarkId:M.id,caseSummary:I})})]},`${m.agentId}/${M.id}`):r.jsx(Xr,{title:f.benchmark.selectBenchmark})})]})}function gP(){Jr(f.admin.users);const{user:e,desktopMode:t}=vn(),[a,i]=x.useState(null),[l,c]=x.useState(null),[u,m]=x.useState(!1),[p,h]=x.useState(null),[g,v]=x.useState(null),k=x.useCallback(async()=>{try{i((await s4()).users),c(null)}catch(w){c(Oe(w))}},[]);return x.useEffect(()=>{e?.isAdmin&&!t&&k()},[e?.isAdmin,t,k]),e&&(!e.isAdmin||t)?r.jsx(Mc,{to:"/chat",replace:!0}):r.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6",children:[r.jsxs("div",{className:"mx-auto max-w-3xl",children:[r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsx("h1",{className:"text-xl font-semibold",children:f.admin.users}),r.jsx(ve,{variant:"primary",onClick:()=>m(!0),children:f.admin.createUser})]}),a===null?r.jsx("p",{className:"text-sm text-gray-400",children:f.common.loading}):r.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.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:[r.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:f.common.username}),r.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:f.common.role}),r.jsx("th",{className:"whitespace-nowrap px-3 py-2 font-medium",children:f.common.created}),r.jsx("th",{className:"whitespace-nowrap px-3 py-2 text-right font-medium",children:f.common.actions})]})}),r.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:a.map(w=>r.jsxs("tr",{children:[r.jsxs("td",{className:"whitespace-nowrap px-3 py-2 font-medium",children:[w.userId,w.passwordIsInitial&&r.jsx("span",{className:"ml-2 align-middle",children:r.jsx(Cn,{tone:"gray",children:f.admin.initialPasswordFlag})})]}),r.jsx("td",{className:"whitespace-nowrap px-3 py-2",children:r.jsx(Cn,{tone:"gray",children:w.isAdmin?f.admin.roleAdmin:f.admin.roleUser})}),r.jsx("td",{className:"whitespace-nowrap px-3 py-2 text-gray-500 dark:text-gray-400",children:Oa(w.createdAt)}),r.jsxs("td",{className:"whitespace-nowrap px-3 py-1.5 text-right",children:[r.jsx(ve,{size:"sm",variant:"ghost",onClick:()=>h(w),children:f.admin.resetPassword}),!w.isAdmin&&r.jsx(ve,{size:"sm",variant:"ghost",onClick:()=>v(w),children:f.common.delete})]})]},w.userId))})]})}),l&&r.jsx("p",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]}),r.jsx(xP,{open:u,onClose:()=>m(!1),onDone:()=>{m(!1),k()}}),r.jsx(yP,{user:p,onClose:()=>h(null)}),r.jsx(vP,{user:g,onClose:()=>v(null),onDone:()=>{v(null),k()}})]})}function xP({open:e,onClose:t,onDone:a}){const[i,l]=x.useState(""),[c,u]=x.useState(""),[m,p]=x.useState({}),[h,g]=x.useState(!1),v=()=>p(w=>w.userId||w.password?{}:w);x.useEffect(()=>{e&&(l(""),u(""),p({}))},[e]);const k=async()=>{const w=i.trim(),S={};if(w?Hk.test(w)||(S.userId=f.auth.usernameHint):S.userId=f.common.requiredField,c||(S.password=f.common.requiredField),S.userId||S.password){p(S);return}g(!0),p({});try{await i4({userId:w,password:c}),a()}catch(M){M instanceof sa&&M.code==="invalid_password"?p({password:Oe(M)}):p({userId:Oe(M)})}finally{g(!1)}};return r.jsx(Xt,{open:e,title:f.admin.createUser,onClose:t,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:t,disabled:h,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:h,onClick:()=>{k()},children:f.common.create})]}),children:r.jsxs("div",{className:"space-y-3",children:[r.jsx(rt,{label:f.common.username,required:!0,size:"sm",value:i,onChange:w=>{l(w.target.value),v()},error:m.userId,hint:f.auth.usernameHint,autoFocus:!0}),r.jsx(ci,{label:f.admin.initialPassword,required:!0,size:"sm",value:c,onChange:w=>{u(w.target.value),v()},error:m.password,autoComplete:"new-password",hint:f.auth.passwordHint}),Hk.test(i.trim())&&r.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:f.admin.defaultProjectNote(`${i.trim()}-default_project`)})]})})}function yP({user:e,onClose:t}){const[a,i]=x.useState(""),[l,c]=x.useState(void 0),[u,m]=x.useState(!1);x.useEffect(()=>{e&&(i(""),c(void 0))},[e]);const p=async()=>{if(e){if(!a){c(f.common.requiredField);return}m(!0),c(void 0);try{await l4(e.userId,{password:a}),t()}catch(h){c(Oe(h))}finally{m(!1)}}};return r.jsx(Xt,{open:e!==null,title:e?f.admin.resetPasswordTitle(e.userId):"",onClose:t,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:t,disabled:u,children:f.common.cancel}),r.jsx(ve,{variant:"primary",disabled:u,onClick:()=>{p()},children:f.common.save})]}),children:r.jsxs("div",{className:"space-y-3",children:[r.jsx(ci,{label:f.admin.initialPassword,required:!0,size:"sm",value:a,onChange:h=>{i(h.target.value),c(void 0)},error:l,autoComplete:"new-password",hint:f.auth.passwordHint,autoFocus:!0}),r.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:f.admin.resetPasswordNote})]})})}function vP({user:e,onClose:t,onDone:a}){const[i,l]=x.useState(!1),[c,u]=x.useState(null),[m,p]=x.useState(!1);x.useEffect(()=>{e&&(l(!1),u(null))},[e]);const h=async()=>{if(e){p(!0),u(null);try{await o4(e.userId),a()}catch(g){u(Oe(g))}finally{p(!1)}}};return r.jsx(Xt,{open:e!==null,title:e?f.admin.deleteUserTitle(e.userId):"",onClose:t,footer:r.jsxs(r.Fragment,{children:[r.jsx(ve,{onClick:t,disabled:m,children:f.common.cancel}),i?r.jsx(ve,{variant:"danger",disabled:m,onClick:()=>{h()},children:f.common.confirm}):r.jsx(ve,{variant:"danger",onClick:()=>l(!0),children:f.common.delete})]}),children:r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:e?f.admin.deleteUserConfirm(e.userId):""}),c&&r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:c})]})})}function bP(){const{user:e}=vn();return e===void 0?null:e===null?r.jsx(Mc,{to:"/login",replace:!0}):r.jsx(r3,{children:r.jsx(m3,{children:r.jsx(sU,{})})})}function kP(){const{user:e}=vn();return e?r.jsx(Mc,{to:"/chat",replace:!0}):r.jsx(pU,{})}function wP(){return r.jsx(WM,{children:r.jsxs(kM,{children:[r.jsx(Ra,{path:"/login",element:r.jsx(kP,{})}),r.jsxs(Ra,{element:r.jsx(bP,{}),children:[r.jsx(Ra,{index:!0,element:r.jsx(Mc,{to:"/chat",replace:!0})}),r.jsx(Ra,{path:"/chat/:sessionId?",element:r.jsx(_9,{})}),r.jsx(Ra,{path:"/agents",element:r.jsx(xU,{})}),r.jsx(Ra,{path:"/agents/:agentId",element:r.jsx(tz,{})}),r.jsx(Ra,{path:"/skills",element:r.jsx(dz,{})}),r.jsx(Ra,{path:"/models",element:r.jsx(Hz,{})}),r.jsx(Ra,{path:"/usage",element:r.jsx(S$,{})}),r.jsx(Ra,{path:"/traces",element:r.jsx(X$,{})}),r.jsx(Ra,{path:"/benchmark",element:r.jsx(hP,{})}),r.jsx(Ra,{path:"/admin/users",element:r.jsx(gP,{})}),r.jsx(Ra,{path:"*",element:r.jsx(Mc,{to:"/chat",replace:!0})})]})]})})}function SP(){return x.useEffect(()=>(window.addEventListener("dragover",dk),window.addEventListener("drop",fk),()=>{window.removeEventListener("dragover",dk),window.removeEventListener("drop",fk)}),[]),r.jsx(qN,{children:r.jsx(JN,{children:r.jsx(gT,{children:r.jsxs(GN,{children:[r.jsx(wP,{}),r.jsx(bA,{})]})})})})}const F5=document.getElementById("root");if(!F5)throw new Error("#root mount point not found");zN.createRoot(F5).render(r.jsx(x.StrictMode,{children:r.jsx(SP,{})}));export{WD as L,ln as _,zE as a,e6 as b,q1 as c,QE as f,JE as h,CP as i,jP as r,u0 as s,FE as w};