@anhlp/alp-cli 0.0.1-beta.6 → 0.0.1-beta.8

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.
@@ -0,0 +1,59 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-BbYa_Xkd.js","assets/TerminalPanel-DLuoa74B.css"])))=>i.map(i=>d[i]);
2
+ function Lk(s,t){for(var i=0;i<t.length;i++){const a=t[i];if(typeof a!="string"&&!Array.isArray(a)){for(const l in a)if(l!=="default"&&!(l in s)){const u=Object.getOwnPropertyDescriptor(a,l);u&&Object.defineProperty(s,l,u.get?u:{enumerable:!0,get:()=>a[l]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))a(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function i(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function a(l){if(l.ep)return;l.ep=!0;const u=i(l);fetch(l.href,u)}})();function Ok(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var _d={exports:{}},Lr={};var gx;function Dk(){if(gx)return Lr;gx=1;var s=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function i(a,l,u){var d=null;if(u!==void 0&&(d=""+u),l.key!==void 0&&(d=""+l.key),"key"in l){u={};for(var h in l)h!=="key"&&(u[h]=l[h])}else u=l;return l=u.ref,{$$typeof:s,type:a,key:d,ref:l!==void 0?l:null,props:u}}return Lr.Fragment=t,Lr.jsx=i,Lr.jsxs=i,Lr}var xx;function qk(){return xx||(xx=1,_d.exports=Dk()),_d.exports}var o=qk(),Ld={exports:{}},Ie={};var yx;function Bk(){if(yx)return Ie;yx=1;var s=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=y&&T[y]||T["@@iterator"],typeof T=="function"?T:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,S={};function A(T,z,F){this.props=T,this.context=z,this.refs=S,this.updater=F||k}A.prototype.isReactComponent={},A.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=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,T,z,"setState")},A.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function R(){}R.prototype=A.prototype;function q(T,z,F){this.props=T,this.context=z,this.refs=S,this.updater=F||k}var O=q.prototype=new R;O.constructor=q,j(O,A.prototype),O.isPureReactComponent=!0;var L=Array.isArray,B={H:null,A:null,T:null,S:null,V:null},_=Object.prototype.hasOwnProperty;function Q(T,z,F,J,le,ne){return F=ne.ref,{$$typeof:s,type:T,key:z,ref:F!==void 0?F:null,props:ne}}function C(T,z){return Q(T.type,z,void 0,void 0,void 0,T.props)}function Y(T){return typeof T=="object"&&T!==null&&T.$$typeof===s}function H(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(F){return z[F]})}var fe=/\/+/g;function ee(T,z){return typeof T=="object"&&T!==null&&T.key!=null?H(""+T.key):z.toString(36)}function xe(){}function re(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(xe,xe):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function de(T,z,F,J,le){var ne=typeof T;(ne==="undefined"||ne==="boolean")&&(T=null);var ce=!1;if(T===null)ce=!0;else switch(ne){case"bigint":case"string":case"number":ce=!0;break;case"object":switch(T.$$typeof){case s:case t:ce=!0;break;case x:return ce=T._init,de(ce(T._payload),z,F,J,le)}}if(ce)return le=le(T),ce=J===""?"."+ee(T,0):J,L(le)?(F="",ce!=null&&(F=ce.replace(fe,"$&/")+"/"),de(le,z,F,"",function(Me){return Me})):le!=null&&(Y(le)&&(le=C(le,F+(le.key==null||T&&T.key===le.key?"":(""+le.key).replace(fe,"$&/")+"/")+ce)),z.push(le)),1;ce=0;var ve=J===""?".":J+":";if(L(T))for(var Re=0;Re<T.length;Re++)J=T[Re],ne=ve+ee(J,Re),ce+=de(J,z,F,ne,le);else if(Re=w(T),typeof Re=="function")for(T=Re.call(T),Re=0;!(J=T.next()).done;)J=J.value,ne=ve+ee(J,Re++),ce+=de(J,z,F,ne,le);else if(ne==="object"){if(typeof T.then=="function")return de(re(T),z,F,J,le);throw z=String(T),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(T).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.")}return ce}function U(T,z,F){if(T==null)return T;var J=[],le=0;return de(T,J,"","",function(ne){return z.call(F,ne,le++)}),J}function Z(T){if(T._status===-1){var z=T._result;z=z(),z.then(function(F){(T._status===0||T._status===-1)&&(T._status=1,T._result=F)},function(F){(T._status===0||T._status===-1)&&(T._status=2,T._result=F)}),T._status===-1&&(T._status=0,T._result=z)}if(T._status===1)return T._result.default;throw T._result}var oe=typeof reportError=="function"?reportError:function(T){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof T=="object"&&T!==null&&typeof T.message=="string"?String(T.message):String(T),error:T});if(!window.dispatchEvent(z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",T);return}console.error(T)};function ge(){}return Ie.Children={map:U,forEach:function(T,z,F){U(T,function(){z.apply(this,arguments)},F)},count:function(T){var z=0;return U(T,function(){z++}),z},toArray:function(T){return U(T,function(z){return z})||[]},only:function(T){if(!Y(T))throw Error("React.Children.only expected to receive a single React element child.");return T}},Ie.Component=A,Ie.Fragment=i,Ie.Profiler=l,Ie.PureComponent=q,Ie.StrictMode=a,Ie.Suspense=m,Ie.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,Ie.__COMPILER_RUNTIME={__proto__:null,c:function(T){return B.H.useMemoCache(T)}},Ie.cache=function(T){return function(){return T.apply(null,arguments)}},Ie.cloneElement=function(T,z,F){if(T==null)throw Error("The argument must be a React element, but you passed "+T+".");var J=j({},T.props),le=T.key,ne=void 0;if(z!=null)for(ce in z.ref!==void 0&&(ne=void 0),z.key!==void 0&&(le=""+z.key),z)!_.call(z,ce)||ce==="key"||ce==="__self"||ce==="__source"||ce==="ref"&&z.ref===void 0||(J[ce]=z[ce]);var ce=arguments.length-2;if(ce===1)J.children=F;else if(1<ce){for(var ve=Array(ce),Re=0;Re<ce;Re++)ve[Re]=arguments[Re+2];J.children=ve}return Q(T.type,le,void 0,void 0,ne,J)},Ie.createContext=function(T){return T={$$typeof:d,_currentValue:T,_currentValue2:T,_threadCount:0,Provider:null,Consumer:null},T.Provider=T,T.Consumer={$$typeof:u,_context:T},T},Ie.createElement=function(T,z,F){var J,le={},ne=null;if(z!=null)for(J in z.key!==void 0&&(ne=""+z.key),z)_.call(z,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(le[J]=z[J]);var ce=arguments.length-2;if(ce===1)le.children=F;else if(1<ce){for(var ve=Array(ce),Re=0;Re<ce;Re++)ve[Re]=arguments[Re+2];le.children=ve}if(T&&T.defaultProps)for(J in ce=T.defaultProps,ce)le[J]===void 0&&(le[J]=ce[J]);return Q(T,ne,void 0,void 0,null,le)},Ie.createRef=function(){return{current:null}},Ie.forwardRef=function(T){return{$$typeof:h,render:T}},Ie.isValidElement=Y,Ie.lazy=function(T){return{$$typeof:x,_payload:{_status:-1,_result:T},_init:Z}},Ie.memo=function(T,z){return{$$typeof:p,type:T,compare:z===void 0?null:z}},Ie.startTransition=function(T){var z=B.T,F={};B.T=F;try{var J=T(),le=B.S;le!==null&&le(F,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(ge,oe)}catch(ne){oe(ne)}finally{B.T=z}},Ie.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()},Ie.use=function(T){return B.H.use(T)},Ie.useActionState=function(T,z,F){return B.H.useActionState(T,z,F)},Ie.useCallback=function(T,z){return B.H.useCallback(T,z)},Ie.useContext=function(T){return B.H.useContext(T)},Ie.useDebugValue=function(){},Ie.useDeferredValue=function(T,z){return B.H.useDeferredValue(T,z)},Ie.useEffect=function(T,z,F){var J=B.H;if(typeof F=="function")throw Error("useEffect CRUD overload is not enabled in this build of React.");return J.useEffect(T,z)},Ie.useId=function(){return B.H.useId()},Ie.useImperativeHandle=function(T,z,F){return B.H.useImperativeHandle(T,z,F)},Ie.useInsertionEffect=function(T,z){return B.H.useInsertionEffect(T,z)},Ie.useLayoutEffect=function(T,z){return B.H.useLayoutEffect(T,z)},Ie.useMemo=function(T,z){return B.H.useMemo(T,z)},Ie.useOptimistic=function(T,z){return B.H.useOptimistic(T,z)},Ie.useReducer=function(T,z,F){return B.H.useReducer(T,z,F)},Ie.useRef=function(T){return B.H.useRef(T)},Ie.useState=function(T){return B.H.useState(T)},Ie.useSyncExternalStore=function(T,z,F){return B.H.useSyncExternalStore(T,z,F)},Ie.useTransition=function(){return B.H.useTransition()},Ie.version="19.1.0",Ie}var bx;function Vf(){return bx||(bx=1,Ld.exports=Bk()),Ld.exports}var b=Vf();const $k=Ok(b),Uk=Lk({__proto__:null,default:$k},[b]);var Od={exports:{}},Or={},Dd={exports:{}},qd={};var vx;function Hk(){return vx||(vx=1,(function(s){function t(U,Z){var oe=U.length;U.push(Z);e:for(;0<oe;){var ge=oe-1>>>1,T=U[ge];if(0<l(T,Z))U[ge]=Z,U[oe]=T,oe=ge;else break e}}function i(U){return U.length===0?null:U[0]}function a(U){if(U.length===0)return null;var Z=U[0],oe=U.pop();if(oe!==Z){U[0]=oe;e:for(var ge=0,T=U.length,z=T>>>1;ge<z;){var F=2*(ge+1)-1,J=U[F],le=F+1,ne=U[le];if(0>l(J,oe))le<T&&0>l(ne,J)?(U[ge]=ne,U[le]=oe,ge=le):(U[ge]=J,U[F]=oe,ge=F);else if(le<T&&0>l(ne,oe))U[ge]=ne,U[le]=oe,ge=le;else break e}}return Z}function l(U,Z){var oe=U.sortIndex-Z.sortIndex;return oe!==0?oe:U.id-Z.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;s.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();s.unstable_now=function(){return d.now()-h}}var m=[],p=[],x=1,y=null,w=3,k=!1,j=!1,S=!1,A=!1,R=typeof setTimeout=="function"?setTimeout:null,q=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function L(U){for(var Z=i(p);Z!==null;){if(Z.callback===null)a(p);else if(Z.startTime<=U)a(p),Z.sortIndex=Z.expirationTime,t(m,Z);else break;Z=i(p)}}function B(U){if(S=!1,L(U),!j)if(i(m)!==null)j=!0,_||(_=!0,ee());else{var Z=i(p);Z!==null&&de(B,Z.startTime-U)}}var _=!1,Q=-1,C=5,Y=-1;function H(){return A?!0:!(s.unstable_now()-Y<C)}function fe(){if(A=!1,_){var U=s.unstable_now();Y=U;var Z=!0;try{e:{j=!1,S&&(S=!1,q(Q),Q=-1),k=!0;var oe=w;try{t:{for(L(U),y=i(m);y!==null&&!(y.expirationTime>U&&H());){var ge=y.callback;if(typeof ge=="function"){y.callback=null,w=y.priorityLevel;var T=ge(y.expirationTime<=U);if(U=s.unstable_now(),typeof T=="function"){y.callback=T,L(U),Z=!0;break t}y===i(m)&&a(m),L(U)}else a(m);y=i(m)}if(y!==null)Z=!0;else{var z=i(p);z!==null&&de(B,z.startTime-U),Z=!1}}break e}finally{y=null,w=oe,k=!1}Z=void 0}}finally{Z?ee():_=!1}}}var ee;if(typeof O=="function")ee=function(){O(fe)};else if(typeof MessageChannel<"u"){var xe=new MessageChannel,re=xe.port2;xe.port1.onmessage=fe,ee=function(){re.postMessage(null)}}else ee=function(){R(fe,0)};function de(U,Z){Q=R(function(){U(s.unstable_now())},Z)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(U){U.callback=null},s.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):C=0<U?Math.floor(1e3/U):5},s.unstable_getCurrentPriorityLevel=function(){return w},s.unstable_next=function(U){switch(w){case 1:case 2:case 3:var Z=3;break;default:Z=w}var oe=w;w=Z;try{return U()}finally{w=oe}},s.unstable_requestPaint=function(){A=!0},s.unstable_runWithPriority=function(U,Z){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var oe=w;w=U;try{return Z()}finally{w=oe}},s.unstable_scheduleCallback=function(U,Z,oe){var ge=s.unstable_now();switch(typeof oe=="object"&&oe!==null?(oe=oe.delay,oe=typeof oe=="number"&&0<oe?ge+oe:ge):oe=ge,U){case 1:var T=-1;break;case 2:T=250;break;case 5:T=1073741823;break;case 4:T=1e4;break;default:T=5e3}return T=oe+T,U={id:x++,callback:Z,priorityLevel:U,startTime:oe,expirationTime:T,sortIndex:-1},oe>ge?(U.sortIndex=oe,t(p,U),i(m)===null&&U===i(p)&&(S?(q(Q),Q=-1):S=!0,de(B,oe-ge))):(U.sortIndex=T,t(m,U),j||k||(j=!0,_||(_=!0,ee()))),U},s.unstable_shouldYield=H,s.unstable_wrapCallback=function(U){var Z=w;return function(){var oe=w;w=Z;try{return U.apply(this,arguments)}finally{w=oe}}}})(qd)),qd}var wx;function Ik(){return wx||(wx=1,Dd.exports=Hk()),Dd.exports}var Bd={exports:{}},Pt={};var kx;function Gk(){if(kx)return Pt;kx=1;var s=Vf();function t(m){var p="https://react.dev/errors/"+m;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var x=2;x<arguments.length;x++)p+="&args[]="+encodeURIComponent(arguments[x])}return"Minified React error #"+m+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var a={d:{f:i,r:function(){throw Error(t(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},l=Symbol.for("react.portal");function u(m,p,x){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:l,key:y==null?null:""+y,children:m,containerInfo:p,implementation:x}}var d=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(m,p){if(m==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Pt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Pt.createPortal=function(m,p){var x=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return u(m,p,null,x)},Pt.flushSync=function(m){var p=d.T,x=a.p;try{if(d.T=null,a.p=2,m)return m()}finally{d.T=p,a.p=x,a.d.f()}},Pt.preconnect=function(m,p){typeof m=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,a.d.C(m,p))},Pt.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Pt.preinit=function(m,p){if(typeof m=="string"&&p&&typeof p.as=="string"){var x=p.as,y=h(x,p.crossOrigin),w=typeof p.integrity=="string"?p.integrity:void 0,k=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;x==="style"?a.d.S(m,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:y,integrity:w,fetchPriority:k}):x==="script"&&a.d.X(m,{crossOrigin:y,integrity:w,fetchPriority:k,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Pt.preinitModule=function(m,p){if(typeof m=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var x=h(p.as,p.crossOrigin);a.d.M(m,{crossOrigin:x,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&a.d.M(m)},Pt.preload=function(m,p){if(typeof m=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var x=p.as,y=h(x,p.crossOrigin);a.d.L(m,x,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},Pt.preloadModule=function(m,p){if(typeof m=="string")if(p){var x=h(p.as,p.crossOrigin);a.d.m(m,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:x,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else a.d.m(m)},Pt.requestFormReset=function(m){a.d.r(m)},Pt.unstable_batchedUpdates=function(m,p){return m(p)},Pt.useFormState=function(m,p,x){return d.H.useFormState(m,p,x)},Pt.useFormStatus=function(){return d.H.useHostTransitionStatus()},Pt.version="19.1.0",Pt}var jx;function Yk(){if(jx)return Bd.exports;jx=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(t){console.error(t)}}return s(),Bd.exports=Gk(),Bd.exports}var Sx;function Vk(){if(Sx)return Or;Sx=1;var s=Ik(),t=Vf(),i=Yk();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)n+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var n=e,r=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(r=n.return),e=n.return;while(e)}return n.tag===3?r:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(u(e)!==e)throw Error(a(188))}function m(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(a(188));return n!==e?null:e}for(var r=e,c=n;;){var f=r.return;if(f===null)break;var g=f.alternate;if(g===null){if(c=f.return,c!==null){r=c;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===r)return h(f),e;if(g===c)return h(f),n;g=g.sibling}throw Error(a(188))}if(r.return!==c.return)r=f,c=g;else{for(var v=!1,N=f.child;N;){if(N===r){v=!0,r=f,c=g;break}if(N===c){v=!0,c=f,r=g;break}N=N.sibling}if(!v){for(N=g.child;N;){if(N===r){v=!0,r=g,c=f;break}if(N===c){v=!0,c=g,r=f;break}N=N.sibling}if(!v)throw Error(a(189))}}if(r.alternate!==c)throw Error(a(190))}if(r.tag!==3)throw Error(a(188));return r.stateNode.current===r?e:n}function p(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=p(e),n!==null)return n;e=e.sibling}return null}var x=Object.assign,y=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),q=Symbol.for("react.consumer"),O=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),H=Symbol.for("react.memo_cache_sentinel"),fe=Symbol.iterator;function ee(e){return e===null||typeof e!="object"?null:(e=fe&&e[fe]||e["@@iterator"],typeof e=="function"?e:null)}var xe=Symbol.for("react.client.reference");function re(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===xe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case j:return"Fragment";case A:return"Profiler";case S:return"StrictMode";case B:return"Suspense";case _:return"SuspenseList";case Y:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case O:return(e.displayName||"Context")+".Provider";case q:return(e._context.displayName||"Context")+".Consumer";case L:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Q:return n=e.displayName||null,n!==null?n:re(e.type)||"Memo";case C:n=e._payload,e=e._init;try{return re(e(n))}catch{}}return null}var de=Array.isArray,U=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},ge=[],T=-1;function z(e){return{current:e}}function F(e){0>T||(e.current=ge[T],ge[T]=null,T--)}function J(e,n){T++,ge[T]=e.current,e.current=n}var le=z(null),ne=z(null),ce=z(null),ve=z(null);function Re(e,n){switch(J(ce,n),J(ne,e),J(le,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Yg(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Yg(n),e=Vg(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}F(le),J(le,e)}function Me(){F(le),F(ne),F(ce)}function Qe(e){e.memoizedState!==null&&J(ve,e);var n=le.current,r=Vg(n,e.type);n!==r&&(J(ne,e),J(le,r))}function Ue(e){ne.current===e&&(F(le),F(ne)),ve.current===e&&(F(ve),Er._currentValue=oe)}var et=Object.prototype.hasOwnProperty,Fe=s.unstable_scheduleCallback,be=s.unstable_cancelCallback,ye=s.unstable_shouldYield,Ae=s.unstable_requestPaint,Ne=s.unstable_now,Ht=s.unstable_getCurrentPriorityLevel,cn=s.unstable_ImmediatePriority,ze=s.unstable_UserBlockingPriority,ut=s.unstable_NormalPriority,At=s.unstable_LowPriority,Rt=s.unstable_IdlePriority,In=s.log,kn=s.unstable_setDisableYieldValue,Qt=null,Je=null;function jt(e){if(typeof In=="function"&&kn(e),Je&&typeof Je.setStrictMode=="function")try{Je.setStrictMode(Qt,e)}catch{}}var St=Math.clz32?Math.clz32:js,un=Math.log,Gn=Math.LN2;function js(e){return e>>>=0,e===0?32:31-(un(e)/Gn|0)|0}var dn=256,fn=4194304;function Ct(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194048;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function jn(e,n,r){var c=e.pendingLanes;if(c===0)return 0;var f=0,g=e.suspendedLanes,v=e.pingedLanes;e=e.warmLanes;var N=c&134217727;return N!==0?(c=N&~g,c!==0?f=Ct(c):(v&=N,v!==0?f=Ct(v):r||(r=N&~e,r!==0&&(f=Ct(r))))):(N=c&~g,N!==0?f=Ct(N):v!==0?f=Ct(v):r||(r=c&~e,r!==0&&(f=Ct(r)))),f===0?0:n!==0&&n!==f&&(n&g)===0&&(g=f&-f,r=n&-n,g>=r||g===32&&(r&4194048)!==0)?n:f}function E(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function V(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 ue(){var e=dn;return dn<<=1,(dn&4194048)===0&&(dn=256),e}function he(){var e=fn;return fn<<=1,(fn&62914560)===0&&(fn=4194304),e}function pe(e){for(var n=[],r=0;31>r;r++)n.push(e);return n}function $e(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function We(e,n,r,c,f,g){var v=e.pendingLanes;e.pendingLanes=r,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=r,e.entangledLanes&=r,e.errorRecoveryDisabledLanes&=r,e.shellSuspendCounter=0;var N=e.entanglements,M=e.expirationTimes,K=e.hiddenUpdates;for(r=v&~r;0<r;){var te=31-St(r),ae=1<<te;N[te]=0,M[te]=-1;var X=K[te];if(X!==null)for(K[te]=null,te=0;te<X.length;te++){var P=X[te];P!==null&&(P.lane&=-536870913)}r&=~ae}c!==0&&ft(e,c,0),g!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=g&~(v&~n))}function ft(e,n,r){e.pendingLanes|=n,e.suspendedLanes&=~n;var c=31-St(n);e.entangledLanes|=n,e.entanglements[c]=e.entanglements[c]|1073741824|r&4194090}function W(e,n){var r=e.entangledLanes|=n;for(e=e.entanglements;r;){var c=31-St(r),f=1<<c;f&n|e[c]&n&&(e[c]|=n),r&=~f}}function me(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ht(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Wt(){var e=Z.p;return e!==0?e:(e=window.event,e===void 0?32:ux(e.type))}function mt(e,n){var r=Z.p;try{return Z.p=e,n()}finally{Z.p=r}}var bt=Math.random().toString(36).slice(2),gt="__reactFiber$"+bt,Et="__reactProps$"+bt,Sn="__reactContainer$"+bt,Nc="__reactEvents$"+bt,Sv="__reactListeners$"+bt,Nv="__reactHandles$"+bt,Rh="__reactResources$"+bt,Ua="__reactMarker$"+bt;function Tc(e){delete e[gt],delete e[Et],delete e[Nc],delete e[Sv],delete e[Nv]}function Ii(e){var n=e[gt];if(n)return n;for(var r=e.parentNode;r;){if(n=r[Sn]||r[gt]){if(r=n.alternate,n.child!==null||r!==null&&r.child!==null)for(e=Pg(e);e!==null;){if(r=e[gt])return r;e=Pg(e)}return n}e=r,r=e.parentNode}return null}function Gi(e){if(e=e[gt]||e[Sn]){var n=e.tag;if(n===5||n===6||n===13||n===26||n===27||n===3)return e}return null}function Ha(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function Yi(e){var n=e[Rh];return n||(n=e[Rh]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function qt(e){e[Ua]=!0}var _h=new Set,Lh={};function ri(e,n){Vi(e,n),Vi(e+"Capture",n)}function Vi(e,n){for(Lh[e]=n,e=0;e<n.length;e++)_h.add(n[e])}var Tv=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]*$"),Oh={},Dh={};function Av(e){return et.call(Dh,e)?!0:et.call(Oh,e)?!1:Tv.test(e)?Dh[e]=!0:(Oh[e]=!0,!1)}function mo(e,n,r){if(Av(n))if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var c=n.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+r)}}function po(e,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+r)}}function es(e,n,r,c){if(c===null)e.removeAttribute(r);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttributeNS(n,r,""+c)}}var Ac,qh;function Ki(e){if(Ac===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);Ac=n&&n[1]||"",qh=-1<r.stack.indexOf(`
3
+ at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
4
+ `+Ac+e+qh}var Cc=!1;function Ec(e,n){if(!e||Cc)return"";Cc=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(n){var ae=function(){throw Error()};if(Object.defineProperty(ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ae,[])}catch(P){var X=P}Reflect.construct(e,[],ae)}else{try{ae.call()}catch(P){X=P}e.call(ae.prototype)}}else{try{throw Error()}catch(P){X=P}(ae=e())&&typeof ae.catch=="function"&&ae.catch(function(){})}}catch(P){if(P&&X&&typeof P.stack=="string")return[P.stack,X.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=c.DetermineComponentFrameRoot(),v=g[0],N=g[1];if(v&&N){var M=v.split(`
5
+ `),K=N.split(`
6
+ `);for(f=c=0;c<M.length&&!M[c].includes("DetermineComponentFrameRoot");)c++;for(;f<K.length&&!K[f].includes("DetermineComponentFrameRoot");)f++;if(c===M.length||f===K.length)for(c=M.length-1,f=K.length-1;1<=c&&0<=f&&M[c]!==K[f];)f--;for(;1<=c&&0<=f;c--,f--)if(M[c]!==K[f]){if(c!==1||f!==1)do if(c--,f--,0>f||M[c]!==K[f]){var te=`
7
+ `+M[c].replace(" at new "," at ");return e.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",e.displayName)),te}while(1<=c&&0<=f);break}}}finally{Cc=!1,Error.prepareStackTrace=r}return(r=e?e.displayName||e.name:"")?Ki(r):""}function Cv(e){switch(e.tag){case 26:case 27:case 5:return Ki(e.type);case 16:return Ki("Lazy");case 13:return Ki("Suspense");case 19:return Ki("SuspenseList");case 0:case 15:return Ec(e.type,!1);case 11:return Ec(e.type.render,!1);case 1:return Ec(e.type,!0);case 31:return Ki("Activity");default:return""}}function Bh(e){try{var n="";do n+=Cv(e),e=e.return;while(e);return n}catch(r){return`
8
+ Error generating stack: `+r.message+`
9
+ `+r.stack}}function Nn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function $h(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Ev(e){var n=$h(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),c=""+e[n];if(!e.hasOwnProperty(n)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var f=r.get,g=r.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(v){c=""+v,g.call(this,v)}}),Object.defineProperty(e,n,{enumerable:r.enumerable}),{getValue:function(){return c},setValue:function(v){c=""+v},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function go(e){e._valueTracker||(e._valueTracker=Ev(e))}function Uh(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var r=n.getValue(),c="";return e&&(c=$h(e)?e.checked?"true":"false":e.value),e=c,e!==r?(n.setValue(e),!0):!1}function xo(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Mv=/[\n"\\]/g;function Tn(e){return e.replace(Mv,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Mc(e,n,r,c,f,g,v,N){e.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?e.type=v:e.removeAttribute("type"),n!=null?v==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Nn(n)):e.value!==""+Nn(n)&&(e.value=""+Nn(n)):v!=="submit"&&v!=="reset"||e.removeAttribute("value"),n!=null?zc(e,v,Nn(n)):r!=null?zc(e,v,Nn(r)):c!=null&&e.removeAttribute("value"),f==null&&g!=null&&(e.defaultChecked=!!g),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?e.name=""+Nn(N):e.removeAttribute("name")}function Hh(e,n,r,c,f,g,v,N){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||r!=null){if(!(g!=="submit"&&g!=="reset"||n!=null))return;r=r!=null?""+Nn(r):"",n=n!=null?""+Nn(n):r,N||n===e.value||(e.value=n),e.defaultValue=n}c=c??f,c=typeof c!="function"&&typeof c!="symbol"&&!!c,e.checked=N?e.checked:!!c,e.defaultChecked=!!c,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(e.name=v)}function zc(e,n,r){n==="number"&&xo(e.ownerDocument)===e||e.defaultValue===""+r||(e.defaultValue=""+r)}function Fi(e,n,r,c){if(e=e.options,n){n={};for(var f=0;f<r.length;f++)n["$"+r[f]]=!0;for(r=0;r<e.length;r++)f=n.hasOwnProperty("$"+e[r].value),e[r].selected!==f&&(e[r].selected=f),f&&c&&(e[r].defaultSelected=!0)}else{for(r=""+Nn(r),n=null,f=0;f<e.length;f++){if(e[f].value===r){e[f].selected=!0,c&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function Ih(e,n,r){if(n!=null&&(n=""+Nn(n),n!==e.value&&(e.value=n),r==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=r!=null?""+Nn(r):""}function Gh(e,n,r,c){if(n==null){if(c!=null){if(r!=null)throw Error(a(92));if(de(c)){if(1<c.length)throw Error(a(93));c=c[0]}r=c}r==null&&(r=""),n=r}r=Nn(n),e.defaultValue=r,c=e.textContent,c===r&&c!==""&&c!==null&&(e.value=c)}function Xi(e,n){if(n){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=n;return}}e.textContent=n}var zv=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 Yh(e,n,r){var c=n.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?c?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":c?e.setProperty(n,r):typeof r!="number"||r===0||zv.has(n)?n==="float"?e.cssFloat=r:e[n]=(""+r).trim():e[n]=r+"px"}function Vh(e,n,r){if(n!=null&&typeof n!="object")throw Error(a(62));if(e=e.style,r!=null){for(var c in r)!r.hasOwnProperty(c)||n!=null&&n.hasOwnProperty(c)||(c.indexOf("--")===0?e.setProperty(c,""):c==="float"?e.cssFloat="":e[c]="");for(var f in n)c=n[f],n.hasOwnProperty(f)&&r[f]!==c&&Yh(e,f,c)}else for(var g in n)n.hasOwnProperty(g)&&Yh(e,g,n[g])}function Rc(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rv=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"]]),_v=/^[\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 yo(e){return _v.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var _c=null;function Lc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Pi=null,Qi=null;function Kh(e){var n=Gi(e);if(n&&(e=n.stateNode)){var r=e[Et]||null;e:switch(e=n.stateNode,n.type){case"input":if(Mc(e,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),n=r.name,r.type==="radio"&&n!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+Tn(""+n)+'"][type="radio"]'),n=0;n<r.length;n++){var c=r[n];if(c!==e&&c.form===e.form){var f=c[Et]||null;if(!f)throw Error(a(90));Mc(c,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<r.length;n++)c=r[n],c.form===e.form&&Uh(c)}break e;case"textarea":Ih(e,r.value,r.defaultValue);break e;case"select":n=r.value,n!=null&&Fi(e,!!r.multiple,n,!1)}}}var Oc=!1;function Fh(e,n,r){if(Oc)return e(n,r);Oc=!0;try{var c=e(n);return c}finally{if(Oc=!1,(Pi!==null||Qi!==null)&&(sl(),Pi&&(n=Pi,e=Qi,Qi=Pi=null,Kh(n),e)))for(n=0;n<e.length;n++)Kh(e[n])}}function Ia(e,n){var r=e.stateNode;if(r===null)return null;var c=r[Et]||null;if(c===null)return null;r=c[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(e=e.type,c=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!c;break e;default:e=!1}if(e)return null;if(r&&typeof r!="function")throw Error(a(231,n,typeof r));return r}var ts=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Dc=!1;if(ts)try{var Ga={};Object.defineProperty(Ga,"passive",{get:function(){Dc=!0}}),window.addEventListener("test",Ga,Ga),window.removeEventListener("test",Ga,Ga)}catch{Dc=!1}var Ss=null,qc=null,bo=null;function Xh(){if(bo)return bo;var e,n=qc,r=n.length,c,f="value"in Ss?Ss.value:Ss.textContent,g=f.length;for(e=0;e<r&&n[e]===f[e];e++);var v=r-e;for(c=1;c<=v&&n[r-c]===f[g-c];c++);return bo=f.slice(e,1<c?1-c:void 0)}function vo(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function wo(){return!0}function Ph(){return!1}function tn(e){function n(r,c,f,g,v){this._reactName=r,this._targetInst=f,this.type=c,this.nativeEvent=g,this.target=v,this.currentTarget=null;for(var N in e)e.hasOwnProperty(N)&&(r=e[N],this[N]=r?r(g):g[N]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?wo:Ph,this.isPropagationStopped=Ph,this}return x(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=wo)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=wo)},persist:function(){},isPersistent:wo}),n}var oi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ko=tn(oi),Ya=x({},oi,{view:0,detail:0}),Lv=tn(Ya),Bc,$c,Va,jo=x({},Ya,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Hc,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Va&&(Va&&e.type==="mousemove"?(Bc=e.screenX-Va.screenX,$c=e.screenY-Va.screenY):$c=Bc=0,Va=e),Bc)},movementY:function(e){return"movementY"in e?e.movementY:$c}}),Qh=tn(jo),Ov=x({},jo,{dataTransfer:0}),Dv=tn(Ov),qv=x({},Ya,{relatedTarget:0}),Uc=tn(qv),Bv=x({},oi,{animationName:0,elapsedTime:0,pseudoElement:0}),$v=tn(Bv),Uv=x({},oi,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Hv=tn(Uv),Iv=x({},oi,{data:0}),Wh=tn(Iv),Gv={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Yv={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"},Vv={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Kv(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Vv[e])?!!n[e]:!1}function Hc(){return Kv}var Fv=x({},Ya,{key:function(e){if(e.key){var n=Gv[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=vo(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Yv[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Hc,charCode:function(e){return e.type==="keypress"?vo(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?vo(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Xv=tn(Fv),Pv=x({},jo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Zh=tn(Pv),Qv=x({},Ya,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Hc}),Wv=tn(Qv),Zv=x({},oi,{propertyName:0,elapsedTime:0,pseudoElement:0}),Jv=tn(Zv),ew=x({},jo,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),tw=tn(ew),nw=x({},oi,{newState:0,oldState:0}),sw=tn(nw),iw=[9,13,27,32],Ic=ts&&"CompositionEvent"in window,Ka=null;ts&&"documentMode"in document&&(Ka=document.documentMode);var aw=ts&&"TextEvent"in window&&!Ka,Jh=ts&&(!Ic||Ka&&8<Ka&&11>=Ka),em=" ",tm=!1;function nm(e,n){switch(e){case"keyup":return iw.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sm(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wi=!1;function rw(e,n){switch(e){case"compositionend":return sm(n);case"keypress":return n.which!==32?null:(tm=!0,em);case"textInput":return e=n.data,e===em&&tm?null:e;default:return null}}function ow(e,n){if(Wi)return e==="compositionend"||!Ic&&nm(e,n)?(e=Xh(),bo=qc=Ss=null,Wi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Jh&&n.locale!=="ko"?null:n.data;default:return null}}var lw={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 im(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!lw[e.type]:n==="textarea"}function am(e,n,r,c){Pi?Qi?Qi.push(c):Qi=[c]:Pi=c,n=cl(n,"onChange"),0<n.length&&(r=new ko("onChange","change",null,r,c),e.push({event:r,listeners:n}))}var Fa=null,Xa=null;function cw(e){$g(e,0)}function So(e){var n=Ha(e);if(Uh(n))return e}function rm(e,n){if(e==="change")return n}var om=!1;if(ts){var Gc;if(ts){var Yc="oninput"in document;if(!Yc){var lm=document.createElement("div");lm.setAttribute("oninput","return;"),Yc=typeof lm.oninput=="function"}Gc=Yc}else Gc=!1;om=Gc&&(!document.documentMode||9<document.documentMode)}function cm(){Fa&&(Fa.detachEvent("onpropertychange",um),Xa=Fa=null)}function um(e){if(e.propertyName==="value"&&So(Xa)){var n=[];am(n,Xa,e,Lc(e)),Fh(cw,n)}}function uw(e,n,r){e==="focusin"?(cm(),Fa=n,Xa=r,Fa.attachEvent("onpropertychange",um)):e==="focusout"&&cm()}function dw(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return So(Xa)}function fw(e,n){if(e==="click")return So(n)}function hw(e,n){if(e==="input"||e==="change")return So(n)}function mw(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var hn=typeof Object.is=="function"?Object.is:mw;function Pa(e,n){if(hn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var r=Object.keys(e),c=Object.keys(n);if(r.length!==c.length)return!1;for(c=0;c<r.length;c++){var f=r[c];if(!et.call(n,f)||!hn(e[f],n[f]))return!1}return!0}function dm(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fm(e,n){var r=dm(e);e=0;for(var c;r;){if(r.nodeType===3){if(c=e+r.textContent.length,e<=n&&c>=n)return{node:r,offset:n-e};e=c}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=dm(r)}}function hm(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?hm(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function mm(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=xo(e.document);n instanceof e.HTMLIFrameElement;){try{var r=typeof n.contentWindow.location.href=="string"}catch{r=!1}if(r)e=n.contentWindow;else break;n=xo(e.document)}return n}function Vc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var pw=ts&&"documentMode"in document&&11>=document.documentMode,Zi=null,Kc=null,Qa=null,Fc=!1;function pm(e,n,r){var c=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Fc||Zi==null||Zi!==xo(c)||(c=Zi,"selectionStart"in c&&Vc(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Qa&&Pa(Qa,c)||(Qa=c,c=cl(Kc,"onSelect"),0<c.length&&(n=new ko("onSelect","select",null,n,r),e.push({event:n,listeners:c}),n.target=Zi)))}function li(e,n){var r={};return r[e.toLowerCase()]=n.toLowerCase(),r["Webkit"+e]="webkit"+n,r["Moz"+e]="moz"+n,r}var Ji={animationend:li("Animation","AnimationEnd"),animationiteration:li("Animation","AnimationIteration"),animationstart:li("Animation","AnimationStart"),transitionrun:li("Transition","TransitionRun"),transitionstart:li("Transition","TransitionStart"),transitioncancel:li("Transition","TransitionCancel"),transitionend:li("Transition","TransitionEnd")},Xc={},gm={};ts&&(gm=document.createElement("div").style,"AnimationEvent"in window||(delete Ji.animationend.animation,delete Ji.animationiteration.animation,delete Ji.animationstart.animation),"TransitionEvent"in window||delete Ji.transitionend.transition);function ci(e){if(Xc[e])return Xc[e];if(!Ji[e])return e;var n=Ji[e],r;for(r in n)if(n.hasOwnProperty(r)&&r in gm)return Xc[e]=n[r];return e}var xm=ci("animationend"),ym=ci("animationiteration"),bm=ci("animationstart"),gw=ci("transitionrun"),xw=ci("transitionstart"),yw=ci("transitioncancel"),vm=ci("transitionend"),wm=new Map,Pc="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(" ");Pc.push("scrollEnd");function qn(e,n){wm.set(e,n),ri(n,[e])}var km=new WeakMap;function An(e,n){if(typeof e=="object"&&e!==null){var r=km.get(e);return r!==void 0?r:(n={value:e,source:n,stack:Bh(n)},km.set(e,n),n)}return{value:e,source:n,stack:Bh(n)}}var Cn=[],ea=0,Qc=0;function No(){for(var e=ea,n=Qc=ea=0;n<e;){var r=Cn[n];Cn[n++]=null;var c=Cn[n];Cn[n++]=null;var f=Cn[n];Cn[n++]=null;var g=Cn[n];if(Cn[n++]=null,c!==null&&f!==null){var v=c.pending;v===null?f.next=f:(f.next=v.next,v.next=f),c.pending=f}g!==0&&jm(r,f,g)}}function To(e,n,r,c){Cn[ea++]=e,Cn[ea++]=n,Cn[ea++]=r,Cn[ea++]=c,Qc|=c,e.lanes|=c,e=e.alternate,e!==null&&(e.lanes|=c)}function Wc(e,n,r,c){return To(e,n,r,c),Ao(e)}function ta(e,n){return To(e,null,null,n),Ao(e)}function jm(e,n,r){e.lanes|=r;var c=e.alternate;c!==null&&(c.lanes|=r);for(var f=!1,g=e.return;g!==null;)g.childLanes|=r,c=g.alternate,c!==null&&(c.childLanes|=r),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(f=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,f&&n!==null&&(f=31-St(r),e=g.hiddenUpdates,c=e[f],c===null?e[f]=[n]:c.push(n),n.lane=r|536870912),g):null}function Ao(e){if(50<wr)throw wr=0,sd=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var na={};function bw(e,n,r,c){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mn(e,n,r,c){return new bw(e,n,r,c)}function Zc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ns(e,n){var r=e.alternate;return r===null?(r=mn(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function Sm(e,n){e.flags&=65011714;var r=e.alternate;return r===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=r.childLanes,e.lanes=r.lanes,e.child=r.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=r.memoizedProps,e.memoizedState=r.memoizedState,e.updateQueue=r.updateQueue,e.type=r.type,n=r.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function Co(e,n,r,c,f,g){var v=0;if(c=e,typeof e=="function")Zc(e)&&(v=1);else if(typeof e=="string")v=wk(e,r,le.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Y:return e=mn(31,r,n,f),e.elementType=Y,e.lanes=g,e;case j:return ui(r.children,f,g,n);case S:v=8,f|=24;break;case A:return e=mn(12,r,n,f|2),e.elementType=A,e.lanes=g,e;case B:return e=mn(13,r,n,f),e.elementType=B,e.lanes=g,e;case _:return e=mn(19,r,n,f),e.elementType=_,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:case O:v=10;break e;case q:v=9;break e;case L:v=11;break e;case Q:v=14;break e;case C:v=16,c=null;break e}v=29,r=Error(a(130,e===null?"null":typeof e,"")),c=null}return n=mn(v,r,n,f),n.elementType=e,n.type=c,n.lanes=g,n}function ui(e,n,r,c){return e=mn(7,e,c,n),e.lanes=r,e}function Jc(e,n,r){return e=mn(6,e,null,n),e.lanes=r,e}function eu(e,n,r){return n=mn(4,e.children!==null?e.children:[],e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var sa=[],ia=0,Eo=null,Mo=0,En=[],Mn=0,di=null,ss=1,is="";function fi(e,n){sa[ia++]=Mo,sa[ia++]=Eo,Eo=e,Mo=n}function Nm(e,n,r){En[Mn++]=ss,En[Mn++]=is,En[Mn++]=di,di=e;var c=ss;e=is;var f=32-St(c)-1;c&=~(1<<f),r+=1;var g=32-St(n)+f;if(30<g){var v=f-f%5;g=(c&(1<<v)-1).toString(32),c>>=v,f-=v,ss=1<<32-St(n)+f|r<<f|c,is=g+e}else ss=1<<g|r<<f|c,is=e}function tu(e){e.return!==null&&(fi(e,1),Nm(e,1,0))}function nu(e){for(;e===Eo;)Eo=sa[--ia],sa[ia]=null,Mo=sa[--ia],sa[ia]=null;for(;e===di;)di=En[--Mn],En[Mn]=null,is=En[--Mn],En[Mn]=null,ss=En[--Mn],En[Mn]=null}var Zt=null,vt=null,nt=!1,hi=null,Yn=!1,su=Error(a(519));function mi(e){var n=Error(a(418,""));throw Ja(An(n,e)),su}function Tm(e){var n=e.stateNode,r=e.type,c=e.memoizedProps;switch(n[gt]=e,n[Et]=c,r){case"dialog":Pe("cancel",n),Pe("close",n);break;case"iframe":case"object":case"embed":Pe("load",n);break;case"video":case"audio":for(r=0;r<jr.length;r++)Pe(jr[r],n);break;case"source":Pe("error",n);break;case"img":case"image":case"link":Pe("error",n),Pe("load",n);break;case"details":Pe("toggle",n);break;case"input":Pe("invalid",n),Hh(n,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0),go(n);break;case"select":Pe("invalid",n);break;case"textarea":Pe("invalid",n),Gh(n,c.value,c.defaultValue,c.children),go(n)}r=c.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||n.textContent===""+r||c.suppressHydrationWarning===!0||Gg(n.textContent,r)?(c.popover!=null&&(Pe("beforetoggle",n),Pe("toggle",n)),c.onScroll!=null&&Pe("scroll",n),c.onScrollEnd!=null&&Pe("scrollend",n),c.onClick!=null&&(n.onclick=ul),n=!0):n=!1,n||mi(e)}function Am(e){for(Zt=e.return;Zt;)switch(Zt.tag){case 5:case 13:Yn=!1;return;case 27:case 3:Yn=!0;return;default:Zt=Zt.return}}function Wa(e){if(e!==Zt)return!1;if(!nt)return Am(e),nt=!0,!1;var n=e.tag,r;if((r=n!==3&&n!==27)&&((r=n===5)&&(r=e.type,r=!(r!=="form"&&r!=="button")||bd(e.type,e.memoizedProps)),r=!r),r&&vt&&mi(e),Am(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));e:{for(e=e.nextSibling,n=0;e;){if(e.nodeType===8)if(r=e.data,r==="/$"){if(n===0){vt=$n(e.nextSibling);break e}n--}else r!=="$"&&r!=="$!"&&r!=="$?"||n++;e=e.nextSibling}vt=null}}else n===27?(n=vt,Us(e.type)?(e=jd,jd=null,vt=e):vt=n):vt=Zt?$n(e.stateNode.nextSibling):null;return!0}function Za(){vt=Zt=null,nt=!1}function Cm(){var e=hi;return e!==null&&(an===null?an=e:an.push.apply(an,e),hi=null),e}function Ja(e){hi===null?hi=[e]:hi.push(e)}var iu=z(null),pi=null,as=null;function Ns(e,n,r){J(iu,n._currentValue),n._currentValue=r}function rs(e){e._currentValue=iu.current,F(iu)}function au(e,n,r){for(;e!==null;){var c=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,c!==null&&(c.childLanes|=n)):c!==null&&(c.childLanes&n)!==n&&(c.childLanes|=n),e===r)break;e=e.return}}function ru(e,n,r,c){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var g=f.dependencies;if(g!==null){var v=f.child;g=g.firstContext;e:for(;g!==null;){var N=g;g=f;for(var M=0;M<n.length;M++)if(N.context===n[M]){g.lanes|=r,N=g.alternate,N!==null&&(N.lanes|=r),au(g.return,r,e),c||(v=null);break e}g=N.next}}else if(f.tag===18){if(v=f.return,v===null)throw Error(a(341));v.lanes|=r,g=v.alternate,g!==null&&(g.lanes|=r),au(v,r,e),v=null}else v=f.child;if(v!==null)v.return=f;else for(v=f;v!==null;){if(v===e){v=null;break}if(f=v.sibling,f!==null){f.return=v.return,v=f;break}v=v.return}f=v}}function er(e,n,r,c){e=null;for(var f=n,g=!1;f!==null;){if(!g){if((f.flags&524288)!==0)g=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var v=f.alternate;if(v===null)throw Error(a(387));if(v=v.memoizedProps,v!==null){var N=f.type;hn(f.pendingProps.value,v.value)||(e!==null?e.push(N):e=[N])}}else if(f===ve.current){if(v=f.alternate,v===null)throw Error(a(387));v.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Er):e=[Er])}f=f.return}e!==null&&ru(n,e,r,c),n.flags|=262144}function zo(e){for(e=e.firstContext;e!==null;){if(!hn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function gi(e){pi=e,as=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Xt(e){return Em(pi,e)}function Ro(e,n){return pi===null&&gi(e),Em(e,n)}function Em(e,n){var r=n._currentValue;if(n={context:n,memoizedValue:r,next:null},as===null){if(e===null)throw Error(a(308));as=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else as=as.next=n;return r}var vw=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(r,c){e.push(c)}};this.abort=function(){n.aborted=!0,e.forEach(function(r){return r()})}},ww=s.unstable_scheduleCallback,kw=s.unstable_NormalPriority,_t={$$typeof:O,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ou(){return{controller:new vw,data:new Map,refCount:0}}function tr(e){e.refCount--,e.refCount===0&&ww(kw,function(){e.controller.abort()})}var nr=null,lu=0,aa=0,ra=null;function jw(e,n){if(nr===null){var r=nr=[];lu=0,aa=ud(),ra={status:"pending",value:void 0,then:function(c){r.push(c)}}}return lu++,n.then(Mm,Mm),n}function Mm(){if(--lu===0&&nr!==null){ra!==null&&(ra.status="fulfilled");var e=nr;nr=null,aa=0,ra=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Sw(e,n){var r=[],c={status:"pending",value:null,reason:null,then:function(f){r.push(f)}};return e.then(function(){c.status="fulfilled",c.value=n;for(var f=0;f<r.length;f++)(0,r[f])(n)},function(f){for(c.status="rejected",c.reason=f,f=0;f<r.length;f++)(0,r[f])(void 0)}),c}var zm=U.S;U.S=function(e,n){typeof n=="object"&&n!==null&&typeof n.then=="function"&&jw(e,n),zm!==null&&zm(e,n)};var xi=z(null);function cu(){var e=xi.current;return e!==null?e:pt.pooledCache}function _o(e,n){n===null?J(xi,xi.current):J(xi,n.pool)}function Rm(){var e=cu();return e===null?null:{parent:_t._currentValue,pool:e}}var sr=Error(a(460)),_m=Error(a(474)),Lo=Error(a(542)),uu={then:function(){}};function Lm(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Oo(){}function Om(e,n,r){switch(r=e[r],r===void 0?e.push(n):r!==n&&(n.then(Oo,Oo),n=r),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,qm(e),e;default:if(typeof n.status=="string")n.then(Oo,Oo);else{if(e=pt,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=n,e.status="pending",e.then(function(c){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=c}},function(c){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=c}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,qm(e),e}throw ir=n,sr}}var ir=null;function Dm(){if(ir===null)throw Error(a(459));var e=ir;return ir=null,e}function qm(e){if(e===sr||e===Lo)throw Error(a(483))}var Ts=!1;function du(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function fu(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function As(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Cs(e,n,r){var c=e.updateQueue;if(c===null)return null;if(c=c.shared,(it&2)!==0){var f=c.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),c.pending=n,n=Ao(e),jm(e,null,r),n}return To(e,c,n,r),Ao(e)}function ar(e,n,r){if(n=n.updateQueue,n!==null&&(n=n.shared,(r&4194048)!==0)){var c=n.lanes;c&=e.pendingLanes,r|=c,n.lanes=r,W(e,r)}}function hu(e,n){var r=e.updateQueue,c=e.alternate;if(c!==null&&(c=c.updateQueue,r===c)){var f=null,g=null;if(r=r.firstBaseUpdate,r!==null){do{var v={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};g===null?f=g=v:g=g.next=v,r=r.next}while(r!==null);g===null?f=g=n:g=g.next=n}else f=g=n;r={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:c.shared,callbacks:c.callbacks},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=n:e.next=n,r.lastBaseUpdate=n}var mu=!1;function rr(){if(mu){var e=ra;if(e!==null)throw e}}function or(e,n,r,c){mu=!1;var f=e.updateQueue;Ts=!1;var g=f.firstBaseUpdate,v=f.lastBaseUpdate,N=f.shared.pending;if(N!==null){f.shared.pending=null;var M=N,K=M.next;M.next=null,v===null?g=K:v.next=K,v=M;var te=e.alternate;te!==null&&(te=te.updateQueue,N=te.lastBaseUpdate,N!==v&&(N===null?te.firstBaseUpdate=K:N.next=K,te.lastBaseUpdate=M))}if(g!==null){var ae=f.baseState;v=0,te=K=M=null,N=g;do{var X=N.lane&-536870913,P=X!==N.lane;if(P?(Ze&X)===X:(c&X)===X){X!==0&&X===aa&&(mu=!0),te!==null&&(te=te.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var De=e,_e=N;X=n;var ct=r;switch(_e.tag){case 1:if(De=_e.payload,typeof De=="function"){ae=De.call(ct,ae,X);break e}ae=De;break e;case 3:De.flags=De.flags&-65537|128;case 0:if(De=_e.payload,X=typeof De=="function"?De.call(ct,ae,X):De,X==null)break e;ae=x({},ae,X);break e;case 2:Ts=!0}}X=N.callback,X!==null&&(e.flags|=64,P&&(e.flags|=8192),P=f.callbacks,P===null?f.callbacks=[X]:P.push(X))}else P={lane:X,tag:N.tag,payload:N.payload,callback:N.callback,next:null},te===null?(K=te=P,M=ae):te=te.next=P,v|=X;if(N=N.next,N===null){if(N=f.shared.pending,N===null)break;P=N,N=P.next,P.next=null,f.lastBaseUpdate=P,f.shared.pending=null}}while(!0);te===null&&(M=ae),f.baseState=M,f.firstBaseUpdate=K,f.lastBaseUpdate=te,g===null&&(f.shared.lanes=0),Ds|=v,e.lanes=v,e.memoizedState=ae}}function Bm(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function $m(e,n){var r=e.callbacks;if(r!==null)for(e.callbacks=null,e=0;e<r.length;e++)Bm(r[e],n)}var oa=z(null),Do=z(0);function Um(e,n){e=hs,J(Do,e),J(oa,n),hs=e|n.baseLanes}function pu(){J(Do,hs),J(oa,oa.current)}function gu(){hs=Do.current,F(oa),F(Do)}var Es=0,Ge=null,ot=null,Mt=null,qo=!1,la=!1,yi=!1,Bo=0,lr=0,ca=null,Nw=0;function Nt(){throw Error(a(321))}function xu(e,n){if(n===null)return!1;for(var r=0;r<n.length&&r<e.length;r++)if(!hn(e[r],n[r]))return!1;return!0}function yu(e,n,r,c,f,g){return Es=g,Ge=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,U.H=e===null||e.memoizedState===null?jp:Sp,yi=!1,g=r(c,f),yi=!1,la&&(g=Im(n,r,c,f)),Hm(e),g}function Hm(e){U.H=Yo;var n=ot!==null&&ot.next!==null;if(Es=0,Mt=ot=Ge=null,qo=!1,lr=0,ca=null,n)throw Error(a(300));e===null||Bt||(e=e.dependencies,e!==null&&zo(e)&&(Bt=!0))}function Im(e,n,r,c){Ge=e;var f=0;do{if(la&&(ca=null),lr=0,la=!1,25<=f)throw Error(a(301));if(f+=1,Mt=ot=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}U.H=Rw,g=n(r,c)}while(la);return g}function Tw(){var e=U.H,n=e.useState()[0];return n=typeof n.then=="function"?cr(n):n,e=e.useState()[0],(ot!==null?ot.memoizedState:null)!==e&&(Ge.flags|=1024),n}function bu(){var e=Bo!==0;return Bo=0,e}function vu(e,n,r){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r}function wu(e){if(qo){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}qo=!1}Es=0,Mt=ot=Ge=null,la=!1,lr=Bo=0,ca=null}function nn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mt===null?Ge.memoizedState=Mt=e:Mt=Mt.next=e,Mt}function zt(){if(ot===null){var e=Ge.alternate;e=e!==null?e.memoizedState:null}else e=ot.next;var n=Mt===null?Ge.memoizedState:Mt.next;if(n!==null)Mt=n,ot=e;else{if(e===null)throw Ge.alternate===null?Error(a(467)):Error(a(310));ot=e,e={memoizedState:ot.memoizedState,baseState:ot.baseState,baseQueue:ot.baseQueue,queue:ot.queue,next:null},Mt===null?Ge.memoizedState=Mt=e:Mt=Mt.next=e}return Mt}function ku(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function cr(e){var n=lr;return lr+=1,ca===null&&(ca=[]),e=Om(ca,e,n),n=Ge,(Mt===null?n.memoizedState:Mt.next)===null&&(n=n.alternate,U.H=n===null||n.memoizedState===null?jp:Sp),e}function $o(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return cr(e);if(e.$$typeof===O)return Xt(e)}throw Error(a(438,String(e)))}function ju(e){var n=null,r=Ge.updateQueue;if(r!==null&&(n=r.memoCache),n==null){var c=Ge.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(n={data:c.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),r===null&&(r=ku(),Ge.updateQueue=r),r.memoCache=n,r=n.data[n.index],r===void 0)for(r=n.data[n.index]=Array(e),c=0;c<e;c++)r[c]=H;return n.index++,r}function os(e,n){return typeof n=="function"?n(e):n}function Uo(e){var n=zt();return Su(n,ot,e)}function Su(e,n,r){var c=e.queue;if(c===null)throw Error(a(311));c.lastRenderedReducer=r;var f=e.baseQueue,g=c.pending;if(g!==null){if(f!==null){var v=f.next;f.next=g.next,g.next=v}n.baseQueue=f=g,c.pending=null}if(g=e.baseState,f===null)e.memoizedState=g;else{n=f.next;var N=v=null,M=null,K=n,te=!1;do{var ae=K.lane&-536870913;if(ae!==K.lane?(Ze&ae)===ae:(Es&ae)===ae){var X=K.revertLane;if(X===0)M!==null&&(M=M.next={lane:0,revertLane:0,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null}),ae===aa&&(te=!0);else if((Es&X)===X){K=K.next,X===aa&&(te=!0);continue}else ae={lane:0,revertLane:K.revertLane,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null},M===null?(N=M=ae,v=g):M=M.next=ae,Ge.lanes|=X,Ds|=X;ae=K.action,yi&&r(g,ae),g=K.hasEagerState?K.eagerState:r(g,ae)}else X={lane:ae,revertLane:K.revertLane,action:K.action,hasEagerState:K.hasEagerState,eagerState:K.eagerState,next:null},M===null?(N=M=X,v=g):M=M.next=X,Ge.lanes|=ae,Ds|=ae;K=K.next}while(K!==null&&K!==n);if(M===null?v=g:M.next=N,!hn(g,e.memoizedState)&&(Bt=!0,te&&(r=ra,r!==null)))throw r;e.memoizedState=g,e.baseState=v,e.baseQueue=M,c.lastRenderedState=g}return f===null&&(c.lanes=0),[e.memoizedState,c.dispatch]}function Nu(e){var n=zt(),r=n.queue;if(r===null)throw Error(a(311));r.lastRenderedReducer=e;var c=r.dispatch,f=r.pending,g=n.memoizedState;if(f!==null){r.pending=null;var v=f=f.next;do g=e(g,v.action),v=v.next;while(v!==f);hn(g,n.memoizedState)||(Bt=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),r.lastRenderedState=g}return[g,c]}function Gm(e,n,r){var c=Ge,f=zt(),g=nt;if(g){if(r===void 0)throw Error(a(407));r=r()}else r=n();var v=!hn((ot||f).memoizedState,r);v&&(f.memoizedState=r,Bt=!0),f=f.queue;var N=Km.bind(null,c,f,e);if(ur(2048,8,N,[e]),f.getSnapshot!==n||v||Mt!==null&&Mt.memoizedState.tag&1){if(c.flags|=2048,ua(9,Ho(),Vm.bind(null,c,f,r,n),null),pt===null)throw Error(a(349));g||(Es&124)!==0||Ym(c,n,r)}return r}function Ym(e,n,r){e.flags|=16384,e={getSnapshot:n,value:r},n=Ge.updateQueue,n===null?(n=ku(),Ge.updateQueue=n,n.stores=[e]):(r=n.stores,r===null?n.stores=[e]:r.push(e))}function Vm(e,n,r,c){n.value=r,n.getSnapshot=c,Fm(n)&&Xm(e)}function Km(e,n,r){return r(function(){Fm(n)&&Xm(e)})}function Fm(e){var n=e.getSnapshot;e=e.value;try{var r=n();return!hn(e,r)}catch{return!0}}function Xm(e){var n=ta(e,2);n!==null&&bn(n,e,2)}function Tu(e){var n=nn();if(typeof e=="function"){var r=e;if(e=r(),yi){jt(!0);try{r()}finally{jt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:os,lastRenderedState:e},n}function Pm(e,n,r,c){return e.baseState=r,Su(e,ot,typeof c=="function"?c:os)}function Aw(e,n,r,c,f){if(Go(e))throw Error(a(485));if(e=n.action,e!==null){var g={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){g.listeners.push(v)}};U.T!==null?r(!0):g.isTransition=!1,c(g),r=n.pending,r===null?(g.next=n.pending=g,Qm(n,g)):(g.next=r.next,n.pending=r.next=g)}}function Qm(e,n){var r=n.action,c=n.payload,f=e.state;if(n.isTransition){var g=U.T,v={};U.T=v;try{var N=r(f,c),M=U.S;M!==null&&M(v,N),Wm(e,n,N)}catch(K){Au(e,n,K)}finally{U.T=g}}else try{g=r(f,c),Wm(e,n,g)}catch(K){Au(e,n,K)}}function Wm(e,n,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(c){Zm(e,n,c)},function(c){return Au(e,n,c)}):Zm(e,n,r)}function Zm(e,n,r){n.status="fulfilled",n.value=r,Jm(n),e.state=r,n=e.pending,n!==null&&(r=n.next,r===n?e.pending=null:(r=r.next,n.next=r,Qm(e,r)))}function Au(e,n,r){var c=e.pending;if(e.pending=null,c!==null){c=c.next;do n.status="rejected",n.reason=r,Jm(n),n=n.next;while(n!==c)}e.action=null}function Jm(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function ep(e,n){return n}function tp(e,n){if(nt){var r=pt.formState;if(r!==null){e:{var c=Ge;if(nt){if(vt){t:{for(var f=vt,g=Yn;f.nodeType!==8;){if(!g){f=null;break t}if(f=$n(f.nextSibling),f===null){f=null;break t}}g=f.data,f=g==="F!"||g==="F"?f:null}if(f){vt=$n(f.nextSibling),c=f.data==="F!";break e}}mi(c)}c=!1}c&&(n=r[0])}}return r=nn(),r.memoizedState=r.baseState=n,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ep,lastRenderedState:n},r.queue=c,r=vp.bind(null,Ge,c),c.dispatch=r,c=Tu(!1),g=Ru.bind(null,Ge,!1,c.queue),c=nn(),f={state:n,dispatch:null,action:e,pending:null},c.queue=f,r=Aw.bind(null,Ge,f,g,r),f.dispatch=r,c.memoizedState=e,[n,r,!1]}function np(e){var n=zt();return sp(n,ot,e)}function sp(e,n,r){if(n=Su(e,n,ep)[0],e=Uo(os)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var c=cr(n)}catch(v){throw v===sr?Lo:v}else c=n;n=zt();var f=n.queue,g=f.dispatch;return r!==n.memoizedState&&(Ge.flags|=2048,ua(9,Ho(),Cw.bind(null,f,r),null)),[c,g,e]}function Cw(e,n){e.action=n}function ip(e){var n=zt(),r=ot;if(r!==null)return sp(n,r,e);zt(),n=n.memoizedState,r=zt();var c=r.queue.dispatch;return r.memoizedState=e,[n,c,!1]}function ua(e,n,r,c){return e={tag:e,create:r,deps:c,inst:n,next:null},n=Ge.updateQueue,n===null&&(n=ku(),Ge.updateQueue=n),r=n.lastEffect,r===null?n.lastEffect=e.next=e:(c=r.next,r.next=e,e.next=c,n.lastEffect=e),e}function Ho(){return{destroy:void 0,resource:void 0}}function ap(){return zt().memoizedState}function Io(e,n,r,c){var f=nn();c=c===void 0?null:c,Ge.flags|=e,f.memoizedState=ua(1|n,Ho(),r,c)}function ur(e,n,r,c){var f=zt();c=c===void 0?null:c;var g=f.memoizedState.inst;ot!==null&&c!==null&&xu(c,ot.memoizedState.deps)?f.memoizedState=ua(n,g,r,c):(Ge.flags|=e,f.memoizedState=ua(1|n,g,r,c))}function rp(e,n){Io(8390656,8,e,n)}function op(e,n){ur(2048,8,e,n)}function lp(e,n){return ur(4,2,e,n)}function cp(e,n){return ur(4,4,e,n)}function up(e,n){if(typeof n=="function"){e=e();var r=n(e);return function(){typeof r=="function"?r():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function dp(e,n,r){r=r!=null?r.concat([e]):null,ur(4,4,up.bind(null,n,e),r)}function Cu(){}function fp(e,n){var r=zt();n=n===void 0?null:n;var c=r.memoizedState;return n!==null&&xu(n,c[1])?c[0]:(r.memoizedState=[e,n],e)}function hp(e,n){var r=zt();n=n===void 0?null:n;var c=r.memoizedState;if(n!==null&&xu(n,c[1]))return c[0];if(c=e(),yi){jt(!0);try{e()}finally{jt(!1)}}return r.memoizedState=[c,n],c}function Eu(e,n,r){return r===void 0||(Es&1073741824)!==0?e.memoizedState=n:(e.memoizedState=r,e=gg(),Ge.lanes|=e,Ds|=e,r)}function mp(e,n,r,c){return hn(r,n)?r:oa.current!==null?(e=Eu(e,r,c),hn(e,n)||(Bt=!0),e):(Es&42)===0?(Bt=!0,e.memoizedState=r):(e=gg(),Ge.lanes|=e,Ds|=e,n)}function pp(e,n,r,c,f){var g=Z.p;Z.p=g!==0&&8>g?g:8;var v=U.T,N={};U.T=N,Ru(e,!1,n,r);try{var M=f(),K=U.S;if(K!==null&&K(N,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var te=Sw(M,c);dr(e,n,te,yn(e))}else dr(e,n,c,yn(e))}catch(ae){dr(e,n,{then:function(){},status:"rejected",reason:ae},yn())}finally{Z.p=g,U.T=v}}function Ew(){}function Mu(e,n,r,c){if(e.tag!==5)throw Error(a(476));var f=gp(e).queue;pp(e,f,n,oe,r===null?Ew:function(){return xp(e),r(c)})}function gp(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:os,lastRenderedState:oe},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:os,lastRenderedState:r},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function xp(e){var n=gp(e).next.queue;dr(e,n,{},yn())}function zu(){return Xt(Er)}function yp(){return zt().memoizedState}function bp(){return zt().memoizedState}function Mw(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var r=yn();e=As(r);var c=Cs(n,e,r);c!==null&&(bn(c,n,r),ar(c,n,r)),n={cache:ou()},e.payload=n;return}n=n.return}}function zw(e,n,r){var c=yn();r={lane:c,revertLane:0,action:r,hasEagerState:!1,eagerState:null,next:null},Go(e)?wp(n,r):(r=Wc(e,n,r,c),r!==null&&(bn(r,e,c),kp(r,n,c)))}function vp(e,n,r){var c=yn();dr(e,n,r,c)}function dr(e,n,r,c){var f={lane:c,revertLane:0,action:r,hasEagerState:!1,eagerState:null,next:null};if(Go(e))wp(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var v=n.lastRenderedState,N=g(v,r);if(f.hasEagerState=!0,f.eagerState=N,hn(N,v))return To(e,n,f,0),pt===null&&No(),!1}catch{}if(r=Wc(e,n,f,c),r!==null)return bn(r,e,c),kp(r,n,c),!0}return!1}function Ru(e,n,r,c){if(c={lane:2,revertLane:ud(),action:c,hasEagerState:!1,eagerState:null,next:null},Go(e)){if(n)throw Error(a(479))}else n=Wc(e,r,c,2),n!==null&&bn(n,e,2)}function Go(e){var n=e.alternate;return e===Ge||n!==null&&n===Ge}function wp(e,n){la=qo=!0;var r=e.pending;r===null?n.next=n:(n.next=r.next,r.next=n),e.pending=n}function kp(e,n,r){if((r&4194048)!==0){var c=n.lanes;c&=e.pendingLanes,r|=c,n.lanes=r,W(e,r)}}var Yo={readContext:Xt,use:$o,useCallback:Nt,useContext:Nt,useEffect:Nt,useImperativeHandle:Nt,useLayoutEffect:Nt,useInsertionEffect:Nt,useMemo:Nt,useReducer:Nt,useRef:Nt,useState:Nt,useDebugValue:Nt,useDeferredValue:Nt,useTransition:Nt,useSyncExternalStore:Nt,useId:Nt,useHostTransitionStatus:Nt,useFormState:Nt,useActionState:Nt,useOptimistic:Nt,useMemoCache:Nt,useCacheRefresh:Nt},jp={readContext:Xt,use:$o,useCallback:function(e,n){return nn().memoizedState=[e,n===void 0?null:n],e},useContext:Xt,useEffect:rp,useImperativeHandle:function(e,n,r){r=r!=null?r.concat([e]):null,Io(4194308,4,up.bind(null,n,e),r)},useLayoutEffect:function(e,n){return Io(4194308,4,e,n)},useInsertionEffect:function(e,n){Io(4,2,e,n)},useMemo:function(e,n){var r=nn();n=n===void 0?null:n;var c=e();if(yi){jt(!0);try{e()}finally{jt(!1)}}return r.memoizedState=[c,n],c},useReducer:function(e,n,r){var c=nn();if(r!==void 0){var f=r(n);if(yi){jt(!0);try{r(n)}finally{jt(!1)}}}else f=n;return c.memoizedState=c.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},c.queue=e,e=e.dispatch=zw.bind(null,Ge,e),[c.memoizedState,e]},useRef:function(e){var n=nn();return e={current:e},n.memoizedState=e},useState:function(e){e=Tu(e);var n=e.queue,r=vp.bind(null,Ge,n);return n.dispatch=r,[e.memoizedState,r]},useDebugValue:Cu,useDeferredValue:function(e,n){var r=nn();return Eu(r,e,n)},useTransition:function(){var e=Tu(!1);return e=pp.bind(null,Ge,e.queue,!0,!1),nn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,r){var c=Ge,f=nn();if(nt){if(r===void 0)throw Error(a(407));r=r()}else{if(r=n(),pt===null)throw Error(a(349));(Ze&124)!==0||Ym(c,n,r)}f.memoizedState=r;var g={value:r,getSnapshot:n};return f.queue=g,rp(Km.bind(null,c,g,e),[e]),c.flags|=2048,ua(9,Ho(),Vm.bind(null,c,g,r,n),null),r},useId:function(){var e=nn(),n=pt.identifierPrefix;if(nt){var r=is,c=ss;r=(c&~(1<<32-St(c)-1)).toString(32)+r,n="«"+n+"R"+r,r=Bo++,0<r&&(n+="H"+r.toString(32)),n+="»"}else r=Nw++,n="«"+n+"r"+r.toString(32)+"»";return e.memoizedState=n},useHostTransitionStatus:zu,useFormState:tp,useActionState:tp,useOptimistic:function(e){var n=nn();n.memoizedState=n.baseState=e;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=r,n=Ru.bind(null,Ge,!0,r),r.dispatch=n,[e,n]},useMemoCache:ju,useCacheRefresh:function(){return nn().memoizedState=Mw.bind(null,Ge)}},Sp={readContext:Xt,use:$o,useCallback:fp,useContext:Xt,useEffect:op,useImperativeHandle:dp,useInsertionEffect:lp,useLayoutEffect:cp,useMemo:hp,useReducer:Uo,useRef:ap,useState:function(){return Uo(os)},useDebugValue:Cu,useDeferredValue:function(e,n){var r=zt();return mp(r,ot.memoizedState,e,n)},useTransition:function(){var e=Uo(os)[0],n=zt().memoizedState;return[typeof e=="boolean"?e:cr(e),n]},useSyncExternalStore:Gm,useId:yp,useHostTransitionStatus:zu,useFormState:np,useActionState:np,useOptimistic:function(e,n){var r=zt();return Pm(r,ot,e,n)},useMemoCache:ju,useCacheRefresh:bp},Rw={readContext:Xt,use:$o,useCallback:fp,useContext:Xt,useEffect:op,useImperativeHandle:dp,useInsertionEffect:lp,useLayoutEffect:cp,useMemo:hp,useReducer:Nu,useRef:ap,useState:function(){return Nu(os)},useDebugValue:Cu,useDeferredValue:function(e,n){var r=zt();return ot===null?Eu(r,e,n):mp(r,ot.memoizedState,e,n)},useTransition:function(){var e=Nu(os)[0],n=zt().memoizedState;return[typeof e=="boolean"?e:cr(e),n]},useSyncExternalStore:Gm,useId:yp,useHostTransitionStatus:zu,useFormState:ip,useActionState:ip,useOptimistic:function(e,n){var r=zt();return ot!==null?Pm(r,ot,e,n):(r.baseState=e,[e,r.queue.dispatch])},useMemoCache:ju,useCacheRefresh:bp},da=null,fr=0;function Vo(e){var n=fr;return fr+=1,da===null&&(da=[]),Om(da,e,n)}function hr(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ko(e,n){throw n.$$typeof===y?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Np(e){var n=e._init;return n(e._payload)}function Tp(e){function n($,D){if(e){var G=$.deletions;G===null?($.deletions=[D],$.flags|=16):G.push(D)}}function r($,D){if(!e)return null;for(;D!==null;)n($,D),D=D.sibling;return null}function c($){for(var D=new Map;$!==null;)$.key!==null?D.set($.key,$):D.set($.index,$),$=$.sibling;return D}function f($,D){return $=ns($,D),$.index=0,$.sibling=null,$}function g($,D,G){return $.index=G,e?(G=$.alternate,G!==null?(G=G.index,G<D?($.flags|=67108866,D):G):($.flags|=67108866,D)):($.flags|=1048576,D)}function v($){return e&&$.alternate===null&&($.flags|=67108866),$}function N($,D,G,se){return D===null||D.tag!==6?(D=Jc(G,$.mode,se),D.return=$,D):(D=f(D,G),D.return=$,D)}function M($,D,G,se){var Se=G.type;return Se===j?te($,D,G.props.children,se,G.key):D!==null&&(D.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===C&&Np(Se)===D.type)?(D=f(D,G.props),hr(D,G),D.return=$,D):(D=Co(G.type,G.key,G.props,null,$.mode,se),hr(D,G),D.return=$,D)}function K($,D,G,se){return D===null||D.tag!==4||D.stateNode.containerInfo!==G.containerInfo||D.stateNode.implementation!==G.implementation?(D=eu(G,$.mode,se),D.return=$,D):(D=f(D,G.children||[]),D.return=$,D)}function te($,D,G,se,Se){return D===null||D.tag!==7?(D=ui(G,$.mode,se,Se),D.return=$,D):(D=f(D,G),D.return=$,D)}function ae($,D,G){if(typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint")return D=Jc(""+D,$.mode,G),D.return=$,D;if(typeof D=="object"&&D!==null){switch(D.$$typeof){case w:return G=Co(D.type,D.key,D.props,null,$.mode,G),hr(G,D),G.return=$,G;case k:return D=eu(D,$.mode,G),D.return=$,D;case C:var se=D._init;return D=se(D._payload),ae($,D,G)}if(de(D)||ee(D))return D=ui(D,$.mode,G,null),D.return=$,D;if(typeof D.then=="function")return ae($,Vo(D),G);if(D.$$typeof===O)return ae($,Ro($,D),G);Ko($,D)}return null}function X($,D,G,se){var Se=D!==null?D.key:null;if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return Se!==null?null:N($,D,""+G,se);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case w:return G.key===Se?M($,D,G,se):null;case k:return G.key===Se?K($,D,G,se):null;case C:return Se=G._init,G=Se(G._payload),X($,D,G,se)}if(de(G)||ee(G))return Se!==null?null:te($,D,G,se,null);if(typeof G.then=="function")return X($,D,Vo(G),se);if(G.$$typeof===O)return X($,D,Ro($,G),se);Ko($,G)}return null}function P($,D,G,se,Se){if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return $=$.get(G)||null,N(D,$,""+se,Se);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case w:return $=$.get(se.key===null?G:se.key)||null,M(D,$,se,Se);case k:return $=$.get(se.key===null?G:se.key)||null,K(D,$,se,Se);case C:var Ve=se._init;return se=Ve(se._payload),P($,D,G,se,Se)}if(de(se)||ee(se))return $=$.get(G)||null,te(D,$,se,Se,null);if(typeof se.then=="function")return P($,D,G,Vo(se),Se);if(se.$$typeof===O)return P($,D,G,Ro(D,se),Se);Ko(D,se)}return null}function De($,D,G,se){for(var Se=null,Ve=null,Ce=D,Le=D=0,Ut=null;Ce!==null&&Le<G.length;Le++){Ce.index>Le?(Ut=Ce,Ce=null):Ut=Ce.sibling;var tt=X($,Ce,G[Le],se);if(tt===null){Ce===null&&(Ce=Ut);break}e&&Ce&&tt.alternate===null&&n($,Ce),D=g(tt,D,Le),Ve===null?Se=tt:Ve.sibling=tt,Ve=tt,Ce=Ut}if(Le===G.length)return r($,Ce),nt&&fi($,Le),Se;if(Ce===null){for(;Le<G.length;Le++)Ce=ae($,G[Le],se),Ce!==null&&(D=g(Ce,D,Le),Ve===null?Se=Ce:Ve.sibling=Ce,Ve=Ce);return nt&&fi($,Le),Se}for(Ce=c(Ce);Le<G.length;Le++)Ut=P(Ce,$,Le,G[Le],se),Ut!==null&&(e&&Ut.alternate!==null&&Ce.delete(Ut.key===null?Le:Ut.key),D=g(Ut,D,Le),Ve===null?Se=Ut:Ve.sibling=Ut,Ve=Ut);return e&&Ce.forEach(function(Vs){return n($,Vs)}),nt&&fi($,Le),Se}function _e($,D,G,se){if(G==null)throw Error(a(151));for(var Se=null,Ve=null,Ce=D,Le=D=0,Ut=null,tt=G.next();Ce!==null&&!tt.done;Le++,tt=G.next()){Ce.index>Le?(Ut=Ce,Ce=null):Ut=Ce.sibling;var Vs=X($,Ce,tt.value,se);if(Vs===null){Ce===null&&(Ce=Ut);break}e&&Ce&&Vs.alternate===null&&n($,Ce),D=g(Vs,D,Le),Ve===null?Se=Vs:Ve.sibling=Vs,Ve=Vs,Ce=Ut}if(tt.done)return r($,Ce),nt&&fi($,Le),Se;if(Ce===null){for(;!tt.done;Le++,tt=G.next())tt=ae($,tt.value,se),tt!==null&&(D=g(tt,D,Le),Ve===null?Se=tt:Ve.sibling=tt,Ve=tt);return nt&&fi($,Le),Se}for(Ce=c(Ce);!tt.done;Le++,tt=G.next())tt=P(Ce,$,Le,tt.value,se),tt!==null&&(e&&tt.alternate!==null&&Ce.delete(tt.key===null?Le:tt.key),D=g(tt,D,Le),Ve===null?Se=tt:Ve.sibling=tt,Ve=tt);return e&&Ce.forEach(function(_k){return n($,_k)}),nt&&fi($,Le),Se}function ct($,D,G,se){if(typeof G=="object"&&G!==null&&G.type===j&&G.key===null&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case w:e:{for(var Se=G.key;D!==null;){if(D.key===Se){if(Se=G.type,Se===j){if(D.tag===7){r($,D.sibling),se=f(D,G.props.children),se.return=$,$=se;break e}}else if(D.elementType===Se||typeof Se=="object"&&Se!==null&&Se.$$typeof===C&&Np(Se)===D.type){r($,D.sibling),se=f(D,G.props),hr(se,G),se.return=$,$=se;break e}r($,D);break}else n($,D);D=D.sibling}G.type===j?(se=ui(G.props.children,$.mode,se,G.key),se.return=$,$=se):(se=Co(G.type,G.key,G.props,null,$.mode,se),hr(se,G),se.return=$,$=se)}return v($);case k:e:{for(Se=G.key;D!==null;){if(D.key===Se)if(D.tag===4&&D.stateNode.containerInfo===G.containerInfo&&D.stateNode.implementation===G.implementation){r($,D.sibling),se=f(D,G.children||[]),se.return=$,$=se;break e}else{r($,D);break}else n($,D);D=D.sibling}se=eu(G,$.mode,se),se.return=$,$=se}return v($);case C:return Se=G._init,G=Se(G._payload),ct($,D,G,se)}if(de(G))return De($,D,G,se);if(ee(G)){if(Se=ee(G),typeof Se!="function")throw Error(a(150));return G=Se.call(G),_e($,D,G,se)}if(typeof G.then=="function")return ct($,D,Vo(G),se);if(G.$$typeof===O)return ct($,D,Ro($,G),se);Ko($,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,D!==null&&D.tag===6?(r($,D.sibling),se=f(D,G),se.return=$,$=se):(r($,D),se=Jc(G,$.mode,se),se.return=$,$=se),v($)):r($,D)}return function($,D,G,se){try{fr=0;var Se=ct($,D,G,se);return da=null,Se}catch(Ce){if(Ce===sr||Ce===Lo)throw Ce;var Ve=mn(29,Ce,null,$.mode);return Ve.lanes=se,Ve.return=$,Ve}}}var fa=Tp(!0),Ap=Tp(!1),zn=z(null),Vn=null;function Ms(e){var n=e.alternate;J(Lt,Lt.current&1),J(zn,e),Vn===null&&(n===null||oa.current!==null||n.memoizedState!==null)&&(Vn=e)}function Cp(e){if(e.tag===22){if(J(Lt,Lt.current),J(zn,e),Vn===null){var n=e.alternate;n!==null&&n.memoizedState!==null&&(Vn=e)}}else zs()}function zs(){J(Lt,Lt.current),J(zn,zn.current)}function ls(e){F(zn),Vn===e&&(Vn=null),F(Lt)}var Lt=z(0);function Fo(e){for(var n=e;n!==null;){if(n.tag===13){var r=n.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||kd(r)))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}function _u(e,n,r,c){n=e.memoizedState,r=r(c,n),r=r==null?n:x({},n,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var Lu={enqueueSetState:function(e,n,r){e=e._reactInternals;var c=yn(),f=As(c);f.payload=n,r!=null&&(f.callback=r),n=Cs(e,f,c),n!==null&&(bn(n,e,c),ar(n,e,c))},enqueueReplaceState:function(e,n,r){e=e._reactInternals;var c=yn(),f=As(c);f.tag=1,f.payload=n,r!=null&&(f.callback=r),n=Cs(e,f,c),n!==null&&(bn(n,e,c),ar(n,e,c))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var r=yn(),c=As(r);c.tag=2,n!=null&&(c.callback=n),n=Cs(e,c,r),n!==null&&(bn(n,e,r),ar(n,e,r))}};function Ep(e,n,r,c,f,g,v){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(c,g,v):n.prototype&&n.prototype.isPureReactComponent?!Pa(r,c)||!Pa(f,g):!0}function Mp(e,n,r,c){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(r,c),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(r,c),n.state!==e&&Lu.enqueueReplaceState(n,n.state,null)}function bi(e,n){var r=n;if("ref"in n){r={};for(var c in n)c!=="ref"&&(r[c]=n[c])}if(e=e.defaultProps){r===n&&(r=x({},r));for(var f in e)r[f]===void 0&&(r[f]=e[f])}return r}var Xo=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)};function zp(e){Xo(e)}function Rp(e){console.error(e)}function _p(e){Xo(e)}function Po(e,n){try{var r=e.onUncaughtError;r(n.value,{componentStack:n.stack})}catch(c){setTimeout(function(){throw c})}}function Lp(e,n,r){try{var c=e.onCaughtError;c(r.value,{componentStack:r.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function Ou(e,n,r){return r=As(r),r.tag=3,r.payload={element:null},r.callback=function(){Po(e,n)},r}function Op(e){return e=As(e),e.tag=3,e}function Dp(e,n,r,c){var f=r.type.getDerivedStateFromError;if(typeof f=="function"){var g=c.value;e.payload=function(){return f(g)},e.callback=function(){Lp(n,r,c)}}var v=r.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(e.callback=function(){Lp(n,r,c),typeof f!="function"&&(qs===null?qs=new Set([this]):qs.add(this));var N=c.stack;this.componentDidCatch(c.value,{componentStack:N!==null?N:""})})}function _w(e,n,r,c,f){if(r.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(n=r.alternate,n!==null&&er(n,r,f,!0),r=zn.current,r!==null){switch(r.tag){case 13:return Vn===null?ad():r.alternate===null&&wt===0&&(wt=3),r.flags&=-257,r.flags|=65536,r.lanes=f,c===uu?r.flags|=16384:(n=r.updateQueue,n===null?r.updateQueue=new Set([c]):n.add(c),od(e,c,f)),!1;case 22:return r.flags|=65536,c===uu?r.flags|=16384:(n=r.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([c])},r.updateQueue=n):(r=n.retryQueue,r===null?n.retryQueue=new Set([c]):r.add(c)),od(e,c,f)),!1}throw Error(a(435,r.tag))}return od(e,c,f),ad(),!1}if(nt)return n=zn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,c!==su&&(e=Error(a(422),{cause:c}),Ja(An(e,r)))):(c!==su&&(n=Error(a(423),{cause:c}),Ja(An(n,r))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,c=An(c,r),f=Ou(e.stateNode,c,f),hu(e,f),wt!==4&&(wt=2)),!1;var g=Error(a(520),{cause:c});if(g=An(g,r),vr===null?vr=[g]:vr.push(g),wt!==4&&(wt=2),n===null)return!0;c=An(c,r),r=n;do{switch(r.tag){case 3:return r.flags|=65536,e=f&-f,r.lanes|=e,e=Ou(r.stateNode,c,e),hu(r,e),!1;case 1:if(n=r.type,g=r.stateNode,(r.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(qs===null||!qs.has(g))))return r.flags|=65536,f&=-f,r.lanes|=f,f=Op(f),Dp(f,e,r,c),hu(r,f),!1}r=r.return}while(r!==null);return!1}var qp=Error(a(461)),Bt=!1;function It(e,n,r,c){n.child=e===null?Ap(n,null,r,c):fa(n,e.child,r,c)}function Bp(e,n,r,c,f){r=r.render;var g=n.ref;if("ref"in c){var v={};for(var N in c)N!=="ref"&&(v[N]=c[N])}else v=c;return gi(n),c=yu(e,n,r,v,g,f),N=bu(),e!==null&&!Bt?(vu(e,n,f),cs(e,n,f)):(nt&&N&&tu(n),n.flags|=1,It(e,n,c,f),n.child)}function $p(e,n,r,c,f){if(e===null){var g=r.type;return typeof g=="function"&&!Zc(g)&&g.defaultProps===void 0&&r.compare===null?(n.tag=15,n.type=g,Up(e,n,g,c,f)):(e=Co(r.type,null,c,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Gu(e,f)){var v=g.memoizedProps;if(r=r.compare,r=r!==null?r:Pa,r(v,c)&&e.ref===n.ref)return cs(e,n,f)}return n.flags|=1,e=ns(g,c),e.ref=n.ref,e.return=n,n.child=e}function Up(e,n,r,c,f){if(e!==null){var g=e.memoizedProps;if(Pa(g,c)&&e.ref===n.ref)if(Bt=!1,n.pendingProps=c=g,Gu(e,f))(e.flags&131072)!==0&&(Bt=!0);else return n.lanes=e.lanes,cs(e,n,f)}return Du(e,n,r,c,f)}function Hp(e,n,r){var c=n.pendingProps,f=c.children,g=e!==null?e.memoizedState:null;if(c.mode==="hidden"){if((n.flags&128)!==0){if(c=g!==null?g.baseLanes|r:r,e!==null){for(f=n.child=e.child,g=0;f!==null;)g=g|f.lanes|f.childLanes,f=f.sibling;n.childLanes=g&~c}else n.childLanes=0,n.child=null;return Ip(e,n,c,r)}if((r&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&_o(n,g!==null?g.cachePool:null),g!==null?Um(n,g):pu(),Cp(n);else return n.lanes=n.childLanes=536870912,Ip(e,n,g!==null?g.baseLanes|r:r,r)}else g!==null?(_o(n,g.cachePool),Um(n,g),zs(),n.memoizedState=null):(e!==null&&_o(n,null),pu(),zs());return It(e,n,f,r),n.child}function Ip(e,n,r,c){var f=cu();return f=f===null?null:{parent:_t._currentValue,pool:f},n.memoizedState={baseLanes:r,cachePool:f},e!==null&&_o(n,null),pu(),Cp(n),e!==null&&er(e,n,c,!0),null}function Qo(e,n){var r=n.ref;if(r===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(a(284));(e===null||e.ref!==r)&&(n.flags|=4194816)}}function Du(e,n,r,c,f){return gi(n),r=yu(e,n,r,c,void 0,f),c=bu(),e!==null&&!Bt?(vu(e,n,f),cs(e,n,f)):(nt&&c&&tu(n),n.flags|=1,It(e,n,r,f),n.child)}function Gp(e,n,r,c,f,g){return gi(n),n.updateQueue=null,r=Im(n,c,r,f),Hm(e),c=bu(),e!==null&&!Bt?(vu(e,n,g),cs(e,n,g)):(nt&&c&&tu(n),n.flags|=1,It(e,n,r,g),n.child)}function Yp(e,n,r,c,f){if(gi(n),n.stateNode===null){var g=na,v=r.contextType;typeof v=="object"&&v!==null&&(g=Xt(v)),g=new r(c,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Lu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=c,g.state=n.memoizedState,g.refs={},du(n),v=r.contextType,g.context=typeof v=="object"&&v!==null?Xt(v):na,g.state=n.memoizedState,v=r.getDerivedStateFromProps,typeof v=="function"&&(_u(n,r,v,c),g.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(v=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),v!==g.state&&Lu.enqueueReplaceState(g,g.state,null),or(n,c,g,f),rr(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),c=!0}else if(e===null){g=n.stateNode;var N=n.memoizedProps,M=bi(r,N);g.props=M;var K=g.context,te=r.contextType;v=na,typeof te=="object"&&te!==null&&(v=Xt(te));var ae=r.getDerivedStateFromProps;te=typeof ae=="function"||typeof g.getSnapshotBeforeUpdate=="function",N=n.pendingProps!==N,te||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(N||K!==v)&&Mp(n,g,c,v),Ts=!1;var X=n.memoizedState;g.state=X,or(n,c,g,f),rr(),K=n.memoizedState,N||X!==K||Ts?(typeof ae=="function"&&(_u(n,r,ae,c),K=n.memoizedState),(M=Ts||Ep(n,r,M,c,X,K,v))?(te||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(n.flags|=4194308)):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=c,n.memoizedState=K),g.props=c,g.state=K,g.context=v,c=M):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),c=!1)}else{g=n.stateNode,fu(e,n),v=n.memoizedProps,te=bi(r,v),g.props=te,ae=n.pendingProps,X=g.context,K=r.contextType,M=na,typeof K=="object"&&K!==null&&(M=Xt(K)),N=r.getDerivedStateFromProps,(K=typeof N=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(v!==ae||X!==M)&&Mp(n,g,c,M),Ts=!1,X=n.memoizedState,g.state=X,or(n,c,g,f),rr();var P=n.memoizedState;v!==ae||X!==P||Ts||e!==null&&e.dependencies!==null&&zo(e.dependencies)?(typeof N=="function"&&(_u(n,r,N,c),P=n.memoizedState),(te=Ts||Ep(n,r,te,c,X,P,M)||e!==null&&e.dependencies!==null&&zo(e.dependencies))?(K||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(c,P,M),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(c,P,M)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(n.flags|=1024),n.memoizedProps=c,n.memoizedState=P),g.props=c,g.state=P,g.context=M,c=te):(typeof g.componentDidUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||v===e.memoizedProps&&X===e.memoizedState||(n.flags|=1024),c=!1)}return g=c,Qo(e,n),c=(n.flags&128)!==0,g||c?(g=n.stateNode,r=c&&typeof r.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&c?(n.child=fa(n,e.child,null,f),n.child=fa(n,null,r,f)):It(e,n,r,f),n.memoizedState=g.state,e=n.child):e=cs(e,n,f),e}function Vp(e,n,r,c){return Za(),n.flags|=256,It(e,n,r,c),n.child}var qu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Bu(e){return{baseLanes:e,cachePool:Rm()}}function $u(e,n,r){return e=e!==null?e.childLanes&~r:0,n&&(e|=Rn),e}function Kp(e,n,r){var c=n.pendingProps,f=!1,g=(n.flags&128)!==0,v;if((v=g)||(v=e!==null&&e.memoizedState===null?!1:(Lt.current&2)!==0),v&&(f=!0,n.flags&=-129),v=(n.flags&32)!==0,n.flags&=-33,e===null){if(nt){if(f?Ms(n):zs(),nt){var N=vt,M;if(M=N){e:{for(M=N,N=Yn;M.nodeType!==8;){if(!N){N=null;break e}if(M=$n(M.nextSibling),M===null){N=null;break e}}N=M}N!==null?(n.memoizedState={dehydrated:N,treeContext:di!==null?{id:ss,overflow:is}:null,retryLane:536870912,hydrationErrors:null},M=mn(18,null,null,0),M.stateNode=N,M.return=n,n.child=M,Zt=n,vt=null,M=!0):M=!1}M||mi(n)}if(N=n.memoizedState,N!==null&&(N=N.dehydrated,N!==null))return kd(N)?n.lanes=32:n.lanes=536870912,null;ls(n)}return N=c.children,c=c.fallback,f?(zs(),f=n.mode,N=Wo({mode:"hidden",children:N},f),c=ui(c,f,r,null),N.return=n,c.return=n,N.sibling=c,n.child=N,f=n.child,f.memoizedState=Bu(r),f.childLanes=$u(e,v,r),n.memoizedState=qu,c):(Ms(n),Uu(n,N))}if(M=e.memoizedState,M!==null&&(N=M.dehydrated,N!==null)){if(g)n.flags&256?(Ms(n),n.flags&=-257,n=Hu(e,n,r)):n.memoizedState!==null?(zs(),n.child=e.child,n.flags|=128,n=null):(zs(),f=c.fallback,N=n.mode,c=Wo({mode:"visible",children:c.children},N),f=ui(f,N,r,null),f.flags|=2,c.return=n,f.return=n,c.sibling=f,n.child=c,fa(n,e.child,null,r),c=n.child,c.memoizedState=Bu(r),c.childLanes=$u(e,v,r),n.memoizedState=qu,n=f);else if(Ms(n),kd(N)){if(v=N.nextSibling&&N.nextSibling.dataset,v)var K=v.dgst;v=K,c=Error(a(419)),c.stack="",c.digest=v,Ja({value:c,source:null,stack:null}),n=Hu(e,n,r)}else if(Bt||er(e,n,r,!1),v=(r&e.childLanes)!==0,Bt||v){if(v=pt,v!==null&&(c=r&-r,c=(c&42)!==0?1:me(c),c=(c&(v.suspendedLanes|r))!==0?0:c,c!==0&&c!==M.retryLane))throw M.retryLane=c,ta(e,c),bn(v,e,c),qp;N.data==="$?"||ad(),n=Hu(e,n,r)}else N.data==="$?"?(n.flags|=192,n.child=e.child,n=null):(e=M.treeContext,vt=$n(N.nextSibling),Zt=n,nt=!0,hi=null,Yn=!1,e!==null&&(En[Mn++]=ss,En[Mn++]=is,En[Mn++]=di,ss=e.id,is=e.overflow,di=n),n=Uu(n,c.children),n.flags|=4096);return n}return f?(zs(),f=c.fallback,N=n.mode,M=e.child,K=M.sibling,c=ns(M,{mode:"hidden",children:c.children}),c.subtreeFlags=M.subtreeFlags&65011712,K!==null?f=ns(K,f):(f=ui(f,N,r,null),f.flags|=2),f.return=n,c.return=n,c.sibling=f,n.child=c,c=f,f=n.child,N=e.child.memoizedState,N===null?N=Bu(r):(M=N.cachePool,M!==null?(K=_t._currentValue,M=M.parent!==K?{parent:K,pool:K}:M):M=Rm(),N={baseLanes:N.baseLanes|r,cachePool:M}),f.memoizedState=N,f.childLanes=$u(e,v,r),n.memoizedState=qu,c):(Ms(n),r=e.child,e=r.sibling,r=ns(r,{mode:"visible",children:c.children}),r.return=n,r.sibling=null,e!==null&&(v=n.deletions,v===null?(n.deletions=[e],n.flags|=16):v.push(e)),n.child=r,n.memoizedState=null,r)}function Uu(e,n){return n=Wo({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function Wo(e,n){return e=mn(22,e,null,n),e.lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Hu(e,n,r){return fa(n,e.child,null,r),e=Uu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Fp(e,n,r){e.lanes|=n;var c=e.alternate;c!==null&&(c.lanes|=n),au(e.return,n,r)}function Iu(e,n,r,c,f){var g=e.memoizedState;g===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:c,tail:r,tailMode:f}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=r,g.tailMode=f)}function Xp(e,n,r){var c=n.pendingProps,f=c.revealOrder,g=c.tail;if(It(e,n,c.children,r),c=Lt.current,(c&2)!==0)c=c&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Fp(e,r,n);else if(e.tag===19)Fp(e,r,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}c&=1}switch(J(Lt,c),f){case"forwards":for(r=n.child,f=null;r!==null;)e=r.alternate,e!==null&&Fo(e)===null&&(f=r),r=r.sibling;r=f,r===null?(f=n.child,n.child=null):(f=r.sibling,r.sibling=null),Iu(n,!1,f,r,g);break;case"backwards":for(r=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Fo(e)===null){n.child=f;break}e=f.sibling,f.sibling=r,r=f,f=e}Iu(n,!0,r,null,g);break;case"together":Iu(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function cs(e,n,r){if(e!==null&&(n.dependencies=e.dependencies),Ds|=n.lanes,(r&n.childLanes)===0)if(e!==null){if(er(e,n,r,!1),(r&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,r=ns(e,e.pendingProps),n.child=r,r.return=n;e.sibling!==null;)e=e.sibling,r=r.sibling=ns(e,e.pendingProps),r.return=n;r.sibling=null}return n.child}function Gu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&zo(e)))}function Lw(e,n,r){switch(n.tag){case 3:Re(n,n.stateNode.containerInfo),Ns(n,_t,e.memoizedState.cache),Za();break;case 27:case 5:Qe(n);break;case 4:Re(n,n.stateNode.containerInfo);break;case 10:Ns(n,n.type,n.memoizedProps.value);break;case 13:var c=n.memoizedState;if(c!==null)return c.dehydrated!==null?(Ms(n),n.flags|=128,null):(r&n.child.childLanes)!==0?Kp(e,n,r):(Ms(n),e=cs(e,n,r),e!==null?e.sibling:null);Ms(n);break;case 19:var f=(e.flags&128)!==0;if(c=(r&n.childLanes)!==0,c||(er(e,n,r,!1),c=(r&n.childLanes)!==0),f){if(c)return Xp(e,n,r);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),J(Lt,Lt.current),c)break;return null;case 22:case 23:return n.lanes=0,Hp(e,n,r);case 24:Ns(n,_t,e.memoizedState.cache)}return cs(e,n,r)}function Pp(e,n,r){if(e!==null)if(e.memoizedProps!==n.pendingProps)Bt=!0;else{if(!Gu(e,r)&&(n.flags&128)===0)return Bt=!1,Lw(e,n,r);Bt=(e.flags&131072)!==0}else Bt=!1,nt&&(n.flags&1048576)!==0&&Nm(n,Mo,n.index);switch(n.lanes=0,n.tag){case 16:e:{e=n.pendingProps;var c=n.elementType,f=c._init;if(c=f(c._payload),n.type=c,typeof c=="function")Zc(c)?(e=bi(c,e),n.tag=1,n=Yp(null,n,c,e,r)):(n.tag=0,n=Du(null,n,c,e,r));else{if(c!=null){if(f=c.$$typeof,f===L){n.tag=11,n=Bp(null,n,c,e,r);break e}else if(f===Q){n.tag=14,n=$p(null,n,c,e,r);break e}}throw n=re(c)||c,Error(a(306,n,""))}}return n;case 0:return Du(e,n,n.type,n.pendingProps,r);case 1:return c=n.type,f=bi(c,n.pendingProps),Yp(e,n,c,f,r);case 3:e:{if(Re(n,n.stateNode.containerInfo),e===null)throw Error(a(387));c=n.pendingProps;var g=n.memoizedState;f=g.element,fu(e,n),or(n,c,null,r);var v=n.memoizedState;if(c=v.cache,Ns(n,_t,c),c!==g.cache&&ru(n,[_t],r,!0),rr(),c=v.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:v.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=Vp(e,n,c,r);break e}else if(c!==f){f=An(Error(a(424)),n),Ja(f),n=Vp(e,n,c,r);break e}else for(e=n.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,vt=$n(e.firstChild),Zt=n,nt=!0,hi=null,Yn=!0,r=Ap(n,null,c,r),n.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Za(),c===f){n=cs(e,n,r);break e}It(e,n,c,r)}n=n.child}return n;case 26:return Qo(e,n),e===null?(r=Jg(n.type,null,n.pendingProps,null))?n.memoizedState=r:nt||(r=n.type,e=n.pendingProps,c=dl(ce.current).createElement(r),c[gt]=n,c[Et]=e,Yt(c,r,e),qt(c),n.stateNode=c):n.memoizedState=Jg(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Qe(n),e===null&&nt&&(c=n.stateNode=Qg(n.type,n.pendingProps,ce.current),Zt=n,Yn=!0,f=vt,Us(n.type)?(jd=f,vt=$n(c.firstChild)):vt=f),It(e,n,n.pendingProps.children,r),Qo(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&nt&&((f=c=vt)&&(c=lk(c,n.type,n.pendingProps,Yn),c!==null?(n.stateNode=c,Zt=n,vt=$n(c.firstChild),Yn=!1,f=!0):f=!1),f||mi(n)),Qe(n),f=n.type,g=n.pendingProps,v=e!==null?e.memoizedProps:null,c=g.children,bd(f,g)?c=null:v!==null&&bd(f,v)&&(n.flags|=32),n.memoizedState!==null&&(f=yu(e,n,Tw,null,null,r),Er._currentValue=f),Qo(e,n),It(e,n,c,r),n.child;case 6:return e===null&&nt&&((e=r=vt)&&(r=ck(r,n.pendingProps,Yn),r!==null?(n.stateNode=r,Zt=n,vt=null,e=!0):e=!1),e||mi(n)),null;case 13:return Kp(e,n,r);case 4:return Re(n,n.stateNode.containerInfo),c=n.pendingProps,e===null?n.child=fa(n,null,c,r):It(e,n,c,r),n.child;case 11:return Bp(e,n,n.type,n.pendingProps,r);case 7:return It(e,n,n.pendingProps,r),n.child;case 8:return It(e,n,n.pendingProps.children,r),n.child;case 12:return It(e,n,n.pendingProps.children,r),n.child;case 10:return c=n.pendingProps,Ns(n,n.type,c.value),It(e,n,c.children,r),n.child;case 9:return f=n.type._context,c=n.pendingProps.children,gi(n),f=Xt(f),c=c(f),n.flags|=1,It(e,n,c,r),n.child;case 14:return $p(e,n,n.type,n.pendingProps,r);case 15:return Up(e,n,n.type,n.pendingProps,r);case 19:return Xp(e,n,r);case 31:return c=n.pendingProps,r=n.mode,c={mode:c.mode,children:c.children},e===null?(r=Wo(c,r),r.ref=n.ref,n.child=r,r.return=n,n=r):(r=ns(e.child,c),r.ref=n.ref,n.child=r,r.return=n,n=r),n;case 22:return Hp(e,n,r);case 24:return gi(n),c=Xt(_t),e===null?(f=cu(),f===null&&(f=pt,g=ou(),f.pooledCache=g,g.refCount++,g!==null&&(f.pooledCacheLanes|=r),f=g),n.memoizedState={parent:c,cache:f},du(n),Ns(n,_t,f)):((e.lanes&r)!==0&&(fu(e,n),or(n,null,null,r),rr()),f=e.memoizedState,g=n.memoizedState,f.parent!==c?(f={parent:c,cache:c},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Ns(n,_t,c)):(c=g.cache,Ns(n,_t,c),c!==f.cache&&ru(n,[_t],r,!0))),It(e,n,n.pendingProps.children,r),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function us(e){e.flags|=4}function Qp(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!ix(n)){if(n=zn.current,n!==null&&((Ze&4194048)===Ze?Vn!==null:(Ze&62914560)!==Ze&&(Ze&536870912)===0||n!==Vn))throw ir=uu,_m;e.flags|=8192}}function Zo(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?he():536870912,e.lanes|=n,ga|=n)}function mr(e,n){if(!nt)switch(e.tailMode){case"hidden":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:c.sibling=null}}function yt(e){var n=e.alternate!==null&&e.alternate.child===e.child,r=0,c=0;if(n)for(var f=e.child;f!==null;)r|=f.lanes|f.childLanes,c|=f.subtreeFlags&65011712,c|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)r|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=c,e.childLanes=r,n}function Ow(e,n,r){var c=n.pendingProps;switch(nu(n),n.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yt(n),null;case 1:return yt(n),null;case 3:return r=n.stateNode,c=null,e!==null&&(c=e.memoizedState.cache),n.memoizedState.cache!==c&&(n.flags|=2048),rs(_t),Me(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Wa(n)?us(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Cm())),yt(n),null;case 26:return r=n.memoizedState,e===null?(us(n),r!==null?(yt(n),Qp(n,r)):(yt(n),n.flags&=-16777217)):r?r!==e.memoizedState?(us(n),yt(n),Qp(n,r)):(yt(n),n.flags&=-16777217):(e.memoizedProps!==c&&us(n),yt(n),n.flags&=-16777217),null;case 27:Ue(n),r=ce.current;var f=n.type;if(e!==null&&n.stateNode!=null)e.memoizedProps!==c&&us(n);else{if(!c){if(n.stateNode===null)throw Error(a(166));return yt(n),null}e=le.current,Wa(n)?Tm(n):(e=Qg(f,c,r),n.stateNode=e,us(n))}return yt(n),null;case 5:if(Ue(n),r=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==c&&us(n);else{if(!c){if(n.stateNode===null)throw Error(a(166));return yt(n),null}if(e=le.current,Wa(n))Tm(n);else{switch(f=dl(ce.current),e){case 1:e=f.createElementNS("http://www.w3.org/2000/svg",r);break;case 2:e=f.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;default:switch(r){case"svg":e=f.createElementNS("http://www.w3.org/2000/svg",r);break;case"math":e=f.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;case"script":e=f.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e=typeof c.is=="string"?f.createElement("select",{is:c.is}):f.createElement("select"),c.multiple?e.multiple=!0:c.size&&(e.size=c.size);break;default:e=typeof c.is=="string"?f.createElement(r,{is:c.is}):f.createElement(r)}}e[gt]=n,e[Et]=c;e:for(f=n.child;f!==null;){if(f.tag===5||f.tag===6)e.appendChild(f.stateNode);else if(f.tag!==4&&f.tag!==27&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===n)break e;for(;f.sibling===null;){if(f.return===null||f.return===n)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}n.stateNode=e;e:switch(Yt(e,r,c),r){case"button":case"input":case"select":case"textarea":e=!!c.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&us(n)}}return yt(n),n.flags&=-16777217,null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==c&&us(n);else{if(typeof c!="string"&&n.stateNode===null)throw Error(a(166));if(e=ce.current,Wa(n)){if(e=n.stateNode,r=n.memoizedProps,c=null,f=Zt,f!==null)switch(f.tag){case 27:case 5:c=f.memoizedProps}e[gt]=n,e=!!(e.nodeValue===r||c!==null&&c.suppressHydrationWarning===!0||Gg(e.nodeValue,r)),e||mi(n)}else e=dl(e).createTextNode(c),e[gt]=n,n.stateNode=e}return yt(n),null;case 13:if(c=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=Wa(n),c!==null&&c.dehydrated!==null){if(e===null){if(!f)throw Error(a(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(a(317));f[gt]=n}else Za(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;yt(n),f=!1}else f=Cm(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(ls(n),n):(ls(n),null)}if(ls(n),(n.flags&128)!==0)return n.lanes=r,n;if(r=c!==null,e=e!==null&&e.memoizedState!==null,r){c=n.child,f=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(f=c.alternate.memoizedState.cachePool.pool);var g=null;c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==f&&(c.flags|=2048)}return r!==e&&r&&(n.child.flags|=8192),Zo(n,n.updateQueue),yt(n),null;case 4:return Me(),e===null&&md(n.stateNode.containerInfo),yt(n),null;case 10:return rs(n.type),yt(n),null;case 19:if(F(Lt),f=n.memoizedState,f===null)return yt(n),null;if(c=(n.flags&128)!==0,g=f.rendering,g===null)if(c)mr(f,!1);else{if(wt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=Fo(e),g!==null){for(n.flags|=128,mr(f,!1),e=g.updateQueue,n.updateQueue=e,Zo(n,e),n.subtreeFlags=0,e=r,r=n.child;r!==null;)Sm(r,e),r=r.sibling;return J(Lt,Lt.current&1|2),n.child}e=e.sibling}f.tail!==null&&Ne()>tl&&(n.flags|=128,c=!0,mr(f,!1),n.lanes=4194304)}else{if(!c)if(e=Fo(g),e!==null){if(n.flags|=128,c=!0,e=e.updateQueue,n.updateQueue=e,Zo(n,e),mr(f,!0),f.tail===null&&f.tailMode==="hidden"&&!g.alternate&&!nt)return yt(n),null}else 2*Ne()-f.renderingStartTime>tl&&r!==536870912&&(n.flags|=128,c=!0,mr(f,!1),n.lanes=4194304);f.isBackwards?(g.sibling=n.child,n.child=g):(e=f.last,e!==null?e.sibling=g:n.child=g,f.last=g)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=Ne(),n.sibling=null,e=Lt.current,J(Lt,c?e&1|2:e&1),n):(yt(n),null);case 22:case 23:return ls(n),gu(),c=n.memoizedState!==null,e!==null?e.memoizedState!==null!==c&&(n.flags|=8192):c&&(n.flags|=8192),c?(r&536870912)!==0&&(n.flags&128)===0&&(yt(n),n.subtreeFlags&6&&(n.flags|=8192)):yt(n),r=n.updateQueue,r!==null&&Zo(n,r.retryQueue),r=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),c=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(c=n.memoizedState.cachePool.pool),c!==r&&(n.flags|=2048),e!==null&&F(xi),null;case 24:return r=null,e!==null&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),rs(_t),yt(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function Dw(e,n){switch(nu(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return rs(_t),Me(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Ue(n),null;case 13:if(ls(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));Za()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return F(Lt),null;case 4:return Me(),null;case 10:return rs(n.type),null;case 22:case 23:return ls(n),gu(),e!==null&&F(xi),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return rs(_t),null;case 25:return null;default:return null}}function Wp(e,n){switch(nu(n),n.tag){case 3:rs(_t),Me();break;case 26:case 27:case 5:Ue(n);break;case 4:Me();break;case 13:ls(n);break;case 19:F(Lt);break;case 10:rs(n.type);break;case 22:case 23:ls(n),gu(),e!==null&&F(xi);break;case 24:rs(_t)}}function pr(e,n){try{var r=n.updateQueue,c=r!==null?r.lastEffect:null;if(c!==null){var f=c.next;r=f;do{if((r.tag&e)===e){c=void 0;var g=r.create,v=r.inst;c=g(),v.destroy=c}r=r.next}while(r!==f)}}catch(N){dt(n,n.return,N)}}function Rs(e,n,r){try{var c=n.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var g=f.next;c=g;do{if((c.tag&e)===e){var v=c.inst,N=v.destroy;if(N!==void 0){v.destroy=void 0,f=n;var M=r,K=N;try{K()}catch(te){dt(f,M,te)}}}c=c.next}while(c!==g)}}catch(te){dt(n,n.return,te)}}function Zp(e){var n=e.updateQueue;if(n!==null){var r=e.stateNode;try{$m(n,r)}catch(c){dt(e,e.return,c)}}}function Jp(e,n,r){r.props=bi(e.type,e.memoizedProps),r.state=e.memoizedState;try{r.componentWillUnmount()}catch(c){dt(e,n,c)}}function gr(e,n){try{var r=e.ref;if(r!==null){switch(e.tag){case 26:case 27:case 5:var c=e.stateNode;break;case 30:c=e.stateNode;break;default:c=e.stateNode}typeof r=="function"?e.refCleanup=r(c):r.current=c}}catch(f){dt(e,n,f)}}function Kn(e,n){var r=e.ref,c=e.refCleanup;if(r!==null)if(typeof c=="function")try{c()}catch(f){dt(e,n,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(f){dt(e,n,f)}else r.current=null}function eg(e){var n=e.type,r=e.memoizedProps,c=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":r.autoFocus&&c.focus();break e;case"img":r.src?c.src=r.src:r.srcSet&&(c.srcset=r.srcSet)}}catch(f){dt(e,e.return,f)}}function Yu(e,n,r){try{var c=e.stateNode;sk(c,e.type,r,n),c[Et]=n}catch(f){dt(e,e.return,f)}}function tg(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Us(e.type)||e.tag===4}function Vu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||tg(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Us(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ku(e,n,r){var c=e.tag;if(c===5||c===6)e=e.stateNode,n?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(e,n):(n=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,n.appendChild(e),r=r._reactRootContainer,r!=null||n.onclick!==null||(n.onclick=ul));else if(c!==4&&(c===27&&Us(e.type)&&(r=e.stateNode,n=null),e=e.child,e!==null))for(Ku(e,n,r),e=e.sibling;e!==null;)Ku(e,n,r),e=e.sibling}function Jo(e,n,r){var c=e.tag;if(c===5||c===6)e=e.stateNode,n?r.insertBefore(e,n):r.appendChild(e);else if(c!==4&&(c===27&&Us(e.type)&&(r=e.stateNode),e=e.child,e!==null))for(Jo(e,n,r),e=e.sibling;e!==null;)Jo(e,n,r),e=e.sibling}function ng(e){var n=e.stateNode,r=e.memoizedProps;try{for(var c=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);Yt(n,c,r),n[gt]=e,n[Et]=r}catch(g){dt(e,e.return,g)}}var ds=!1,Tt=!1,Fu=!1,sg=typeof WeakSet=="function"?WeakSet:Set,$t=null;function qw(e,n){if(e=e.containerInfo,xd=xl,e=mm(e),Vc(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var c=r.getSelection&&r.getSelection();if(c&&c.rangeCount!==0){r=c.anchorNode;var f=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{r.nodeType,g.nodeType}catch{r=null;break e}var v=0,N=-1,M=-1,K=0,te=0,ae=e,X=null;t:for(;;){for(var P;ae!==r||f!==0&&ae.nodeType!==3||(N=v+f),ae!==g||c!==0&&ae.nodeType!==3||(M=v+c),ae.nodeType===3&&(v+=ae.nodeValue.length),(P=ae.firstChild)!==null;)X=ae,ae=P;for(;;){if(ae===e)break t;if(X===r&&++K===f&&(N=v),X===g&&++te===c&&(M=v),(P=ae.nextSibling)!==null)break;ae=X,X=ae.parentNode}ae=P}r=N===-1||M===-1?null:{start:N,end:M}}else r=null}r=r||{start:0,end:0}}else r=null;for(yd={focusedElem:e,selectionRange:r},xl=!1,$t=n;$t!==null;)if(n=$t,e=n.child,(n.subtreeFlags&1024)!==0&&e!==null)e.return=n,$t=e;else for(;$t!==null;){switch(n=$t,g=n.alternate,e=n.flags,n.tag){case 0:break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,r=n,f=g.memoizedProps,g=g.memoizedState,c=r.stateNode;try{var De=bi(r.type,f,r.elementType===r.type);e=c.getSnapshotBeforeUpdate(De,g),c.__reactInternalSnapshotBeforeUpdate=e}catch(_e){dt(r,r.return,_e)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,r=e.nodeType,r===9)wd(e);else if(r===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":wd(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(a(163))}if(e=n.sibling,e!==null){e.return=n.return,$t=e;break}$t=n.return}}function ig(e,n,r){var c=r.flags;switch(r.tag){case 0:case 11:case 15:_s(e,r),c&4&&pr(5,r);break;case 1:if(_s(e,r),c&4)if(e=r.stateNode,n===null)try{e.componentDidMount()}catch(v){dt(r,r.return,v)}else{var f=bi(r.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(v){dt(r,r.return,v)}}c&64&&Zp(r),c&512&&gr(r,r.return);break;case 3:if(_s(e,r),c&64&&(e=r.updateQueue,e!==null)){if(n=null,r.child!==null)switch(r.child.tag){case 27:case 5:n=r.child.stateNode;break;case 1:n=r.child.stateNode}try{$m(e,n)}catch(v){dt(r,r.return,v)}}break;case 27:n===null&&c&4&&ng(r);case 26:case 5:_s(e,r),n===null&&c&4&&eg(r),c&512&&gr(r,r.return);break;case 12:_s(e,r);break;case 13:_s(e,r),c&4&&og(e,r),c&64&&(e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(r=Kw.bind(null,r),uk(e,r))));break;case 22:if(c=r.memoizedState!==null||ds,!c){n=n!==null&&n.memoizedState!==null||Tt,f=ds;var g=Tt;ds=c,(Tt=n)&&!g?Ls(e,r,(r.subtreeFlags&8772)!==0):_s(e,r),ds=f,Tt=g}break;case 30:break;default:_s(e,r)}}function ag(e){var n=e.alternate;n!==null&&(e.alternate=null,ag(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&Tc(n)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var xt=null,sn=!1;function fs(e,n,r){for(r=r.child;r!==null;)rg(e,n,r),r=r.sibling}function rg(e,n,r){if(Je&&typeof Je.onCommitFiberUnmount=="function")try{Je.onCommitFiberUnmount(Qt,r)}catch{}switch(r.tag){case 26:Tt||Kn(r,n),fs(e,n,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:Tt||Kn(r,n);var c=xt,f=sn;Us(r.type)&&(xt=r.stateNode,sn=!1),fs(e,n,r),Nr(r.stateNode),xt=c,sn=f;break;case 5:Tt||Kn(r,n);case 6:if(c=xt,f=sn,xt=null,fs(e,n,r),xt=c,sn=f,xt!==null)if(sn)try{(xt.nodeType===9?xt.body:xt.nodeName==="HTML"?xt.ownerDocument.body:xt).removeChild(r.stateNode)}catch(g){dt(r,n,g)}else try{xt.removeChild(r.stateNode)}catch(g){dt(r,n,g)}break;case 18:xt!==null&&(sn?(e=xt,Xg(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,r.stateNode),_r(e)):Xg(xt,r.stateNode));break;case 4:c=xt,f=sn,xt=r.stateNode.containerInfo,sn=!0,fs(e,n,r),xt=c,sn=f;break;case 0:case 11:case 14:case 15:Tt||Rs(2,r,n),Tt||Rs(4,r,n),fs(e,n,r);break;case 1:Tt||(Kn(r,n),c=r.stateNode,typeof c.componentWillUnmount=="function"&&Jp(r,n,c)),fs(e,n,r);break;case 21:fs(e,n,r);break;case 22:Tt=(c=Tt)||r.memoizedState!==null,fs(e,n,r),Tt=c;break;default:fs(e,n,r)}}function og(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{_r(e)}catch(r){dt(n,n.return,r)}}function Bw(e){switch(e.tag){case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new sg),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new sg),n;default:throw Error(a(435,e.tag))}}function Xu(e,n){var r=Bw(e);n.forEach(function(c){var f=Fw.bind(null,e,c);r.has(c)||(r.add(c),c.then(f,f))})}function pn(e,n){var r=n.deletions;if(r!==null)for(var c=0;c<r.length;c++){var f=r[c],g=e,v=n,N=v;e:for(;N!==null;){switch(N.tag){case 27:if(Us(N.type)){xt=N.stateNode,sn=!1;break e}break;case 5:xt=N.stateNode,sn=!1;break e;case 3:case 4:xt=N.stateNode.containerInfo,sn=!0;break e}N=N.return}if(xt===null)throw Error(a(160));rg(g,v,f),xt=null,sn=!1,g=f.alternate,g!==null&&(g.return=null),f.return=null}if(n.subtreeFlags&13878)for(n=n.child;n!==null;)lg(n,e),n=n.sibling}var Bn=null;function lg(e,n){var r=e.alternate,c=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:pn(n,e),gn(e),c&4&&(Rs(3,e,e.return),pr(3,e),Rs(5,e,e.return));break;case 1:pn(n,e),gn(e),c&512&&(Tt||r===null||Kn(r,r.return)),c&64&&ds&&(e=e.updateQueue,e!==null&&(c=e.callbacks,c!==null&&(r=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=r===null?c:r.concat(c))));break;case 26:var f=Bn;if(pn(n,e),gn(e),c&512&&(Tt||r===null||Kn(r,r.return)),c&4){var g=r!==null?r.memoizedState:null;if(c=e.memoizedState,r===null)if(c===null)if(e.stateNode===null){e:{c=e.type,r=e.memoizedProps,f=f.ownerDocument||f;t:switch(c){case"title":g=f.getElementsByTagName("title")[0],(!g||g[Ua]||g[gt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=f.createElement(c),f.head.insertBefore(g,f.querySelector("head > title"))),Yt(g,c,r),g[gt]=e,qt(g),c=g;break e;case"link":var v=nx("link","href",f).get(c+(r.href||""));if(v){for(var N=0;N<v.length;N++)if(g=v[N],g.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&g.getAttribute("rel")===(r.rel==null?null:r.rel)&&g.getAttribute("title")===(r.title==null?null:r.title)&&g.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){v.splice(N,1);break t}}g=f.createElement(c),Yt(g,c,r),f.head.appendChild(g);break;case"meta":if(v=nx("meta","content",f).get(c+(r.content||""))){for(N=0;N<v.length;N++)if(g=v[N],g.getAttribute("content")===(r.content==null?null:""+r.content)&&g.getAttribute("name")===(r.name==null?null:r.name)&&g.getAttribute("property")===(r.property==null?null:r.property)&&g.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&g.getAttribute("charset")===(r.charSet==null?null:r.charSet)){v.splice(N,1);break t}}g=f.createElement(c),Yt(g,c,r),f.head.appendChild(g);break;default:throw Error(a(468,c))}g[gt]=e,qt(g),c=g}e.stateNode=c}else sx(f,e.type,e.stateNode);else e.stateNode=tx(f,c,e.memoizedProps);else g!==c?(g===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):g.count--,c===null?sx(f,e.type,e.stateNode):tx(f,c,e.memoizedProps)):c===null&&e.stateNode!==null&&Yu(e,e.memoizedProps,r.memoizedProps)}break;case 27:pn(n,e),gn(e),c&512&&(Tt||r===null||Kn(r,r.return)),r!==null&&c&4&&Yu(e,e.memoizedProps,r.memoizedProps);break;case 5:if(pn(n,e),gn(e),c&512&&(Tt||r===null||Kn(r,r.return)),e.flags&32){f=e.stateNode;try{Xi(f,"")}catch(P){dt(e,e.return,P)}}c&4&&e.stateNode!=null&&(f=e.memoizedProps,Yu(e,f,r!==null?r.memoizedProps:f)),c&1024&&(Fu=!0);break;case 6:if(pn(n,e),gn(e),c&4){if(e.stateNode===null)throw Error(a(162));c=e.memoizedProps,r=e.stateNode;try{r.nodeValue=c}catch(P){dt(e,e.return,P)}}break;case 3:if(ml=null,f=Bn,Bn=fl(n.containerInfo),pn(n,e),Bn=f,gn(e),c&4&&r!==null&&r.memoizedState.isDehydrated)try{_r(n.containerInfo)}catch(P){dt(e,e.return,P)}Fu&&(Fu=!1,cg(e));break;case 4:c=Bn,Bn=fl(e.stateNode.containerInfo),pn(n,e),gn(e),Bn=c;break;case 12:pn(n,e),gn(e);break;case 13:pn(n,e),gn(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(ed=Ne()),c&4&&(c=e.updateQueue,c!==null&&(e.updateQueue=null,Xu(e,c)));break;case 22:f=e.memoizedState!==null;var M=r!==null&&r.memoizedState!==null,K=ds,te=Tt;if(ds=K||f,Tt=te||M,pn(n,e),Tt=te,ds=K,gn(e),c&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(r===null||M||ds||Tt||vi(e)),r=null,n=e;;){if(n.tag===5||n.tag===26){if(r===null){M=r=n;try{if(g=M.stateNode,f)v=g.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{N=M.stateNode;var ae=M.memoizedProps.style,X=ae!=null&&ae.hasOwnProperty("display")?ae.display:null;N.style.display=X==null||typeof X=="boolean"?"":(""+X).trim()}}catch(P){dt(M,M.return,P)}}}else if(n.tag===6){if(r===null){M=n;try{M.stateNode.nodeValue=f?"":M.memoizedProps}catch(P){dt(M,M.return,P)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;r===n&&(r=null),n=n.return}r===n&&(r=null),n.sibling.return=n.return,n=n.sibling}c&4&&(c=e.updateQueue,c!==null&&(r=c.retryQueue,r!==null&&(c.retryQueue=null,Xu(e,r))));break;case 19:pn(n,e),gn(e),c&4&&(c=e.updateQueue,c!==null&&(e.updateQueue=null,Xu(e,c)));break;case 30:break;case 21:break;default:pn(n,e),gn(e)}}function gn(e){var n=e.flags;if(n&2){try{for(var r,c=e.return;c!==null;){if(tg(c)){r=c;break}c=c.return}if(r==null)throw Error(a(160));switch(r.tag){case 27:var f=r.stateNode,g=Vu(e);Jo(e,g,f);break;case 5:var v=r.stateNode;r.flags&32&&(Xi(v,""),r.flags&=-33);var N=Vu(e);Jo(e,N,v);break;case 3:case 4:var M=r.stateNode.containerInfo,K=Vu(e);Ku(e,K,M);break;default:throw Error(a(161))}}catch(te){dt(e,e.return,te)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function cg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;cg(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function _s(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)ig(e,n.alternate,n),n=n.sibling}function vi(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Rs(4,n,n.return),vi(n);break;case 1:Kn(n,n.return);var r=n.stateNode;typeof r.componentWillUnmount=="function"&&Jp(n,n.return,r),vi(n);break;case 27:Nr(n.stateNode);case 26:case 5:Kn(n,n.return),vi(n);break;case 22:n.memoizedState===null&&vi(n);break;case 30:vi(n);break;default:vi(n)}e=e.sibling}}function Ls(e,n,r){for(r=r&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var c=n.alternate,f=e,g=n,v=g.flags;switch(g.tag){case 0:case 11:case 15:Ls(f,g,r),pr(4,g);break;case 1:if(Ls(f,g,r),c=g,f=c.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(K){dt(c,c.return,K)}if(c=g,f=c.updateQueue,f!==null){var N=c.stateNode;try{var M=f.shared.hiddenCallbacks;if(M!==null)for(f.shared.hiddenCallbacks=null,f=0;f<M.length;f++)Bm(M[f],N)}catch(K){dt(c,c.return,K)}}r&&v&64&&Zp(g),gr(g,g.return);break;case 27:ng(g);case 26:case 5:Ls(f,g,r),r&&c===null&&v&4&&eg(g),gr(g,g.return);break;case 12:Ls(f,g,r);break;case 13:Ls(f,g,r),r&&v&4&&og(f,g);break;case 22:g.memoizedState===null&&Ls(f,g,r),gr(g,g.return);break;case 30:break;default:Ls(f,g,r)}n=n.sibling}}function Pu(e,n){var r=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==r&&(e!=null&&e.refCount++,r!=null&&tr(r))}function Qu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&tr(e))}function Fn(e,n,r,c){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)ug(e,n,r,c),n=n.sibling}function ug(e,n,r,c){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Fn(e,n,r,c),f&2048&&pr(9,n);break;case 1:Fn(e,n,r,c);break;case 3:Fn(e,n,r,c),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&tr(e)));break;case 12:if(f&2048){Fn(e,n,r,c),e=n.stateNode;try{var g=n.memoizedProps,v=g.id,N=g.onPostCommit;typeof N=="function"&&N(v,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(M){dt(n,n.return,M)}}else Fn(e,n,r,c);break;case 13:Fn(e,n,r,c);break;case 23:break;case 22:g=n.stateNode,v=n.alternate,n.memoizedState!==null?g._visibility&2?Fn(e,n,r,c):xr(e,n):g._visibility&2?Fn(e,n,r,c):(g._visibility|=2,ha(e,n,r,c,(n.subtreeFlags&10256)!==0)),f&2048&&Pu(v,n);break;case 24:Fn(e,n,r,c),f&2048&&Qu(n.alternate,n);break;default:Fn(e,n,r,c)}}function ha(e,n,r,c,f){for(f=f&&(n.subtreeFlags&10256)!==0,n=n.child;n!==null;){var g=e,v=n,N=r,M=c,K=v.flags;switch(v.tag){case 0:case 11:case 15:ha(g,v,N,M,f),pr(8,v);break;case 23:break;case 22:var te=v.stateNode;v.memoizedState!==null?te._visibility&2?ha(g,v,N,M,f):xr(g,v):(te._visibility|=2,ha(g,v,N,M,f)),f&&K&2048&&Pu(v.alternate,v);break;case 24:ha(g,v,N,M,f),f&&K&2048&&Qu(v.alternate,v);break;default:ha(g,v,N,M,f)}n=n.sibling}}function xr(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var r=e,c=n,f=c.flags;switch(c.tag){case 22:xr(r,c),f&2048&&Pu(c.alternate,c);break;case 24:xr(r,c),f&2048&&Qu(c.alternate,c);break;default:xr(r,c)}n=n.sibling}}var yr=8192;function ma(e){if(e.subtreeFlags&yr)for(e=e.child;e!==null;)dg(e),e=e.sibling}function dg(e){switch(e.tag){case 26:ma(e),e.flags&yr&&e.memoizedState!==null&&jk(Bn,e.memoizedState,e.memoizedProps);break;case 5:ma(e);break;case 3:case 4:var n=Bn;Bn=fl(e.stateNode.containerInfo),ma(e),Bn=n;break;case 22:e.memoizedState===null&&(n=e.alternate,n!==null&&n.memoizedState!==null?(n=yr,yr=16777216,ma(e),yr=n):ma(e));break;default:ma(e)}}function fg(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function br(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var c=n[r];$t=c,mg(c,e)}fg(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)hg(e),e=e.sibling}function hg(e){switch(e.tag){case 0:case 11:case 15:br(e),e.flags&2048&&Rs(9,e,e.return);break;case 3:br(e);break;case 12:br(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,el(e)):br(e);break;default:br(e)}}function el(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var c=n[r];$t=c,mg(c,e)}fg(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Rs(8,n,n.return),el(n);break;case 22:r=n.stateNode,r._visibility&2&&(r._visibility&=-3,el(n));break;default:el(n)}e=e.sibling}}function mg(e,n){for(;$t!==null;){var r=$t;switch(r.tag){case 0:case 11:case 15:Rs(8,r,n);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var c=r.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:tr(r.memoizedState.cache)}if(c=r.child,c!==null)c.return=r,$t=c;else e:for(r=e;$t!==null;){c=$t;var f=c.sibling,g=c.return;if(ag(c),c===r){$t=null;break e}if(f!==null){f.return=g,$t=f;break e}$t=g}}}var $w={getCacheForType:function(e){var n=Xt(_t),r=n.data.get(e);return r===void 0&&(r=e(),n.data.set(e,r)),r}},Uw=typeof WeakMap=="function"?WeakMap:Map,it=0,pt=null,Xe=null,Ze=0,at=0,xn=null,Os=!1,pa=!1,Wu=!1,hs=0,wt=0,Ds=0,wi=0,Zu=0,Rn=0,ga=0,vr=null,an=null,Ju=!1,ed=0,tl=1/0,nl=null,qs=null,Gt=0,Bs=null,xa=null,ya=0,td=0,nd=null,pg=null,wr=0,sd=null;function yn(){if((it&2)!==0&&Ze!==0)return Ze&-Ze;if(U.T!==null){var e=aa;return e!==0?e:ud()}return Wt()}function gg(){Rn===0&&(Rn=(Ze&536870912)===0||nt?ue():536870912);var e=zn.current;return e!==null&&(e.flags|=32),Rn}function bn(e,n,r){(e===pt&&(at===2||at===9)||e.cancelPendingCommit!==null)&&(ba(e,0),$s(e,Ze,Rn,!1)),$e(e,r),((it&2)===0||e!==pt)&&(e===pt&&((it&2)===0&&(wi|=r),wt===4&&$s(e,Ze,Rn,!1)),Xn(e))}function xg(e,n,r){if((it&6)!==0)throw Error(a(327));var c=!r&&(n&124)===0&&(n&e.expiredLanes)===0||E(e,n),f=c?Gw(e,n):rd(e,n,!0),g=c;do{if(f===0){pa&&!c&&$s(e,n,0,!1);break}else{if(r=e.current.alternate,g&&!Hw(r)){f=rd(e,n,!1),g=!1;continue}if(f===2){if(g=n,e.errorRecoveryDisabledLanes&g)var v=0;else v=e.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){n=v;e:{var N=e;f=vr;var M=N.current.memoizedState.isDehydrated;if(M&&(ba(N,v).flags|=256),v=rd(N,v,!1),v!==2){if(Wu&&!M){N.errorRecoveryDisabledLanes|=g,wi|=g,f=4;break e}g=an,an=f,g!==null&&(an===null?an=g:an.push.apply(an,g))}f=v}if(g=!1,f!==2)continue}}if(f===1){ba(e,0),$s(e,n,0,!0);break}e:{switch(c=e,g=f,g){case 0:case 1:throw Error(a(345));case 4:if((n&4194048)!==n)break;case 6:$s(c,n,Rn,!Os);break e;case 2:an=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(f=ed+300-Ne(),10<f)){if($s(c,n,Rn,!Os),jn(c,0,!0)!==0)break e;c.timeoutHandle=Kg(yg.bind(null,c,r,an,nl,Ju,n,Rn,wi,ga,Os,g,2,-0,0),f);break e}yg(c,r,an,nl,Ju,n,Rn,wi,ga,Os,g,0,-0,0)}}break}while(!0);Xn(e)}function yg(e,n,r,c,f,g,v,N,M,K,te,ae,X,P){if(e.timeoutHandle=-1,ae=n.subtreeFlags,(ae&8192||(ae&16785408)===16785408)&&(Cr={stylesheets:null,count:0,unsuspend:kk},dg(n),ae=Sk(),ae!==null)){e.cancelPendingCommit=ae(Ng.bind(null,e,n,g,r,c,f,v,N,M,te,1,X,P)),$s(e,g,v,!K);return}Ng(e,n,g,r,c,f,v,N,M)}function Hw(e){for(var n=e;;){var r=n.tag;if((r===0||r===11||r===15)&&n.flags&16384&&(r=n.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var c=0;c<r.length;c++){var f=r[c],g=f.getSnapshot;f=f.value;try{if(!hn(g(),f))return!1}catch{return!1}}if(r=n.child,n.subtreeFlags&16384&&r!==null)r.return=n,n=r;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function $s(e,n,r,c){n&=~Zu,n&=~wi,e.suspendedLanes|=n,e.pingedLanes&=~n,c&&(e.warmLanes|=n),c=e.expirationTimes;for(var f=n;0<f;){var g=31-St(f),v=1<<g;c[g]=-1,f&=~v}r!==0&&ft(e,r,n)}function sl(){return(it&6)===0?(kr(0),!1):!0}function id(){if(Xe!==null){if(at===0)var e=Xe.return;else e=Xe,as=pi=null,wu(e),da=null,fr=0,e=Xe;for(;e!==null;)Wp(e.alternate,e),e=e.return;Xe=null}}function ba(e,n){var r=e.timeoutHandle;r!==-1&&(e.timeoutHandle=-1,ak(r)),r=e.cancelPendingCommit,r!==null&&(e.cancelPendingCommit=null,r()),id(),pt=e,Xe=r=ns(e.current,null),Ze=n,at=0,xn=null,Os=!1,pa=E(e,n),Wu=!1,ga=Rn=Zu=wi=Ds=wt=0,an=vr=null,Ju=!1,(n&8)!==0&&(n|=n&32);var c=e.entangledLanes;if(c!==0)for(e=e.entanglements,c&=n;0<c;){var f=31-St(c),g=1<<f;n|=e[f],c&=~g}return hs=n,No(),r}function bg(e,n){Ge=null,U.H=Yo,n===sr||n===Lo?(n=Dm(),at=3):n===_m?(n=Dm(),at=4):at=n===qp?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,xn=n,Xe===null&&(wt=1,Po(e,An(n,e.current)))}function vg(){var e=U.H;return U.H=Yo,e===null?Yo:e}function wg(){var e=U.A;return U.A=$w,e}function ad(){wt=4,Os||(Ze&4194048)!==Ze&&zn.current!==null||(pa=!0),(Ds&134217727)===0&&(wi&134217727)===0||pt===null||$s(pt,Ze,Rn,!1)}function rd(e,n,r){var c=it;it|=2;var f=vg(),g=wg();(pt!==e||Ze!==n)&&(nl=null,ba(e,n)),n=!1;var v=wt;e:do try{if(at!==0&&Xe!==null){var N=Xe,M=xn;switch(at){case 8:id(),v=6;break e;case 3:case 2:case 9:case 6:zn.current===null&&(n=!0);var K=at;if(at=0,xn=null,va(e,N,M,K),r&&pa){v=0;break e}break;default:K=at,at=0,xn=null,va(e,N,M,K)}}Iw(),v=wt;break}catch(te){bg(e,te)}while(!0);return n&&e.shellSuspendCounter++,as=pi=null,it=c,U.H=f,U.A=g,Xe===null&&(pt=null,Ze=0,No()),v}function Iw(){for(;Xe!==null;)kg(Xe)}function Gw(e,n){var r=it;it|=2;var c=vg(),f=wg();pt!==e||Ze!==n?(nl=null,tl=Ne()+500,ba(e,n)):pa=E(e,n);e:do try{if(at!==0&&Xe!==null){n=Xe;var g=xn;t:switch(at){case 1:at=0,xn=null,va(e,n,g,1);break;case 2:case 9:if(Lm(g)){at=0,xn=null,jg(n);break}n=function(){at!==2&&at!==9||pt!==e||(at=7),Xn(e)},g.then(n,n);break e;case 3:at=7;break e;case 4:at=5;break e;case 7:Lm(g)?(at=0,xn=null,jg(n)):(at=0,xn=null,va(e,n,g,7));break;case 5:var v=null;switch(Xe.tag){case 26:v=Xe.memoizedState;case 5:case 27:var N=Xe;if(!v||ix(v)){at=0,xn=null;var M=N.sibling;if(M!==null)Xe=M;else{var K=N.return;K!==null?(Xe=K,il(K)):Xe=null}break t}}at=0,xn=null,va(e,n,g,5);break;case 6:at=0,xn=null,va(e,n,g,6);break;case 8:id(),wt=6;break e;default:throw Error(a(462))}}Yw();break}catch(te){bg(e,te)}while(!0);return as=pi=null,U.H=c,U.A=f,it=r,Xe!==null?0:(pt=null,Ze=0,No(),wt)}function Yw(){for(;Xe!==null&&!ye();)kg(Xe)}function kg(e){var n=Pp(e.alternate,e,hs);e.memoizedProps=e.pendingProps,n===null?il(e):Xe=n}function jg(e){var n=e,r=n.alternate;switch(n.tag){case 15:case 0:n=Gp(r,n,n.pendingProps,n.type,void 0,Ze);break;case 11:n=Gp(r,n,n.pendingProps,n.type.render,n.ref,Ze);break;case 5:wu(n);default:Wp(r,n),n=Xe=Sm(n,hs),n=Pp(r,n,hs)}e.memoizedProps=e.pendingProps,n===null?il(e):Xe=n}function va(e,n,r,c){as=pi=null,wu(n),da=null,fr=0;var f=n.return;try{if(_w(e,f,n,r,Ze)){wt=1,Po(e,An(r,e.current)),Xe=null;return}}catch(g){if(f!==null)throw Xe=f,g;wt=1,Po(e,An(r,e.current)),Xe=null;return}n.flags&32768?(nt||c===1?e=!0:pa||(Ze&536870912)!==0?e=!1:(Os=e=!0,(c===2||c===9||c===3||c===6)&&(c=zn.current,c!==null&&c.tag===13&&(c.flags|=16384))),Sg(n,e)):il(n)}function il(e){var n=e;do{if((n.flags&32768)!==0){Sg(n,Os);return}e=n.return;var r=Ow(n.alternate,n,hs);if(r!==null){Xe=r;return}if(n=n.sibling,n!==null){Xe=n;return}Xe=n=e}while(n!==null);wt===0&&(wt=5)}function Sg(e,n){do{var r=Dw(e.alternate,e);if(r!==null){r.flags&=32767,Xe=r;return}if(r=e.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!n&&(e=e.sibling,e!==null)){Xe=e;return}Xe=e=r}while(e!==null);wt=6,Xe=null}function Ng(e,n,r,c,f,g,v,N,M){e.cancelPendingCommit=null;do al();while(Gt!==0);if((it&6)!==0)throw Error(a(327));if(n!==null){if(n===e.current)throw Error(a(177));if(g=n.lanes|n.childLanes,g|=Qc,We(e,r,g,v,N,M),e===pt&&(Xe=pt=null,Ze=0),xa=n,Bs=e,ya=r,td=g,nd=f,pg=c,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Xw(ut,function(){return Mg(),null})):(e.callbackNode=null,e.callbackPriority=0),c=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||c){c=U.T,U.T=null,f=Z.p,Z.p=2,v=it,it|=4;try{qw(e,n,r)}finally{it=v,Z.p=f,U.T=c}}Gt=1,Tg(),Ag(),Cg()}}function Tg(){if(Gt===1){Gt=0;var e=Bs,n=xa,r=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||r){r=U.T,U.T=null;var c=Z.p;Z.p=2;var f=it;it|=4;try{lg(n,e);var g=yd,v=mm(e.containerInfo),N=g.focusedElem,M=g.selectionRange;if(v!==N&&N&&N.ownerDocument&&hm(N.ownerDocument.documentElement,N)){if(M!==null&&Vc(N)){var K=M.start,te=M.end;if(te===void 0&&(te=K),"selectionStart"in N)N.selectionStart=K,N.selectionEnd=Math.min(te,N.value.length);else{var ae=N.ownerDocument||document,X=ae&&ae.defaultView||window;if(X.getSelection){var P=X.getSelection(),De=N.textContent.length,_e=Math.min(M.start,De),ct=M.end===void 0?_e:Math.min(M.end,De);!P.extend&&_e>ct&&(v=ct,ct=_e,_e=v);var $=fm(N,_e),D=fm(N,ct);if($&&D&&(P.rangeCount!==1||P.anchorNode!==$.node||P.anchorOffset!==$.offset||P.focusNode!==D.node||P.focusOffset!==D.offset)){var G=ae.createRange();G.setStart($.node,$.offset),P.removeAllRanges(),_e>ct?(P.addRange(G),P.extend(D.node,D.offset)):(G.setEnd(D.node,D.offset),P.addRange(G))}}}}for(ae=[],P=N;P=P.parentNode;)P.nodeType===1&&ae.push({element:P,left:P.scrollLeft,top:P.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<ae.length;N++){var se=ae[N];se.element.scrollLeft=se.left,se.element.scrollTop=se.top}}xl=!!xd,yd=xd=null}finally{it=f,Z.p=c,U.T=r}}e.current=n,Gt=2}}function Ag(){if(Gt===2){Gt=0;var e=Bs,n=xa,r=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||r){r=U.T,U.T=null;var c=Z.p;Z.p=2;var f=it;it|=4;try{ig(e,n.alternate,n)}finally{it=f,Z.p=c,U.T=r}}Gt=3}}function Cg(){if(Gt===4||Gt===3){Gt=0,Ae();var e=Bs,n=xa,r=ya,c=pg;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Gt=5:(Gt=0,xa=Bs=null,Eg(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(qs=null),ht(r),n=n.stateNode,Je&&typeof Je.onCommitFiberRoot=="function")try{Je.onCommitFiberRoot(Qt,n,void 0,(n.current.flags&128)===128)}catch{}if(c!==null){n=U.T,f=Z.p,Z.p=2,U.T=null;try{for(var g=e.onRecoverableError,v=0;v<c.length;v++){var N=c[v];g(N.value,{componentStack:N.stack})}}finally{U.T=n,Z.p=f}}(ya&3)!==0&&al(),Xn(e),f=e.pendingLanes,(r&4194090)!==0&&(f&42)!==0?e===sd?wr++:(wr=0,sd=e):wr=0,kr(0)}}function Eg(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,tr(n)))}function al(e){return Tg(),Ag(),Cg(),Mg()}function Mg(){if(Gt!==5)return!1;var e=Bs,n=td;td=0;var r=ht(ya),c=U.T,f=Z.p;try{Z.p=32>r?32:r,U.T=null,r=nd,nd=null;var g=Bs,v=ya;if(Gt=0,xa=Bs=null,ya=0,(it&6)!==0)throw Error(a(331));var N=it;if(it|=4,hg(g.current),ug(g,g.current,v,r),it=N,kr(0,!1),Je&&typeof Je.onPostCommitFiberRoot=="function")try{Je.onPostCommitFiberRoot(Qt,g)}catch{}return!0}finally{Z.p=f,U.T=c,Eg(e,n)}}function zg(e,n,r){n=An(r,n),n=Ou(e.stateNode,n,2),e=Cs(e,n,2),e!==null&&($e(e,2),Xn(e))}function dt(e,n,r){if(e.tag===3)zg(e,e,r);else for(;n!==null;){if(n.tag===3){zg(n,e,r);break}else if(n.tag===1){var c=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(qs===null||!qs.has(c))){e=An(r,e),r=Op(2),c=Cs(n,r,2),c!==null&&(Dp(r,c,n,e),$e(c,2),Xn(c));break}}n=n.return}}function od(e,n,r){var c=e.pingCache;if(c===null){c=e.pingCache=new Uw;var f=new Set;c.set(n,f)}else f=c.get(n),f===void 0&&(f=new Set,c.set(n,f));f.has(r)||(Wu=!0,f.add(r),e=Vw.bind(null,e,n,r),n.then(e,e))}function Vw(e,n,r){var c=e.pingCache;c!==null&&c.delete(n),e.pingedLanes|=e.suspendedLanes&r,e.warmLanes&=~r,pt===e&&(Ze&r)===r&&(wt===4||wt===3&&(Ze&62914560)===Ze&&300>Ne()-ed?(it&2)===0&&ba(e,0):Zu|=r,ga===Ze&&(ga=0)),Xn(e)}function Rg(e,n){n===0&&(n=he()),e=ta(e,n),e!==null&&($e(e,n),Xn(e))}function Kw(e){var n=e.memoizedState,r=0;n!==null&&(r=n.retryLane),Rg(e,r)}function Fw(e,n){var r=0;switch(e.tag){case 13:var c=e.stateNode,f=e.memoizedState;f!==null&&(r=f.retryLane);break;case 19:c=e.stateNode;break;case 22:c=e.stateNode._retryCache;break;default:throw Error(a(314))}c!==null&&c.delete(n),Rg(e,r)}function Xw(e,n){return Fe(e,n)}var rl=null,wa=null,ld=!1,ol=!1,cd=!1,ki=0;function Xn(e){e!==wa&&e.next===null&&(wa===null?rl=wa=e:wa=wa.next=e),ol=!0,ld||(ld=!0,Qw())}function kr(e,n){if(!cd&&ol){cd=!0;do for(var r=!1,c=rl;c!==null;){if(e!==0){var f=c.pendingLanes;if(f===0)var g=0;else{var v=c.suspendedLanes,N=c.pingedLanes;g=(1<<31-St(42|e)+1)-1,g&=f&~(v&~N),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(r=!0,Dg(c,g))}else g=Ze,g=jn(c,c===pt?g:0,c.cancelPendingCommit!==null||c.timeoutHandle!==-1),(g&3)===0||E(c,g)||(r=!0,Dg(c,g));c=c.next}while(r);cd=!1}}function Pw(){_g()}function _g(){ol=ld=!1;var e=0;ki!==0&&(ik()&&(e=ki),ki=0);for(var n=Ne(),r=null,c=rl;c!==null;){var f=c.next,g=Lg(c,n);g===0?(c.next=null,r===null?rl=f:r.next=f,f===null&&(wa=r)):(r=c,(e!==0||(g&3)!==0)&&(ol=!0)),c=f}kr(e)}function Lg(e,n){for(var r=e.suspendedLanes,c=e.pingedLanes,f=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var v=31-St(g),N=1<<v,M=f[v];M===-1?((N&r)===0||(N&c)!==0)&&(f[v]=V(N,n)):M<=n&&(e.expiredLanes|=N),g&=~N}if(n=pt,r=Ze,r=jn(e,e===n?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),c=e.callbackNode,r===0||e===n&&(at===2||at===9)||e.cancelPendingCommit!==null)return c!==null&&c!==null&&be(c),e.callbackNode=null,e.callbackPriority=0;if((r&3)===0||E(e,r)){if(n=r&-r,n===e.callbackPriority)return n;switch(c!==null&&be(c),ht(r)){case 2:case 8:r=ze;break;case 32:r=ut;break;case 268435456:r=Rt;break;default:r=ut}return c=Og.bind(null,e),r=Fe(r,c),e.callbackPriority=n,e.callbackNode=r,n}return c!==null&&c!==null&&be(c),e.callbackPriority=2,e.callbackNode=null,2}function Og(e,n){if(Gt!==0&&Gt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var r=e.callbackNode;if(al()&&e.callbackNode!==r)return null;var c=Ze;return c=jn(e,e===pt?c:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),c===0?null:(xg(e,c,n),Lg(e,Ne()),e.callbackNode!=null&&e.callbackNode===r?Og.bind(null,e):null)}function Dg(e,n){if(al())return null;xg(e,n,!0)}function Qw(){rk(function(){(it&6)!==0?Fe(cn,Pw):_g()})}function ud(){return ki===0&&(ki=ue()),ki}function qg(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:yo(""+e)}function Bg(e,n){var r=n.ownerDocument.createElement("input");return r.name=n.name,r.value=n.value,e.id&&r.setAttribute("form",e.id),n.parentNode.insertBefore(r,n),e=new FormData(e),r.parentNode.removeChild(r),e}function Ww(e,n,r,c,f){if(n==="submit"&&r&&r.stateNode===f){var g=qg((f[Et]||null).action),v=c.submitter;v&&(n=(n=v[Et]||null)?qg(n.formAction):v.getAttribute("formAction"),n!==null&&(g=n,v=null));var N=new ko("action","action",null,c,f);e.push({event:N,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(ki!==0){var M=v?Bg(f,v):new FormData(f);Mu(r,{pending:!0,data:M,method:f.method,action:g},null,M)}}else typeof g=="function"&&(N.preventDefault(),M=v?Bg(f,v):new FormData(f),Mu(r,{pending:!0,data:M,method:f.method,action:g},g,M))},currentTarget:f}]})}}for(var dd=0;dd<Pc.length;dd++){var fd=Pc[dd],Zw=fd.toLowerCase(),Jw=fd[0].toUpperCase()+fd.slice(1);qn(Zw,"on"+Jw)}qn(xm,"onAnimationEnd"),qn(ym,"onAnimationIteration"),qn(bm,"onAnimationStart"),qn("dblclick","onDoubleClick"),qn("focusin","onFocus"),qn("focusout","onBlur"),qn(gw,"onTransitionRun"),qn(xw,"onTransitionStart"),qn(yw,"onTransitionCancel"),qn(vm,"onTransitionEnd"),Vi("onMouseEnter",["mouseout","mouseover"]),Vi("onMouseLeave",["mouseout","mouseover"]),Vi("onPointerEnter",["pointerout","pointerover"]),Vi("onPointerLeave",["pointerout","pointerover"]),ri("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ri("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ri("onBeforeInput",["compositionend","keypress","textInput","paste"]),ri("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ri("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ri("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var jr="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(" "),ek=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(jr));function $g(e,n){n=(n&4)!==0;for(var r=0;r<e.length;r++){var c=e[r],f=c.event;c=c.listeners;e:{var g=void 0;if(n)for(var v=c.length-1;0<=v;v--){var N=c[v],M=N.instance,K=N.currentTarget;if(N=N.listener,M!==g&&f.isPropagationStopped())break e;g=N,f.currentTarget=K;try{g(f)}catch(te){Xo(te)}f.currentTarget=null,g=M}else for(v=0;v<c.length;v++){if(N=c[v],M=N.instance,K=N.currentTarget,N=N.listener,M!==g&&f.isPropagationStopped())break e;g=N,f.currentTarget=K;try{g(f)}catch(te){Xo(te)}f.currentTarget=null,g=M}}}}function Pe(e,n){var r=n[Nc];r===void 0&&(r=n[Nc]=new Set);var c=e+"__bubble";r.has(c)||(Ug(n,e,2,!1),r.add(c))}function hd(e,n,r){var c=0;n&&(c|=4),Ug(r,e,c,n)}var ll="_reactListening"+Math.random().toString(36).slice(2);function md(e){if(!e[ll]){e[ll]=!0,_h.forEach(function(r){r!=="selectionchange"&&(ek.has(r)||hd(r,!1,e),hd(r,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[ll]||(n[ll]=!0,hd("selectionchange",!1,n))}}function Ug(e,n,r,c){switch(ux(n)){case 2:var f=Ak;break;case 8:f=Ck;break;default:f=Cd}r=f.bind(null,n,r,e),f=void 0,!Dc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),c?f!==void 0?e.addEventListener(n,r,{capture:!0,passive:f}):e.addEventListener(n,r,!0):f!==void 0?e.addEventListener(n,r,{passive:f}):e.addEventListener(n,r,!1)}function pd(e,n,r,c,f){var g=c;if((n&1)===0&&(n&2)===0&&c!==null)e:for(;;){if(c===null)return;var v=c.tag;if(v===3||v===4){var N=c.stateNode.containerInfo;if(N===f)break;if(v===4)for(v=c.return;v!==null;){var M=v.tag;if((M===3||M===4)&&v.stateNode.containerInfo===f)return;v=v.return}for(;N!==null;){if(v=Ii(N),v===null)return;if(M=v.tag,M===5||M===6||M===26||M===27){c=g=v;continue e}N=N.parentNode}}c=c.return}Fh(function(){var K=g,te=Lc(r),ae=[];e:{var X=wm.get(e);if(X!==void 0){var P=ko,De=e;switch(e){case"keypress":if(vo(r)===0)break e;case"keydown":case"keyup":P=Xv;break;case"focusin":De="focus",P=Uc;break;case"focusout":De="blur",P=Uc;break;case"beforeblur":case"afterblur":P=Uc;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":P=Qh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":P=Dv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":P=Wv;break;case xm:case ym:case bm:P=$v;break;case vm:P=Jv;break;case"scroll":case"scrollend":P=Lv;break;case"wheel":P=tw;break;case"copy":case"cut":case"paste":P=Hv;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":P=Zh;break;case"toggle":case"beforetoggle":P=sw}var _e=(n&4)!==0,ct=!_e&&(e==="scroll"||e==="scrollend"),$=_e?X!==null?X+"Capture":null:X;_e=[];for(var D=K,G;D!==null;){var se=D;if(G=se.stateNode,se=se.tag,se!==5&&se!==26&&se!==27||G===null||$===null||(se=Ia(D,$),se!=null&&_e.push(Sr(D,se,G))),ct)break;D=D.return}0<_e.length&&(X=new P(X,De,null,r,te),ae.push({event:X,listeners:_e}))}}if((n&7)===0){e:{if(X=e==="mouseover"||e==="pointerover",P=e==="mouseout"||e==="pointerout",X&&r!==_c&&(De=r.relatedTarget||r.fromElement)&&(Ii(De)||De[Sn]))break e;if((P||X)&&(X=te.window===te?te:(X=te.ownerDocument)?X.defaultView||X.parentWindow:window,P?(De=r.relatedTarget||r.toElement,P=K,De=De?Ii(De):null,De!==null&&(ct=u(De),_e=De.tag,De!==ct||_e!==5&&_e!==27&&_e!==6)&&(De=null)):(P=null,De=K),P!==De)){if(_e=Qh,se="onMouseLeave",$="onMouseEnter",D="mouse",(e==="pointerout"||e==="pointerover")&&(_e=Zh,se="onPointerLeave",$="onPointerEnter",D="pointer"),ct=P==null?X:Ha(P),G=De==null?X:Ha(De),X=new _e(se,D+"leave",P,r,te),X.target=ct,X.relatedTarget=G,se=null,Ii(te)===K&&(_e=new _e($,D+"enter",De,r,te),_e.target=G,_e.relatedTarget=ct,se=_e),ct=se,P&&De)t:{for(_e=P,$=De,D=0,G=_e;G;G=ka(G))D++;for(G=0,se=$;se;se=ka(se))G++;for(;0<D-G;)_e=ka(_e),D--;for(;0<G-D;)$=ka($),G--;for(;D--;){if(_e===$||$!==null&&_e===$.alternate)break t;_e=ka(_e),$=ka($)}_e=null}else _e=null;P!==null&&Hg(ae,X,P,_e,!1),De!==null&&ct!==null&&Hg(ae,ct,De,_e,!0)}}e:{if(X=K?Ha(K):window,P=X.nodeName&&X.nodeName.toLowerCase(),P==="select"||P==="input"&&X.type==="file")var Se=rm;else if(im(X))if(om)Se=hw;else{Se=dw;var Ve=uw}else P=X.nodeName,!P||P.toLowerCase()!=="input"||X.type!=="checkbox"&&X.type!=="radio"?K&&Rc(K.elementType)&&(Se=rm):Se=fw;if(Se&&(Se=Se(e,K))){am(ae,Se,r,te);break e}Ve&&Ve(e,X,K),e==="focusout"&&K&&X.type==="number"&&K.memoizedProps.value!=null&&zc(X,"number",X.value)}switch(Ve=K?Ha(K):window,e){case"focusin":(im(Ve)||Ve.contentEditable==="true")&&(Zi=Ve,Kc=K,Qa=null);break;case"focusout":Qa=Kc=Zi=null;break;case"mousedown":Fc=!0;break;case"contextmenu":case"mouseup":case"dragend":Fc=!1,pm(ae,r,te);break;case"selectionchange":if(pw)break;case"keydown":case"keyup":pm(ae,r,te)}var Ce;if(Ic)e:{switch(e){case"compositionstart":var Le="onCompositionStart";break e;case"compositionend":Le="onCompositionEnd";break e;case"compositionupdate":Le="onCompositionUpdate";break e}Le=void 0}else Wi?nm(e,r)&&(Le="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(Le="onCompositionStart");Le&&(Jh&&r.locale!=="ko"&&(Wi||Le!=="onCompositionStart"?Le==="onCompositionEnd"&&Wi&&(Ce=Xh()):(Ss=te,qc="value"in Ss?Ss.value:Ss.textContent,Wi=!0)),Ve=cl(K,Le),0<Ve.length&&(Le=new Wh(Le,e,null,r,te),ae.push({event:Le,listeners:Ve}),Ce?Le.data=Ce:(Ce=sm(r),Ce!==null&&(Le.data=Ce)))),(Ce=aw?rw(e,r):ow(e,r))&&(Le=cl(K,"onBeforeInput"),0<Le.length&&(Ve=new Wh("onBeforeInput","beforeinput",null,r,te),ae.push({event:Ve,listeners:Le}),Ve.data=Ce)),Ww(ae,e,K,r,te)}$g(ae,n)})}function Sr(e,n,r){return{instance:e,listener:n,currentTarget:r}}function cl(e,n){for(var r=n+"Capture",c=[];e!==null;){var f=e,g=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||g===null||(f=Ia(e,r),f!=null&&c.unshift(Sr(e,f,g)),f=Ia(e,n),f!=null&&c.push(Sr(e,f,g))),e.tag===3)return c;e=e.return}return[]}function ka(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Hg(e,n,r,c,f){for(var g=n._reactName,v=[];r!==null&&r!==c;){var N=r,M=N.alternate,K=N.stateNode;if(N=N.tag,M!==null&&M===c)break;N!==5&&N!==26&&N!==27||K===null||(M=K,f?(K=Ia(r,g),K!=null&&v.unshift(Sr(r,K,M))):f||(K=Ia(r,g),K!=null&&v.push(Sr(r,K,M)))),r=r.return}v.length!==0&&e.push({event:n,listeners:v})}var tk=/\r\n?/g,nk=/\u0000|\uFFFD/g;function Ig(e){return(typeof e=="string"?e:""+e).replace(tk,`
10
+ `).replace(nk,"")}function Gg(e,n){return n=Ig(n),Ig(e)===n}function ul(){}function lt(e,n,r,c,f,g){switch(r){case"children":typeof c=="string"?n==="body"||n==="textarea"&&c===""||Xi(e,c):(typeof c=="number"||typeof c=="bigint")&&n!=="body"&&Xi(e,""+c);break;case"className":po(e,"class",c);break;case"tabIndex":po(e,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":po(e,r,c);break;case"style":Vh(e,c,g);break;case"data":if(n!=="object"){po(e,"data",c);break}case"src":case"href":if(c===""&&(n!=="a"||r!=="href")){e.removeAttribute(r);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){e.removeAttribute(r);break}c=yo(""+c),e.setAttribute(r,c);break;case"action":case"formAction":if(typeof c=="function"){e.setAttribute(r,"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 g=="function"&&(r==="formAction"?(n!=="input"&&lt(e,n,"name",f.name,f,null),lt(e,n,"formEncType",f.formEncType,f,null),lt(e,n,"formMethod",f.formMethod,f,null),lt(e,n,"formTarget",f.formTarget,f,null)):(lt(e,n,"encType",f.encType,f,null),lt(e,n,"method",f.method,f,null),lt(e,n,"target",f.target,f,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){e.removeAttribute(r);break}c=yo(""+c),e.setAttribute(r,c);break;case"onClick":c!=null&&(e.onclick=ul);break;case"onScroll":c!=null&&Pe("scroll",e);break;case"onScrollEnd":c!=null&&Pe("scrollend",e);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(a(61));if(r=c.__html,r!=null){if(f.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"multiple":e.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":e.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){e.removeAttribute("xlink:href");break}r=yo(""+c),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?e.setAttribute(r,""+c):e.removeAttribute(r);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":c&&typeof c!="function"&&typeof c!="symbol"?e.setAttribute(r,""):e.removeAttribute(r);break;case"capture":case"download":c===!0?e.setAttribute(r,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?e.setAttribute(r,c):e.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?e.setAttribute(r,c):e.removeAttribute(r);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?e.removeAttribute(r):e.setAttribute(r,c);break;case"popover":Pe("beforetoggle",e),Pe("toggle",e),mo(e,"popover",c);break;case"xlinkActuate":es(e,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":es(e,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":es(e,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":es(e,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":es(e,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":es(e,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":es(e,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":es(e,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":es(e,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":mo(e,"is",c);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=Rv.get(r)||r,mo(e,r,c))}}function gd(e,n,r,c,f,g){switch(r){case"style":Vh(e,c,g);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(a(61));if(r=c.__html,r!=null){if(f.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"children":typeof c=="string"?Xi(e,c):(typeof c=="number"||typeof c=="bigint")&&Xi(e,""+c);break;case"onScroll":c!=null&&Pe("scroll",e);break;case"onScrollEnd":c!=null&&Pe("scrollend",e);break;case"onClick":c!=null&&(e.onclick=ul);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Lh.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(f=r.endsWith("Capture"),n=r.slice(2,f?r.length-7:void 0),g=e[Et]||null,g=g!=null?g[r]:null,typeof g=="function"&&e.removeEventListener(n,g,f),typeof c=="function")){typeof g!="function"&&g!==null&&(r in e?e[r]=null:e.hasAttribute(r)&&e.removeAttribute(r)),e.addEventListener(n,c,f);break e}r in e?e[r]=c:c===!0?e.setAttribute(r,""):mo(e,r,c)}}}function Yt(e,n,r){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Pe("error",e),Pe("load",e);var c=!1,f=!1,g;for(g in r)if(r.hasOwnProperty(g)){var v=r[g];if(v!=null)switch(g){case"src":c=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:lt(e,n,g,v,r,null)}}f&&lt(e,n,"srcSet",r.srcSet,r,null),c&&lt(e,n,"src",r.src,r,null);return;case"input":Pe("invalid",e);var N=g=v=f=null,M=null,K=null;for(c in r)if(r.hasOwnProperty(c)){var te=r[c];if(te!=null)switch(c){case"name":f=te;break;case"type":v=te;break;case"checked":M=te;break;case"defaultChecked":K=te;break;case"value":g=te;break;case"defaultValue":N=te;break;case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(a(137,n));break;default:lt(e,n,c,te,r,null)}}Hh(e,g,N,M,K,v,f,!1),go(e);return;case"select":Pe("invalid",e),c=v=g=null;for(f in r)if(r.hasOwnProperty(f)&&(N=r[f],N!=null))switch(f){case"value":g=N;break;case"defaultValue":v=N;break;case"multiple":c=N;default:lt(e,n,f,N,r,null)}n=g,r=v,e.multiple=!!c,n!=null?Fi(e,!!c,n,!1):r!=null&&Fi(e,!!c,r,!0);return;case"textarea":Pe("invalid",e),g=f=c=null;for(v in r)if(r.hasOwnProperty(v)&&(N=r[v],N!=null))switch(v){case"value":c=N;break;case"defaultValue":f=N;break;case"children":g=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(a(91));break;default:lt(e,n,v,N,r,null)}Gh(e,c,f,g),go(e);return;case"option":for(M in r)r.hasOwnProperty(M)&&(c=r[M],c!=null)&&(M==="selected"?e.selected=c&&typeof c!="function"&&typeof c!="symbol":lt(e,n,M,c,r,null));return;case"dialog":Pe("beforetoggle",e),Pe("toggle",e),Pe("cancel",e),Pe("close",e);break;case"iframe":case"object":Pe("load",e);break;case"video":case"audio":for(c=0;c<jr.length;c++)Pe(jr[c],e);break;case"image":Pe("error",e),Pe("load",e);break;case"details":Pe("toggle",e);break;case"embed":case"source":case"link":Pe("error",e),Pe("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(K in r)if(r.hasOwnProperty(K)&&(c=r[K],c!=null))switch(K){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:lt(e,n,K,c,r,null)}return;default:if(Rc(n)){for(te in r)r.hasOwnProperty(te)&&(c=r[te],c!==void 0&&gd(e,n,te,c,r,void 0));return}}for(N in r)r.hasOwnProperty(N)&&(c=r[N],c!=null&&lt(e,n,N,c,r,null))}function sk(e,n,r,c){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,g=null,v=null,N=null,M=null,K=null,te=null;for(P in r){var ae=r[P];if(r.hasOwnProperty(P)&&ae!=null)switch(P){case"checked":break;case"value":break;case"defaultValue":M=ae;default:c.hasOwnProperty(P)||lt(e,n,P,null,c,ae)}}for(var X in c){var P=c[X];if(ae=r[X],c.hasOwnProperty(X)&&(P!=null||ae!=null))switch(X){case"type":g=P;break;case"name":f=P;break;case"checked":K=P;break;case"defaultChecked":te=P;break;case"value":v=P;break;case"defaultValue":N=P;break;case"children":case"dangerouslySetInnerHTML":if(P!=null)throw Error(a(137,n));break;default:P!==ae&&lt(e,n,X,P,c,ae)}}Mc(e,v,N,M,K,te,g,f);return;case"select":P=v=N=X=null;for(g in r)if(M=r[g],r.hasOwnProperty(g)&&M!=null)switch(g){case"value":break;case"multiple":P=M;default:c.hasOwnProperty(g)||lt(e,n,g,null,c,M)}for(f in c)if(g=c[f],M=r[f],c.hasOwnProperty(f)&&(g!=null||M!=null))switch(f){case"value":X=g;break;case"defaultValue":N=g;break;case"multiple":v=g;default:g!==M&&lt(e,n,f,g,c,M)}n=N,r=v,c=P,X!=null?Fi(e,!!r,X,!1):!!c!=!!r&&(n!=null?Fi(e,!!r,n,!0):Fi(e,!!r,r?[]:"",!1));return;case"textarea":P=X=null;for(N in r)if(f=r[N],r.hasOwnProperty(N)&&f!=null&&!c.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:lt(e,n,N,null,c,f)}for(v in c)if(f=c[v],g=r[v],c.hasOwnProperty(v)&&(f!=null||g!=null))switch(v){case"value":X=f;break;case"defaultValue":P=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(a(91));break;default:f!==g&&lt(e,n,v,f,c,g)}Ih(e,X,P);return;case"option":for(var De in r)X=r[De],r.hasOwnProperty(De)&&X!=null&&!c.hasOwnProperty(De)&&(De==="selected"?e.selected=!1:lt(e,n,De,null,c,X));for(M in c)X=c[M],P=r[M],c.hasOwnProperty(M)&&X!==P&&(X!=null||P!=null)&&(M==="selected"?e.selected=X&&typeof X!="function"&&typeof X!="symbol":lt(e,n,M,X,c,P));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 _e in r)X=r[_e],r.hasOwnProperty(_e)&&X!=null&&!c.hasOwnProperty(_e)&&lt(e,n,_e,null,c,X);for(K in c)if(X=c[K],P=r[K],c.hasOwnProperty(K)&&X!==P&&(X!=null||P!=null))switch(K){case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(a(137,n));break;default:lt(e,n,K,X,c,P)}return;default:if(Rc(n)){for(var ct in r)X=r[ct],r.hasOwnProperty(ct)&&X!==void 0&&!c.hasOwnProperty(ct)&&gd(e,n,ct,void 0,c,X);for(te in c)X=c[te],P=r[te],!c.hasOwnProperty(te)||X===P||X===void 0&&P===void 0||gd(e,n,te,X,c,P);return}}for(var $ in r)X=r[$],r.hasOwnProperty($)&&X!=null&&!c.hasOwnProperty($)&&lt(e,n,$,null,c,X);for(ae in c)X=c[ae],P=r[ae],!c.hasOwnProperty(ae)||X===P||X==null&&P==null||lt(e,n,ae,X,c,P)}var xd=null,yd=null;function dl(e){return e.nodeType===9?e:e.ownerDocument}function Yg(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Vg(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function bd(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var vd=null;function ik(){var e=window.event;return e&&e.type==="popstate"?e===vd?!1:(vd=e,!0):(vd=null,!1)}var Kg=typeof setTimeout=="function"?setTimeout:void 0,ak=typeof clearTimeout=="function"?clearTimeout:void 0,Fg=typeof Promise=="function"?Promise:void 0,rk=typeof queueMicrotask=="function"?queueMicrotask:typeof Fg<"u"?function(e){return Fg.resolve(null).then(e).catch(ok)}:Kg;function ok(e){setTimeout(function(){throw e})}function Us(e){return e==="head"}function Xg(e,n){var r=n,c=0,f=0;do{var g=r.nextSibling;if(e.removeChild(r),g&&g.nodeType===8)if(r=g.data,r==="/$"){if(0<c&&8>c){r=c;var v=e.ownerDocument;if(r&1&&Nr(v.documentElement),r&2&&Nr(v.body),r&4)for(r=v.head,Nr(r),v=r.firstChild;v;){var N=v.nextSibling,M=v.nodeName;v[Ua]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&v.rel.toLowerCase()==="stylesheet"||r.removeChild(v),v=N}}if(f===0){e.removeChild(g),_r(n);return}f--}else r==="$"||r==="$?"||r==="$!"?f++:c=r.charCodeAt(0)-48;else c=0;r=g}while(r);_r(n)}function wd(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var r=n;switch(n=n.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":wd(r),Tc(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}e.removeChild(r)}}function lk(e,n,r,c){for(;e.nodeType===1;){var f=r;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!c&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(c){if(!e[Ua])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(g=e.getAttribute("rel"),g==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(g!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=$n(e.nextSibling),e===null)break}return null}function ck(e,n,r){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=$n(e.nextSibling),e===null))return null;return e}function kd(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState==="complete"}function uk(e,n){var r=e.ownerDocument;if(e.data!=="$?"||r.readyState==="complete")n();else{var c=function(){n(),r.removeEventListener("DOMContentLoaded",c)};r.addEventListener("DOMContentLoaded",c),e._reactRetry=c}}function $n(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="F!"||n==="F")break;if(n==="/$")return null}}return e}var jd=null;function Pg(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"){if(n===0)return e;n--}else r==="/$"&&n++}e=e.previousSibling}return null}function Qg(e,n,r){switch(n=dl(r),e){case"html":if(e=n.documentElement,!e)throw Error(a(452));return e;case"head":if(e=n.head,!e)throw Error(a(453));return e;case"body":if(e=n.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function Nr(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Tc(e)}var _n=new Map,Wg=new Set;function fl(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ms=Z.d;Z.d={f:dk,r:fk,D:hk,C:mk,L:pk,m:gk,X:yk,S:xk,M:bk};function dk(){var e=ms.f(),n=sl();return e||n}function fk(e){var n=Gi(e);n!==null&&n.tag===5&&n.type==="form"?xp(n):ms.r(e)}var ja=typeof document>"u"?null:document;function Zg(e,n,r){var c=ja;if(c&&typeof n=="string"&&n){var f=Tn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof r=="string"&&(f+='[crossorigin="'+r+'"]'),Wg.has(f)||(Wg.add(f),e={rel:e,crossOrigin:r,href:n},c.querySelector(f)===null&&(n=c.createElement("link"),Yt(n,"link",e),qt(n),c.head.appendChild(n)))}}function hk(e){ms.D(e),Zg("dns-prefetch",e,null)}function mk(e,n){ms.C(e,n),Zg("preconnect",e,n)}function pk(e,n,r){ms.L(e,n,r);var c=ja;if(c&&e&&n){var f='link[rel="preload"][as="'+Tn(n)+'"]';n==="image"&&r&&r.imageSrcSet?(f+='[imagesrcset="'+Tn(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(f+='[imagesizes="'+Tn(r.imageSizes)+'"]')):f+='[href="'+Tn(e)+'"]';var g=f;switch(n){case"style":g=Sa(e);break;case"script":g=Na(e)}_n.has(g)||(e=x({rel:"preload",href:n==="image"&&r&&r.imageSrcSet?void 0:e,as:n},r),_n.set(g,e),c.querySelector(f)!==null||n==="style"&&c.querySelector(Tr(g))||n==="script"&&c.querySelector(Ar(g))||(n=c.createElement("link"),Yt(n,"link",e),qt(n),c.head.appendChild(n)))}}function gk(e,n){ms.m(e,n);var r=ja;if(r&&e){var c=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+Tn(c)+'"][href="'+Tn(e)+'"]',g=f;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Na(e)}if(!_n.has(g)&&(e=x({rel:"modulepreload",href:e},n),_n.set(g,e),r.querySelector(f)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(Ar(g)))return}c=r.createElement("link"),Yt(c,"link",e),qt(c),r.head.appendChild(c)}}}function xk(e,n,r){ms.S(e,n,r);var c=ja;if(c&&e){var f=Yi(c).hoistableStyles,g=Sa(e);n=n||"default";var v=f.get(g);if(!v){var N={loading:0,preload:null};if(v=c.querySelector(Tr(g)))N.loading=5;else{e=x({rel:"stylesheet",href:e,"data-precedence":n},r),(r=_n.get(g))&&Sd(e,r);var M=v=c.createElement("link");qt(M),Yt(M,"link",e),M._p=new Promise(function(K,te){M.onload=K,M.onerror=te}),M.addEventListener("load",function(){N.loading|=1}),M.addEventListener("error",function(){N.loading|=2}),N.loading|=4,hl(v,n,c)}v={type:"stylesheet",instance:v,count:1,state:N},f.set(g,v)}}}function yk(e,n){ms.X(e,n);var r=ja;if(r&&e){var c=Yi(r).hoistableScripts,f=Na(e),g=c.get(f);g||(g=r.querySelector(Ar(f)),g||(e=x({src:e,async:!0},n),(n=_n.get(f))&&Nd(e,n),g=r.createElement("script"),qt(g),Yt(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(f,g))}}function bk(e,n){ms.M(e,n);var r=ja;if(r&&e){var c=Yi(r).hoistableScripts,f=Na(e),g=c.get(f);g||(g=r.querySelector(Ar(f)),g||(e=x({src:e,async:!0,type:"module"},n),(n=_n.get(f))&&Nd(e,n),g=r.createElement("script"),qt(g),Yt(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},c.set(f,g))}}function Jg(e,n,r,c){var f=(f=ce.current)?fl(f):null;if(!f)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(n=Sa(r.href),r=Yi(f).hoistableStyles,c=r.get(n),c||(c={type:"style",instance:null,count:0,state:null},r.set(n,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){e=Sa(r.href);var g=Yi(f).hoistableStyles,v=g.get(e);if(v||(f=f.ownerDocument||f,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,v),(g=f.querySelector(Tr(e)))&&!g._p&&(v.instance=g,v.state.loading=5),_n.has(e)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},_n.set(e,r),g||vk(f,e,r,v.state))),n&&c===null)throw Error(a(528,""));return v}if(n&&c!==null)throw Error(a(529,""));return null;case"script":return n=r.async,r=r.src,typeof r=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Na(r),r=Yi(f).hoistableScripts,c=r.get(n),c||(c={type:"script",instance:null,count:0,state:null},r.set(n,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Sa(e){return'href="'+Tn(e)+'"'}function Tr(e){return'link[rel="stylesheet"]['+e+"]"}function ex(e){return x({},e,{"data-precedence":e.precedence,precedence:null})}function vk(e,n,r,c){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?c.loading=1:(n=e.createElement("link"),c.preload=n,n.addEventListener("load",function(){return c.loading|=1}),n.addEventListener("error",function(){return c.loading|=2}),Yt(n,"link",r),qt(n),e.head.appendChild(n))}function Na(e){return'[src="'+Tn(e)+'"]'}function Ar(e){return"script[async]"+e}function tx(e,n,r){if(n.count++,n.instance===null)switch(n.type){case"style":var c=e.querySelector('style[data-href~="'+Tn(r.href)+'"]');if(c)return n.instance=c,qt(c),c;var f=x({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return c=(e.ownerDocument||e).createElement("style"),qt(c),Yt(c,"style",f),hl(c,r.precedence,e),n.instance=c;case"stylesheet":f=Sa(r.href);var g=e.querySelector(Tr(f));if(g)return n.state.loading|=4,n.instance=g,qt(g),g;c=ex(r),(f=_n.get(f))&&Sd(c,f),g=(e.ownerDocument||e).createElement("link"),qt(g);var v=g;return v._p=new Promise(function(N,M){v.onload=N,v.onerror=M}),Yt(g,"link",c),n.state.loading|=4,hl(g,r.precedence,e),n.instance=g;case"script":return g=Na(r.src),(f=e.querySelector(Ar(g)))?(n.instance=f,qt(f),f):(c=r,(f=_n.get(g))&&(c=x({},r),Nd(c,f)),e=e.ownerDocument||e,f=e.createElement("script"),qt(f),Yt(f,"link",c),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(c=n.instance,n.state.loading|=4,hl(c,r.precedence,e));return n.instance}function hl(e,n,r){for(var c=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=c.length?c[c.length-1]:null,g=f,v=0;v<c.length;v++){var N=c[v];if(N.dataset.precedence===n)g=N;else if(g!==f)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=r.nodeType===9?r.head:r,n.insertBefore(e,n.firstChild))}function Sd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function Nd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var ml=null;function nx(e,n,r){if(ml===null){var c=new Map,f=ml=new Map;f.set(r,c)}else f=ml,c=f.get(r),c||(c=new Map,f.set(r,c));if(c.has(e))return c;for(c.set(e,null),r=r.getElementsByTagName(e),f=0;f<r.length;f++){var g=r[f];if(!(g[Ua]||g[gt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var v=g.getAttribute(n)||"";v=e+v;var N=c.get(v);N?N.push(g):c.set(v,[g])}}return c}function sx(e,n,r){e=e.ownerDocument||e,e.head.insertBefore(r,n==="title"?e.querySelector("head > title"):null)}function wk(e,n,r){if(r===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(e=n.disabled,typeof n.precedence=="string"&&e==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function ix(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}var Cr=null;function kk(){}function jk(e,n,r){if(Cr===null)throw Error(a(475));var c=Cr;if(n.type==="stylesheet"&&(typeof r.media!="string"||matchMedia(r.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var f=Sa(r.href),g=e.querySelector(Tr(f));if(g){e=g._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(c.count++,c=pl.bind(c),e.then(c,c)),n.state.loading|=4,n.instance=g,qt(g);return}g=e.ownerDocument||e,r=ex(r),(f=_n.get(f))&&Sd(r,f),g=g.createElement("link"),qt(g);var v=g;v._p=new Promise(function(N,M){v.onload=N,v.onerror=M}),Yt(g,"link",r),n.instance=g}c.stylesheets===null&&(c.stylesheets=new Map),c.stylesheets.set(n,e),(e=n.state.preload)&&(n.state.loading&3)===0&&(c.count++,n=pl.bind(c),e.addEventListener("load",n),e.addEventListener("error",n))}}function Sk(){if(Cr===null)throw Error(a(475));var e=Cr;return e.stylesheets&&e.count===0&&Td(e,e.stylesheets),0<e.count?function(n){var r=setTimeout(function(){if(e.stylesheets&&Td(e,e.stylesheets),e.unsuspend){var c=e.unsuspend;e.unsuspend=null,c()}},6e4);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r)}}:null}function pl(){if(this.count--,this.count===0){if(this.stylesheets)Td(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var gl=null;function Td(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,gl=new Map,n.forEach(Nk,e),gl=null,pl.call(e))}function Nk(e,n){if(!(n.state.loading&4)){var r=gl.get(e);if(r)var c=r.get(null);else{r=new Map,gl.set(e,r);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<f.length;g++){var v=f[g];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(r.set(v.dataset.precedence,v),c=v)}c&&r.set(null,c)}f=n.instance,v=f.getAttribute("data-precedence"),g=r.get(v)||c,g===c&&r.set(null,f),r.set(v,f),this.count++,c=pl.bind(this),f.addEventListener("load",c),f.addEventListener("error",c),g?g.parentNode.insertBefore(f,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var Er={$$typeof:O,Provider:null,Consumer:null,_currentValue:oe,_currentValue2:oe,_threadCount:0};function Tk(e,n,r,c,f,g,v,N){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pe(0),this.hiddenUpdates=pe(null),this.identifierPrefix=c,this.onUncaughtError=f,this.onCaughtError=g,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=N,this.incompleteTransitions=new Map}function ax(e,n,r,c,f,g,v,N,M,K,te,ae){return e=new Tk(e,n,r,v,N,M,K,ae),n=1,g===!0&&(n|=24),g=mn(3,null,null,n),e.current=g,g.stateNode=e,n=ou(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:c,isDehydrated:r,cache:n},du(g),e}function rx(e){return e?(e=na,e):na}function ox(e,n,r,c,f,g){f=rx(f),c.context===null?c.context=f:c.pendingContext=f,c=As(n),c.payload={element:r},g=g===void 0?null:g,g!==null&&(c.callback=g),r=Cs(e,c,n),r!==null&&(bn(r,e,n),ar(r,e,n))}function lx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<n?r:n}}function Ad(e,n){lx(e,n),(e=e.alternate)&&lx(e,n)}function cx(e){if(e.tag===13){var n=ta(e,67108864);n!==null&&bn(n,e,67108864),Ad(e,67108864)}}var xl=!0;function Ak(e,n,r,c){var f=U.T;U.T=null;var g=Z.p;try{Z.p=2,Cd(e,n,r,c)}finally{Z.p=g,U.T=f}}function Ck(e,n,r,c){var f=U.T;U.T=null;var g=Z.p;try{Z.p=8,Cd(e,n,r,c)}finally{Z.p=g,U.T=f}}function Cd(e,n,r,c){if(xl){var f=Ed(c);if(f===null)pd(e,n,c,yl,r),dx(e,c);else if(Mk(f,e,n,r,c))c.stopPropagation();else if(dx(e,c),n&4&&-1<Ek.indexOf(e)){for(;f!==null;){var g=Gi(f);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var v=Ct(g.pendingLanes);if(v!==0){var N=g;for(N.pendingLanes|=2,N.entangledLanes|=2;v;){var M=1<<31-St(v);N.entanglements[1]|=M,v&=~M}Xn(g),(it&6)===0&&(tl=Ne()+500,kr(0))}}break;case 13:N=ta(g,2),N!==null&&bn(N,g,2),sl(),Ad(g,2)}if(g=Ed(c),g===null&&pd(e,n,c,yl,r),g===f)break;f=g}f!==null&&c.stopPropagation()}else pd(e,n,c,null,r)}}function Ed(e){return e=Lc(e),Md(e)}var yl=null;function Md(e){if(yl=null,e=Ii(e),e!==null){var n=u(e);if(n===null)e=null;else{var r=n.tag;if(r===13){if(e=d(n),e!==null)return e;e=null}else if(r===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return yl=e,null}function ux(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ht()){case cn:return 2;case ze:return 8;case ut:case At:return 32;case Rt:return 268435456;default:return 32}default:return 32}}var zd=!1,Hs=null,Is=null,Gs=null,Mr=new Map,zr=new Map,Ys=[],Ek="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 dx(e,n){switch(e){case"focusin":case"focusout":Hs=null;break;case"dragenter":case"dragleave":Is=null;break;case"mouseover":case"mouseout":Gs=null;break;case"pointerover":case"pointerout":Mr.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":zr.delete(n.pointerId)}}function Rr(e,n,r,c,f,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:r,eventSystemFlags:c,nativeEvent:g,targetContainers:[f]},n!==null&&(n=Gi(n),n!==null&&cx(n)),e):(e.eventSystemFlags|=c,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function Mk(e,n,r,c,f){switch(n){case"focusin":return Hs=Rr(Hs,e,n,r,c,f),!0;case"dragenter":return Is=Rr(Is,e,n,r,c,f),!0;case"mouseover":return Gs=Rr(Gs,e,n,r,c,f),!0;case"pointerover":var g=f.pointerId;return Mr.set(g,Rr(Mr.get(g)||null,e,n,r,c,f)),!0;case"gotpointercapture":return g=f.pointerId,zr.set(g,Rr(zr.get(g)||null,e,n,r,c,f)),!0}return!1}function fx(e){var n=Ii(e.target);if(n!==null){var r=u(n);if(r!==null){if(n=r.tag,n===13){if(n=d(r),n!==null){e.blockedOn=n,mt(e.priority,function(){if(r.tag===13){var c=yn();c=me(c);var f=ta(r,c);f!==null&&bn(f,r,c),Ad(r,c)}});return}}else if(n===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function bl(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var r=Ed(e.nativeEvent);if(r===null){r=e.nativeEvent;var c=new r.constructor(r.type,r);_c=c,r.target.dispatchEvent(c),_c=null}else return n=Gi(r),n!==null&&cx(n),e.blockedOn=r,!1;n.shift()}return!0}function hx(e,n,r){bl(e)&&r.delete(n)}function zk(){zd=!1,Hs!==null&&bl(Hs)&&(Hs=null),Is!==null&&bl(Is)&&(Is=null),Gs!==null&&bl(Gs)&&(Gs=null),Mr.forEach(hx),zr.forEach(hx)}function vl(e,n){e.blockedOn===n&&(e.blockedOn=null,zd||(zd=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,zk)))}var wl=null;function mx(e){wl!==e&&(wl=e,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){wl===e&&(wl=null);for(var n=0;n<e.length;n+=3){var r=e[n],c=e[n+1],f=e[n+2];if(typeof c!="function"){if(Md(c||r)===null)continue;break}var g=Gi(r);g!==null&&(e.splice(n,3),n-=3,Mu(g,{pending:!0,data:f,method:r.method,action:c},c,f))}}))}function _r(e){function n(M){return vl(M,e)}Hs!==null&&vl(Hs,e),Is!==null&&vl(Is,e),Gs!==null&&vl(Gs,e),Mr.forEach(n),zr.forEach(n);for(var r=0;r<Ys.length;r++){var c=Ys[r];c.blockedOn===e&&(c.blockedOn=null)}for(;0<Ys.length&&(r=Ys[0],r.blockedOn===null);)fx(r),r.blockedOn===null&&Ys.shift();if(r=(e.ownerDocument||e).$$reactFormReplay,r!=null)for(c=0;c<r.length;c+=3){var f=r[c],g=r[c+1],v=f[Et]||null;if(typeof g=="function")v||mx(r);else if(v){var N=null;if(g&&g.hasAttribute("formAction")){if(f=g,v=g[Et]||null)N=v.formAction;else if(Md(f)!==null)continue}else N=v.action;typeof N=="function"?r[c+1]=N:(r.splice(c,3),c-=3),mx(r)}}}function Rd(e){this._internalRoot=e}kl.prototype.render=Rd.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var r=n.current,c=yn();ox(r,c,e,n,null,null)},kl.prototype.unmount=Rd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;ox(e.current,2,null,e,null,null),sl(),n[Sn]=null}};function kl(e){this._internalRoot=e}kl.prototype.unstable_scheduleHydration=function(e){if(e){var n=Wt();e={blockedOn:null,target:e,priority:n};for(var r=0;r<Ys.length&&n!==0&&n<Ys[r].priority;r++);Ys.splice(r,0,e),r===0&&fx(e)}};var px=t.version;if(px!=="19.1.0")throw Error(a(527,px,"19.1.0"));Z.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=m(n),e=e!==null?p(e):null,e=e===null?null:e.stateNode,e};var Rk={bundleType:0,version:"19.1.0",rendererPackageName:"react-dom",currentDispatcherRef:U,reconcilerVersion:"19.1.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jl.isDisabled&&jl.supportsFiber)try{Qt=jl.inject(Rk),Je=jl}catch{}}return Or.createRoot=function(e,n){if(!l(e))throw Error(a(299));var r=!1,c="",f=zp,g=Rp,v=_p,N=null;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(c=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(v=n.onRecoverableError),n.unstable_transitionCallbacks!==void 0&&(N=n.unstable_transitionCallbacks)),n=ax(e,1,!1,null,null,r,c,f,g,v,N,null),e[Sn]=n.current,md(e),new Rd(n)},Or.hydrateRoot=function(e,n,r){if(!l(e))throw Error(a(299));var c=!1,f="",g=zp,v=Rp,N=_p,M=null,K=null;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(f=r.identifierPrefix),r.onUncaughtError!==void 0&&(g=r.onUncaughtError),r.onCaughtError!==void 0&&(v=r.onCaughtError),r.onRecoverableError!==void 0&&(N=r.onRecoverableError),r.unstable_transitionCallbacks!==void 0&&(M=r.unstable_transitionCallbacks),r.formState!==void 0&&(K=r.formState)),n=ax(e,1,!0,n,r??null,c,f,g,v,N,M,K),n.context=rx(null),r=n.current,c=yn(),c=me(c),f=As(c),f.callback=null,Cs(r,f,c),r=c,n.current.lanes=r,$e(n,r),Xn(n),e[Sn]=n.current,md(e),new kl(n)},Or.version="19.1.0",Or}var Nx;function Kk(){if(Nx)return Od.exports;Nx=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(t){console.error(t)}}return s(),Od.exports=Vk(),Od.exports}var Fk=Kk();const Xk=1,mf=16*1024*1024;class Kf extends Error{constructor(t){super(t?.message??"ALP daemon request failed"),this.code=t?.code,this.data=t?.data}}const Pk=Object.freeze({failed:1e3,notFound:1001,forbidden:1003,conflict:1004,unavailable:1005,protocol:1006}),Hl=Object.freeze({maxReadBytes:1024*1024,maxListEntries:1e3,maxPathLength:4096,maxPreviewBytes:50*1024*1024,maxPreviewChunkBytes:8*1024*1024,maxFindEntries:1e3}),Ci=Object.freeze({maxPerPrincipal:4,maxPerDaemon:16,maxInputBytes:64*1024,maxOutputFrameBytes:64*1024,replayBytes:1024*1024,idleMs:1800*1e3,maxLifetimeMs:480*60*1e3,reconnectMs:60*1e3,minCols:2,maxCols:500,minRows:1,maxRows:200}),Sl=s=>typeof s=="string"&&/^term_[0-9a-f]{32}$/.test(s),Qk=new Set([".git",".alp",".ssh",".gnupg",".aws",".azure",".kube",".docker","gcloud"]),Wk=new Set([".netrc","_netrc",".npmrc",".yarnrc.yml",".pypirc",".pgpass",".htpasswd",".git-credentials",".dockercfg",".boto",".s3cfg",".mcp.json","auth.json","kubeconfig","settings.local.json",".vault-token","application_default_credentials.json","token.json"]),Zk=new Set(["gh/hosts.yml"]),Jk=new Set(["credential","credentials","secret","secrets"]),e2=new Set(["ts","tsx","mts","cts","js","jsx","mjs","cjs","py","go","rs","java","kt","kts","rb","php","cs","swift","c","cc","cpp","h","hpp","m","mm","scala","dart","vue","svelte"]),t2=new Set(["pem","key","p12","pfx","p8","jks","keystore","ppk","der","gpg","pgp","asc","kdbx","ovpn","tfstate","tfvars"]),n2=/^(?:\.env|id_|service[-_]?account)|_history$|\.tfstate\.backup$/;function $i(s){let t="";for(const i of String(s).toLowerCase().split(/[\\/]/)){if(!i)continue;if(Zk.has(`${t}/${i}`)||(t=i,Qk.has(i)||Wk.has(i)||n2.test(i)))return!0;const a=i.lastIndexOf("."),l=a>=0?i.slice(a+1):"";if(t2.has(l))return!0;const u=i.replace(/^\.+/,"").split(".");if(u.length>1&&u.pop(),u.some(d=>Jk.has(d))&&!e2.has(l))return!0}return!1}const bb=Symbol.for("@anhlp/alp-client/AlpClientError");class st extends Error{constructor(t,{reason:i,cause:a,data:l}){super(t,a===void 0?void 0:{cause:a}),this.name="AlpClientError",this.reason=i,this.data=l,Object.defineProperty(this,bb,{value:!0})}}function Ff(s,t){return typeof s=="object"&&s!==null&&s[bb]===!0&&(t===void 0||s.reason===t)}function no(s){let t=0;for(let i=0;i<s.length;i++){const a=s.charCodeAt(i);a<128?t+=1:a<2048?t+=2:a>=55296&&a<=56319&&i+1<s.length&&(s.charCodeAt(i+1)&64512)===56320?(t+=4,i++):t+=3}return t}const s2=2147483647;function pf(s,t="timeoutMs"){if(!(s===void 0||s===1/0)){if(typeof s!="number"||Number.isNaN(s)||s<0)throw new TypeError(`${t} must be a non-negative number of milliseconds`);return s>s2?void 0:s}}const Dr="ALP daemon connection closed",i2=4096,a2=s=>{setTimeout(()=>{throw s},0)};function r2(s){for(const t of["send","onMessage","onClose","close"])if(typeof s?.[t]!="function")throw new TypeError(`ALP transport must implement ${t}()`)}const Tx=s=>new st("ALP request aborted",{reason:"aborted",cause:s.reason}),qr=(s,t)=>Object.prototype.hasOwnProperty.call(s,t);class o2{#e;#j=0;#p=new Map;#n=new Set;#i=new Set;#m=new Set;#o=new Set;#f=[];#a;#s;#g;#c;#y;constructor(t,{maxPending:i=i2,maxFrame:a=mf,timeoutMs:l,onListenerError:u=a2}={}){r2(t),this.#e=t,this.#s=i,this.#g=a,pf(l),this.#c=l,this.#y=u,this.#f.push(t.onMessage(d=>this.#h(d))),this.#f.push(t.onClose(d=>this.#S(this.#w(d)))),t.state==="closed"&&this.#S(new st(Dr,{reason:"disconnected"}))}get closed(){return this.#a!==void 0}get pendingCount(){return this.#p.size}request(t,i={},{signal:a,timeoutMs:l=this.#c}={}){if(this.#a)return Promise.reject(new st(Dr,{reason:this.#a.reason==="closed"?"closed":"disconnected",cause:this.#a}));if(a?.aborted)return Promise.reject(Tx(a));if(this.#p.size>=this.#s)return Promise.reject(new st(`Too many ALP requests waiting for an answer (${this.#s})`,{reason:"overloaded"}));let u;try{u=pf(l)}catch(m){return Promise.reject(m)}const d=++this.#j;let h;try{h=JSON.stringify({jsonrpc:"2.0",id:d,method:t,params:i})}catch(m){return Promise.reject(m)}return no(h)>=this.#g?Promise.reject(new st(`ALP request ${t} exceeds the ${this.#g}-byte frame limit`,{reason:"send_failed"})):new Promise((m,p)=>{let x;const y=()=>{this.#p.delete(d)&&(w(),p(Tx(a)))},w=()=>{x!==void 0&&clearTimeout(x),a?.removeEventListener("abort",y)};this.#p.set(d,{resolve:m,reject:p,cleanup:w}),u!==void 0&&(x=setTimeout(()=>{this.#p.delete(d)&&(w(),p(new st(`ALP request ${t} timed out after ${l} ms`,{reason:"timeout"})))},u)),a?.addEventListener("abort",y,{once:!0});try{this.#e.send(h)}catch(k){this.#e.state==="closed"?this.#S(new st(Dr,{reason:"disconnected",cause:k})):this.#p.delete(d)&&(w(),p(new st(`Could not send ALP request ${t}: ${k instanceof Error?k.message:String(k)}`,{reason:"send_failed",cause:k})))}})}onEvent(t){return this.#v(this.#n,t)}onNotification(t){return this.#v(this.#i,t)}onRequest(t){return this.#v(this.#o,t)}onClose(t){return this.#v(this.#m,t)}close(){this.#a||this.#S(new st(Dr,{reason:"closed"}))}#v(t,i){if(typeof i!="function")throw new TypeError("ALP client listener must be a function");return this.#a?()=>!1:(t.add(i),()=>t.delete(i))}#w(t={}){if(t.error instanceof st)return t.error;const i=t.code!==void 0||t.reason?{code:t.code,reason:t.reason}:void 0;return new st(t.error?.message??Dr,{reason:"disconnected",cause:t.error,data:i})}#b(t){this.#S(new st(t,{reason:"protocol"}))}#d(t,...i){try{t(...i)}catch(a){this.#y(a)}}#h(t){if(this.#a)return;if(typeof t!="string")return this.#b("Invalid frame from ALP daemon");let i;try{i=JSON.parse(t)}catch{return this.#b("Invalid frame from ALP daemon")}if(typeof i!="object"||i===null||Array.isArray(i))return this.#b("Invalid frame from ALP daemon");const a=i.id!==void 0&&i.id!==null;if(i.method==="event"){for(const u of[...this.#n])this.#d(u,i.params);for(const u of[...this.#i])this.#d(u,i.method,i.params);return}if(typeof i.method=="string"&&a&&!qr(i,"result")&&!qr(i,"error"))return this.#k(i.id,i.method,i.params??{});if(typeof i.method=="string"&&!a){for(const u of[...this.#i])this.#d(u,i.method,i.params);return}const l=this.#p.get(i.id);l&&(this.#p.delete(i.id),l.cleanup(),qr(i,"error")&&typeof i.error=="object"&&i.error!==null?l.reject(new Kf(i.error)):qr(i,"result")&&!qr(i,"error")?l.resolve(i.result):l.reject(new st("Malformed response from ALP daemon",{reason:"protocol",data:{id:i.id}})))}#k(t,i,a){const l=m=>{try{const p=JSON.stringify({jsonrpc:"2.0",id:t,...m});return no(p)<this.#g?p:void 0}catch{return}},u=m=>{if(!this.#a){if(m===void 0)return this.#S(new st("ALP reply exceeds the frame limit",{reason:"protocol"}));try{this.#e.send(m)}catch(p){this.#S(new st("Could not send ALP reply",{reason:"send_failed",cause:p}))}}},d=m=>{const p=m&&typeof m.code=="number"?m.code:1e3,x=m instanceof Error?m.message:String(m),y=x.length>2e3?`${x.slice(0,2e3)}...`:x,w=m&&m.data!==void 0?{data:m.data}:{};return l({error:{code:p,message:y,...w}})??l({error:{code:p,message:y}})??l({error:{code:-32603,message:"The reply could not be sent"}})},[h]=this.#o;if(!h)return u(d(Object.assign(new Error(`Unknown method '${i}'`),{code:-32601})));Promise.resolve().then(async()=>{try{const m=await h(i,a),p=l({result:m===void 0?{}:m});u(p??d(new Error(`The result of ${i} cannot be serialized or exceeds the ${this.#g}-byte frame limit`)))}catch(m){u(d(m))}})}#S(t){if(this.#a)return;this.#a=t;for(const l of this.#f.splice(0))try{l()}catch{}try{this.#e.close()}catch{}const i=[...this.#p.values()];this.#p.clear();for(const l of i)l.cleanup(),l.reject(t);const a=[...this.#m];this.#n.clear(),this.#i.clear(),this.#o.clear(),this.#m.clear();for(const l of a)this.#d(l,t)}}const l2="principal.agent";function Ax(s,t={name:"alp",version:"0"},i,{agent:a=!1}={}){return s.request("daemon.hello",{protocolVersion:Xk,client:t,...a?{capabilities:[l2]}:{}},i)}function c2(s,{initialMs:t=250,maxMs:i=1e4,factor:a=2,jitter:l=.2}={},u=Math.random){const d=Math.min(i,t*a**Math.max(0,s-1));return Math.max(0,Math.round(d*(1+l*(2*u()-1))))}function u2(s){return!(s instanceof Kf&&s.code===Pk.protocol)}function d2(){if(typeof globalThis.AbortController=="function"){const i=new globalThis.AbortController;return{signal:i.signal,abort:a=>i.abort(a)}}const s=new Set,t={aborted:!1,reason:void 0,addEventListener(i,a){s.add(a)},removeEventListener(i,a){s.delete(a)}};return{signal:t,abort(i){if(!t.aborted){t.aborted=!0,t.reason=i;for(const a of[...s])a();s.clear()}}}}function Cx({connect:s,onConnect:t,onDisconnect:i,backoff:a={},maxAttempts:l=1/0,stableMs:u=5e3,shouldRetry:d=u2,client:h,random:m=Math.random}){if(typeof s!="function")throw new TypeError("createReconnectingClient needs connect()");let p="connecting",x,y=0,w=!1,k;const j=d2(),S=new Set,A=new Set,R=new Set,q=new Set,O=h?.onListenerError??(C=>{setTimeout(()=>{throw C},0)}),L=(C,...Y)=>{try{C(...Y)}catch(H){O(H)}},B=(C,Y)=>{p=C;for(const H of[...R])if(L(H,C,Y),p!==C)return;if(C==="open"&&x)for(const H of[...q])q.delete(H),H.resolve(x);if(C==="stopped")for(const H of[...q])q.delete(H),H.reject(Y??new st("ALP connection stopped",{reason:"closed"}))},_=C=>{if(p!=="stopped"){if(y>=l||!d(C))return B("stopped",C);B("waiting",C),p==="waiting"&&(k=setTimeout(()=>{k=void 0,Q()},c2(y,a,m)))}},Q=async()=>{if(p==="stopped")return;y++,B("connecting");const{signal:C}=j;if(p!=="connecting"||C.aborted)return;let Y;const H=()=>Y?.close();C.addEventListener("abort",H,{once:!0});try{const re=await s({attempt:y,signal:C});if(C.aborted){try{re.close()}catch{}return}if(Y=new o2(re,h),Y.onEvent(de=>{for(const U of[...S])L(U,de)}),Y.onNotification((de,U)=>{for(const Z of[...A])L(Z,de,U)}),t&&await t(Y,{attempt:y,reconnect:w,signal:C}),C.aborted){Y.close();return}if(Y.closed)throw new st("ALP connection closed during onConnect",{reason:"disconnected"})}catch(re){return Y?.close(),C.aborted?void 0:_(re instanceof Error?re:new Error(String(re)))}finally{C.removeEventListener("abort",H)}const fe=Y;x=fe;const ee=w;w=!0;const xe=Date.now();fe.onClose(re=>{x===fe&&(x=void 0,Date.now()-xe>=u&&(y=0),L(()=>i?.(re,{reconnect:ee})),_(re))}),B("open")};return Q(),{get state(){return p},get client(){return x},get attempt(){return y},ready({signal:C}={}){return p==="open"&&x?Promise.resolve(x):p==="stopped"?Promise.reject(new st("ALP connection stopped",{reason:"closed"})):new Promise((Y,H)=>{const fe={resolve:xe=>{C?.removeEventListener("abort",ee),Y(xe)},reject:xe=>{C?.removeEventListener("abort",ee),H(xe)}},ee=()=>{q.delete(fe),H(new st("Waiting for the ALP connection was aborted",{reason:"aborted",cause:C?.reason}))};if(C?.aborted)return ee();q.add(fe),C?.addEventListener("abort",ee,{once:!0})})},request(C,Y,H){return p!=="open"||!x?Promise.reject(new st("ALP daemon connection closed",{reason:p==="stopped"?"closed":"disconnected"})):x.request(C,Y,H)},onEvent(C){return S.add(C),()=>S.delete(C)},onNotification(C){return A.add(C),()=>A.delete(C)},onState(C){return R.add(C),()=>R.delete(C)},stop(){if(p==="stopped")return;k!==void 0&&(clearTimeout(k),k=void 0),j.abort(new st("ALP connection stopped",{reason:"closed"}));const C=x;x=void 0,B("stopped"),C?.close(),S.clear(),A.clear(),R.clear()}}}const ji="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function f2(s){let t="",i=0;for(;i+2<s.length;i+=3){const a=s[i]<<16|s[i+1]<<8|s[i+2];t+=ji[a>>18]+ji[a>>12&63]+ji[a>>6&63]+ji[a&63]}if(i<s.length){const a=s[i]<<16|(i+1<s.length?s[i+1]:0)<<8;t+=ji[a>>18]+ji[a>>12&63]+(i+1<s.length?ji[a>>6&63]:"=")+"="}return t}async function vb(s){const t=globalThis.crypto?.subtle;if(!t)throw new Error("SHA-256 needs WebCrypto here; pass sha256 yourself");const i=new Uint8Array(await t.digest("SHA-256",s));return Array.from(i,a=>a.toString(16).padStart(2,"0")).join("")}function $d(s){const t={begin:i=>s.request("attachment.begin",i),chunk:i=>s.request("attachment.chunk",i),commit:i=>s.request("attachment.commit",i),abort:i=>s.request("attachment.abort",{uploadId:i}),get:i=>s.request("attachment.get",{attachmentId:i}),delete:i=>s.request("attachment.delete",{attachmentId:i}),upload({sessionId:i,name:a,mimeType:l,data:u,requestId:d,sha256:h,maxChunkBytes:m,signal:p,onBegun:x,onProgress:y}){let w,k=!1,j;const S=()=>k||(p?.aborted??!1),A=()=>j??p?.reason??new Error("Upload aborted"),R=()=>{w&&t.abort(w).catch(()=>{})};p?.addEventListener?.("abort",R,{once:!0});const q=(async()=>{try{if(S())throw A();const O=h??await vb(u);if(S())throw A();const L=await t.begin({sessionId:i,name:a,size:u.length,mimeType:l,sha256:O,requestId:d});w=L.uploadId;try{x?.(L.uploadId)}catch(Q){throw L.state!=="committed"&&await t.abort(L.uploadId).catch(()=>{}),Q}if(S())throw L.state!=="committed"&&await t.abort(L.uploadId).catch(()=>{}),A();if(L.state==="committed"&&L.attachmentId)return(await t.get(L.attachmentId)).attachment;const B=Math.max(1,Math.min(L.maxChunkBytes,m??1/0));let _=L.received;for(let Q=0;_<u.length;){if(S())throw await t.abort(L.uploadId).catch(()=>{}),A();const C=Math.min(u.length,_+B);try{const{received:Y}=await t.chunk({uploadId:L.uploadId,offset:_,data:f2(u.subarray(_,C))});_=Y}catch(Y){if(S())throw await t.abort(L.uploadId).catch(()=>{}),A();const H=Y?.data;if(H?.reason!=="offset_mismatch"||!Number.isSafeInteger(H.received)||++Q>3)throw Y;_=H.received;continue}if(S())throw await t.abort(L.uploadId).catch(()=>{}),A();try{y?.(_,u.length)}catch(Y){throw await t.abort(L.uploadId).catch(()=>{}),Y}}if(S())throw await t.abort(L.uploadId).catch(()=>{}),A();return(await t.commit({uploadId:L.uploadId,sha256:O})).attachment}finally{p?.removeEventListener?.("abort",R)}})();return Object.defineProperty(q,"uploadId",{get:()=>w,enumerable:!0}),q.abort=async O=>{k=!0,j=O??new Error("Upload aborted"),w&&await t.abort(w).catch(()=>{})},q}};return t}function h2(s,t){const i=t.capabilities.includes("terminal.watch")&&!!s.onNotification;let a=!1,l="",u="",d=!1,h;const m=new Map,p=s.onNotification?.((S,A)=>{a||!i||S!=="terminal.changed"||!/^[0-9a-f]{32}$/.test(A?.watchId)||!/^[0-9a-f]{32}$/.test(A?.cursor)||(m.size>=4&&!m.has(A.watchId)&&m.delete(m.keys().next().value??""),m.set(A.watchId,A.cursor),A.watchId===l&&A.cursor!==u&&(d=!0,x()))});function x(){return a?Promise.resolve():h||(h=(async()=>{do{d=!1;try{const S=await s.request(i?"terminal.watch":"terminal.list",{...t.workspaceId?{workspaceId:t.workspaceId}:{},...i&&u?{after:u}:{}});if(a)return;if(!Array.isArray(S?.terminals))throw new Error("Invalid terminal directory snapshot");if(i){if(!/^[0-9a-f]{32}$/.test(S.watchId)||!/^[0-9a-f]{32}$/.test(S.cursor)||typeof S.reset!="boolean")throw new Error("Invalid terminal directory cursor");l=S.watchId,u=S.cursor,d=m.has(l)&&m.get(l)!==u,m.clear()}t.onSnapshot(S.terminals)}catch(S){t.onError?.(S);return}}while(d&&!a)})().finally(()=>{h=void 0}),h)}const y=i?void 0:setInterval(()=>{x()},t.pollMs??5e3);let w=()=>{};function k(S=!0){a||(a=!0,y!==void 0&&clearInterval(y),p?.(),w(),m.clear(),i&&S&&s.request("terminal.unwatch",{}).catch(()=>{}))}return w=s.onClose(()=>k(!1)),a&&w(),t.onMode?.(i?"events":"polling"),{ready:x(),refresh:x,close:k,mode:i?"events":"polling"}}class Ra extends Error{constructor(t="The gateway refused this access token. It may be mistyped, revoked, rotated or expired."){super(t),this.name="AuthenticationError"}}class Ke extends Error{constructor(t){super(t),this.name="ConfigurationError"}}class Ai extends Error{constructor(t){super(t),this.name="TransientError"}}class wb extends Error{constructor(t,i){super(t),this.name="CreateOutcomeUnknownError",this.sessionId=i}}const m2=new Set(["attachment_unsupported","attachment_limit","attachment_unavailable","attachment_too_large","attachment_forbidden","attachment_referenced","quota_exceeded","invalid_name","invalid_data","hash_mismatch","upload_incomplete","chunk_conflict","offset_mismatch","request_conflict","persistence_failed","upload_expired"]),p2=s=>s&&typeof s=="object"&&s.data&&typeof s.data.reason=="string"?s.data.reason:void 0,Xf=s=>s instanceof Kf||!!s&&typeof s=="object"&&typeof s.code=="number"&&!Ff(s);function Ud(s){const t=Xf(s)?s.code:void 0;return t===1001||t===1003||t===-32601||t===-32602}function Be(s){if(s instanceof Ra)return{message:s.message,sent:"no",terminal:!0};if(s instanceof Ke)return{message:s.message,sent:"no",terminal:!0};if(s instanceof Ai)return{message:s.message,sent:"no",terminal:!1};if(s instanceof wb)return{message:s.message,sent:"unknown",terminal:!1};if(Ff(s))switch(s.reason){case"send_failed":case"overloaded":return{message:"The request could not be sent. Nothing reached the host.",sent:"no",terminal:!1};case"closed":return{message:"Disconnected from the host.",sent:"unknown",terminal:!1};case"timeout":return{message:"The host did not answer in time. The request may still have run.",sent:"unknown",terminal:!1};case"aborted":return{message:"Stopped waiting for the host. The request may still have run.",sent:"unknown",terminal:!1};case"protocol":return{message:"The host sent something this app does not understand.",sent:"unknown",terminal:!1};default:return{message:"The connection dropped before the host answered. The request may still have run.",sent:"unknown",terminal:!1}}if(Xf(s)){const t=typeof s.code=="number"?s.code:1e3,i=p2(s),a={code:t,...i?{reason:i}:{},sent:"yes",terminal:!1};if(t===1e3&&(i==="gateway_timeout"||i==="daemon_disconnected"))return{...a,sent:"unknown",message:i==="gateway_timeout"?"The host took too long to answer. The request may still have run.":"The gateway lost the host before it answered. The request may still have run."};if(t===1004&&i==="outcome_unknown")return{...a,sent:"unknown",message:"The host cannot tell whether the agent received this message. Check the conversation before sending it again."};if(i&&m2.has(i)&&s.message)return{...a,message:/[.!?]$/.test(s.message)?s.message:`${s.message}.`};if(t===1005&&i==="not_sent")return{...a,sent:"no",message:"The gateway was too busy to pass the request on. Nothing reached the host."};if(t===1005&&i==="rate_limited")return{...a,sent:"no",message:"Too many requests at once. Wait a moment and try again."};if(t===1005&&i==="too_many_pending")return{...a,sent:"no",message:"Too many requests are waiting. Wait a moment and try again."};if(t===1005&&i==="busy")return{...a,message:"Tasks are locked by another writer on the host. Try again in a moment."};if(t===1003&&i==="grant"){const l=s.data?.permission;return{...a,message:`Your access token does not allow this${l?` (needs ${l})`:""}.`}}return t===1003&&i==="mode"?{...a,message:"Your access token cannot drive a session in this mode. Ask the host owner for a token with that mode, or use a session in a granted mode."}:t===1003&&i==="outside_workspace"?{...a,message:"That workspace is not granted to your access token."}:t===1003&&i==="spec_field"?{...a,message:"The host refused one of the session settings."}:t===1003&&i==="content_type"?{...a,message:s.message?/[.!?]$/.test(s.message)?s.message:`${s.message}.`:"This message contains content the host does not accept."}:t===1003?{...a,message:"The host refused this request."}:t===1001?{...a,message:"Not found on the host. It may have been removed or expired."}:t===1004&&i==="revision_conflict"?{...a,message:"It changed on the host meanwhile. The latest version is shown; try again if you still want to."}:t===1004&&i==="task_state"?{...a,message:"The task's current state does not allow that."}:t===1004&&i==="key_conflict"?{...a,message:"That request id was already used for something else."}:t===-32601?{...a,message:"The host does not offer this through the gateway."}:t===-32602?{...a,message:"The host refused the request as invalid."}:t===1006?{...a,terminal:!0,message:"This host speaks a different protocol version. Update ALP on the host or this app."}:{...a,message:s.message?`The host could not do that: ${s.message}`:"The host could not do that."}}return{message:s instanceof Error&&s.message?s.message:"Something went wrong.",sent:"unknown",terminal:!1}}const Ir=Object.freeze({blocked_path:"This file is never shown remotely: secrets, keys, .git and ALP configuration are blocked.",ignored:"This file is ignored by .gitignore, so it is hidden by default.",linked:"This path is a link, or it changed while it was read. Links are not followed.",binary:"Binary preview unavailable",too_large:"This file is too large to display",not_found:"This file or folder is not on the host. It may have been moved or removed.",invalid_path:"That is not a valid path in this workspace.",not_directory:"The workspace folder cannot be read on the host."});class Ei extends Error{constructor(t){super(t.message),this.name="FileAccessError",this.failure=t,this.reason=t.reason}}function g2(s){if(s instanceof Ei)return s.failure;const t=Be(s),i=t.reason;if(!Xf(s)||!i)return t;const a=Ir[i];return!a||i==="not_found"&&t.code!==1001?t:{...t,message:a}}const Hd=["name","modified","size"],Id=Object.freeze({name:"Name",modified:"Modified",size:"Size"});function Ex(s){const t=Hd.indexOf(s);return Hd[(t+1)%Hd.length]}function Js(s){if(typeof s!="string")return;let t=s;for(;t.startsWith("./");)t=t.slice(2);if(!(!t||t.length>Hl.maxPathLength)&&!(t.startsWith("/")||/^[a-zA-Z]:/.test(t)||/[\\\0]/.test(t))&&!t.split("/").some(i=>!i||i==="."||i===".."))return t}const gf=s=>{const t=typeof s=="string"?Date.parse(s):NaN;return Number.isFinite(t)?t:0};function x2(s,t){const i=t?`${t}/`:"",a=[],l=new Set;for(const d of Array.isArray(s?.entries)?s.entries:[]){if(!d||typeof d!="object")continue;const{name:h,kind:m}=d;if(typeof h!="string"||!h||h.includes("/")||m!=="file"&&m!=="directory")continue;const p=Js(d.path);if(!(!p||p!==`${i}${h}`||$i(p)||l.has(p))&&(l.add(p),a.push({name:h,path:p,kind:m,...m==="file"&&typeof d.size=="number"&&Number.isFinite(d.size)&&d.size>=0?{size:d.size}:{},...typeof d.modifiedAt=="string"&&gf(d.modifiedAt)?{modifiedAt:d.modifiedAt}:{}}),a.length>=Hl.maxListEntries))break}const u=Array.isArray(s?.entries)&&s.entries.length>Hl.maxListEntries;return{entries:a,truncated:s?.truncated===!0||u}}const y2=s=>s.startsWith(".");function b2(s,t){return[...s].sort((i,a)=>i.kind!==a.kind?i.kind==="directory"?-1:1:t==="modified"?gf(a.modifiedAt)-gf(i.modifiedAt)||i.name.localeCompare(a.name):t==="size"&&(a.size??0)-(i.size??0)||i.name.localeCompare(a.name))}function v2(s,t){return s.includes(t)?s.filter(i=>i!==t):[...s,t]}function w2(s,t,{sort:i,showHidden:a}){const l=new Set(t),u=[],d=(h,m)=>{const p=s[h];if(!p||p.status==="loading"){u.push({kind:"status",path:h,depth:m,status:"loading"});return}if(p.status==="error"){u.push({kind:"status",path:h,depth:m,status:"error",...p.error?{message:p.error}:{}});return}const x=b2((p.entries??[]).filter(y=>a||!y2(y.name)),i);x.length||u.push({kind:"status",path:h,depth:m,status:"empty"});for(const y of x){const w=y.kind==="directory"&&l.has(y.path);u.push({kind:"entry",entry:y,depth:m,open:w}),w&&d(y.path,m+1)}p.truncated&&u.push({kind:"status",path:h,depth:m,status:"truncated"})};return d("",0),u}function k2(s){return typeof s!="number"||!Number.isFinite(s)||s<0?"":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function j2(s){if(!s)return 0;const t=s.split(`
11
+ `).length;return s.endsWith(`
12
+ `)?t-1:t}const S2=s=>/\.(md|markdown|mdx)$/i.test(s),N2=0,Vr=1,Mx=Object.freeze({unsupportedData:4003,tooLarge:4009}),T2=250,A2=123;function xf(s){const t=/^([a-z][a-z0-9+.-]*:\/\/)(?:[^/?#\\]*@)?([^/?#\\@]*)([^?#]*)/i.exec(String(s));return t?`${t[1]}${t[2]}${t[3]}`:"<websocket>"}function zx(s,t){const a=((s instanceof Error?s.message:String(s??"")).split(String(t)).join(xf(t))||"WebSocket error").replace(/[a-z][a-z0-9+.-]*:\/\/[^\s'"<>]+/gi,u=>xf(u)),l=new Error(a);return s instanceof Error&&s.name&&(l.name=s.name),l}function C2(s){let t=s;for(;no(t)>A2;)t=t.slice(0,-1);return t}function _l(s,t,i){if(!(s.readyState!==N2&&s.readyState!==Vr)){try{t===void 0?s.close():s.close(t,C2(i??""));return}catch{}try{s.close()}catch{}}}function kb(s){typeof s.addEventListener=="function"&&s.addEventListener("error",()=>{})}function _a(s,t,i){if(typeof s.addEventListener=="function")return s.addEventListener(t,i),()=>s.removeEventListener?.(t,i);const a=`on${t}`,l=s[a];return s[a]=u=>{l?.(u),i(u)},()=>{s[a]=l??null}}const jb=s=>{const t=s?.error instanceof Error&&s.error.message||typeof s?.message=="string"&&s.message||"WebSocket error";return s?.error instanceof Error&&s.error.message?s.error:new Error(t)};function E2(s,{maxFrame:t=mf,maxBufferedBytes:i=4*mf}={}){if(s.readyState!==Vr)throw new st("WebSocket is not open",{reason:"disconnected"});kb(s);try{s.binaryType="arraybuffer"}catch{}const a=new Set,l=new Set;let u;const d=[];let h,m;const p=y=>{if(u)return;u=y,m!==void 0&&clearTimeout(m);for(const k of d.splice(0))k();a.clear();const w=[...l];l.clear();for(const k of w)k(y)},x=(y,w)=>{const k=new st(y,{reason:"protocol"});_l(s,w,y),p({error:k})};return d.push(_a(s,"message",y=>{if(u)return;const w=y?.data;if(typeof w!="string")return x("Binary WebSocket messages are not ALP frames",Mx.unsupportedData);if(no(w)>t)return x(`ALP frame exceeds ${t} bytes`,Mx.tooLarge);for(const k of w.includes(`
13
+ `)?w.split(`
14
+ `):[w]){if(u)return;if(k.trim())for(const j of[...a])j(k)}})),d.push(_a(s,"close",y=>p({error:h,code:typeof y?.code=="number"?y.code:void 0,reason:typeof y?.reason=="string"&&y.reason?y.reason:void 0}))),d.push(_a(s,"error",y=>{h||(h=jb(y),m=setTimeout(()=>p({error:h}),T2),_l(s))})),{get state(){return u||s.readyState!==Vr?"closed":"open"},send(y){if(u||s.readyState!==Vr)throw new st("WebSocket is not open",{reason:"send_failed"});if((s.bufferedAmount??0)+no(y)>i)throw new st(`WebSocket send buffer is over ${i} bytes`,{reason:"send_failed"});s.send(y)},onMessage(y){return u?()=>!1:(a.add(y),()=>a.delete(y))},onClose(y){return u?()=>!1:(l.add(y),()=>l.delete(y))},close(){_l(s,1e3,"client closed"),p({code:1e3,reason:"client closed"})}}}function M2(s,{WebSocket:t,protocols:i,createSocket:a,signal:l,timeoutMs:u=15e3,...d}={}){const h=xf(s);let m;try{m=pf(u)}catch(y){return Promise.reject(y)}if(l?.aborted)return Promise.reject(new st(`Connecting to ${h} was aborted`,{reason:"aborted",cause:l.reason}));const p=t??globalThis.WebSocket;if(!a&&typeof p!="function")return Promise.reject(new TypeError("No WebSocket implementation: pass options.WebSocket or options.createSocket"));let x;try{x=a?a(s,i):i===void 0?new p(s):new p(s,i)}catch(y){return Promise.reject(new st(`Could not connect to ${h}`,{reason:"disconnected",cause:zx(y,s)}))}return kb(x),new Promise((y,w)=>{const k=[];let j;const S=()=>{for(const O of k.splice(0))O();j!==void 0&&clearTimeout(j),l?.removeEventListener("abort",R)},A=O=>{S(),_l(x),w(O)},R=()=>A(new st(`Connecting to ${h} was aborted`,{reason:"aborted",cause:l?.reason})),q=()=>{S();try{y(E2(x,d))}catch(O){w(O)}};if(x.readyState===Vr)return q();k.push(_a(x,"open",q)),k.push(_a(x,"error",O=>A(new st(`Could not connect to ${h}`,{reason:"disconnected",cause:zx(jb(O),s)})))),k.push(_a(x,"close",O=>A(new st(`Could not connect to ${h}`,{reason:"disconnected",data:{code:O?.code,reason:O?.reason||void 0}})))),l?.addEventListener("abort",R,{once:!0}),m!==void 0&&(j=setTimeout(()=>A(new st(`Connecting to ${h} timed out after ${u} ms`,{reason:"timeout"})),m))})}const z2=new Set(["localhost","127.0.0.1"]);function Sb(s){let t;try{t=new URL(String(s).trim())}catch{throw new Ke("Enter the gateway address, such as https://alp.example.com or http://127.0.0.1:7434.")}if(t.username||t.password||t.search||t.hash)throw new Ke("Use a gateway address without a user name, password, query or fragment.");if(t.protocol!=="https:"&&!(t.protocol==="http:"&&z2.has(t.hostname)))throw new Ke("Use https, or http only on this machine (127.0.0.1 or localhost, for example through an SSH tunnel).");return`${t.origin}${t.pathname.replace(/\/+$/,"")}`}const Nl=s=>Array.isArray(s)&&s.every(t=>typeof t=="string");function R2(s){if(!s||typeof s!="object")return;const{websocket:t,subprotocols:i,principal:a}=s;if(t!=="/v1/ws"||!Nl(i)||!i.includes("alp.v1")||!a||typeof a.id!="string"||!Nl(a.permissions)||!Nl(a.workspaces)||a.modes!==void 0&&!Nl(a.modes))return;const l={id:a.id,...typeof a.label=="string"?{label:a.label}:{},permissions:[...a.permissions],workspaces:[...a.workspaces],...Array.isArray(a.workspaceRoots)?{workspaceRoots:a.workspaceRoots.filter(u=>u&&typeof u.path=="string"&&typeof u.canonical=="string").map(u=>({path:u.path,canonical:u.canonical}))}:{},...a.modes?{modes:[...a.modes]}:{}};return{websocket:t,subprotocols:i,principal:l}}async function _2(s){try{const t=await s.json();return typeof t?.error=="string"?t.error:void 0}catch{return}}function L2(s,t){const i=new AbortController,a=setTimeout(()=>i.abort(new Ai("The gateway did not answer in time.")),t),l=()=>i.abort(s?.reason);return s?.aborted?l():s?.addEventListener("abort",l,{once:!0}),{signal:i.signal,done(){clearTimeout(a),s?.removeEventListener("abort",l)}}}async function O2({url:s,token:t,signal:i,timeoutMs:a=15e3,fetch:l=globalThis.fetch.bind(globalThis),WebSocket:u}){const d=Sb(s);if(!t||/\s/.test(t))throw new Ra("Enter the access token printed by alp-gateway credential create.");const h=L2(i,a);let m;try{m=await l(`${d}/v1/tickets`,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",headers:{authorization:`Bearer ${t}`},signal:h.signal})}catch(p){throw h.done(),i?.aborted?i.reason??p:h.signal.reason instanceof Ai?h.signal.reason:new Ai("Cannot reach the gateway. Check that it is running at this address and that it allows this page's origin (alp-gateway serve --origin).")}try{if(m.status===401)throw new Ra;if(m.status===403){const w=await _2(m);throw new Ke(w==="tls_required"?"The gateway only accepts this connection over HTTPS.":"The gateway does not allow this page's origin. Start it with --origin set to this page's address.")}if(m.status===421)throw new Ke("The gateway does not know this host name. Add it with alp-gateway serve --public-host.");if(m.status===429)throw new Ai("The gateway is limiting requests from this address. Wait a moment.");if(m.status!==201)throw new Ai(`The gateway is not ready (HTTP ${m.status}).`);const p=R2(await m.json().catch(()=>{}));if(!p)throw new Ke("The gateway answered with an unexpected ticket. Check that the address points to an ALP gateway.");const x=`${d.replace(/^http/,"ws")}${p.websocket}`;return{transport:await M2(x,{protocols:p.subprotocols,signal:h.signal,timeoutMs:a,...u?{WebSocket:u}:{}}).catch(w=>{throw i?.aborted?i.reason??w:new Ai("The gateway accepted the token but the live connection failed. Retrying may help.")}),principal:p.principal}}finally{h.done()}}function Ll(s,t){return!s||!t?void 0:(s.workspaceRoots?.length?s.workspaceRoots:s.workspaces.map(a=>({path:a,canonical:a}))).find(a=>a.path===t||a.canonical===t)}function Te(s,t){return s?s.permissions.includes(t)?!0:t.endsWith(".read")&&s.permissions.includes(t.replace(/\.read$/,".write")):!1}const Pf="alp-web:link-token",D2=/^alpgw1\.[a-f0-9]{16}\.[A-Za-z0-9_-]{43}$/,q2="This link's access token is no longer valid. Run `alp web` again to open ALP with a new link.",B2="This page is not on this machine's loopback address, so it did not use the access token in its link. Open the address `alp web` printed.",$2="The access token in this link is incomplete or damaged. Run `alp web` again, or copy its whole address.",U2=new Set(["127.0.0.1","localhost"]),Nb=s=>typeof s=="string"&&D2.test(s);function H2(s){const t=String(s??"").replace(/^#/,"");if(!t)return;const i=new URLSearchParams(t);if(!i.has("token"))return;const a=i.get("token");return Nb(a)?{token:a}:{malformed:!0}}const Tb=s=>s.protocol==="http:"&&U2.has(s.hostname);function I2(s){let t;try{t=s?.getItem(Pf)}catch{return}if(t!=null){if(Nb(t))return t;Kr(s)}}function Kr(s){try{s?.removeItem(Pf)}catch{}}function Ab({location:s,history:t,storage:i}){const a=H2(s.hash);a&&t.replaceState(t.state,"",`${s.pathname}${s.search}`);const l=Tb(s);if(a&&("malformed"in a||!l))return Kr(i),{error:"malformed"in a?$2:B2};if(a){try{i?.setItem(Pf,a.token)}catch{}return{url:s.origin,token:a.token}}if(!l)return;const u=I2(i);return u?{url:s.origin,token:u}:void 0}const G2="http://127.0.0.1:7434",Cb=({location:s,dev:t=!1})=>!t&&Tb(s);function Y2({location:s,remembered:t,dev:i=!1}){return t||(Cb({location:s,dev:i})?s.origin:G2)}function sc(s=16){const t=new Uint8Array(Math.ceil(s/2));return globalThis.crypto.getRandomValues(t),Array.from(t,i=>i.toString(16).padStart(2,"0")).join("").slice(0,s)}const V2=()=>`web_${sc(16)}`,Tl=()=>`web-msg-${sc(20)}`,K2=()=>`web-task-${sc(16)}`,Qf=()=>`web-conv-${sc(16)}`,F2="Files in the workspace are not changed or restored: only the conversation goes back.",X2="Files are not copied: the fork works on the current files of where it runs.",yf={runtime_unsupported:"This session runs on a runtime that cannot fork or rewind its conversation.",not_persistent:"This session keeps no native conversation to fork or rewind.",not_root:"Only a main conversation can be forked or rewound; an agent's work belongs to its requester."},Al=Object.freeze({session_busy:"The session or one of its agents is still working. Wait until everything is idle, then try again.",stale_generation:"The conversation changed since this view loaded. It was reloaded; check it and try again.",turn_not_found:"That message is no longer part of this conversation. It was reloaded; try again.",turn_in_progress:"A turn is still running. Wait until it ends, then try again.",empty_prefix:"Nothing comes before the first message. Start a new session instead.",boundary_unmapped:"The agent's runtime cannot go back to exactly this point (that turn was not started by ALP). Choose another message.",runtime_unsupported:yf.runtime_unsupported,native_refused:"The agent's runtime refused it. Nothing changed.",outcome_unknown:"The host cannot tell whether it happened. Check the session list and this conversation before trying again; a new attempt is a new request.",key_conflict:"That request id was already used for something else. Try again.",branch_not_found:"That branch is no longer kept on the host.",not_root:yf.not_root,outside_workspace:"That workspace is not granted to your access token.",attachment_forbidden:"This conversation holds an attachment your access token may not use.",request_conflict:"A session with that id already exists.",persistence_failed:"The host could not finish saving it. Trying again finishes it.",invalid_params:"The host did not accept this request for this session. Reload the page and try again; if it keeps happening, this app and the host may run different versions of ALP."}),P2=s=>typeof s?.data?.reason=="string"?s.data.reason:void 0;function ei(s){const t=s,i=P2(t),a=typeof t?.code=="number"?t.code:void 0,l=Be(s),u=l.sent!=="yes"&&i!=="outcome_unknown",d=i==="stale_generation"||i==="turn_not_found";if(i==="persistence_failed")return{message:Al.persistence_failed,reason:i,code:a,retrySame:!0,reload:!1};if(a===1003&&i==="grant")return{message:`Your access token cannot do this (it needs ${typeof t?.data?.permission=="string"?t.data.permission:"session.write"}).`,reason:i,code:a,retrySame:!1,reload:!1};if(a===1003&&i==="mode"){const h=Array.isArray(t?.data?.modes)?t.data.modes.filter(m=>typeof m=="string"):[];return{message:`Your access token cannot drive this conversation in its mode${h.length?` (it may use ${h.join(", ")})`:""}. Ask the host owner for a token with that mode.`,reason:i,code:a,retrySame:!1,reload:!1}}if(i&&Al[i])return{message:Al[i],reason:i,code:a,retrySame:!1,reload:d};if(u){const h=l.sent==="no"?" Trying again is safe.":" It may have happened: trying again sends the same request, which the host answers only once.";return{message:`${l.message}${l.terminal?"":h}`,...i?{reason:i}:{},code:a,retrySame:!l.terminal,reload:!1}}return a===-32601?{message:"This host does not offer it. Update ALP on the host.",code:a,retrySame:!1,reload:!1}:a===-32602?{message:Al.invalid_params,...i?{reason:i}:{},code:a,retrySame:!1,reload:!1}:{message:s instanceof Error&&s.message?s.message:"Something went wrong.",...i?{reason:i}:{},code:a,retrySame:!1,reload:d}}function Q2({capabilities:s,canRead:t,canWrite:i,summary:a,busy:l=!1,generation:u,online:d=!0,driveBlock:h}){const m=a?.conversation,p=(k=void 0)=>({shown:!1,...k?{reason:k}:{}}),x=m?.reason?yf[m.reason]??`Not available here (${m.reason}).`:void 0,y=s.includes("session.history")&&!!u,w=k=>s.includes(`session.${k}`)?!m||m[k]!==!0?p(x):!i||k==="fork"&&!t?p("Your access token cannot change this conversation (it needs session.write)."):h?p(h):y?d?k==="rewind"&&l?{shown:!0,reason:"Wait until main and its agents are idle."}:{shown:!0}:{shown:!0,reason:"Reconnecting…"}:p("This host does not keep a history generation for this view."):p();return{fork:w("fork"),rewind:w("rewind")}}const W2="Restart the agent's process on the same conversation and settings, for example after a new sign-in. Its messages, history and files stay.",Fr=Object.freeze({session_busy:"The agent or one of its agents is still working. Wait until everything is idle, then reload.",session_closed:"The session is closed. Send it a message to open it again on its conversation.",no_history:"The agent has no conversation to keep yet. Send it a message first, or start a new session.",native_refused:"The agent could not be restarted on its conversation. The session was closed with its conversation kept; send it a message to open it again.",runtime_unsupported:"This session runs on a runtime the host cannot reload.",not_root:"Only the main agent of a session can be reloaded."});function Z2(s){const t=ei(s),i=t.reason?Fr[t.reason]:void 0;return i?{...t,message:i}:t}const J2="Main writes a checkpoint of its work, then its context is compacted (or a fresh conversation starts from the checkpoint). Its session, history and files stay; while it is busy, this waits for the end of its turn.",Wf=Object.freeze({session_busy:"The session is not open. Send it a message to open it, then compact it.",session_closed:"The session is closed. Send it a message to open it, then compact it.",runtime_unsupported:"Only the main agent of a session can be compacted.",not_root:"Only the main agent of a session can be compacted."});function ej(s){return s==="deferred"?"Compaction will start when the main agent finishes its current turn.":s==="running"?"The main agent is already compacting its context.":"Compacting the main agent's context: it writes a checkpoint first."}function tj(s){const t=ei(s),i=t.reason?Wf[t.reason]:void 0;return i?{...t,message:i}:t}function nj({capabilities:s,canRead:t,canWrite:i,summary:a,root:l,closed:u=!1,busy:d=!1,generation:h,online:m=!0,driveBlock:p}){const x=j=>({shown:!0,enabled:!1,reason:j}),y=s.includes("session.resumeCommand")?t?m?{shown:!0,enabled:!0}:x("Reconnecting…"):x("Your access token cannot read this session."):{shown:!1,enabled:!1},w=()=>{if(!s.includes("session.reload"))return{shown:!1,enabled:!1};if(!l)return x(Fr.not_root);const j=a?.conversation;return j?.reload!==!0?x(j?.reason==="not_persistent"?"This session keeps no native conversation to reload.":Fr.runtime_unsupported):i?p?x(p):u?x(Fr.session_closed):!s.includes("session.history")||!h?x("The conversation is still loading."):m?d?x("Wait until main and its agents are idle."):{shown:!0,enabled:!0}:x("Reconnecting…"):x("Your access token cannot reload agents (it needs session.write).")},k=()=>l?i?p?x(p):u?x(Wf.session_closed):m?{shown:!0,enabled:!0}:x("Reconnecting…"):x("Your access token cannot compact agents (it needs session.write)."):{shown:!1,enabled:!1};return{reload:w(),compact:k(),resume:y}}function sj(s,t={}){const i=new Map,a=s.turnOrder??[];for(const l of s.entries){if(l.sessionId!==s.rootId)continue;const u=l.item;if(u.kind!=="user_message"||typeof u.clientMessageId!="string")continue;const d=s.prompts[u.clientMessageId];if(!d||d.state!=="accepted"||d.result!=="turn"||!d.turnId)continue;const h=a.indexOf(d.turnId);h<0||i.set(l.key,{turnId:d.turnId,index:h,later:a.length-h,rewindable:h>0||!!t.hasOlder,ended:s.turns[d.turnId]==="ended",text:typeof u.text=="string"?u.text:""})}return i}function Zf(s){return s?.kind!=="notice"||typeof s.id!="string"?null:s.id.startsWith("rewind:")&&s.id.length>7?{kind:"rewind",branchId:s.id.slice(7)}:s.id.startsWith("fork:")&&s.id.length>5?{kind:"fork",sessionId:s.id.slice(5)}:null}const ij=s=>`${s} later turn${s===1?"":"s"}`,aj=s=>`${s} turn${s===1?"":"s"}`;function rj(s,t,i){const a=t?.find(u=>u.branchId===i)?.turns;if(typeof a=="number")return a;const l=/(\d+) later turn/.exec(String(s?.text??""));return l?Number(l[1]):void 0}const Il=Object.freeze({capability:"This host does not offer Git changes. Update ALP on the host.",registry:"This host does not list its workspaces, so Git changes cannot be shown. Update ALP on the host.",projectRead:"This access token cannot read Git status (needs project.read).",filesRead:"This access token cannot read file contents, so diffs are hidden (needs files.read).",workspace:"Choose a workspace to see its changes.",unregistered:"This workspace is not registered on the host, so its Git changes cannot be shown. The host owner can add it as a project.",loading:"Loading workspaces…"}),Gl=Object.freeze({not_repository:"Not a git repository",unknown_ref:"The base branch is not known in this repository.",invalid_compare:"The host refused this comparison. Pick Uncommitted or a branch name Git accepts.",stale_snapshot:"The checkout changed since this list was loaded. It was loaded again from the start.",invalid_cursor:"The rest of this list is no longer available. It was loaded again from the start.",git_unavailable:"Git is not available on the host.",git_failed:"Git failed on the host. Try again; the host's logs may say why.",blocked_path:"This file is never shown remotely: secrets, keys, .git and ALP configuration are blocked.",invalid_path:"That is not a valid path in this workspace."}),Eb=Object.freeze([{id:"uncommitted",label:"Uncommitted"},{id:"base",label:"Committed"},{id:"staged",label:"Staged"},{id:"unstaged",label:"Unstaged"}]),Rx=Object.freeze({modified:"Modified",added:"New",deleted:"Deleted",renamed:"Renamed",copied:"Copied",typechange:"Type changed",untracked:"Untracked",conflicted:"Conflicted"}),oj=Object.freeze({modified:"M",added:"A",deleted:"D",renamed:"R",copied:"C",typechange:"T",untracked:"U",conflicted:"!"}),Mb=Object.freeze({binary:"Binary file",too_large:"Diff too large to display",withheld:"Content withheld: it looks like it holds a private key.",symlink:"Symbolic link: its target is not shown.",submodule:"Submodule: its content is not shown."});class ys extends Error{constructor(t){super(t.message),this.name="GitAccessError",this.failure=t,this.reason=t.reason}}function _i(s){if(s instanceof ys)return s.failure;const t=Be(s);if(t.code===1003&&t.reason==="grant"){const a=s?.data?.permission;return a==="files.read"?{...t,message:Il.filesRead}:a==="project.read"?{...t,message:Il.projectRead}:t}const i=t.reason?Gl[t.reason]:void 0;return i?{...t,message:i}:t}function lj(s){const t=_i(s);return t.code===1004&&t.reason==="stale_snapshot"||t.code===-32602&&t.reason==="invalid_cursor"}function Jf(s){const t=s.workspace;if(!t)return;const i=Ll(s.principal??void 0,t),a=new Set([t,...i?[i.path,i.canonical]:[]]);return s.registry.workspaces.filter(l=>a.has(l.directory)&&!l.archivedAt).sort((l,u)=>+!!u.pinnedAt-+!!l.pinnedAt||String(l.createdAt).localeCompare(String(u.createdAt))||l.id.localeCompare(u.id))[0]}function Gd(s){const t=l=>({status:!1,reason:l,message:Il[l]});if(!s.workspace)return t("workspace");if(!s.connection.capabilities.includes("workspace.git"))return t("capability");if(!Te(s.principal??void 0,"project.read"))return t("projectRead");if(!s.connection.capabilities.includes("workspace.registry"))return t("registry");const i=Jf(s);if(!i)return t(s.registry.loading?"loading":"unregistered");const a=Te(s.principal??void 0,"files.read");return{status:!0,workspaceId:i.id,content:a,...a?{}:{contentMessage:Il.filesRead}}}function cj(s){const t=typeof s=="string"&&s?Js(s):void 0;return t&&!$i(t)?t:void 0}function uj({mode:s,baseRef:t,ignoreWhitespace:i}){const a=Eb.some(l=>l.id===s)?s:"uncommitted";return{mode:a,...a==="base"&&t?{baseRef:t}:{},...i?{ignoreWhitespace:!0}:{}}}function _x(s,t){const i=Array.isArray(t?.files)?t.files:[],a=Number.isSafeInteger(t?.hiddenCount)&&t.hiddenCount>0?t.hiddenCount:0,l=s&&s.snapshot===t.snapshot?s:void 0;return{compare:t.compare,snapshot:t.snapshot,files:l?[...l.files,...i]:[...i],hiddenCount:(l?.hiddenCount??0)+a,truncated:t.truncated===!0,...typeof t.nextCursor=="string"&&t.nextCursor?{nextCursor:t.nextCursor}:{}}}function dj(s){const t=[];for(const i of Array.isArray(s?.hunks)?s.hunks:[]){t.push({type:"hunk",text:`@@ -${i.oldStart},${i.oldCount} +${i.newStart},${i.newCount} @@${i.context?` ${i.context}`:""}`});let a=i.oldStart,l=i.newStart;for(const u of Array.isArray(i.lines)?i.lines:[]){const d=u.noNewline===!0?{noNewline:!0}:{};u.type==="add"?t.push({type:"add",text:u.content,newLine:l++,...d}):u.type==="remove"?t.push({type:"remove",text:u.content,oldLine:a++,...d}):t.push({type:"context",text:u.content,oldLine:a++,newLine:l++,...d})}}return t}function fj(s){let t=0,i=0;for(const a of s)t+=a.additions||0,i+=a.deletions||0;return{additions:t,deletions:i}}function Lx(s){if(!Number.isFinite(s)||s<1e3)return String(Math.max(0,Math.floor(s||0)));const t=s/1e3;return`${t>=10?Math.round(t):Math.round(t*10)/10}k`}function Ox(s){const i=[s.branch??(s.detached&&s.head?`Detached at ${s.head.slice(0,7)}`:s.head?s.head.slice(0,7):"No commits yet")];if(s.upstream){const{ref:a,ahead:l,behind:u}=s.upstream;i.push(`${a}${l||u?` (${[l?`↑${l}`:"",u?`↓${u}`:""].filter(Boolean).join(" ")})`:""}`)}return i.join(" · ")}function hj(s){return s?s.replace(/^refs\/(heads|remotes)\//,"").trim():"base"}const zb=Object.freeze(["image/png","image/jpeg","image/gif","image/webp"]),Mi=Object.freeze({maxCount:4,maxBytes:2*1024*1024,maxTotalBytes:2.5*1024*1024});function mj(s,t=!0){const i={maxCount:0,maxBytes:0,maxTotalBytes:0};if(!t)return i;if(s===void 0)return{...Mi};if(!s||typeof s!="object"||Array.isArray(s))return i;const a=s;if(!["maxCount","maxBytes","maxTotalBytes"].every(u=>Number.isSafeInteger(a[u])&&a[u]>=0))return i;const l=Math.min(Mi.maxTotalBytes,a.maxTotalBytes);return{maxCount:Math.min(Mi.maxCount,a.maxCount),maxBytes:Math.min(Mi.maxBytes,l,a.maxBytes),maxTotalBytes:l}}const Li=s=>s>=1024*1024?`${(s/1024/1024).toFixed(1).replace(/\.0$/,"")} MB`:`${Math.max(1,Math.round(s/1024))} KB`;function Rb(s){const t=String(s?.type??"").split(";",1)[0].trim().toLowerCase(),i=t==="image/jpg"?"image/jpeg":t;return zb.includes(i)?i:null}function Dx(s){if(!s)return[];const t=Array.from(s.files??[]);return t.length?t:Array.from(s.items??[]).filter(i=>i?.kind==="file").map(i=>i.getAsFile?.()).filter(i=>!!i)}function pj(s){let t="";for(let i=0;i<s.length;i+=32768)t+=String.fromCharCode(...s.subarray(i,i+32768));return btoa(t)}let gj=0;function _b(s,t,i,a,l=Mi){const u=s.reduce((d,h)=>d+h.size,0);return i?!l.maxCount||!l.maxBytes||!l.maxTotalBytes?"This connection takes no images.":s.length>=l.maxCount?`A message carries at most ${l.maxCount} images.`:a>l.maxBytes?`${t} is ${Li(a)}; an image is at most ${Li(l.maxBytes)}.`:u+a>l.maxTotalBytes?`The images of a message are at most ${Li(l.maxTotalBytes)} together.`:null:`${t} is not a PNG, JPEG, GIF or WebP image.`}async function xj(s,t,i=Mi){const a=[];let l=null;for(const u of Array.from(t)){const d=String(u.name||"image"),h=Rb(u),m=_b([...s,...a],d,h,u.size,i);if(m||!h){l??=m;continue}let p;try{p=pj(new Uint8Array(await u.arrayBuffer()))}catch{l??=`Could not read ${d}.`;continue}a.push({id:`image-${++gj}`,type:"image",mimeType:h,data:p,name:d,size:u.size})}return{added:a,error:l}}function Xr(s,t,i=Mi){const a=[...s];let l=null;for(const u of t){const d=_b(a,u.name,u.mimeType,u.size,i);if(d){l??=d;continue}a.push(u)}return{attachments:a,error:l}}function yj(s,t=[]){return[...s.trim()||!t.length?[{type:"text",text:s}]:[],...t.map(i=>({type:"image",mimeType:i.mimeType,data:i.data,...i.name?{name:i.name.slice(0,255)}:{}}))]}const Lb=s=>`data:${s.mimeType};base64,${s.data}`,Ps=Object.freeze({maxObjectBytes:0,maxPerPrompt:0,maxPromptBytes:0,maxChunkBytes:0}),qx=["maxObjectBytes","maxPerPrompt","maxPromptBytes","maxChunkBytes"];function bj(s,t){if(!t||!s||typeof s!="object"||Array.isArray(s))return{...Ps};const i=s;if(!qx.every(h=>Number.isSafeInteger(i[h])&&i[h]>=0))return{...Ps};const[a,l,u,d]=qx.map(h=>i[h]);return!l||!u||!d?{...Ps}:{maxObjectBytes:Math.min(a,u),maxPerPrompt:l,maxPromptBytes:u,maxChunkBytes:d}}const Ob=s=>s<1024?`${s} B`:Li(s),Db=s=>!!s&&s.maxPerPrompt>0&&s.maxPromptBytes>0&&s.maxChunkBytes>0;function vj({capable:s,permitted:t,writable:i,limits:a,session:l,known:u=!0}){if(!s)return"The host behind this gateway does not store files.";if(!i)return"Your access token cannot send messages.";if(!t)return"Your access token cannot upload files (it needs attachments.write).";if(!Db(a))return"This connection takes no files.";if(!u)return null;const d=l?.promptAttachments;if(!Array.isArray(d)||!d.length){const h=typeof l?.agent=="string"?l.agent:"This agent",m=typeof l?.runtime=="string"?l.runtime:"a runtime";return`${h} runs on ${m} here, which cannot read attached files.`}return null}function wj(s){const t=String(s??"").normalize("NFC").replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}/\\]/gu,"").trim();let i="",a=0;for(const l of t){const u=new TextEncoder().encode(l).length;if(a+u>255)break;i+=l,a+=u}return i.trim()||"file"}const kj=/^[a-z0-9][a-z0-9!#$&^_.+-]{0,126}\/[a-z0-9][a-z0-9!#$&^_.+-]{0,126}$/;function jj(s){const t=String(s?.type??"").split(";",1)[0].trim().toLowerCase();return kj.test(t)?t:"application/octet-stream"}function qb(s,t,i,a){const l=s.reduce((u,d)=>u+d.size,0);return Db(a)?s.length>=a.maxPerPrompt?`A message carries at most ${a.maxPerPrompt} files.`:i>a.maxObjectBytes?`${t} is ${Li(i)}; a file is at most ${Li(a.maxObjectBytes)}.`:l+i>a.maxPromptBytes?`The files of a message are at most ${Li(a.maxPromptBytes)} together.`:null:"This connection takes no files."}let Sj=0;async function Nj(s,t,i){const a=[];let l=null;for(const u of Array.from(t)){const d=wj(u.name),h=qb([...s,...a],d,u.size,i);if(h){l??=h;continue}let m;try{m=new Uint8Array(await u.arrayBuffer())}catch{l??=`Could not read ${d}.`;continue}a.push({id:`file-${++Sj}`,type:"file",name:d,mimeType:jj(u),size:m.length,data:m})}return{added:a,error:l}}function Ol(s,t,i){const a=[...s];let l=null;for(const u of t){const d=qb(a,u.name,u.size,i);if(d){l??=d;continue}a.push(u)}return{attachments:a,error:l}}const Bx=(s,t,i=0)=>`${s}:file-${t}${i?`.${i}`:""}`;async function Tj(s,{sessionId:t,file:i,requestId:a,digest:l}){try{const u=await s.begin({sessionId:t,name:i.name,size:i.data.length,mimeType:i.mimeType,sha256:await l(i.data),requestId:a});return u?.state!=="uploading"||typeof u.uploadId!="string"?!1:(await s.abort(u.uploadId),!0)}catch{return!1}}function Aj(s,t=[],i=[]){const a=yj(s,t);if(!i.length)return a;if(i.some(l=>typeof l.attachmentId!="string"))throw new Error("A file of this message is not uploaded yet.");return[...s.trim()?[{type:"text",text:s}]:[],...t.map(l=>({type:"image",mimeType:l.mimeType,data:l.data,...l.name?{name:l.name.slice(0,255)}:{}})),...i.map(l=>({type:"attachment",attachmentId:l.attachmentId}))]}function Cj(s){return Array.isArray(s)?s.filter(t=>t&&typeof t=="object"&&typeof t.attachmentId=="string"&&typeof t.name=="string"&&Number.isSafeInteger(t.size)&&t.size>=0).map(t=>({attachmentId:t.attachmentId,name:t.name,size:t.size})):[]}function bs(s){return{rootId:s,cursor:0,entries:[],positions:{},sessions:{},order:[],running:{},closed:{},questions:{},prompts:{},turns:{},turnOrder:[],historyUnavailable:!1,reset:0}}function Yd(s,t){const i=s.positions[t.key];if(i!==void 0){const a=s.entries.slice();return a[i]=t,{...s,entries:a}}return{...s,entries:[...s.entries,t],positions:{...s.positions,[t.key]:s.entries.length}}}const Ea=(s,t)=>{if(!(t in s))return s;const i={...s};return delete i[t],i};function $x(s,t){if(typeof t!="string"||!t)return s;const i=s.turnOrder??[];return i.includes(t)?s:{...s,turnOrder:[...i,t]}}function zi(s,t){if(!t||typeof t!="object"||!t.event||typeof t.sessionId!="string")return s;const i=typeof t.cursor=="number";if(i&&t.cursor<=s.cursor)return s;let a=i?{...s,cursor:t.cursor}:s;const l=t.sessionId,u=typeof t.ts=="string"?t.ts:"",d=t.event;d.type==="item"&&!a.sessions[l]&&(a={...a,sessions:{...a.sessions,[l]:{id:l}},order:a.order.includes(l)?a.order:[...a.order,l]});const h=()=>`${l}:${d.type}:${t.cursor??`${t.epoch}:${t.seq}`}`;switch(d.type){case"session.opened":case"session.updated":{const m=d.session&&typeof d.session=="object"?d.session:{},p=a.sessions[l];return a={...a,sessions:{...a.sessions,[l]:{...p,...m,id:l,...d.type==="session.opened"?{status:m.busy?"running":"idle"}:{}}},order:a.order.includes(l)?a.order:[...a.order,l]},d.type==="session.opened"&&(a={...a,closed:Ea(a.closed,l)}),a}case"session.closed":{const m=a.sessions[l];return{...a,closed:{...a.closed,[l]:!0},running:Ea(a.running,l),questions:Object.fromEntries(Object.entries(a.questions).filter(([,p])=>p.sessionId!==l)),sessions:m?{...a.sessions,[l]:{...m,status:"closed",busy:!1}}:a.sessions}}case"session.failed":return Yd(a,{key:h(),sessionId:l,ts:u,item:{kind:"session_event",id:h(),level:"error",text:d.error?.message?`The session failed: ${d.error.message}`:"The session failed."}});case"prompt.accepted":{if(typeof d.clientMessageId!="string")return a;const m=d.result==="turn"||d.result==="steer"?d.result:void 0;return a={...a,prompts:{...a.prompts,[d.clientMessageId]:{state:"accepted",...typeof d.turnId=="string"?{turnId:d.turnId}:{},...m?{result:m}:{}}}},m==="turn"&&l===a.rootId?$x(a,d.turnId):a}case"prompt.failed":return typeof d.clientMessageId=="string"?{...a,prompts:{...a.prompts,[d.clientMessageId]:{state:"failed",...d.error?.code?{errorCode:d.error.code}:{},...d.error?.message?{error:d.error.message}:{}}}}:a;case"turn.started":{l===a.rootId&&(a=$x(a,d.turnId));const m=a.sessions[l],p=a.turns[d.turnId]==="ended"?a.turns:{...a.turns,[String(d.turnId)]:"running"};return{...a,turns:p,running:{...a.running,[l]:String(d.turnId)},...m?{sessions:{...a.sessions,[l]:{...m,status:"running",busy:!0}}}:{}}}case"turn.ended":{const m=a.sessions[l];return a={...a,running:Ea(a.running,l),turns:{...a.turns,[String(d.turnId)]:"ended"},...m&&m.status!=="closed"?{sessions:{...a.sessions,[l]:{...m,status:"idle"}}}:{}},(d.state==="failed"||d.state==="canceled")&&(a=Yd(a,{key:h(),sessionId:l,ts:u,item:{kind:"turn_end",id:h(),state:d.state,...d.error?.message?{error:d.error.message}:{}}})),a}case"item":{const m=d.item;return!m||typeof m!="object"||typeof m.id!="string"||typeof m.kind!="string"||!["user_message","assistant_message","notice","tool_call","todo","compaction"].includes(m.kind)?a:Yd(a,{key:`${l}:${m.id}`,sessionId:l,ts:u,item:m})}case"usage":{const m=a.sessions[l];return!d.usage||typeof d.usage!="object"||Array.isArray(d.usage)?a:{...a,sessions:{...a.sessions,[l]:{...m,id:l,usage:d.usage}}}}case"question":{const m=d.question;return!m||typeof m.id!="string"?a:{...a,questions:{...a.questions,[m.id]:m}}}case"question.resolved":return typeof d.questionId=="string"?{...a,questions:Ea(a.questions,d.questionId)}:a;default:return a}}function Ux(s,t,i){let a=t.reset?{...bs(s.rootId),reset:s.reset+1}:{...s,questions:{}};const l=i.filter(p=>typeof p?.cursor=="number").sort((p,x)=>p.cursor-x.cursor),u=i.filter(p=>typeof p?.cursor!="number"),d=a.cursor;for(const p of l)a=zi(a,p);for(const p of u)a=zi(a,p);const h=t.session,m=a.rootId;if(h&&(h.id===void 0||h.id===m)){const p=a.sessions[m];a={...a,sessions:{...a.sessions,[m]:{...p,...h,id:m}},order:a.order.includes(m)?a.order:[m,...a.order]},h.status==="closed"?a={...a,closed:{...a.closed,[m]:!0},running:Ea(a.running,m)}:h.status==="idle"&&!h.busy&&(a={...a,running:Ea(a.running,m)})}return t.reset&&(a={...a,historyUnavailable:a.cursor===d}),a}function Bb(s){return(s.order.includes(s.rootId)?s.order:[s.rootId,...s.order]).map(i=>({id:i,session:s.sessions[i],running:i in s.running,closed:!!s.closed[i]}))}function Ej(s,t){return s.entries.filter(i=>i.sessionId===t)}function Hx(s,t){const i=s.prompts[t];if(!i)return!1;if(i.state==="failed")return i.errorCode!=="outcome_unknown";const a=Object.values(s.running);if(!i.turnId)return a.length===0;const l=s.turns[i.turnId];return l==="ended"||l==="running"&&!a.includes(i.turnId)}function Ix(s){const t=new Set;for(const i of s.entries)i.item.kind==="user_message"&&typeof i.item.clientMessageId=="string"&&t.add(i.item.clientMessageId);return t}function bf(s,t){return s.oversized?{sessionId:t,epoch:"history",seq:s.cursor,cursor:s.cursor,ts:"",event:{type:"item",item:{kind:"notice",id:`oversized:${s.cursor}`,level:"warning",text:`History event ${s.cursor} is too large to display (${s.oversized.bytes} bytes).`}}}:s}function Mj(s,t){let i=bs(s.rootId);for(const d of t)i=zi(i,bf(d,s.rootId));const a=i.entries.slice(),l={...i.positions};for(const d of s.entries){const h=l[d.key];h!==void 0?a[h]=d:(l[d.key]=a.length,a.push(d))}const u={...i.sessions};for(const[d,h]of Object.entries(s.sessions))u[d]={...u[d],...h};return{...s,entries:a,positions:l,sessions:u,order:[...new Set([...i.order,...s.order])],prompts:{...i.prompts,...s.prompts},turns:{...i.turns,...s.turns},turnOrder:[...new Set([...i.turnOrder,...s.turnOrder??[]])]}}const zj={codex:"Codex",claude:"Claude",acp:"ACP",antigravity:"Antigravity"},Rj={"read-only":"Read only","workspace-write":"Workspace write","full-access":"Full access"},$b=s=>s==="custom"?"Custom":s,on=s=>typeof s=="string"&&s.trim()?s:void 0;function Gx(s){if(!Array.isArray(s))return[];const t=new Map;for(const i of s){const a=on(i?.id);if(!a||t.has(a))continue;const l=Array.isArray(i.efforts)?[...new Set(i.efforts.filter(d=>!!on(d)))]:[],u=on(i.effort);t.set(a,{id:a,label:on(i.label)??a,efforts:l,...u&&l.includes(u)?{effort:u}:{}})}return[...t.values()]}function Xs(s){if(s.replace(/[\s_-]+/g,"").toLowerCase()==="xhigh")return"Extra high";const i=s.replace(/[_-]+/g," ").replace(/\s+/g," ").trim();return i?i.charAt(0).toUpperCase()+i.slice(1).toLowerCase():s}function Ub(s,t,i){if(t)return s.find(l=>l.id===t);if(!i?.model)return;const a=i.runtime?`${i.runtime}:${i.model}`:i.model;return s.find(l=>l.id===a)??s.find(l=>l.id===i.model)}function Hb(s){return(s?.efforts??[]).map(t=>({id:t,label:Xs(t)}))}function _j(s,t){return t&&s?.efforts.includes(t)?t:void 0}function Yx(s,t){const i=t.team&&s.teams.some(d=>d.id===t.team)?t.team:void 0,a=t.mode&&s.modes.some(d=>d.id===t.mode)?t.mode:s.defaultMode??s.modes[0]?.id,l=t.model?s.models.find(d=>d.id===t.model):void 0,u=t.thinkingByModel?.[l?.id??"default"];return{...i?{team:i}:{},...a?{mode:a}:{},...l?{model:l.id}:{},...u&&(!l||l.efforts.includes(u))?{thinking:u}:{}}}function Vx(s,t,{persist:i=!1}={}){return{cwd:s,...i?{persist:!0}:{},...t.team?{workflow:t.team}:{},...t.mode?{mode:t.mode}:{},...t.model?{model:t.model}:{},...t.thinking?{thinking:t.thinking}:{}}}function Lj(s){const t=s?.preview;if(!t||typeof t!="object")return;const i=on(t.team),a=on(t.agent);return!i||!a?void 0:{teams:Array.isArray(t.teams)?t.teams.filter(u=>on(u?.id)).map(u=>({id:u.id,label:on(u.label)??u.id,...on(u.description)?{description:u.description}:{}})):[],team:i,agent:a,...on(t.teamLabel)?{teamLabel:t.teamLabel}:{},runtime:on(t.runtime)??"",model:on(t.model)??"",mode:on(t.mode)??"",thinking:on(t.thinking)??""}}function Oj(s,t=[]){const i=Ub(t,void 0,s),a=[{key:"team",label:"Team",value:s.teamLabel??s.teams.find(l=>l.id===s.team)?.label??$b(s.team)},{key:"agent",label:"Agent",value:s.agent}];return s.runtime&&a.push({key:"runtime",label:"Runtime",value:zj[s.runtime]??s.runtime}),s.model&&a.push({key:"model",label:"Model",value:i?.label??s.model}),s.thinking&&a.push({key:"thinking",label:"Thinking",value:Xs(s.thinking)}),s.mode&&a.push({key:"mode",label:"Permissions",value:Rj[s.mode]??s.mode}),a}function Ib(s){return JSON.stringify([typeof s?.workflow=="string"?s.workflow:"",typeof s?.model=="string"?s.model:""])}function Kx(s,t){if(!(!t||s.some(i=>i.id===t.team)))return{id:t.team,label:t.teamLabel??$b(t.team)}}function Dj(s,t){return t&&!s.some(i=>i.id===t.id)?[t,...s]:s}function qj({chosen:s,previewTeam:t,previewSettled:i,previewError:a,previewBlocked:l,previewNeedsRead:u,teams:d,teamsKnown:h,teamsUnavailable:m}){return s?{team:s}:t?{team:t}:i?d.length?{team:d[0].id}:h?{}:{wait:Bj({previewError:a,previewBlocked:l,previewNeedsRead:u,teamsUnavailable:m}),stuck:!0}:{wait:"Checking what would run…"}}function Bj({previewError:s,previewBlocked:t,previewNeedsRead:i,teamsUnavailable:a}){const l=a?.reason==="capability"?"this host does not list teams (no team capability)":a?.reason==="permission"?"your access token cannot list teams (it lacks project.read)":a?.reason==="failed"?`the team list failed${a.message?` (${Vd(a.message)})`:""}`:"the team list is not available",u=t?`the preview is not available${s?` (${Vd(s)})`:""}`:`the preview failed${s?` (${Vd(s)})`:""}`,d=[];(a?.reason==="failed"||!t)&&d.push("use Retry in the preview to ask again");const h=[];a?.reason==="permission"&&h.push("project.read"),t&&i&&h.push("session.read"),h.length&&d.push(`reconnect with a token that has ${h.join(" or ")}`),d.length||d.push("connect to a host that lists teams or previews sessions");const m=d.join(", or ");return`Cannot tell which team would run: ${l}, and ${u}. To start, ${m}.`}function Vd(s){return String(s).trim().replace(/[.。]+$/,"")}function $j(s,t,i){return String(t??"").trim()?`${s} Your first message was not sent; it is back in the New session box${i?` of ${i}`:""}.`:s}async function Uj(s,t,i,{mounted:a,describe:l,nameOf:u}){const d=s.startOrigin();try{return await s.createSession(t)}catch(h){throw a()||(i.trim()&&s.keepUnsentDraft(i,d),s.notify("error",$j(l(h).message,i,d.workspace?u(d.workspace):void 0))),h}}const Gb="session.configure.live",Ma=Object.freeze({session_busy:"The session or one of its agents is working. Wait until everything is idle, then try again.",session_closed:"The session is closed. Send it a message to open it, then change its configuration.",not_root:"Only the main agent of a session can be changed; an agent keeps the team and model it started with.",not_persistent:"This session is not kept, so it cannot continue its conversation with a new configuration.",runtime_unsupported:"The host cannot change this session's model or team while it runs. Start a new session instead.",runtime_mismatch:"A session keeps its runtime. To use another runtime's model, start a new session with it.",agent_mismatch:"That team runs another main agent. Start a new session with that team.",permission_escalation:"The change would give the session more permissions or new commands than it has. Start a new session for it.",team_not_found:"The host defines no such team for this project.",invalid_params:"The host does not offer this model or thinking for this session.",native_refused:"The agent's runtime did not take the new configuration. The session keeps its own.",stale_generation:"The conversation changed since this view loaded. It was reloaded; try again.",key_conflict:"That request id was already used for something else. Try again.",outcome_unknown:"The host cannot tell whether the change happened. Check the session before trying again.",persistence_failed:"The host could not store the change. Check the session before trying again.",turn_in_progress:"A turn of this conversation has not ended. Try again when it has."}),Yb=new Set(["runtime_mismatch","agent_mismatch","permission_escalation","runtime_unsupported"]);function Fx(s){const t=ei(s),a=s?.data?.action==="session.create",l=t.reason?Ma[t.reason]:void 0,u=t.reason==="grant"?t.message:l??t.message;return{...t,message:u,newSession:a||!!t.reason&&Yb.has(t.reason)}}const Hj=s=>/^([a-z]+)[:/]/.exec(s)?.[1];function Ij(s,t){const i=t.runtime,a=i?s.filter(u=>Hj(u.id)===i):[],l=t.model?a.find(u=>u.id===`${i}:${t.model}`)??a.find(u=>u.id===t.model):void 0;return{same:a,current:l,others:s.length-a.length}}function Gj({capabilities:s,canWrite:t,canTeam:i,summary:a,closed:l=!1,busy:u=!1,configuring:d=!1,generation:h,online:m=!0,driveBlock:p}){const x=A=>({enabled:!1,reason:A});if(!s.includes(Gb)){const A="Set when the session started: this host cannot change it on a running session.";return{shown:!1,reason:A,model:x(A),thinking:x(A),team:x(A)}}const y=a?.conversation,k=(()=>{if(y?.configure!==!0)return y?.reason==="not_persistent"?Ma.not_persistent:y?.reason==="not_root"?Ma.not_root:Ma.runtime_unsupported;if(!t)return"Your access token cannot change this session (it needs session.write).";if(p)return p;if(l)return Ma.session_closed;if(!s.includes("session.history")||!h)return"The conversation is still loading.";if(!m)return"Reconnecting…";if(d)return"Applying the last change…";if(u)return"Wait until main and its agents are idle."})(),j=k?x(k):{enabled:!0},S=k?x(k):i?{enabled:!0}:x("Your access token cannot change the team (it needs session.team.write).");return{shown:!0,model:j,thinking:j,team:S}}function Yj(s,t){if(!t)return s;const i=s?.workflow&&typeof s.workflow=="object"?s.workflow:{};return{...s,model:t.model,thinking:t.thinking,mode:t.mode,runtime:t.runtime,workflow:{...i,mode:t.team,supervisor:t.supervisor,...typeof t.maxPeers=="number"?{maxPeers:t.maxPeers}:{}},teamLabel:t.teamLabel??s?.teamLabel??(t.team==="custom"?void 0:t.team)}}function Vj(s,t,i){const a=s.effective,u=`${a.teamLabel??a.team} · main runs ${i??a.model}${a.thinking?` · ${t(a.thinking)}`:""}`;return s.status==="unchanged"?`Nothing to change: ${u}.`:`Changed: ${u}.${s.restarted?" The agent restarted on the same conversation.":""}`}const eh="alp-web:preferences",vf=1,Kj=["interrupt","steer","queue"],Fj=["enter","mod-enter"],Xj=["system","light","dark","zinc","midnight","claude","ghostty","pureBlack"],Pj=["full","collapseToolCalls","collapseTurns"],Qj=["github","catppuccin","dracula","tokyo-night","one","nord","gruvbox","solarized"],On=Object.freeze({uiFontSize:[10,21,14],contentFontSize:[10,21,15],codeFontSize:[9,22,12],contentMaxWidth:[600,4e3,820],terminalScrollback:[0,1e6,1e4]}),Wj=200,Vb=Object.freeze({header:["new-session","history","search"],footer:["tasks"]}),Kb=new Set(["tasks"]),so=s=>Vb[s].map(t=>({id:t,visible:!Kb.has(t)})),Fb=Object.freeze({grouping:"project",sort:"created",titleSource:"title",rowItems:Object.freeze({branch:!1,project:!1,host:!0,labels:!0}),trailing:"timestamp",projectFilters:[]}),Zj=64;function Xx(s){const t=qi(s)?s:{},i=qi(t.rowItems)?t.rowItems:{},a=Fb;return{grouping:t.grouping==="status"?"status":"project",sort:t.sort==="lastPrompt"?"lastPrompt":"created",titleSource:t.titleSource==="branch"?"branch":"title",rowItems:Object.fromEntries(Object.entries(a.rowItems).map(([l,u])=>[l,typeof i[l]=="boolean"?i[l]:u])),trailing:t.trailing==="none"?"none":"timestamp",projectFilters:[...new Set(Array.isArray(t.projectFilters)?t.projectFilters.filter(l=>typeof l=="string"&&l&&l.length<=4096):[])].slice(0,Zj)}}const Kd=Object.freeze({sendBehavior:"steer",sendShortcut:"enter",theme:"system",uiFontFamily:"",monoFontFamily:"",uiFontSize:14,contentFontSize:15,codeFontSize:12,contentMaxWidth:null,syntaxTheme:"one",chatDisplay:"collapseTurns",chatOutline:!0,terminalScrollback:1e4,sidebar:Object.freeze({header:so("header"),footer:so("footer")}),sidebarDisplay:Fb,newSession:Object.freeze({})});function Br(s,[t,i,a]){return typeof s=="number"&&Number.isFinite(s)?Math.min(i,Math.max(t,Math.round(s))):a}function Px(s){if(typeof s!="string")return"";const t=s.trim();return t.length<=Wj&&!/[;{}<>\\()]/.test(t)?t:""}function Qx(s,t){const i=Vb[t],a=[];for(const l of Array.isArray(s)?s:[])qi(l)&&i.includes(l.id)&&!a.some(u=>u.id===l.id)&&a.push({id:l.id,visible:typeof l.visible=="boolean"?l.visible:!Kb.has(l.id)});for(const l of so(t))a.some(u=>u.id===l.id)||a.push(l);return a}const Jj=200,eS=64,qi=s=>!!s&&typeof s=="object"&&!Array.isArray(s),Fd=s=>typeof s=="string"&&s.trim()&&s.length<=Jj?s:void 0;function Xb(s){if(!qi(s))return{};const t=s,i={};for(const a of["team","mode","model"]){const l=Fd(t[a]);l&&(i[a]=l)}if(qi(t.thinkingByModel)){const a={};for(const[l,u]of Object.entries(t.thinkingByModel).slice(0,eS)){const d=Fd(u);Fd(l)&&d&&!Object.hasOwn(Object.prototype,l)&&(a[l]=d)}Object.keys(a).length&&(i.thinkingByModel=a)}return i}function Oi(s){const t=()=>({...Kd,sidebar:{header:so("header"),footer:so("footer")},sidebarDisplay:Xx(null),newSession:{}});if(typeof s!="string"||!s)return t();let i;try{i=JSON.parse(s)}catch{return t()}if(!qi(i)||i.v!==vf)return t();const a=(u,d)=>u.includes(i[d])?i[d]:Kd[d],l=qi(i.sidebar)?i.sidebar:{};return{sendBehavior:a(Kj,"sendBehavior"),sendShortcut:a(Fj,"sendShortcut"),theme:a(Xj,"theme"),uiFontFamily:Px(i.uiFontFamily),monoFontFamily:Px(i.monoFontFamily),uiFontSize:Br(i.uiFontSize,On.uiFontSize),contentFontSize:Br(i.contentFontSize,On.contentFontSize),codeFontSize:Br(i.codeFontSize,On.codeFontSize),contentMaxWidth:typeof i.contentMaxWidth=="number"&&Number.isFinite(i.contentMaxWidth)?Br(i.contentMaxWidth,On.contentMaxWidth):null,syntaxTheme:a(Qj,"syntaxTheme"),chatDisplay:a(Pj,"chatDisplay"),chatOutline:typeof i.chatOutline=="boolean"?i.chatOutline:Kd.chatOutline,terminalScrollback:Br(i.terminalScrollback,On.terminalScrollback),sidebar:{header:Qx(l.header,"header"),footer:Qx(l.footer,"footer")},sidebarDisplay:Xx(i.sidebarDisplay),newSession:Xb(i.newSession)}}const tS=["sendBehavior","sendShortcut","theme","uiFontFamily","monoFontFamily","uiFontSize","contentFontSize","codeFontSize","contentMaxWidth","syntaxTheme","chatDisplay","chatOutline","terminalScrollback","sidebar","sidebarDisplay","newSession"];function nS(s){const t=Oi(JSON.stringify({...s,v:vf}));return JSON.stringify({v:vf,...Object.fromEntries(tS.map(i=>[i,t[i]]))})}function Wx(s){if(!s)return Oi(null);try{return Oi(s.getItem(eh))}catch{return Oi(null)}}function sS(s,t){if(!s)return!1;try{return s.setItem(eh,nS(t)),!0}catch{return!1}}function iS(s,t){const i={...s.thinkingByModel??{}},a=t.model||"default";return t.thinking?i[a]=t.thinking:delete i[a],Xb({team:t.team,mode:t.mode,model:t.model,thinkingByModel:i})}const io=Object.freeze({capability:"The host has not allowed remote terminals (its owner runs: alp terminal allow --yes)",permission:"Your access token cannot open terminals (it needs terminal.exec)",workspace:"Open a workspace to use a terminal.",registry:"This host does not list its workspaces, so it cannot open a terminal here. Update ALP on the host.",loading:"Loading the host's workspaces…",unregistered:"This workspace is not in the host's workspace list, so a terminal cannot open here.",offline:"Not connected to the host."}),VC="This shell runs on the daemon host as the account that runs alpd. The workspace is not a sandbox: the shell can read and write anything that account can, and use the network.",aS=Object.freeze({"root-only":"Limited protection on this Linux host: closing the terminal may not stop background processes.",none:"Process cleanup is not guaranteed on Windows: closing the terminal may not stop background processes."});function KC(s){return s==="root-only"||s==="none"?aS[s]:void 0}const FC="Runs on the daemon host as the account that runs alpd · the workspace is not a sandbox",Zx={terminal_disabled:io.capability,terminal_unsupported:"Terminals are not available on the daemon host (its terminal owner did not load).",terminal_limit:"Too many terminals are open on the host. Close one and try again.",input_too_large:"That input was too large for the terminal."},rS={closed:"closed",idle:"ended after being idle",lifetime:"reached its maximum lifetime",detached:"nobody reattached in time",revoked:"access was revoked",disabled:"the host turned terminals off",shutdown:"the host stopped"};function XC(s){const t=[];return Number.isSafeInteger(s.exitCode)&&t.push(`code ${s.exitCode}`),Number.isSafeInteger(s.signal)&&s.signal&&t.push(`signal ${s.signal}`),s.reason&&s.reason!=="exited"&&t.push(rS[s.reason]??s.reason),t.length?`Process exited (${t.join(" / ")})`:"Process exited"}const Jx=(s,t)=>{const i=t-s+1;return`\r
15
+ \x1B[2m[output lost: ${i} output ${i===1?"event":"events"} (#${s}${i>1?`–${t}`:""}) are no longer kept by the host]\x1B[0m\r
16
+ `};function wf(s){const t=s&&typeof s=="object"?s:{},i=a=>{const l=t[a];return Number.isSafeInteger(l)&&l>=1?Math.min(l,Ci[a]):Ci[a]};return{maxPerPrincipal:i("maxPerPrincipal"),maxPerDaemon:i("maxPerDaemon"),maxInputBytes:i("maxInputBytes"),maxOutputFrameBytes:i("maxOutputFrameBytes"),replayBytes:i("replayBytes"),idleMs:i("idleMs"),maxLifetimeMs:i("maxLifetimeMs"),reconnectMs:i("reconnectMs")}}function Pb(s){const t=[];if(!s.workspace)t.push("workspace");else if(s.connection.phase!=="open"&&!s.connection.capabilities.length)t.push("offline");else if(s.connection.capabilities.includes("terminal")||t.push("capability"),Te(s.principal??void 0,"terminal.exec")||t.push("permission"),!t.length)if(!s.connection.capabilities.includes("workspace.registry"))t.push("registry");else{const i=Jf(s);if(i)return{ok:!0,workspaceId:i.id};t.push(s.registry.loading?"loading":"unregistered")}return{ok:!1,reasons:t,messages:t.map(i=>io[i])}}function oS(s,t){let i=0,a=0;for(;a<s.length;){const l=s.codePointAt(a)??0,u=l<128?1:l<2048?2:l<65536?3:4;if(i+u>t)break;i+=u,a+=l>65535?2:1}return[s.slice(0,a),s.slice(a)]}function ey(s,t){const i=(a,l,u)=>Math.min(u,Math.max(l,Number.isFinite(a)?Math.floor(a):l));return{cols:i(s,Ci.minCols,Ci.maxCols),rows:i(t,Ci.minRows,Ci.maxRows)}}const ty=s=>s?.protection==="root-only"||s?.protection==="none"?s.protection:void 0;class lS{#e={status:"idle"};#j=new Set;#p=new Set;#n=[];#i=0;#m=0;#o=null;#f=0;#a=null;#s="";#g=!1;#c;#y;#v={cols:80,rows:24};#w=null;#b=!0;#d;constructor(t){this.#d={limits:wf(void 0),inputDelayMs:5,resizeDelayMs:120,maxHistoryChars:Ci.replayBytes,newRequestId:()=>globalThis.crypto.randomUUID(),...t}}get workspaceId(){return this.#d.workspaceId}getState(){return this.#e}get lastSeq(){return this.#m}subscribe(t){return this.#j.add(t),()=>{this.#j.delete(t)}}onOutput(t){return this.#p.add(t),()=>{this.#p.delete(t)}}history(){return this.#n.join("")}get accepting(){return this.#e.status==="running"}#h(t){this.#e={...this.#e,...t};for(const i of[...this.#j])i()}#k(t){if(t){for(this.#n.push(t),this.#i+=t.length;this.#i>this.#d.maxHistoryChars&&this.#n.length>1;)this.#i-=this.#n.shift().length;for(const i of[...this.#p])i(t)}}#S(){const{storage:t,storageKey:i}=this.#d;try{const a=t&&i?t.getItem(i):null;return Sl(a)?a:void 0}catch{return}}#C(t){const{storage:i,storageKey:a}=this.#d;if(!(!i||!a))try{t?i.setItem(a,t):i.removeItem(a)}catch{}}start(t,i){if(this.#e.status!=="idle")return;t!==void 0&&i!==void 0&&(this.#v=ey(t,i));const a=this.#d.initialTerminalId,l=this.#S()??(Sl(a)?a:void 0);l?(this.#C(l),this.#h({terminalId:l}),this.#E(0,!0)):this.#z()}restart(){const{status:t,terminalId:i}=this.#e;["exited","gone","failed","closed"].includes(t)&&(i&&t==="exited"&&this.#d.request("terminal.close",{terminalId:i}).catch(()=>{}),this.#C(void 0),this.#M(),this.#k("\x1Bc"),this.#n=[],this.#i=0,this.#e={status:"idle"},this.#z())}#M(){this.#f+=1,this.#m=0,this.#o=null,this.#s="",this.#w=null,this.#a=null}async#z(){const t=++this.#f;this.#a??=this.#d.newRequestId(),this.#h({status:"starting",error:void 0});let i;try{i=await this.#d.request("terminal.create",{workspaceId:this.#d.workspaceId,cols:this.#v.cols,rows:this.#v.rows,requestId:this.#a})}catch(l){if(t!==this.#f)return;if(Be(l).sent!=="yes"){this.#h({status:"reconnecting"}),this.#b&&this.#U();return}this.#a=null,this.#h({status:"failed",error:Xd(l)});return}if(t!==this.#f){const l=i?.terminal?.terminalId;if(this.#e.status==="closed"&&Sl(l))try{await this.#d.request("terminal.close",{terminalId:l})}catch{}return}const a=i?.terminal?.terminalId;if(!Sl(a)){this.#a=null,this.#h({status:"failed",error:"The host sent something this app does not understand."});return}this.#a=null,this.#w={cols:i.terminal.cols,rows:i.terminal.rows},this.#C(a),this.#h({terminalId:a,protection:ty(i.terminal)}),await this.#E(0,!1)}#U(){setTimeout(()=>{this.#b&&this.#e.status==="reconnecting"&&this.connected()},1e3)}async#E(t,i){const a=this.#e.terminalId,l=++this.#f;this.#o=[],this.#h({status:"attaching",error:void 0});let u;try{u=await this.#d.request("terminal.attach",{terminalId:a,...t>0?{after:t}:{}})}catch(p){if(l!==this.#f)return;this.#o=null;const x=Be(p);if(x.sent!=="yes"){this.#h({status:"reconnecting"}),this.#b&&this.#U();return}if(x.code===1001){if(this.#C(void 0),i&&!this.#m){this.#h({terminalId:void 0}),this.#z();return}this.#h({status:"gone",error:"This terminal has ended and the host no longer keeps it."});return}this.#h({status:"failed",error:Xd(p)});return}if(l!==this.#f)return;const d=this.#o??[];this.#o=null;const h=u?.gap;h&&Number.isSafeInteger(h.fromSeq)&&Number.isSafeInteger(h.toSeq)&&h.toSeq>=h.fromSeq&&h.toSeq>this.#m&&(this.#k(Jx(Math.max(h.fromSeq,this.#m+1),h.toSeq)),this.#m=h.toSeq);const m=u?.terminal;m&&Number.isSafeInteger(m.cols)&&(this.#w??={cols:m.cols,rows:m.rows}),this.#h({status:"running",protection:ty(m)??this.#e.protection});for(const p of d)this.#T(p);this.#e.status==="running"&&m?.state==="exited"&&this.#h({status:"exited",exit:{exitCode:m.exitCode??null,signal:m.signal??null,reason:m.endReason??"exited"}}),this.#e.status==="running"&&this.#D(0)}event(t){if(!(!t||t.terminalId!==this.#e.terminalId)){if(this.#o){this.#o.push(t);return}this.#T(t)}}#T(t){if(t.type==="detached"){if(t.reason==="slow_consumer"){this.#b?this.#E(this.#m,!1):this.#h({status:"reconnecting"});return}this.#f+=1,this.#s="",this.#h({status:"replaced"});return}!Number.isSafeInteger(t.seq)||t.seq<=this.#m||(t.seq>this.#m+1&&this.#k(Jx(this.#m+1,t.seq-1)),this.#m=t.seq,t.type==="output"&&typeof t.data=="string"?this.#k(t.data):t.type==="exit"&&(this.#s="",this.#h({status:"exited",exit:{exitCode:t.exitCode??null,signal:t.signal??null,reason:typeof t.reason=="string"?t.reason:"exited"}})))}input(t){return!this.accepting||typeof t!="string"||!t?!1:(this.#s+=t,!this.#g&&this.#c===void 0&&(this.#c=setTimeout(()=>{this.#c=void 0,this.#l()},this.#d.inputDelayMs)),!0)}async#l(){if(this.#g||!this.#s||!this.accepting)return;const[t,i]=oS(this.#s,this.#d.limits.maxInputBytes);if(!t){this.#s="";return}this.#s=i,this.#g=!0;const a=this.#e.terminalId;try{await this.#d.request("terminal.input",{terminalId:a,data:t})}catch(l){const u=Be(l);if(this.#s="",u.reason!=="terminal_exited"&&u.reason!=="not_attached"){const d=u.sent==="yes"?`Input was not delivered: ${Xd(l)}`:"The last input may not have reached the shell (the connection dropped). It is not sent again.";this.#h({lost:d}),this.#k(`\r
17
+ \x1B[2m[${d}]\x1B[0m\r
18
+ `)}}finally{this.#g=!1}this.#s&&this.#l()}resize(t,i){this.#v=ey(t,i),this.#D(this.#d.resizeDelayMs)}#D(t){this.#y!==void 0&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.#y=void 0,this.#H()},t)}async#H(){if(!this.accepting)return;const t=this.#v;if(!(this.#w&&this.#w.cols===t.cols&&this.#w.rows===t.rows))try{const i=await this.#d.request("terminal.resize",{terminalId:this.#e.terminalId,cols:t.cols,rows:t.rows});this.#w={cols:Number(i?.cols??t.cols),rows:Number(i?.rows??t.rows)}}catch{this.#w=null}}reattach(){this.#e.status!=="replaced"||!this.#e.terminalId||this.#E(this.#m,!1)}connected(){this.#b=!0;const{status:t,terminalId:i}=this.#e;t!=="reconnecting"&&t!=="attaching"&&t!=="starting"&&t!=="running"||(this.#w=null,i?this.#E(this.#m,!1):this.#a&&this.#z())}disconnected(){this.#b=!1,this.#f+=1,this.#o=null,this.#s&&(this.#s="",this.#h({lost:"Input typed while the connection dropped was not sent."})),["running","attaching","starting"].includes(this.#e.status)&&this.#h({status:"reconnecting"})}async close(){const{terminalId:t,status:i}=this.#e;if(this.dispose(),this.#C(void 0),this.#h({status:"closed"}),!(!t||i==="gone"||i==="closed"))try{await this.#d.request("terminal.close",{terminalId:t})}catch{}}#I(){this.#f+=1,this.#c!==void 0&&clearTimeout(this.#c),this.#y!==void 0&&clearTimeout(this.#y),this.#c=this.#y=void 0,this.#s=""}dispose(){this.#I(),this.#p.clear()}dismissLost(){this.#e.lost&&this.#h({lost:void 0})}}function Xd(s){const t=Be(s);return t.reason&&Zx[t.reason]?Zx[t.reason]:t.code===1003&&t.reason==="grant"?io.permission:t.code===1003&&t.reason==="outside_workspace"?"This workspace is not granted to your access token.":t.message}const cS=["attach.after","prompt.receipts"],ny={name:"alp-web",version:"0.10.0"},sy="Stop is waiting for this message’s outcome.",uS=15e3,dS=200,iy={"read-only":"Read only","workspace-write":"Workspace write","full-access":"Full access"};function ic(s,t){const i=s.tree,a=i&&i.rootId===t?Object.keys(i.projection.questions).length>0:!1;return i&&i.rootId===t&&i.status==="attached"?a:a||(s.attention[t]??0)>0}function ao(s,t){return s.turnAttention[t]?.reason}function Pd(s){if(!s||s.reason!=="finished"&&s.reason!=="error"||typeof s.at!="string")return;const t=Date.parse(s.at),i=s.reason==="error"&&typeof s.message=="string"&&s.message.trim()?s.message:void 0;return{reason:s.reason,at:Number.isFinite(t)?t:Date.now(),hostAt:s.at,...typeof s.turnId=="string"?{turnId:s.turnId}:{},...i?{message:i}:{}}}function fS(s){const t=Object.entries(s.turnAttention).filter(([i])=>s.tree?.rootId===i||s.sessions.list.some(a=>a.id===i&&!a.archived));return t.length===Object.keys(s.turnAttention).length?s.turnAttention:Object.fromEntries(t)}const ay="This access token cannot list files (needs project.read).",kf="This access token cannot read files (needs files.read).",Qb="This host does not offer file reading. Update ALP on the host.",Wb=100;function hS(s){if(typeof s!="string")return;const t=s.trim();return t&&t.length<=253&&!/[\p{Cc}\p{Cf}]/u.test(t)?t:void 0}function ry(s,t){const i=(Array.isArray(s?.sessions)?s.sessions:[]).filter(a=>a&&typeof a.id=="string"&&!a.parentId);return t?i.sort((a,l)=>String(l.updatedAt??l.createdAt??"").localeCompare(String(a.updatedAt??a.createdAt??""))):i}function mS(){try{return globalThis.sessionStorage??void 0}catch{return}}function rn(s=""){return{connection:{phase:"idle",gateway:s,attempt:0,capabilities:[]},principal:null,workspace:null,catalog:{status:"idle",teams:[],modes:[],models:[]},sessions:{status:"idle",list:[]},registry:{workspaces:[],revision:0},terminalDirectory:{items:[],mode:"idle"},history:{status:"idle",list:[],query:""},attention:{},turnAttention:{},selected:null,focus:null,tree:null,prompts:[],queued:[],busy:{},tasks:{status:"idle",visible:!1,rows:[],unreadable:0,creates:[],busy:{}},settings:{status:"idle",models:[]},notice:null,preferences:Oi(null)}}class $r extends Error{constructor(){super("The message was discarded."),this.name="DiscardedError"}}class oy extends Error{constructor(t,i,a){super(i.message),this.name="UploadError",this.fileName=t,this.failure=i,this.dropped=a}}class pS{#e;#j=new Set;#p=!1;#n;#i=null;#m="";#o=new Map;#f=new Map;#a=null;#s=null;#g=new Map;#c=new Map;#y=new Map;#v=new Map;#w=new Map;#b=new Map;#d=new Map;#h=new WeakMap;#k(t,i){const a=(this.#h.get(t)??Promise.resolve()).then(i);return this.#h.set(t,a.catch(()=>{})),a}#S=new WeakSet;#C=!1;#M=null;#z=new Set;#U=0;#E=!1;#T=null;#l={};#D={};#H=new Map;#I;#ae;#re;#N=null;#X=null;#P=null;#q=new Map;#Oe=0;#G=0;#xe={visible:!0,focused:!0};#tt=0;#R=new Map;#Y=new Map;#B;constructor(t={}){this.#n={open:O2,reconnecting:Cx,backoff:{initialMs:500,maxMs:15e3},stableMs:5e3,requestTimeoutMs:3e4,createTimeoutMs:12e4,taskPollMs:5e3,sessionPollMs:15e3,attentionPollMs:5e3,attentionWatchPollMs:6e4,historyPageSize:dS,releaseTimeoutMs:5e3,busyUnseenMs:uS,...t},this.#e={...rn(),preferences:Wx(t.storage)}}getState(){return this.#e}subscribe(t){return this.#j.add(t),()=>{this.#j.delete(t)}}#t(t){const i=typeof t=="function"?t(this.#e):t;this.#e={...this.#e,...i},this.#nt(),this.#e.queued.length&&this.#Tt()}#nt(){this.#p||(this.#p=!0,queueMicrotask(()=>{this.#p=!1;for(const t of[...this.#j])t()}))}#u(t,i,a){this.#t({notice:{id:++this.#tt,level:t,text:i,...a?.action?{action:a.action}:{}}})}dismissNotice(){this.#t({notice:null})}notify(t,i){this.#u(t,i)}#r(){const t=this.#i?.alp;if(!t||t.state!=="open"||!t.client)throw new Ke(this.#e.connection.phase==="reconnecting"?"Reconnecting to the host. Try again in a moment.":"Not connected to a host.");return t.client}connect({url:t,token:i,link:a=!1}){this.#oe(),a||Kr(this.#n.linkStorage);let l;try{l=Sb(t)}catch(k){this.#t({connection:{...this.#e.connection,phase:"failed",gateway:String(t),error:Be(k)}});return}const u=String(i??"").trim();if(!u){this.#t({connection:{...this.#e.connection,phase:"failed",gateway:l,error:Be(new Ra("Enter an access token."))}});return}this.#m=u,this.#e={...rn(l),preferences:this.#e.preferences},this.#t({connection:{phase:"connecting",gateway:l,attempt:1,capabilities:[],...a?{link:!0}:{}}});const d={opened:!1,...a?{link:!0}:{}};this.#i=d;const{open:h,reconnecting:m,backoff:p,stableMs:x,requestTimeoutMs:y}=this.#n,w=m({connect:async({signal:k})=>{const{transport:j,principal:S}=await h({url:l,token:this.#m,signal:k});if(this.#i!==d)throw j.close(),new Error("This connection was replaced.");return d.principal=S,j},onConnect:(k,j)=>this.#it(d,k,j.signal),onDisconnect:()=>{if(this.#i===d){this.#B?.close(!1),this.#B=void 0;for(const k of this.#R.values())k.disconnected();this.#s=null,this.#g.clear(),this.#a=null;for(const k of this.#o.values())k.attaching=null}},shouldRetry:k=>!Be(k).terminal,backoff:p,stableMs:x,client:{timeoutMs:y}});d.alp=w,w.onEvent(k=>{this.#i===d&&this.#dt(k)&&this.#ft(k)}),w.onNotification((k,j)=>{if(this.#i===d){if(k==="catalog.updated"){this.#et();return}if(k==="terminal.event")for(const S of this.#R.values())S.event(j)}}),w.onState((k,j)=>{this.#i===d&&this.#st(d,k,j)})}showError(t){this.#oe(),this.#t({connection:{...rn(this.#e.connection.gateway).connection,phase:"failed",error:{message:t,sent:"no",terminal:!0}}})}disconnect({keepTerminals:t=!1,keepLink:i=!1}={}){i||Kr(this.#n.linkStorage),this.#oe({keepTerminals:t})}#oe({keepTerminals:t=!1}={}){const i=this.#i;this.#i=null,this.#m="",this.#ye(),this.#o.clear(),this.#c.clear(),this.#f.clear(),this.#K.clear(),this.#se.clear(),this.#F.clear(),this.#ne.clear(),this.#g.clear();const a=[...this.#x.values()];this.#x.clear();for(const u of a)clearTimeout(u.retry),u.observer?.stop(),u.done();this.#O.clear(),this.#ge.clear(),this.#$!==void 0&&(clearTimeout(this.#$),this.#$=void 0),this.#a=null,this.#s=null,this.#M=null,this.#U+=1,this.#l={},this.#N=null;const l=this.#ct(t?null:i);if(i?.alp){const u=i.alp;l?l.then(()=>u.stop()):u.stop()}i&&this.#t({...rn(this.#e.connection.gateway),preferences:this.#e.preferences})}#st(t,i,a){const l=this.#e.connection;if(i==="open"){t.opened=!0,this.#t({connection:{...l,phase:"open",attempt:0,error:void 0}}),this.#rt();return}if(i==="connecting"){this.#t({connection:{...l,phase:t.opened?"reconnecting":"connecting",attempt:t.alp?.attempt??l.attempt}});return}if(i==="waiting"){if(!t.opened&&!t.link)return this.#De(a??new Error("Could not connect."));if(!t.opened){this.#t({connection:{...l,phase:"connecting",error:a?Be(a):void 0}});return}this.#ye(),this.#t({connection:{...l,phase:"reconnecting",error:a?Be(a):void 0}});return}i==="stopped"&&a&&this.#De(a)}#De(t){const i=this.#e.connection.gateway;let a=Be(t);this.#i?.link&&t instanceof Ra&&(Kr(this.#n.linkStorage),a={...a,message:q2}),this.#oe(),this.#t({connection:{...rn(i).connection,phase:"failed",error:a}})}async#it(t,i,a){const l=await Ax(i,ny,{signal:a,timeoutMs:15e3});if(this.#i!==t)throw new Error("This connection was replaced.");const u=Array.isArray(l?.capabilities)?l.capabilities.filter(m=>typeof m=="string"):[],d=cS.filter(m=>!u.includes(m));if(d.length)throw new Ke(`The host behind this gateway is too old for this app (it lacks ${d.join(", ")}). Update ALP on the host.`);this.#at(t.principal,u,typeof l?.daemonVersion=="string"?l.daemonVersion:void 0,hS(l?.hostname),mj(l?.promptImageLimits,u.includes("prompt.images")),bj(l?.attachmentLimits,u.includes("attachments")),u.includes("terminal")?wf(l?.terminalLimits):void 0),this.#s=null,this.#a=null;const h=this.#e.selected;if(h&&h!==this.#T&&!this.#o.get(h)?.gone){this.#_(h).failed=null;try{if(await this.#ue(i,h,a),this.#i!==t||a.aborted)throw new Error("This connection was replaced.");this.#s={client:i,root:h}}catch(m){if(this.#i!==t||a.aborted||!Ud(m))throw m;this.#$e(h,m)}}}#at(t,i,a,l,u,d={...Ps},h=void 0){this.#D={};const m=this.#e.workspace,p=m&&Ll(t,m)?m:t.workspaces[0]??null,x=JSON.stringify(t)!==JSON.stringify(this.#e.principal);p!==m&&(this.#l={},this.#N=null),this.#t(y=>({principal:t,registry:x?rn().registry:{...y.registry,loading:!1},connection:{...y.connection,capabilities:i,...a?{daemonVersion:a}:{},hostname:l,promptImageLimits:u,attachmentLimits:d,terminalLimits:h},...p!==y.workspace?{workspace:p,selected:null,focus:null,tree:null,sessions:rn().sessions,history:rn().history,attention:{},turnAttention:{},tasks:{...rn().tasks,visible:y.tasks.visible}}:{},...x||p!==y.workspace?{catalog:rn().catalog}:{}}))}#rt(){this.#lt();for(const t of this.#R.values())t.connected();this.#V(),this.#kt();for(const[t,i]of this.#x)i.attempts=0,i.exhausted=!1,this.#A(t);this.refreshRegistry(),this.#e.workspace&&(this.refreshSessions(),this.refreshAttention(),this.#e.history.status!=="idle"&&this.loadHistory({quiet:!0}),this.#e.catalog.status!=="ready"&&this.#Te(),this.#e.tasks.visible&&this.refreshTasks()),this.#ot()}#ot(){this.#ye(),this.#ae=setInterval(()=>{this.#e.workspace&&this.#e.connection.phase==="open"&&this.refreshSessions({quiet:!0})},this.#n.sessionPollMs);const t=this.hasCapability("question.watch")?this.#n.attentionWatchPollMs:this.#n.attentionPollMs;this.#re=setInterval(()=>{this.#e.workspace&&this.#e.connection.phase==="open"&&this.refreshAttention()},t),this.#I=setInterval(()=>{this.#e.tasks.visible&&this.#e.workspace&&this.#e.connection.phase==="open"&&this.refreshTasks({quiet:!0})},this.#n.taskPollMs)}#ye(){this.#ae!==void 0&&clearInterval(this.#ae),this.#I!==void 0&&clearInterval(this.#I),this.#re!==void 0&&clearInterval(this.#re),this.#ae=this.#I=this.#re=void 0}hasCapability(t){return this.#e.connection.capabilities.includes(t)}terminalGate(){return Pb(this.#e)}#lt(){this.#B?.close(),this.#B=void 0;const t=this.#i;!t||!this.hasCapability("terminal")||!Te(this.#e.principal??void 0,"terminal.exec")||(this.#B=h2(this.#r(),{capabilities:this.#e.connection.capabilities,onMode:i=>{this.#i===t&&this.#t(a=>({terminalDirectory:{...a.terminalDirectory,mode:i}}))},onSnapshot:i=>{this.#i===t&&this.#t(a=>({terminalDirectory:{...a.terminalDirectory,items:i,error:void 0}}))},onError:i=>{this.#i===t&&this.#t(a=>({terminalDirectory:{...a.terminalDirectory,error:Be(i).message}}))}}))}openListedTerminal(t,i){const a=this.terminalTabs(t),l=a.tabs.find(h=>h.session.getState().terminalId===i);if(l){this.selectTerminal(t,l.key);return}if(!this.#e.terminalDirectory.items.some(h=>h.terminalId===i&&h.workspaceId===t&&h.state==="running")||a.tabs.length>=32)return;const u=globalThis.crypto.randomUUID(),d=this.#be(t,u,a.storage,a.storageKey,i);a.tabs=[...a.tabs,{key:u,session:d}],a.active=u,this.#Q(t)}terminal(t){let i=this.#Y.get(t)??this.terminalTabs(t);return i.tabs.length||(this.addTerminal(t),i=this.terminalTabs(t)),(i.tabs.find(a=>a.key===i.active)??i.tabs[0]).session}terminalTabs(t){const i=this.terminalGate();if(!i.ok||i.workspaceId!==t)throw new Ke(i.ok?"That workspace is not the open one.":i.messages.join(" "));let a=this.#Y.get(t);if(a)return a;const l=this.#n.terminalStorage===void 0?mS():this.#n.terminalStorage??void 0,u=`alp-web.terminal|${this.#e.connection.gateway}|${this.#e.principal?.id??""}|${t}`;let d=["default"],h="default";try{const m=JSON.parse(l?.getItem(`${u}|tabs`)??"null");m?.v===1&&Array.isArray(m.keys)&&m.keys.length<=32&&m.keys.every(p=>typeof p=="string"&&/^(default|[a-zA-Z0-9-]{1,64})$/.test(p))&&new Set(m.keys).size===m.keys.length&&(d=m.keys,h=d.includes(m.active)?m.active:d[0]??null)}catch{}return a={tabs:d.map(m=>({key:m,session:this.#be(t,m,l,u)})),active:h,storage:l,storageKey:u},this.#Y.set(t,a),a}#be(t,i,a,l,u){const d=new lS({workspaceId:t,...u?{initialTerminalId:u}:{},request:(h,m)=>this.#r().request(h,m,{timeoutMs:this.#n.requestTimeoutMs}),limits:this.#e.connection.terminalLimits??wf(void 0),...a?{storage:a,storageKey:i==="default"?l:`${l}|${i}`}:{},...this.#n.terminalOptions});return this.#R.set(JSON.stringify([t,i]),d),d}#Q(t){const i=this.#Y.get(t);if(i){try{i.storage?.setItem(`${i.storageKey}|tabs`,JSON.stringify({v:1,keys:i.tabs.map(a=>a.key),active:i.active}))}catch{}this.#t({})}}addTerminal(t){const i=this.terminalTabs(t);if(i.tabs.length>=32)return i.active;const a=globalThis.crypto.randomUUID();return i.tabs=[...i.tabs,{key:a,session:this.#be(t,a,i.storage,i.storageKey)}],i.active=a,this.#Q(t),a}selectTerminal(t,i){const a=this.terminalTabs(t);a.tabs.some(l=>l.key===i)&&(a.active=i,this.#Q(t))}closeTerminalTab(t,i){const a=this.terminalTabs(t),l=a.tabs.findIndex(d=>d.key===i);if(l<0)return Promise.resolve();const u=a.tabs[l];return a.tabs=a.tabs.filter(d=>d.key!==i),a.active===i&&(a.active=a.tabs[Math.min(l,a.tabs.length-1)]?.key??null),this.#R.delete(JSON.stringify([t,i])),this.#Q(t),u.session.close()}closeTerminal(t=Jf(this.#e)?.id){const i=t?this.#Y.get(t):void 0;if(!t||!i)return Promise.resolve();const a=i.tabs;i.tabs=[],i.active=null;for(const l of a)this.#R.delete(JSON.stringify([t,l.key]));return this.#Q(t),Promise.allSettled(a.map(l=>l.session.close()))}#ct(t){this.#B?.close(),this.#B=void 0;const i=t?.alp?.state==="open"?t.alp.client:void 0,a=[];for(const l of this.#R.values()){const{terminalId:u,status:d}=l.getState();l.dispose(),i&&u&&d!=="gone"&&d!=="closed"&&a.push(i.request("terminal.close",{terminalId:u},{timeoutMs:1e3}).catch(()=>{}))}return this.#R.clear(),this.#Y.clear(),a.length?Promise.allSettled(a):void 0}#_(t){let i=this.#o.get(t);return i||(i={projection:bs(t),attaching:null,gone:null,failed:null},this.#o.set(t,i),this.#f.set(t,t)),i}#W(t){for(const i of t.order)this.#f.set(i,t.rootId);return t}#ut(t){const i=t?.sessionId;if(typeof i!="string")return;let a=this.#f.get(i);if(!a){const l=t.event?.type==="session.opened"?t.event.session?.parentId:void 0;a=typeof l=="string"&&this.#f.get(l)||void 0,a&&this.#f.set(i,a)}return a===this.#a?a:void 0}#dt(t){const i=t?.event;if(i?.type==="question"){const a=i.question?.id,l=i.question?.rootId;return typeof a=="string"&&typeof l=="string"&&this.#X?.events.push({id:a,root:l}),this.#N&&typeof a=="string"&&typeof l=="string"&&this.#N.get(a)!==l&&(this.#N.set(a,l),this.#ve()),t.cursor!==void 0||!!this.#a&&l===this.#a}if(i?.type==="attention"&&t.cursor===void 0)return typeof t.sessionId=="string"&&(this.#P&&this.#P.push([t.sessionId,i.attention??null]),this.#ht(t.sessionId,i.attention)),!1;if(i?.type==="turn.ended"&&t.cursor===void 0){if(typeof t.sessionId=="string"){const a=t.sessionId;this.#e.sessions.list.some(l=>l.id===a&&(l.status==="running"||l.busy))&&this.#t(l=>({sessions:{...l.sessions,list:l.sessions.list.map(u=>u.id===a?{...u,busy:!1,...u.status==="running"?{status:"idle"}:{}}:u)}})),this.#qe(a,i)}return!1}if(i?.type==="question.resolved"){if(typeof i.questionId=="string"&&this.#X?.events.push({id:i.questionId}),this.#N?.delete(i.questionId)&&this.#ve(),t.cursor!==void 0)return!0;const a=this.#a?this.#o.get(this.#a):void 0;return a?Object.hasOwn(a.projection.questions,i.questionId)||!!a.attaching?.buffer.some(l=>l.event?.type==="question"&&l.event.question?.id===i.questionId):!1}return!0}#ve(){if(!this.#N)return;const t={};for(const i of this.#N.values())t[i]=(t[i]??0)+1;JSON.stringify(t)!==JSON.stringify(this.#e.attention)&&this.#t({attention:t})}#ft(t){const i=this.#ut(t);if(!i)return;const a=this.#o.get(i);if(!a)return;if(t.event?.type==="history.reset"&&t.sessionId===i){this.#Be(i,t.event.generation);return}if(a.attaching){a.attaching.buffer.push(t);return}a.projection=this.#W(zi(a.projection,t)),this.#L(i);const l=t.event?.type;t.sessionId===i&&l==="turn.ended"?this.#qe(i,t.event):t.sessionId===i&&l==="turn.started"&&(this.#q.delete(i),this.#Z(i))}get#le(){return this.hasCapability("session.attention")&&this.hasCapability("question.watch")}#ht(t,i){this.#q.delete(t);const a=Pd(i);if(!a){this.#Z(t);return}if(this.#ce(t)){this.#Z(t),this.#we(t,a);return}this.#e.history.list.some(l=>l.id===t&&l.archived)||this.#e.turnAttention[t]?.hostAt!==a.hostAt&&this.#t(l=>({turnAttention:{...l.turnAttention,[t]:a}}))}#we(t,i){if(!this.#le||this.#e.connection.phase!=="open")return;const a={},l=this.#l;this.#q.set(t,a);const u=()=>{this.#q.get(t)===a&&(this.#q.delete(t),!(l!==this.#l||this.#e.turnAttention[t])&&(this.#e.history.list.some(d=>d.id===t&&d.archived)||this.#t(d=>({turnAttention:{...d.turnAttention,[t]:i}}))))};try{this.#r().request("session.attention.clear",{sessionId:t,...i.hostAt?{at:i.hostAt}:{}}).then(()=>{this.#q.get(t)===a&&this.#q.delete(t)},u)}catch{u()}}#Z(t){this.#e.turnAttention[t]&&this.#t(i=>{const{[t]:a,...l}=i.turnAttention;return{turnAttention:l}})}#qe(t,i){if(this.#le)return;const a=i?.state==="completed"?"finished":i?.state==="failed"?"error":void 0;if(!a){this.#Z(t);return}if(this.#ce(t)||this.#e.history.list.some(d=>d.id===t&&d.archived))return;const l=typeof i?.error?.message=="string"&&i.error.message.trim()?i.error.message:void 0,u={reason:a,at:Date.now(),...typeof i?.turnId=="string"?{turnId:i.turnId}:{},...a==="error"&&l?{message:l}:{}};this.#t(d=>({turnAttention:{...d.turnAttention,[t]:u}}))}#ce(t){const i=this.#e.focus??this.#e.selected;return this.#xe.visible&&this.#xe.focused&&(i===t||this.#e.selected===t)}setPresence({visible:t,focused:i}){this.#xe={visible:!!t,focused:!!i};const a=this.#e.focus??this.#e.selected;a&&this.#ce(a)&&this.clearAttention(a)}clearAttention(t){const i=t?this.#e.turnAttention[t]:void 0;!t||!i||(this.#Z(t),this.#we(t,i))}async#ue(t,i,a,l=0){const u=this.#_(i),d={buffer:[]};u.attaching=d,this.#a=i;const h=this.#y.get(i)??0;this.#e.selected===i&&this.#t(m=>({tree:{rootId:i,status:"attaching",projection:u.projection,...m.tree?.rootId===i&&m.tree.error?{}:{}}}));try{if(this.hasCapability("session.history")&&!this.#c.has(i)){const y=await t.request("session.history",{sessionId:i},{timeoutMs:this.#n.requestTimeoutMs,...a?{signal:a}:{}});if(u.attaching!==d)return;u.projection=bs(i);for(const w of y.items)u.projection=zi(u.projection,bf(w,i));this.#W(u.projection),u.projection={...u.projection,cursor:y.tipCursor},this.#c.set(i,{generation:y.generation,olderCursor:y.olderCursor,hasOlder:y.hasOlder})}const m=u.projection.cursor,p=this.#c.get(i),x=await t.request("session.attach",{sessionId:i,...p?{after:m,generation:p.generation}:m>0?{after:m}:{}},{timeoutMs:this.#n.requestTimeoutMs,...a?{signal:a}:{}});if(u.attaching!==d)return;u.attaching=null,u.gone=null,u.failed=null,this.#ke(i,u,x,d.buffer),(this.#y.get(i)??0)!==h&&this.#c.get(i)?.generation!==this.#v.get(i)&&(this.#c.delete(i),queueMicrotask(()=>{this.#je(t,i)}))}catch(m){if(u.attaching!==d)throw m;if(m?.data?.reason==="stale_cursor"&&l<1&&this.#c.has(i))return this.#c.delete(i),u.projection=bs(i),u.attaching===d&&(u.attaching=null),this.#ue(t,i,a,l+1);throw u.attaching===d&&(u.attaching=null),t===this.#i?.alp?.client&&this.#a===i&&(this.#a=null),m}}#ke(t,i,a,l){i.projection=this.#W(Ux(i.projection,a??{},l)),a?.reset&&!i.projection.historyUnavailable&&this.#u("info","The host restarted this conversation's history; it was loaded again from the beginning."),this.#L(t,"attached")}#Be(t,i){if(typeof i!="string"||!i||this.#c.get(t)?.generation===i||this.#v.get(t)===i)return;this.#v.set(t,i),this.#y.set(t,(this.#y.get(t)??0)+1),this.#c.delete(t);const a=this.#o.get(t);a&&this.#We(t,a.projection);const l=this.#s?.root===t?this.#s.client:void 0;a&&l&&!a.attaching&&this.#je(l,t)}#je(t,i){return this.#k(t,()=>this.#mt(t,i))}async#mt(t,i){if(!(t!==this.#i?.alp?.client||this.#e.selected!==i)&&!(this.#s?.client!==t||this.#s.root!==i)){this.#c.delete(i);try{await this.#ue(t,i)}catch(a){this.#Ne(t,i,a)}}}async loadOlder(){const t=this.#e.selected;if(!t)return;const i=this.#c.get(t),a=this.#o.get(t),l=this.#s?.root===t?this.#s.client:null;if(!i?.hasOlder||i.loading||!a||!l)return;const u={...i,loading:!0,error:void 0};this.#c.set(t,u),this.#L(t);try{const d=await l.request("session.history",{sessionId:t,before:i.olderCursor},{timeoutMs:this.#n.requestTimeoutMs});if(this.#c.get(t)!==u)return;if(d.generation!==i.generation)throw new Error("History changed; reconnect to refresh it.");a.projection=this.#W(Mj(a.projection,d.items)),this.#c.set(t,{generation:d.generation,olderCursor:d.olderCursor,hasOlder:d.hasOlder})}catch(d){this.#c.get(t)===u&&this.#c.set(t,{...i,error:Be(d).message})}this.#L(t)}#$e(t,i){const a=this.#_(t);a.gone=Be(i),a.attaching=null,this.#a===t&&(this.#a=null),this.#e.selected===t&&this.#t({tree:{rootId:t,status:"gone",error:a.gone,projection:a.projection}})}#L(t,i){if(this.#e.selected!==t){this.#A(t);return}const a=this.#o.get(t);if(!a)return;const l=Ix(a.projection),u=a.projection.prompts;for(const h of this.#O.get(t)??[]){const m=u[h];(m?.state==="failed"&&m.errorCode!=="outcome_unknown"||m?.turnId&&a.projection.turns[m.turnId]==="ended")&&this.#O.get(t)?.delete(h)}let d=this.#e.prompts.filter(h=>h.rootId!==t||!l.has(h.id));d=d.map(h=>{const m=u[h.id];if(h.rootId!==t||m?.state!=="failed")return h;const p=m.errorCode==="outcome_unknown",x=p?"unknown":"failed";if(h.status===x)return h;const y=p?"The host cannot tell whether the agent took the message":"The agent did not take the message";return{...h,status:x,error:m.error?`${y}: ${m.error}`:`${y}.`,retrySameId:!1}}),this.#t(h=>({tree:{rootId:t,status:i??(h.tree?.rootId===t?h.tree.status:"attached"),projection:a.projection,...this.#c.has(t)?{older:this.#c.get(t)}:{},...i==="attached"?{}:h.tree?.rootId===t&&h.tree.error?{error:h.tree.error}:{}},...d.length!==h.prompts.length||d.some((m,p)=>m!==h.prompts[p])?{prompts:d}:{},sessions:this.#Ue(h.sessions,t,a.projection),busy:{...h.busy,interrupt:this.#x.has(t)&&!this.#x.get(t)?.exhausted}})),this.#A(t)}#Ue(t,i,a){const l=t.list.findIndex(p=>p.id===i);if(l<0)return t;const u=t.list[l],d=a.sessions[i],h=a.closed[i]?"closed":i in a.running?"running":d?.status==="closed"||u.status==="closed"&&!d?"closed":"idle";if(u.status===h&&(!d?.title||d.title===u.title))return t;const m=t.list.slice();return m[l]={...u,status:h,...d?.title?{title:d.title}:{}},{...t,list:m}}async#V(){const t=this.#i?.alp?.client;if(t){if(this.#S.has(t)){this.#E=!0;return}this.#S.add(t);try{for(;;){this.#E=!1;const i=await this.#k(t,()=>this.#pt(t));if(t!==this.#i?.alp?.client||!i&&!this.#E)break}}finally{this.#S.delete(t)}}}async#pt(t){if(this.#i?.alp?.state!=="open"||t!==this.#i.alp.client)return!1;const i=this.#e.selected;this.#s&&this.#s.client!==t&&(this.#s=null);const a=this.#s;if(a&&a.root!==i)return this.#s=null,this.#a===a.root&&(this.#a=null),await this.#J(a),!0;if(!i||i===this.#T||this.#s?.root===i)return!1;const l=this.#_(i);if(l.gone)return this.#t({tree:{rootId:i,status:"gone",error:l.gone,projection:l.projection}}),!1;if(l.failed)return this.#t({tree:{rootId:i,status:"error",error:l.failed,projection:l.projection}}),!1;const u=this.#g.get(i);try{return this.#g.delete(i),this.#s={client:t,root:i},await this.#ue(t,i),t!==this.#i?.alp?.client?!0:(this.#s={client:t,root:i},this.#e.selected!==i)}catch(d){return u&&t===this.#i?.alp?.client&&(this.#s?.client===t&&this.#s.root===i&&(this.#s=null),await this.#J(u)),this.#Ne(t,i,d),!1}}async#J(t){const i=this.#x.get(t.root)?.observer;i&&i.state!=="stopped"?(this.#g.set(t.root,t),i.ready().catch(()=>{}).then(()=>this.#Se(t.root,t))):(this.#g.delete(t.root),await t.client.request("session.release",{sessionId:t.root},{timeoutMs:this.#n.releaseTimeoutMs}).catch(()=>{}))}#Se(t,i){const a=this.#g.get(t);!a||i&&a!==i||this.#k(a.client,async()=>{this.#g.get(t)===a&&(this.#g.delete(t),this.#i?.alp?.client===a.client&&(this.#s?.client===a.client&&this.#s.root===t||await a.client.request("session.release",{sessionId:t},{timeoutMs:this.#n.releaseTimeoutMs}).catch(()=>{})))})}#Ne(t,i,a){if(t!==this.#i?.alp?.client)return;if(Ud(a)){this.#$e(i,a);return}const l=this.#_(i);l.failed=Be(a),this.#e.selected===i&&this.#t({tree:{rootId:i,status:"error",error:l.failed,projection:l.projection}})}retryAttach(){const t=this.#e.selected;if(!t)return;const i=this.#o.get(t);i&&(i.gone=null,i.failed=null);const a=this.#i?.alp?.client;a&&this.#k(a,async()=>{const l=this.#s;l?.client===a&&l.root===t&&(this.#s=null,this.#a===t&&(this.#a=null),await this.#J(l))}).finally(()=>this.#V())}selectWorkspace(t){const i=this.#e.principal,a=t&&(Ll(i??void 0,t)||this.#e.registry.workspaces.some(l=>l.managedWorktree&&l.directory===t))?t:null;a!==this.#e.workspace&&(this.#l={},this.#N=null,this.#t(l=>({workspace:a,selected:null,focus:null,tree:null,sessions:rn().sessions,history:rn().history,attention:{},turnAttention:{},catalog:rn().catalog,tasks:{...rn().tasks,visible:l.tasks.visible}})),this.#V(),a&&this.#e.connection.phase==="open"&&(this.refreshSessions(),this.refreshAttention(),this.#Te(),this.#e.tasks.visible&&this.refreshTasks()))}async refreshRegistry(){if(!this.hasCapability("workspace.registry")||!Te(this.#e.principal??void 0,"project.read")||this.#e.registry.loading)return;const t=this.#D,i=this.#i;this.#t(a=>({registry:{...a.registry,loading:!0}}));try{const a=[];let l,u=0;do{const d=await this.#r().request("workspace.list",{limit:500,...l?{cursor:l}:{}});a.push(...d.workspaces),u=d.revision,l=d.nextCursor}while(l);t===this.#D&&i===this.#i&&this.#t({registry:{workspaces:a,revision:u}})}catch(a){t===this.#D&&i===this.#i&&this.#t(l=>({registry:{...l.registry,loading:!1,error:a instanceof Error?a.message:String(a)}}))}}async pinWorkspace(t,i){if(!Te(this.#e.principal??void 0,"workspace.write")){this.#u("error","Ask the host owner to add workspace.write to your credential to change shared pins.");return}const a=()=>this.#r().request("workspace.update",{workspaceId:t,pinned:i,ifRevision:this.#e.registry.revision,requestId:globalThis.crypto.randomUUID()});try{try{await a()}catch(l){if(l?.data?.reason!=="stale_revision")throw l;await this.refreshRegistry(),await a()}await this.refreshRegistry()}catch(l){this.#u("error",`Pin was not saved. ${l instanceof Error?l.message:String(l)} Refresh and try again.`),await this.refreshRegistry()}}async renameWorkspace(t,i){if(!Te(this.#e.principal??void 0,"workspace.write"))return this.#u("error","Ask the host owner to add workspace.write to your credential to rename shared workspaces."),!1;try{return await this.#r().request("workspace.update",{workspaceId:t,title:i.trim()||null,ifRevision:this.#e.registry.revision,requestId:globalThis.crypto.randomUUID()}),await this.refreshRegistry(),!0}catch(a){return this.#u("error",`Name was not saved. ${a instanceof Error?a.message:String(a)} Refresh and try again.`),await this.refreshRegistry(),!1}}async worktreeOptions(t){return(await this.#r().request("workspace.worktree.options",{workspaceId:t})).mappingIds}async mutateWorktree(t,i,a){if(!this.hasCapability("workspace.worktree")||!Te(this.#e.principal??void 0,"workspace.manage"))return!1;const l=t+":"+i+":"+(a??"");let u=this.#H.get(l);u||(u={workspaceId:i,...a?{mappingId:a}:{},ifRevision:this.#e.registry.revision,requestId:globalThis.crypto.randomUUID()},this.#H.set(l,u));try{return await this.#r().request("workspace.worktree."+t,u),this.#H.delete(l),await this.refreshRegistry(),!0}catch(d){return d?.data?.reason==="stale_revision"&&this.#H.delete(l),this.#u("error",`Worktree ${t} was not confirmed. ${d instanceof Error?d.message:String(d)} Retry the same operation to reconcile its outcome.`),await this.refreshRegistry(),!1}}async registerProject(t){if(!Te(this.#e.principal??void 0,"workspace.write")){this.#u("error","Ask the host owner to add workspace.write to your credential. To add another directory, the owner must grant it locally first.");return}try{await this.#r().request("project.register",{directory:t,ifRevision:this.#e.registry.revision,requestId:globalThis.crypto.randomUUID()}),await this.refreshRegistry()}catch(i){this.#u("error",`Project was not added. ${i instanceof Error?i.message:String(i)} Refresh and try again.`),await this.refreshRegistry()}}async listWorkspaceSessions(t){if(!Te(this.#e.principal??void 0,"session.read")||this.#e.connection.phase!=="open")return{};const i=this.#r(),a=await Promise.all(t.map(async l=>{try{const u=await i.request("session.list",{projectRoot:l,rootsOnly:!0,includeClosed:!0});return[l,(Array.isArray(u?.sessions)?u.sessions:[]).filter(d=>d&&typeof d.id=="string"&&!d.parentId&&!d.archived)]}catch{return null}}));return Object.fromEntries(a.filter(Boolean))}async refreshSessions({quiet:t=!1}={}){this.refreshRegistry();const i=this.#e.workspace;if(!i)return;const a=this.#l;t||this.#t(u=>({sessions:{...u.sessions,status:u.sessions.list.length?u.sessions.status:"loading",error:void 0}}));const l=Date.now();try{const d=await this.#r().request("session.list",{projectRoot:i,rootsOnly:!0,includeClosed:!0});if(a!==this.#l)return;const h=(Array.isArray(d?.sessions)?d.sessions:[]).filter(m=>m&&typeof m.id=="string"&&!m.parentId&&!m.archived).sort((m,p)=>String(p.updatedAt??p.createdAt??"").localeCompare(String(m.updatedAt??m.createdAt??"")));this.#t(m=>{let p={status:"ready",list:h};for(const[j,S]of this.#o)p=this.#Ue(p,j,S.projection);const x=m.selected&&!h.some(j=>j.id===m.selected)?m.sessions.list.find(j=>j.id===m.selected):void 0,w=this.#le?[]:Object.keys(m.turnAttention).filter(j=>m.turnAttention[j].at<l&&h.some(S=>S.id===j&&(S.status==="running"||S.busy))),k=w.length?Object.fromEntries(Object.entries(m.turnAttention).filter(([j])=>!w.includes(j))):m.turnAttention;return{sessions:x?{...p,list:[x,...p.list]}:p,turnAttention:k}})}catch(u){if(a!==this.#l)return;t||this.#t(d=>({sessions:{...d.sessions,status:"error",error:Be(u)}}))}}async refreshAttention(){const t=this.#e.workspace;if(!t||!Te(this.#e.principal??void 0,"session.read"))return;const i=this.#l,a=++this.#Oe,l=this.hasCapability("question.watch"),u=l?{read:a,events:[]}:null;this.#X=u;const d=this.#le,h=d?[]:null;this.#P=h;try{const m=l&&this.hasCapability("question.watch.turns"),p=await this.#r().request(l?"question.watch":"question.list",{projectRoot:t,...m?{turns:!0}:{},...d?{attention:!0}:{}});if(i!==this.#l||a!==this.#Oe)return;d&&Array.isArray(p?.attention)&&this.#gt(p.attention,h??[]);const x=new Map;for(const y of Array.isArray(p?.questions)?p.questions:[])typeof y?.id=="string"&&typeof y.rootId=="string"&&x.set(y.id,y.rootId);for(const y of u?.events??[])y.root?x.set(y.id,y.root):x.delete(y.id);this.#N=x,this.#ve(),l||(this.#N=null)}catch{}finally{this.#X===u&&(this.#X=null),this.#P===h&&(this.#P=null)}}#gt(t,i){const a=new Map;for(const u of t)typeof u?.sessionId=="string"&&Pd(u.attention)&&a.set(u.sessionId,u.attention);for(const[u,d]of i)a.set(u,d);const l={};for(const[u,d]of a){const h=Pd(d);if(!h||this.#e.history.list.some(p=>p.id===u&&p.archived))continue;if(this.#ce(u)){this.#we(u,h);continue}const m=this.#e.turnAttention[u];l[u]=m?.hostAt===h.hostAt?m:h}JSON.stringify(l)!==JSON.stringify(this.#e.turnAttention)&&this.#t({turnAttention:l})}get historyPaged(){return this.hasCapability("session.list.page")}async loadHistory({quiet:t=!1,query:i=this.#e.history.query}={}){const a=this.#e.workspace;if(!a)return;const l=this.#l,u=++this.#G,d=this.historyPaged,h=i.trim();t||this.#t(m=>({history:{...m.history,status:"loading",error:void 0,query:i}}));try{const m=await this.#r().request("session.list",{projectRoot:a,rootsOnly:!0,includeClosed:!0,includeArchived:!0,...d?{limit:this.#n.historyPageSize,...h?{query:h}:{}}:{}});if(l!==this.#l||u!==this.#G)return;const p=d&&typeof m?.nextCursor=="string"?m.nextCursor:void 0;this.#t({history:{status:"ready",list:ry(m,!d),query:i,...p?{nextCursor:p}:{}}})}catch(m){if(l!==this.#l||u!==this.#G)return;(!t||this.#e.history.status!=="ready")&&this.#t(p=>({history:{...p.history,status:"error",error:Be(m),query:i}}))}}async loadMoreHistory(){const t=this.#e.workspace,{status:i,nextCursor:a,query:l,more:u}=this.#e.history;if(!t||i!=="ready"||!a||u==="loading")return;const d=this.#l,h=this.#G,m=l.trim();this.#t(p=>({history:{...p.history,more:"loading"}}));try{const p=await this.#r().request("session.list",{projectRoot:t,rootsOnly:!0,includeClosed:!0,includeArchived:!0,limit:this.#n.historyPageSize,cursor:a,...m?{query:m}:{}});if(d!==this.#l)return;if(h!==this.#G){this.#He();return}const x=typeof p?.nextCursor=="string"?p.nextCursor:void 0;this.#t(y=>{const w=new Set(y.history.list.map(A=>A.id)),{more:k,nextCursor:j,...S}=y.history;return{history:{...S,list:[...S.list,...ry(p,!1).filter(A=>!w.has(A.id))],...x?{nextCursor:x}:{}}}})}catch{if(d!==this.#l)return;if(h!==this.#G){this.#He();return}this.#t(p=>({history:{...p.history,more:"error"}}))}}#He(){if(this.#e.history.more!=="loading")return;const{more:t,...i}=this.#e.history;this.#t({history:i})}get filesSearchable(){return this.hasCapability("workspace.files")}async searchWorkspaceFiles({query:t="",limit:i=Wb}={}){const a=this.#e.workspace;if(!a)throw new Ke("Choose a workspace first.");if(!this.filesSearchable)throw new Ke("The host does not offer file search. Update ALP on the host.");if(!Te(this.#e.principal??void 0,"project.read"))throw new Ke(ay);let l;try{l=await this.#r().request("workspace.files.search",{projectRoot:a,query:String(t).slice(0,200),limit:i})}catch(d){throw Be(d).code===1003?new Ke(ay):d}return{files:(Array.isArray(l?.files)?l.files:[]).filter(d=>d&&typeof d.path=="string"&&d.path).map(d=>({path:String(d.path)})),truncated:l?.truncated===!0}}get filesReadable(){return this.hasCapability("workspace.files.read")}get canReadFiles(){return Te(this.#e.principal??void 0,"files.read")}#Ie(t,i){const a=(d,h,m=!1)=>new Ei({message:d,reason:h,sent:"no",terminal:m}),l=this.#e.workspace;if(!l)throw a("Choose a workspace first.","workspace");if(!this.filesReadable)throw a(Qb,"capability",!0);if(!this.canReadFiles)throw a(kf,"grant",!0);if(t===void 0||t===""){if(i)throw a(Ir.invalid_path,"invalid_path");return{workspace:l,path:void 0}}const u=Js(t);if(!u)throw a(Ir.invalid_path,"invalid_path");if($i(u))throw a(Ir.blocked_path,"blocked_path");return{workspace:l,path:u}}#Ge(t){const i=g2(t);return i.code===1003&&i.reason==="grant"?new Ei({...i,message:kf}):new Ei(i)}async listWorkspaceFiles({path:t,includeIgnored:i=!1}={}){const a=this.#Ie(t,!1);let l;try{l=await this.#r().request("workspace.files.list",{projectRoot:a.workspace,...a.path?{path:a.path}:{},...i?{includeIgnored:!0}:{}})}catch(u){throw this.#Ge(u)}return x2(l,a.path??"")}async readWorkspaceFile({path:t,includeIgnored:i=!1}){const a=this.#Ie(t,!0);let l;try{l=await this.#r().request("workspace.files.read",{projectRoot:a.workspace,path:a.path,...i?{includeIgnored:!0}:{}})}catch(d){throw this.#Ge(d)}const u=typeof l?.content=="string"?l.content:void 0;if(u===void 0||u.length>Hl.maxReadBytes)throw new Ei({message:u===void 0?"The host sent something this app does not understand.":Ir.too_large,...u===void 0?{}:{reason:"too_large"},sent:"yes",terminal:!1});return{path:a.path,content:u,size:typeof l?.size=="number"&&Number.isFinite(l.size)?l.size:u.length,...typeof l?.modifiedAt=="string"?{modifiedAt:l.modifiedAt}:{}}}get gitAccess(){return Gd(this.#e)}async gitStatus(){const t=Gd(this.#e);if(!t.status)throw new ys({message:t.message,reason:t.reason,sent:"no",terminal:t.reason!=="loading"});let i;try{i=await this.#r().request("workspace.git.status",{workspaceId:t.workspaceId})}catch(a){throw new ys(_i(a))}if(!i||typeof i!="object"||typeof i.state!="string"||!Array.isArray(i.files))throw new ys({message:"The host sent something this app does not understand.",sent:"yes",terminal:!1});return i}async gitDiff({compare:t,path:i,cursor:a}){const l=Gd(this.#e);if(!l.status)throw new ys({message:l.message,reason:l.reason,sent:"no",terminal:l.reason!=="loading"});if(!l.content)throw new ys({message:l.contentMessage,reason:"grant",sent:"no",terminal:!0});const u=i===void 0?void 0:cj(i);if(i!==void 0&&!u){const h=Js(i)?"blocked_path":"invalid_path";throw new ys({message:Gl[h],reason:h,sent:"no",terminal:!1})}let d;try{d=await this.#r().request("workspace.git.diff",{workspaceId:l.workspaceId,compare:uj(t),...u?{path:u}:{},...a?{cursor:a}:{}})}catch(h){throw new ys(_i(h))}if(!d||typeof d!="object"||typeof d.snapshot!="string"||!Array.isArray(d.files))throw new ys({message:"The host sent something this app does not understand.",sent:"yes",terminal:!1});return d}isArchived(t){return t?!!this.#e.history.list.find(i=>i.id===t)?.archived&&!this.#e.sessions.list.some(i=>i.id===t):!1}async#Te(){const t=this.#e.workspace,i=this.#e.principal;if(!t||!i)return;const a=this.#l;this.#t(l=>({catalog:{...l.catalog,status:"loading",error:void 0}}));try{const l=this.#r(),[u,d,h]=await Promise.all([this.#Ye(l,i,t),Te(i,"session.read")?l.request("catalog.get",{}).catch(()=>{}):void 0,this.hasCapability("library")&&Te(i,"session.read")?l.request("library.models",{}).catch(()=>{}):void 0]);if(a!==this.#l)return;const m=i.modes,x=(Array.isArray(d?.modes)&&d.modes.length?d.modes:Object.keys(iy).map(k=>({id:k}))).filter(k=>typeof k?.id=="string"&&(!m||m.includes(k.id))).map(k=>({id:k.id,label:typeof k.label=="string"?k.label:iy[k.id]??k.id,...typeof k.description=="string"?{description:k.description}:{}})),y=Gx(h?.models),w=x.some(k=>k.id==="full-access")?"full-access":x[0]?.id;this.#t({catalog:{status:"ready",...u,modes:x,models:y,...w?{defaultMode:w}:{}}})}catch(l){if(a!==this.#l)return;this.#t(u=>({catalog:{...u.catalog,status:"error",error:Be(l)}}))}}async#Ye(t,i,a){if(!this.hasCapability("team"))return{teams:[],teamsKnown:!1,teamsUnavailable:{reason:"capability"}};if(!Te(i,"project.read"))return{teams:[],teamsKnown:!1,teamsUnavailable:{reason:"permission"}};try{const l=await t.request("team.list",{projectRoot:a});return Array.isArray(l?.teams)?{teams:l.teams.filter(d=>typeof d?.id=="string"&&!d.error).map(d=>({id:d.id,label:typeof d.label=="string"?d.label:d.id,...typeof d.description=="string"?{description:d.description}:{}})),teamsKnown:!0}:{teams:[],teamsKnown:!1,teamsUnavailable:{reason:"failed",message:"The host answered team.list in a form this app does not read."}}}catch(l){return{teams:[],teamsKnown:!1,teamsUnavailable:{reason:"failed",message:Be(l).message}}}}startOrigin(){return{workspace:this.#e.workspace,connection:this.#U}}keepUnsentDraft(t,i){if(!t||!i?.workspace||i.connection!==this.#U)return;const a={workspace:i.workspace,text:String(t)};for(const l of this.#z)if(l(a)){this.#M=null;return}this.#M=a}takeUnsentDrafts(t){return this.#z.add(t),()=>{this.#z.delete(t)}}unsentDraft(){const t=this.#M;return t&&t.workspace===this.#e.workspace?t.text:""}clearUnsentDraft(t){(t===void 0||this.#M?.text===t)&&(this.#M=null)}async retryTeams(){const{workspace:t,principal:i,catalog:a}=this.#e;if(!t||!i||a.status!=="ready"||a.teamsUnavailable?.reason!=="failed"||this.#C)return;const l=this.#l;this.#C=!0;try{const u=await this.#Ye(this.#r(),i,t);if(l!==this.#l||this.#e.workspace!==t||this.#e.catalog.status!=="ready")return;this.#t(d=>({catalog:{...d.catalog,teams:u.teams,teamsKnown:u.teamsKnown,teamsUnavailable:u.teamsUnavailable}}))}catch{}finally{this.#C=!1}}selectSession(t){if(this.clearAttention(t),t===this.#e.selected)return;const i=t?this.#_(t):void 0;i&&(i.failed=null),this.#t({selected:t,focus:t,tree:t&&i?{rootId:t,status:i.gone?"gone":"detached",...i.gone?{error:i.gone}:{},projection:i.projection}:null}),this.#V()}focusSession(t){const i=this.#e.tree?.projection;!i||t!==i.rootId&&!i.sessions[t]||(this.clearAttention(t),this.#t({focus:t}))}async createSession({team:t,mode:i,model:a,thinking:l,title:u,prompt:d,files:h=[]}={}){const m=this.#e.workspace;if(!m)throw new Ke("Choose a workspace first.");if(this.#T||this.#e.busy.create)throw new Ke("A new session is already starting.");const p=this.#r(),x=V2(),y=this.#l;this.#T=x,this.#t(A=>({busy:{...A.busy,create:!0}}));const w=this.#_(x),k={id:x,projectRoot:m,status:"initializing",...u?{title:u}:{},createdAt:new Date().toISOString()};this.#t(A=>({selected:x,focus:x,tree:{rootId:x,status:"attaching",projection:w.projection},sessions:{...A.sessions,list:[k,...A.sessions.list.filter(R=>R.id!==x)]}}));const j=()=>y===this.#l&&p===this.#i?.alp?.client,S=()=>{if(!j())throw new Ke("The connection or workspace changed while starting the session.")};try{return await this.#k(p,async()=>{S();const A=this.#s;A&&A.client===p&&(this.#s=null,this.#a=null,await this.#J(A)),S();const R={buffer:[]};w.attaching=R,this.#a=x;const q={cwd:m,persist:!0,...t?{workflow:t}:{},...i?{mode:i}:{},...a?{model:a}:{},...l?{thinking:l}:{}};this.#s={client:p,root:x};try{await p.request("session.create",{sessionId:x,spec:q,history:"skip"},{timeoutMs:this.#n.createTimeoutMs}),S(),this.#s={client:p,root:x}}catch(O){if(!j())throw O;w.attaching=null;const L=Be(O);throw L.sent!=="unknown"?(this.#s?.client===p&&this.#s.root===x&&(this.#s=null,await this.#J({client:p,root:x})),j()&&(this.#o.delete(x),this.#c.delete(x),this.#f.delete(x),this.#a===x&&(this.#a=null),this.#t(B=>({...B.selected===x?{selected:null,focus:null,tree:null}:{},sessions:{...B.sessions,list:B.sessions.list.filter(_=>_.id!==x)}}))),O):(this.refreshSessions(),new wb(`${L.message} If the new session shows in the list, open it and send your message there; otherwise start again.`,x))}try{let O;if(this.hasCapability("session.history")){const B=await p.request("session.history",{sessionId:x,limit:1},{timeoutMs:this.#n.requestTimeoutMs});S(),O=B.generation,this.#c.set(x,{generation:O,hasOlder:!1})}const L=await p.request("session.attach",{sessionId:x,...O?{generation:O,after:0}:{}},{timeoutMs:this.#n.requestTimeoutMs});S(),w.attaching===R&&(w.attaching=null,w.failed=null,this.#ke(x,w,L,R.buffer))}catch(O){if(!j())throw O;w.attaching===R&&(w.attaching=null),this.#a===x&&(this.#a=null),this.#Ne(p,x,O)}return u?.trim()&&await this.renameSession(x,u.trim()).catch(()=>{}),S(),this.#Et({team:t,mode:i,model:a,thinking:l}),(d?.trim()||h.length)&&await this.sendPrompt(d??"",x,[],h,{keepRefused:!0}).catch(O=>this.#u("error",Be(O).message)),this.refreshSessions({quiet:!0}),x})}finally{this.#T===x&&(this.#T=null,this.#t(A=>({busy:{...A.busy,create:!1}}))),this.#V()}}async renameSession(t,i){const u=(await this.#r().request("session.rename",{sessionId:t,title:i}))?.session,d=m=>m.id===t?{...m,...u&&typeof u=="object"?u:{},title:i}:m;this.#t(m=>({sessions:{...m.sessions,list:m.sessions.list.map(d)},history:{...m.history,list:m.history.list.map(d)}}));const h=this.#o.get(t);h&&(h.projection={...h.projection,sessions:{...h.projection.sessions,[t]:{...h.projection.sessions[t],id:t,title:i}}},this.#L(t))}async archiveSession(t){const i=this.#r(),a=this.#l;if(await i.request("session.archive",{sessionId:t,archived:!0}),a!==this.#l)return;this.#e.selected===t&&this.selectSession(null);const{[t]:l,...u}=this.#e.attention,{[t]:d,...h}=this.#e.turnAttention;this.#t(m=>({turnAttention:h,sessions:{...m.sessions,list:m.sessions.list.filter(p=>p.id!==t)},history:{...m.history,list:m.history.list.map(p=>p.id===t?{...p,archived:!0}:p)},attention:u}))}async restoreSession(t){const i=this.#r(),a=this.#l,l=await i.request("session.archive",{sessionId:t,archived:!1});if(a!==this.#l)return;const u=l?.session&&typeof l.session=="object"?l.session:void 0;this.#t(d=>{const m={...d.history.list.find(p=>p.id===t)??{},...u??{},id:t,archived:!1};return{history:{...d.history,list:d.history.list.map(p=>p.id===t?m:p)},sessions:{...d.sessions,list:d.sessions.list.some(p=>p.id===t)?d.sessions.list:[m,...d.sessions.list]}}}),this.refreshSessions({quiet:!0})}#de(t){const i=this.#e.sessions.list.find(l=>l.id===t)??this.#e.history.list.find(l=>l.id===t),a=this.#o.get(t)?.projection.sessions[t];return{...i??{},...a??{},...a?.conversation?{}:i?.conversation?{conversation:i.conversation}:{}}}conversationGate(t=this.#e.tree?.rootId){const{principal:i,connection:a}=this.#e,l=t?this.#o.get(t):void 0,u=!!t&&!!l&&(this.rootBusy(t)||Object.keys(l.projection.running).length>0||Object.keys(l.projection.questions).length>0);return Q2({capabilities:a.capabilities,canRead:Te(i??void 0,"session.read"),canWrite:Te(i??void 0,"session.write"),summary:t?this.#de(t):null,busy:u,generation:t?this.#c.get(t)?.generation??null:null,online:a.phase==="open",driveBlock:t&&t===this.#e.tree?.rootId?this.driveBlock():void 0})}agentControls(t){const{principal:i,connection:a}=this.#e,l=this.#e.tree?.rootId,u=l?this.#o.get(l):void 0,d=!!l&&t===l,h=d&&!!u&&(this.rootBusy(l)||Object.keys(u.projection.running).length>0||Object.keys(u.projection.questions).length>0);return nj({capabilities:a.capabilities,canRead:Te(i??void 0,"session.read"),canWrite:Te(i??void 0,"session.write"),summary:d?this.#de(l):null,root:d,closed:d&&!!u?.projection.closed[l],busy:h,generation:d?this.#c.get(l)?.generation??null:null,online:a.phase==="open",driveBlock:d?this.driveBlock():void 0})}#ee=new Map;async listCommands(t){if(!this.#e.connection.capabilities.includes("session.commands"))return this.#ee.get(t)??[];try{const i=await this.#r().request("session.commands",{sessionId:t}),a=Array.isArray(i?.commands)?i.commands.filter(l=>typeof l?.name=="string"&&l.name):[];return(a.length||!this.#ee.has(t))&&this.#ee.set(t,a),this.#ee.get(t)??[]}catch{return this.#ee.get(t)??[]}}async copyResumeCommand(t,i){try{const a=await this.#r().request("session.resumeCommand",{sessionId:t});if(typeof a?.display!="string"||!a.display)throw new Ke("The host answered no command.");return await i(a.display),this.#u("info",`Copied the resume command: ${a.display}`),a}catch(a){this.#u("error",`Could not copy the resume command: ${Be(a).message}`);return}}async reloadAgent({sessionId:t,requestId:i}){const{root:a,generation:l,client:u}=this.#fe();if(t!==a)throw new Ke(Fr.not_root);this.#u("info","Reloading the agent…");try{const d=await u.request("session.reload",{sessionId:a,requestId:i,ifGeneration:l},{timeoutMs:this.#n.createTimeoutMs});return this.#Ae(d.session),this.refreshSessions({quiet:!0}),this.#u("info","Reloaded the agent: it restarted on the same conversation."),d}catch(d){throw this.#he(a,d),this.#u("error",Z2(d).message),d}}async compactAgent({sessionId:t}){const i=this.#e.tree?.rootId;if(!i||t!==i)throw new Ke(Wf.not_root);try{const a=await this.#r().request("session.compact",{sessionId:i});return this.#u("info",ej(a?.status)),a}catch(a){throw this.#u("error",tj(a).message),a}}rootSummary(t=this.#e.tree?.rootId){return t?this.#de(t):{}}historyGeneration(t){return this.#c.get(t)?.generation}#Ae(t){if(!t||typeof t.id!="string")return;const i=t.id,a=u=>u.id===i?{...u,...t}:u;this.#t(u=>({sessions:{...u.sessions,list:u.sessions.list.map(a)},history:{...u.history,list:u.history.list.map(a)}}));const l=this.#o.get(i);l&&(l.projection={...l.projection,sessions:{...l.projection.sessions,[i]:{...l.projection.sessions[i],...t,id:i}}},this.#L(i))}#fe(){const t=this.#e.tree?.rootId??this.#e.selected;if(!t)throw new Ke("Open a session first.");const i=this.#c.get(t)?.generation;if(!i)throw new Ke("The conversation is still loading. Try again in a moment.");return{root:t,generation:i,client:this.#r()}}#he(t,i){if(!ei(i).reload)return;const a=this.#s?.root===t?this.#s.client:void 0;this.#c.delete(t),a&&this.#je(a,t)}async rewindConversation({beforeTurnId:t,requestId:i}){const{root:a,generation:l,client:u}=this.#fe();try{const d=await u.request("session.rewind",{sessionId:a,requestId:i,ifGeneration:l,beforeTurnId:t},{timeoutMs:this.#n.createTimeoutMs});return this.#Ae(d.session),this.#Be(a,d.generation),this.refreshSessions({quiet:!0}),d}catch(d){throw this.#he(a,d),d}}async forkConversation({requestId:t,boundary:i,branchId:a,workspaceId:l,directory:u,title:d}){const{root:h,generation:m,client:p}=this.#fe();let x;try{x=await p.request("session.fork",{sessionId:h,requestId:t,ifGeneration:m,...i?{boundary:i}:{},...a?{branchId:a}:{},...l?{workspaceId:l}:{},...d?.trim()?{title:d.trim()}:{}},{timeoutMs:this.#n.createTimeoutMs})}catch(y){throw this.#he(h,y),y}return this.#xt(x.session,u),x}#xt(t,i){const a=t?.id;typeof a=="string"&&(i&&i!==this.#e.workspace&&this.selectWorkspace(i),this.#t(l=>({sessions:{...l.sessions,list:[t,...l.sessions.list.filter(u=>u.id!==a)]}})),this.selectSession(a),this.refreshSessions({quiet:!0}))}worktreeForkSource(){const{workspace:t,principal:i,registry:a}=this.#e;if(!t||!this.hasCapability("workspace.worktree")||!this.hasCapability("workspace.registry")||!Te(i??void 0,"workspace.manage"))return null;const l=i?.workspaceRoots?.find(u=>u.path===t)?.canonical;return a.workspaces.find(u=>!u.managedWorktree&&!u.archivedAt&&(u.directory===t||u.directory===l))??null}async forkIntoWorktree({requestId:t,worktreeKey:i=t,mappingId:a,boundary:l,branchId:u,title:d}){const h=this.worktreeForkSource();if(!h)throw new Ke("Worktrees are not available for this workspace.");const m=this.#d.get(t)??i;this.#d.set(t,m);try{let p=this.#w.get(m);if(!p){let y=this.#b.get(m);y||(y={workspaceId:h.id,mappingId:a,ifRevision:this.#e.registry.revision,requestId:`${m}:worktree`},this.#b.set(m,y));let w;try{w=await this.#r().request("workspace.worktree.create",y,{timeoutMs:this.#n.createTimeoutMs})}catch(k){throw(k?.data?.reason==="stale_revision"||Be(k).sent==="yes")&&this.#b.delete(m),k}p={id:w.workspace.id,directory:w.workspace.directory},this.#w.set(m,p),this.#b.delete(m),await this.refreshRegistry()}const x=await this.forkConversation({requestId:t,boundary:l,branchId:u,workspaceId:p.id,directory:p.directory,title:d});return this.#d.delete(t),x}catch(p){throw ei(p).retrySame||this.#d.delete(t),p}}async worktreeForkDestinations(){const t=this.worktreeForkSource();return t?this.worktreeOptions(t.id):[]}driveBlock(){const{principal:t,tree:i}=this.#e;if(!t)return"Not connected.";if(!Te(t,"session.write"))return"Your access token can view sessions but not send messages.";if(!i)return;const a=t.modes;if(a){const l=Bb(i.projection).find(u=>u.session?.mode&&!a.includes(u.session.mode));if(l)return`Your access token can only drive sessions in ${a.join(", ")} mode; this conversation runs in ${l.session?.mode}.`}}#yt(t,i){return this.#k(t,async()=>{if(!(t!==this.#i?.alp?.client||this.#e.selected!==i))try{await this.#bt(t,i)}finally{this.#V()}})}async#bt(t,i){const a=this.#_(i),l=a.projection.sessions[i],u=this.#e.sessions.list.find(y=>y.id===i);if(!(a.projection.closed[i]||l?.status==="closed"||!l&&u?.status==="closed"))return;const h=l?.projectRoot??u?.projectRoot??this.#e.workspace??"",m=Ll(this.#e.principal??void 0,h)?.path??this.#e.workspace??h,p=l?.mode??u?.mode,x={buffer:[]};a.attaching=x,this.#a=i;try{if(await t.request("session.create",{sessionId:i,spec:{cwd:m,...p?{mode:p}:{}},resume:!0,history:"skip"},{timeoutMs:this.#n.createTimeoutMs}),t!==this.#i?.alp?.client)return;if(this.#s={client:t,root:i},this.hasCapability("session.history")&&!this.#c.has(i)){const j=await t.request("session.history",{sessionId:i},{timeoutMs:this.#n.requestTimeoutMs});if(a.attaching!==x)return;a.projection=bs(i);for(const S of j.items)a.projection=zi(a.projection,bf(S,i));this.#W(a.projection),a.projection={...a.projection,cursor:j.tipCursor},this.#c.set(i,{generation:j.generation,olderCursor:j.olderCursor,hasOlder:j.hasOlder})}const y=a.projection.cursor,w=this.#c.get(i),k=await t.request("session.attach",{sessionId:i,...w?{after:y,generation:w.generation}:y>0?{after:y}:{}},{timeoutMs:this.#n.requestTimeoutMs});a.attaching===x&&(a.attaching=null,this.#ke(i,a,k,x.buffer))}catch(y){throw a.attaching===x&&(a.attaching=null),y}}async sendPrompt(t,i=this.#e.selected,a=[],l=[],{keepRefused:u=!1}={}){const d=String(t??"");if(!i||!d.trim()&&!a.length&&!l.length)return;const h=this.driveBlock();if(h)throw new Ke(h);const m=Xr([],a,this.#e.connection.promptImageLimits);if(m.error)throw new Ke(m.error);const p=l.length?this.#Ve(i,l):null;if(p&&!u)throw new Ke(p);const x=Tl(),y={id:x,rootId:i,text:d,...a.length?{images:a}:{},...l.length?{files:l.map(w=>({...w,received:0,error:void 0})),uploadKey:x}:{},delivery:this.rootBusy(i)?"steer":"auto",status:"sending",retrySameId:!0,at:Date.now()};if(this.clearAttention(i),p){this.#t(w=>({prompts:[...w.prompts,{...y,status:"failed",error:p}]})),this.#Me(y);return}this.#t(w=>({prompts:[...w.prompts,y]})),this.#Me(y),await this.#Ke(y)}fileGate(t=this.#e.selected){const{connection:i,principal:a}=this.#e,l=t?this.#o.get(t)?.projection.sessions[t]??this.#e.sessions.list.find(u=>u.id===t):void 0;return vj({capable:i.capabilities.includes("attachments"),permitted:Te(a??void 0,"attachments.write"),writable:Te(a??void 0,"session.write"),limits:i.attachmentLimits,session:l,known:!!t})}#Ve(t,i){return this.fileGate(t)??Ol([],i,this.#e.connection.attachmentLimits??Ps).error}#vt(t,i){const a=this.#wt(t,i);this.#me.set(i.id,a);const l=()=>{this.#me.get(i.id)===a&&this.#me.delete(i.id)};return a.then(l,l),a}#me=new Map;#te(t){return this.#e.prompts.some(i=>i.id===t)}async#wt(t,i){const a=i.files??[],l=i.uploadKey??i.id,u=this.#e.connection.attachmentLimits??Ps,d=(p,x)=>this.#t(y=>({prompts:y.prompts.map(w=>w.id===i.id&&w.files?{...w,files:w.files.map((k,j)=>j===p?{...k,...x}:k)}:w)})),h=$d(t),m=[...a];for(const[p,x]of a.entries())if(!x.attachmentId){if(!this.#te(i.id))throw new $r;d(p,{error:void 0,received:x.received??0,started:!0});try{const y=await h.upload({sessionId:i.rootId,name:x.name,mimeType:x.mimeType,data:x.data,requestId:Bx(l,p,x.attempt),maxChunkBytes:u.maxChunkBytes,onProgress:w=>{if(!this.#te(i.id))throw new $r;d(p,{received:w})}});if(typeof y?.attachmentId!="string")throw new Error(`The host did not answer an attachment for ${x.name}.`);m[p]={...x,attachmentId:y.attachmentId,received:x.size,error:void 0},d(p,{attachmentId:y.attachmentId,received:x.size,error:void 0})}catch(y){if(y instanceof $r||!this.#te(i.id))throw new $r;const w=Be(y);throw d(p,{error:w.message}),new oy(x.name,w,Ff(y)&&["closed","disconnected","send_failed"].includes(y.reason))}}return m}#kt(){for(const t of this.#e.prompts)t.status!=="failed"||!t.resumeUpload||t.resumeUpload>3||this.retryPrompt(t.id,{resume:!0}).catch(()=>{})}async#Ke(t){const i=t.rootId,a=this.#ne.get(i),l=(async()=>{a&&await a.catch(()=>{});const u=this.#e.prompts.find(h=>h.id===t.id);if(!u||u.status!=="sending")return;const d=this.rootBusy(i,t.id)?"steer":"auto";d!==u.delivery&&this.#t(h=>({prompts:h.prompts.map(m=>m.id===t.id?{...m,delivery:d}:m)})),await this.#Fe({...u,delivery:d})})();this.#ne.set(i,l);try{await l}finally{this.#ne.get(i)===l&&this.#ne.delete(i)}}#ne=new Map;rootBusy(t=this.#e.selected,i){if(!t)return!1;const a=this.#o.get(t);if(a&&t in a.projection.running||this.#x.has(t))return!0;for(const u of this.#O.get(t)??[]){if(u===i)continue;const d=a?.projection.prompts[u];if(!this.#F.has(u)&&(!d||d.errorCode==="outcome_unknown"))return!0}if(this.#e.prompts.some(u=>u.rootId===t&&u.id!==i&&u.status==="unknown")||this.#e.prompts.some(u=>u.rootId===t&&u.id!==i&&u.status==="sending"&&!u.accepted&&this.#ge.has(u.id)))return!0;const l=this.#K.get(t);if(!l||!a)return!1;for(const[u]of l){if(u===i)continue;const d=a.projection.prompts[u];if(!(d?.state==="failed"||!d&&!this.#F.has(u)||(!d?.turnId||!a.projection.turns[d.turnId])&&Date.now()-(this.#se.get(u)??0)>this.#Qe)&&(!d||!Hx(a.projection,u)))return!0}return!1}async configureMode(t){const i=this.#e.selected;if(!i||!t)return;const a=this.#e.principal?.modes,l=this.driveBlock()??(a&&!a.includes(t)?`Your access token can only use ${a.join(", ")} mode.`:void 0);if(l){this.#u("error",l);return}if(!this.#e.busy.mode){this.#t(u=>({busy:{...u.busy,mode:!0}}));try{const u=await this.#r().request("session.configure",{sessionId:i,mode:t},{timeoutMs:this.#n.requestTimeoutMs}),d=this.#o.get(i),h=typeof u?.session?.mode=="string"?u.session.mode:t;d&&(d.projection={...d.projection,sessions:{...d.projection.sessions,[i]:{...d.projection.sessions[i],id:i,mode:h}}},this.#L(i)),this.#t(m=>({sessions:{...m.sessions,list:m.sessions.list.map(p=>p.id===i?{...p,mode:h}:p)}}))}catch(u){this.#u("error",Be(u).message)}finally{this.#t(u=>({busy:{...u.busy,mode:!1}}))}}}liveConfigure(){const{principal:t,connection:i,busy:a}=this.#e,l=this.#e.tree?.rootId,u=l?this.#o.get(l):void 0,d=!!l&&!!u&&(this.rootBusy(l)||Object.keys(u.projection.running).length>0||Object.keys(u.projection.questions).length>0);return Gj({capabilities:i.capabilities,canWrite:Te(t??void 0,"session.write"),canTeam:Te(t??void 0,"session.team.write"),summary:l?this.#de(l):null,closed:!!l&&!!u?.projection.closed[l],busy:d,configuring:!!a.configure||!!a.mode,generation:l?this.#c.get(l)?.generation??null:null,online:i.phase==="open",driveBlock:l?this.driveBlock():void 0})}async previewConfigure(t={}){const i=this.#e.tree?.rootId;if(!i||!this.hasCapability(Gb)||!Te(this.#e.principal??void 0,"session.read"))return;const a=await this.#r().request("session.configure.preview",{sessionId:i,...t},{timeoutMs:this.#n.requestTimeoutMs});return a?.preview&&typeof a.preview=="object"?a.preview:void 0}#pe;async configureLive(t){const i=this.#e.tree?.rootId,a=Object.fromEntries(Object.entries(t).filter(([h,m])=>["model","thinking","team"].includes(h)&&typeof m=="string"&&m));if(!i||!Object.keys(a).length||this.#e.busy.configure)return;const l=this.liveConfigure(),u=a.team?l.team:a.model?l.model:l.thinking;if(!l.shown||!u.enabled){this.#u("error",u.reason??l.reason??"This change is not available now.");return}this.#t(h=>({busy:{...h.busy,configure:!0}}));const d=JSON.stringify([i,a]);try{if(a.team){const w=await this.previewConfigure(a).catch(()=>{});if(w&&!w.allowed){const k=w.reason??"runtime_unsupported";this.#u("error",Ma[k]??w.message??"The host would not take this change.",Yb.has(k)?{action:"new-session"}:void 0);return}}const{generation:h,client:m}=this.#fe(),p=this.#pe?.key===d?this.#pe.requestId:Qf();this.#pe=void 0;let x;try{x=await m.request("session.configure",{sessionId:i,...a,requestId:p,ifGeneration:h},{timeoutMs:this.#n.createTimeoutMs})}catch(w){const k=Fx(w);k.retrySame&&(this.#pe={key:d,requestId:p}),this.#he(i,w),this.#u("error",k.message,k.newSession?{action:"new-session"}:void 0);return}const y=x?.configured;if(this.#Ae(Yj(x.session,y?.effective)),this.refreshSessions({quiet:!0}),y){const w=this.#e.catalog.models.find(k=>k.id===`${y.effective.runtime}:${y.effective.model}`)?.label;this.#u("info",Vj(y,Xs,w))}return x}catch(h){this.#u("error",Fx(h).message);return}finally{this.#t(h=>({busy:{...h.busy,configure:!1}}))}}async#Fe(t){const i=a=>this.#t(l=>({prompts:l.prompts.map(u=>u.id===t.id?{...u,...a}:u)}));this.#ge.add(t.id);try{const a=this.#r();!(this.#T===t.rootId&&this.#s?.client===a&&this.#s.root===t.rootId)&&this.#e.selected===t.rootId&&await this.#yt(a,t.rootId);const u=Xr([],t.images??[],this.#e.connection.promptImageLimits);if(u.error)throw new Ke(u.error);let d=t.files??[];if(d.length){const p=this.#Ve(t.rootId,d);if(p)throw new Ke(p);if(d=await this.#vt(a,t),!this.#te(t.id))return}if(!this.#te(t.id))return;i({submitted:!0});let h=this.#O.get(t.rootId);h||this.#O.set(t.rootId,h=new Set),h.add(t.id);const m=await a.request("session.prompt",{sessionId:t.rootId,clientMessageId:t.id,delivery:t.delivery,content:Aj(t.text,t.images,d)},{timeoutMs:this.#n.requestTimeoutMs});if(m?.outcome==="unknown"){i({status:"unknown",error:"The host cannot tell whether the agent took the message.",retrySameId:!1});return}if(m?.outcome==="failed"){this.#_e(t.rootId,t.id),i({status:"failed",error:m.error?.message?`The agent did not take the message: ${m.error.message}`:"The agent did not take the message.",retrySameId:!1});return}this.#F.add(t.id),this.#Nt(),this.#Xe(t)?this.#Ce(t.id):i({accepted:!0})}catch(a){if(this.#Xe(t))return this.#Ce(t.id);if(a instanceof $r)return;if(a instanceof oy){const u=a.dropped,d=this.#e.prompts.find(h=>h.id===t.id)?.resumeUpload??0;i({status:"failed",error:`Could not upload ${a.fileName}: ${a.failure.message}${u?" The upload continues when the connection is back.":""}`,retrySameId:!0,resumeUpload:u?d+1:0});return}const l=Be(a);t.files?.length&&(l.reason==="attachment_unavailable"||l.code===1001)&&await this.#jt(t,a),l.sent==="no"?i({status:"failed",error:l.message,retrySameId:!0}):l.sent==="yes"&&l.reason!=="outcome_unknown"?i({status:"failed",error:l.message,retrySameId:!1}):i({status:"unknown",error:l.message,retrySameId:l.reason!=="outcome_unknown"})}finally{this.#ge.delete(t.id),this.#e.prompts.find(l=>l.id===t.id)?.status==="failed"?this.#_e(t.rootId,t.id):this.#A(t.rootId)}}async#jt(t,i){const a=i?.data,u=(this.#e.prompts.find(h=>h.id===t.id)?.files??[]).filter(h=>typeof h.attachmentId=="string");let d;if(a?.reason==="attachment_unavailable"){const h=u.filter(m=>m.attachmentId===a?.attachmentId);d=new Set((h.length?h:u).map(m=>m.attachmentId))}else{let h;try{h=$d(this.#r())}catch{return}const m=await Promise.all(u.map(p=>h.get(p.attachmentId).then(()=>!1,x=>Be(x).code===1001)));d=new Set(u.filter((p,x)=>m[x]).map(p=>p.attachmentId))}d.size&&this.#t(h=>({prompts:h.prompts.map(m=>m.id===t.id&&m.files?{...m,files:m.files.map(p=>p.attachmentId&&d.has(p.attachmentId)?{...p,attachmentId:void 0,received:0,started:!1,attempt:(p.attempt??0)+1}:p)}:m)}))}#ge=new Set;#Xe(t){const i=this.#o.get(t.rootId);return!!i&&Ix(i.projection).has(t.id)}#Ce(t){this.#t(i=>({prompts:i.prompts.filter(a=>a.id!==t)}))}async retryPrompt(t,{resume:i=!1}={}){const a=this.#e.prompts.find(d=>d.id===t);if(!a||a.status==="sending")return;const l=i?a.resumeUpload:0,u=a.retrySameId?{...a,status:"sending",error:void 0,accepted:!1,resumeUpload:l}:{...a,id:Tl(),delivery:this.rootBusy(a.rootId,a.id)?"steer":"auto",status:"sending",error:void 0,retrySameId:!0,accepted:!1,resumeUpload:l,...a.files?.length?{uploadKey:a.uploadKey??a.id}:{}};if(this.#t(d=>({prompts:d.prompts.map(h=>h.id===t?u:h)})),u.id===a.id)return this.#Fe(u);this.#Pe(a.rootId,a.id),this.#Me(u),await this.#Ke(u)}#Pe(t,i){this.#K.get(t)?.delete(i),this.#se.delete(i),this.#F.delete(i)}discardPrompt(t){const i=this.#e.prompts.find(a=>a.id===t);i&&this.#Pe(i.rootId,t),this.#Ce(t),i&&this.#St(i)}#St(t){const i=(t.files??[]).map((u,d)=>({file:u,slot:d})).filter(({file:u})=>u.started&&!u.attachmentId);if(!i.length)return;const a=t.uploadKey??t.id,l=this.#me.get(t.id)??Promise.resolve();this.#Ee=this.#Ee.then(()=>l.catch(()=>{})).then(async()=>{let u;try{u=this.#r()}catch{return}const d=$d(u);for(const{file:h,slot:m}of i)await Tj(d,{sessionId:t.rootId,file:h,requestId:Bx(a,m,h.attempt),digest:vb})})}#Ee=Promise.resolve();abandonedUploads(){return this.#Ee}#K=new Map;#Me(t){let i=this.#K.get(t.rootId);i||this.#K.set(t.rootId,i=new Map),i.set(t.id,this.#o.get(t.rootId)?.projection.reset??0),this.#se.set(t.id,Date.now())}#se=new Map;#F=new Set;#$;get#Qe(){return this.#n.busyUnseenMs}#Nt(){this.#$!==void 0&&clearTimeout(this.#$),this.#$=setTimeout(()=>{this.#$=void 0,this.#i&&this.#t(t=>({busy:{...t.busy}}))},this.#Qe+100)}#We(t,i){const a=this.#K.get(t);if(!a)return!0;for(const[l,u]of a){const d=i.historyUnavailable&&i.reset>u&&Object.keys(i.running).length===0;(Hx(i,l)||d)&&(a.delete(l),this.#se.delete(l),this.#F.delete(l))}return a.size===0}queuePrompt(t){const i=this.#e.selected,a=String(t??"");if(!i||!a.trim())return;const l=this.driveBlock();if(l)throw new Ke(l);this.#t(u=>({queued:[...u.queued,{id:Tl(),rootId:i,text:a}]}))}interruptAndSend(t){const i=this.#e.selected,a=String(t??"");if(!i||!a.trim())return;const l=this.driveBlock();if(l)throw new Ke(l);this.#t(u=>({queued:[{id:Tl(),rootId:i,text:a},...u.queued]})),this.interrupt()}editQueued(t){const i=this.#e.queued.find(a=>a.id===t);return i?(this.#t(a=>({queued:a.queued.filter(l=>l.id!==t)})),i.text):null}async sendQueuedNow(t){const i=this.#e.queued.find(a=>a.id===t);!i||i.rootId!==this.#e.selected||(this.#t(a=>({queued:a.queued.filter(l=>l.id!==t)})),await this.sendPrompt(i.text))}#ze=!1;#Tt(){this.#ze||(this.#ze=!0,queueMicrotask(()=>{this.#ze=!1,this.#At()}))}#At(){const{selected:t,tree:i,connection:a,prompts:l,queued:u}=this.#e;if(!t||a.phase!=="open"||!i||i.rootId!==t||i.status!=="attached"||t in i.projection.running||l.some(h=>h.rootId===t)||!this.#We(t,i.projection)||this.driveBlock())return;const d=u.find(h=>h.rootId===t);d&&this.sendQueuedNow(d.id).catch(()=>{})}#O=new Map;#x=new Map;async interrupt(){const t=this.#e.selected;if(!t)return;const i=this.#x.get(t);if(i)return i.attempts=0,i.exhausted=!1,i.observer?.state==="stopped"&&this.#Ze(t,i),this.#A(t),i.promise;if(!this.hasCapability("session.interrupt.turn")){this.#u("error","This host cannot safely stop a specific turn. Upgrade the host to use Stop.");return}const a=this.#o.get(t)?.projection,l=a?.running[t],u=l?void 0:[...new Set([...this.#O.get(t)??[],...this.#e.prompts.filter(x=>x.rootId===t&&x.status!=="failed").map(x=>x.id)])].find(x=>{const y=a?.prompts[x];return!y||y.state==="failed"&&y.errorCode==="outcome_unknown"||y.state==="accepted"&&(!y.turnId||a?.turns[y.turnId]!=="ended")});if(!l&&!u)return;const d=this.#e.prompts.find(x=>x.id===u);if(d&&!d.submitted){this.discardPrompt(d.id),this.#u("info","Message canceled before sending.");return}let h=()=>{};const m=new Promise(x=>{h=()=>x(void 0)}),p={...l?{turnId:l}:{messageId:u},done:h,promise:m};return this.#x.set(t,p),this.#Ze(t,p),this.#t(x=>({busy:{...x.busy,interrupt:!0}})),l||this.#u("info",sy),this.#A(t),m}#Ze(t,i){const a=this.#i,l=this.#e.principal?.id,{open:u,backoff:d,stableMs:h,requestTimeoutMs:m}=this.#n,p=this.#e.connection.gateway,x=this.#m;let y=null,w=!1;i.observed??=this.#o.get(t)?.projection??bs(t);const k=()=>this.#i===a&&this.#x.get(t)===i,j=Cx({connect:async({signal:S})=>{const A=await u({url:p,token:x,signal:S});if(!k())throw A.transport.close(),new Ke("This Stop is no longer waiting.");if(A.principal.id!==l||!Te(A.principal,"session.read")||!Te(A.principal,"session.write"))throw A.transport.close(),new Ra("Stop access changed. Reconnect with the original access before trying again.");return A.transport},onConnect:async(S,{signal:A})=>{const R=await Ax(S,ny,{signal:A,timeoutMs:m}),q=Array.isArray(R.capabilities)?R.capabilities:[];if(!q.includes("session.interrupt.turn")||!q.includes("attach.after"))throw new Ke("This host cannot safely observe and stop a specific turn.");y=[];const O=await S.request("session.attach",{sessionId:t,after:i.observed?.cursor??0},{signal:A,timeoutMs:m});k()&&(i.observed=Ux(i.observed??bs(t),O,y),i.observed={...i.observed,cursor:Math.max(i.observed.cursor,O.cursor??0)},y=null,this.#A(t))},onDisconnect:()=>{y=null},shouldRetry:S=>!Be(S).terminal&&!Ud(S),backoff:d,stableMs:h,client:{timeoutMs:m}});i.observer=j,j.onEvent(S=>{if(!(!k()||S.sessionId!==t)){if(y){y.push(S);return}i.observed=zi(i.observed??bs(t),S),this.#A(t)}}),j.onState((S,A)=>{k()&&(S==="open"?(w&&(i.attempts=0,i.exhausted=!1),w=!0,this.#A(t)):S==="stopped"&&(this.#Se(t),i.exhausted=!0,this.#e.selected===t&&this.#t(R=>({busy:{...R.busy,interrupt:!1}})),this.#u("error",`Stop is unresolved: ${Be(A).message}`)))})}#Re(t){const i=this.#x.get(t);i&&(this.#x.delete(t),this.#Se(t),clearTimeout(i.retry),i.observer?.stop(),i.done(),this.#e.notice?.text===sy&&this.#t({notice:null}),this.#e.selected===t&&this.#t(a=>({busy:{...a.busy,interrupt:!1}})))}#_e(t,i){this.#O.get(t)?.delete(i),this.#x.get(t)?.messageId===i&&(this.#u("info","The agent did not take that message. There is no turn to stop."),this.#Re(t))}#A(t){const i=this.#x.get(t);if(!i)return;const a=this.#o.get(t)?.projection,l=[i.observed,a].filter(m=>!!m).sort((m,p)=>(p?.cursor??0)-(m?.cursor??0)),u=i.messageId?l.map(m=>m?.prompts[i.messageId]).find(Boolean):void 0;if(u?.state==="failed"&&u.errorCode!=="outcome_unknown"){this.#_e(t,i.messageId);return}if(!i.turnId&&u?.state==="accepted"&&u.turnId&&(i.turnId=u.turnId),i.turnId&&l.some(m=>m?.turns[i.turnId]==="ended")){this.#Re(t);return}const d=i.observer?.state==="open"?i.observer.client:void 0,h=d??(this.#e.connection.phase==="open"?this.#i?.alp?.client:void 0);if(!(!i.turnId||i.sending||i.exhausted||i.observer?.state==="stopped"||!h)){if(!d&&!this.hasCapability("session.interrupt.turn")){i.warned||(i.warned=!0,this.#u("error","Stop is still waiting: this host cannot safely stop a specific turn."));return}clearTimeout(i.retry),i.sending=!0,i.attempts=(i.attempts??0)+1,this.#e.selected===t&&this.#t(m=>({busy:{...m.busy,interrupt:!0}})),h.request("session.interrupt",{sessionId:t,turnId:i.turnId},{timeoutMs:this.#n.requestTimeoutMs}).then(m=>{this.#x.get(t)===i&&typeof m?.interrupted=="boolean"&&this.#Re(t)},m=>{this.#x.get(t)===i&&this.#u("error",`Stop is still waiting for this turn's outcome: ${Be(m).message}`)}).finally(()=>{i.sending=!1,this.#x.get(t)===i&&((i.attempts??0)<3?i.retry=setTimeout(()=>this.#A(t),250):(i.exhausted=!0,this.#e.selected===t&&this.#t(m=>({busy:{...m.busy,interrupt:!1}})),this.#u("error","Stop is unresolved. Try Stop again to check this same turn.")))})}}async answerQuestion(t,{text:i,dismiss:a=!1}){const l=`question:${t}`;this.#t(u=>({busy:{...u.busy,[l]:!0}}));try{await this.#r().request("question.answer",a?{questionId:t,dismiss:!0,reason:"Declined in ALP web"}:{questionId:t,text:String(i??"")});const u=this.#e.selected,d=u?this.#o.get(u):void 0;if(d&&u&&d.projection.questions[t]){const h={...d.projection.questions};delete h[t],d.projection={...d.projection,questions:h},this.#L(u)}this.refreshAttention()}catch(u){const d=Be(u);this.#u("error",d.code===1001?"That question is no longer waiting for an answer.":d.message)}finally{this.#t(u=>({busy:{...u.busy,[l]:!1}}))}}setTasksVisible(t){this.#Le=Math.max(0,this.#Le+(t?1:-1));const i=this.#Le>0;this.#e.tasks.visible!==i&&(this.#t(a=>({tasks:{...a.tasks,visible:i}})),i&&this.refreshTasks())}#Le=0;tasksBlock(){const{principal:t}=this.#e;if(!t)return"Not connected.";if(!this.hasCapability("task"))return"This host does not offer tasks.";if(!Te(t,"project.read"))return"Your access token cannot read this workspace's tasks."}async refreshTasks({quiet:t=!1}={}){const i=this.#e.workspace;if(!i||this.tasksBlock())return;const a=this.#l;t||this.#t(l=>({tasks:{...l.tasks,status:l.tasks.rows.length?l.tasks.status:"loading",error:void 0}}));try{const l=await this.#r().request("task.list",{projectRoot:i});if(a!==this.#l||t&&l?.revision&&l.revision===this.#e.tasks.revision)return;const u=Array.isArray(l?.tasks)?l.tasks:[];this.#t(d=>({tasks:{...d.tasks,status:"ready",rows:u,revision:l?.revision,unreadable:Array.isArray(l?.unreadable)?l.unreadable.length:0,error:void 0,creates:this.#Ct(d.tasks.creates,u)}}))}catch(l){if(a!==this.#l)return;(!t||this.#e.tasks.status!=="ready")&&this.#t(u=>({tasks:{...u.tasks,status:"error",error:Be(l)}}))}}#Ct(t,i){return t.map(a=>{if(a.status!=="unknown")return a;const l=i.find(u=>u.title===a.title&&u.status!=="closed");return l?{...a,match:l.id}:{...a,match:void 0}})}async createTask({title:t,priority:i=2}){const a=this.#e.workspace,l=String(t??"").trim();if(!a||!l)return;const u={requestId:K2(),title:l,priority:i,status:"creating"};this.#t(d=>({tasks:{...d.tasks,creates:[...d.tasks.creates,u],message:void 0}})),await this.#Je(u)}async#Je(t){const i=this.#e.workspace,a=this.#l,l=u=>this.#t(d=>({tasks:{...d.tasks,creates:u?d.tasks.creates.map(h=>h.requestId===t.requestId?{...h,...u}:h):d.tasks.creates.filter(h=>h.requestId!==t.requestId)}}));try{const u=await this.#r().request("task.create",{projectRoot:i,title:t.title,priority:t.priority,requestId:t.requestId});if(a!==this.#l)return;l(null),this.#t(d=>({tasks:{...d.tasks,message:{level:"info",text:u?.duplicate?`Task ${u.id} already existed for this request.`:`Created task ${u?.id??""}.`}}})),await this.refreshTasks({quiet:!1})}catch(u){if(a!==this.#l)return;const d=Be(u);d.sent==="unknown"||d.code===1e3?(l({status:"unknown",error:`${d.message} The list was read again: check it before creating this task again.`}),await this.refreshTasks()):l({status:"failed",error:d.message})}}async retryTaskCreate(t){const i=this.#e.tasks.creates.find(l=>l.requestId===t);if(!i||i.status==="creating")return;const a={...i,status:"creating",error:void 0,match:void 0};this.#t(l=>({tasks:{...l.tasks,creates:l.tasks.creates.map(u=>u.requestId===t?a:u)}})),await this.#Je(a)}dismissTaskCreate(t){this.#t(i=>({tasks:{...i.tasks,creates:i.tasks.creates.filter(a=>a.requestId!==t)}}))}async changeTask(t,i){const a=this.#e.workspace;if(!a||!t?.id)return;const l=this.#l;this.#t(u=>({tasks:{...u.tasks,busy:{...u.tasks.busy,[t.id]:!0},message:void 0}}));try{const u=this.#r();"gate"in i?await u.request("task.gate.resolve",{projectRoot:a,id:t.id,gate:i.gate,channel:"web",...i.choice?{choice:i.choice}:{},...i.reject?{reject:!0}:{},ifRev:t.rev}):await u.request("task.update",{projectRoot:a,id:t.id,action:i.action,...i.action==="close"?{note:"Closed in ALP web"}:{},ifRev:t.rev})}catch(u){if(l!==this.#l)return;const d=Be(u);this.#t(h=>({tasks:{...h.tasks,message:{level:"error",text:d.sent==="unknown"?`${d.message} The list was read again.`:d.message}}}))}finally{l===this.#l&&(this.#t(u=>({tasks:{...u.tasks,busy:{...u.tasks.busy,[t.id]:!1}}})),await this.refreshTasks())}}setSendBehavior(t){this.#ie({sendBehavior:t})}setTheme(t){this.#ie({theme:t})}updatePreferences(t){this.#ie(t)}#ie(t){const i=Oi(JSON.stringify({...this.#e.preferences,...t,v:1}));this.#t({preferences:i}),sS(this.#n.storage,i)}#Et(t){this.#ie({newSession:iS(this.#e.preferences.newSession,t)})}resetPreferences(){this.#ie(Oi(null))}reloadPreferences(){const t=Wx(this.#n.storage);JSON.stringify(t)!==JSON.stringify(this.#e.preferences)&&this.#t({preferences:t})}previewBlock(){const{principal:t,workspace:i}=this.#e;if(!t)return"Not connected.";if(!Te(t,"session.read"))return"Your access token cannot read sessions, so the host cannot say what would run.";if(!i)return"Choose a workspace first."}async previewSession(t,{signal:i}={}){const a=this.previewBlock();if(a)throw new Ke(a);const l=await this.#r().request("session.preview",{spec:{...t,cwd:this.#e.workspace}},{timeoutMs:this.#n.requestTimeoutMs,...i?{signal:i}:{}}),u=Lj(l);if(!u)throw new Ke("The host answered the preview in a form this app does not read.");return u}libraryBlock(){const{principal:t,workspace:i}=this.#e;if(!t)return"Not connected.";if(!this.hasCapability("library"))return"This host does not offer its library.";if(!Te(t,"project.read"))return"Your access token cannot read this workspace's configuration.";if(!i)return"Choose a workspace first."}async listLibrary(t){const i=this.libraryBlock();if(i)throw new Ke(i);const a=await this.#r().request("library.list",{kind:t,projectRoot:this.#e.workspace},{timeoutMs:this.#n.requestTimeoutMs});return(Array.isArray(a?.entries)?a.entries:[]).filter(l=>l&&typeof l.name=="string")}async getLibraryEntry(t,i){const a=this.libraryBlock();if(a)throw new Ke(a);const l=await this.#r().request("library.get",{kind:t,name:i,projectRoot:this.#e.workspace},{timeoutMs:this.#n.requestTimeoutMs});if(!l||typeof l!="object"||!l.content||typeof l.content!="object"||Array.isArray(l.content))throw new Ke("The host answered library.get in a form this app does not read.");const u=d=>Array.isArray(d)?d.filter(h=>typeof h=="string"):[];return{kind:typeof l.kind=="string"?l.kind:t,name:typeof l.name=="string"?l.name:i,source:typeof l.source=="string"?l.source:"unknown",...typeof l.overrides=="string"?{overrides:l.overrides}:{},content:l.content,...typeof l.revision=="string"||l.revision===null?{revision:l.revision}:{},usedBy:u(l.usedBy),...Array.isArray(l.librarySkills)?{librarySkills:u(l.librarySkills)}:{},secrets:u(l.secrets)}}libraryWriteBlock(t){const i=this.libraryBlock();return i||(Te(this.#e.principal??void 0,"library.write")?this.hasCapability("library.project.write")?["agents","skills"].includes(t)?null:"Executable and administrative configuration is edited on the host.":"Update the host to support safe project instruction editing.":"This token does not grant library.write.")}async writeLibrary(t,i,a){const l=this.libraryWriteBlock(i);if(l)throw new Ke(l);return this.#r().request(`library.${t}`,{...a,kind:i,scope:"project",projectRoot:this.#e.workspace},{timeoutMs:this.#n.requestTimeoutMs})}#et(){this.#e.catalog.status==="ready"&&this.#Te(),this.#e.settings.status==="ready"&&this.loadSettings()}async refreshModels(){!this.#e.principal||!Te(this.#e.principal,"session.read")||!this.hasCapability("catalog.live")||(await this.#r().request("catalog.refresh",{},{timeoutMs:Math.max(this.#n.requestTimeoutMs??0,6e4)}),this.#et())}async loadSettings(){const t=this.#e.principal;if(!t)return;const i=this.#l;this.#t(a=>({settings:{...a.settings,status:"loading",error:void 0}}));try{const a=this.#r(),[l,u]=await Promise.all([this.hasCapability("settings.language")&&Te(t,"session.read")?a.request("settings.language.get",{}).catch(()=>{}):void 0,this.hasCapability("library")&&Te(t,"session.read")?a.request("library.models",{}).catch(()=>{}):void 0]);if(i!==this.#l)return;this.#t({settings:{status:"ready",...l&&typeof l.applies=="string"?{language:l}:{},models:Gx(u?.models)}})}catch(a){if(i!==this.#l)return;this.#t(l=>({settings:{...l.settings,status:"error",error:Be(a)}}))}}}const gS=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Zb=(...s)=>s.filter((t,i,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===i).join(" ").trim();var xS={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const yS=b.forwardRef(({color:s="currentColor",size:t=24,strokeWidth:i=2,absoluteStrokeWidth:a,className:l="",children:u,iconNode:d,...h},m)=>b.createElement("svg",{ref:m,...xS,width:t,height:t,stroke:s,strokeWidth:a?Number(i)*24/Number(t):i,className:Zb("lucide",l),...h},[...d.map(([p,x])=>b.createElement(p,x)),...Array.isArray(u)?u:[u]]));const ie=(s,t)=>{const i=b.forwardRef(({className:a,...l},u)=>b.createElement(yS,{ref:u,iconNode:t,className:Zb(`lucide-${gS(s)}`,a),...l}));return i.displayName=`${s}`,i};const ac=ie("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const bS=ie("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);const vS=ie("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);const wS=ie("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);const Jb=ie("ArrowLeftToLine",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]);const th=ie("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const e0=ie("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);const Dl=ie("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);const rc=ie("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);const kS=ie("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);const jS=ie("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const Oa=ie("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const SS=ie("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);const Pr=ie("Brain",[["path",{d:"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 18Z",key:"l5xja"}],["path",{d:"M12 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 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);const NS=ie("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);const oc=ie("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Qn=ie("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const nh=ie("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const Jn=ie("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const si=ie("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const lc=ie("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const t0=ie("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);const n0=ie("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);const TS=ie("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);const AS=ie("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const s0=ie("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);const CS=ie("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const ES=ie("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const MS=ie("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const i0=ie("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);const zS=ie("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const a0=ie("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const ws=ie("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const jf=ie("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);const RS=ie("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);const _S=ie("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const sh=ie("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);const LS=ie("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const lo=ie("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const OS=ie("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);const Sf=ie("FileDiff",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);const ih=ie("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const r0=ie("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);const ah=ie("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);const DS=ie("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 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.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]);const ly=ie("FolderGit2",[["path",{d:"M9 20H4a2 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.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);const qS=ie("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 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",key:"usdka0"}]]);const cy=ie("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const Da=ie("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const BS=ie("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);const Qs=ie("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const $S=ie("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);const o0=ie("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);const l0=ie("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);const cc=ie("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const US=ie("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const rh=ie("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);const HS=ie("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const IS=ie("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);const oh=ie("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const Bi=ie("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const GS=ie("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);const YS=ie("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);const uc=ie("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const qa=ie("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const VS=ie("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);const KS=ie("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);const uy=ie("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);const FS=ie("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const XS=ie("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);const PS=ie("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);const c0=ie("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);const QS=ie("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);const WS=ie("PanelBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]);const $a=ie("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);const lh=ie("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const ZS=ie("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);const Ui=ie("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const JS=ie("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);const u0=ie("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 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.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);const eN=ie("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);const tN=ie("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);const ks=ie("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const co=ie("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const uo=ie("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const nN=ie("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);const d0=ie("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);const sN=ie("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);const ti=ie("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const Qr=ie("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const iN=ie("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);const ch=ie("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const f0=ie("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const dc=ie("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const aN=ie("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const rN=ie("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);const oN=ie("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const lN=ie("Space",[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);const cN=ie("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);const fc=ie("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);const hc=ie("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);const uN=ie("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const dN=ie("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);const h0=ie("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const uh=ie("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const fN=ie("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const m0=ie("TriangleAlert",[["path",{d:"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-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const hN=ie("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);const p0=ie("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const Yl=ie("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const mN=ie("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);const pN=ie("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const g0=ie("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);const en=ie("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var gN=Object.defineProperty,dh=(s,t)=>gN(s,"name",{value:t,configurable:!0});function Nf(s,t){if(typeof s=="function")return s(t);s!=null&&(s.current=t)}dh(Nf,"setRef");function x0(...s){return t=>{let i=!1;const a=s.map(l=>{const u=Nf(l,t);return!i&&typeof u=="function"&&(i=!0),u});if(i)return()=>{for(let l=0;l<a.length;l++){const u=a[l];typeof u=="function"?u():Nf(s[l],null)}}}}dh(x0,"composeRefs");function y0(...s){return b.useCallback(x0(...s),s)}dh(y0,"useComposedRefs");var xN=Object.defineProperty,wn=(s,t)=>xN(s,"name",{value:t,configurable:!0});function b0(s){const t=b.forwardRef((i,a)=>{let{children:l,...u}=i,d=null,h=!1;const m=[];l=N0(l),b.Children.forEach(l,w=>{if(j0(w)){h=!0;const k=w;let j="child"in k.props?k.props.child:k.props.children;for(;fh(j)&&typeof Vl=="function";)j=Vl(j._payload);d=vN(k,j),m.push(d?.props?.children)}else m.push(w)}),d?d=b.cloneElement(d,void 0,m):!h&&b.Children.count(l)===1&&b.isValidElement(l)&&(d=l);const p=d?k0(d):void 0,x=y0(a,p);if(!d){if(l||l===0)throw new Error(h?jN(s):kN(s));return l}const y=w0(u,d.props??{});return d.type!==b.Fragment&&(y.ref=a?x:p),b.cloneElement(d,y)});return t.displayName=`${s}.Slot`,t}wn(b0,"createSlot");var yN=b0("Slot"),v0=Symbol.for("radix.slottable");function bN(s){const t=wn(i=>"child"in i?i.children(i.child):i.children,"Slottable");return t.displayName=`${s}.Slottable`,t.__radixId=v0,t}wn(bN,"createSlottable");var vN=wn((s,t)=>"child"in s.props?b.isValidElement(t)?b.cloneElement(t,void 0,s.props.children(t.props.children)):null:b.isValidElement(t)?t:null,"getSlottableElementFromSlottable");function w0(s,t){const i={...t};for(const a in t){const l=s[a],u=t[a];/^on[A-Z]/.test(a)?l&&u?i[a]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(i[a]=l):a==="style"?i[a]={...l,...u}:a==="className"?i[a]=[l,u].filter(Boolean).join(" "):a==="aria-describedby"&&(i[a]=T0(u,l))}return{...s,...i}}wn(w0,"mergeProps");function k0(s){let t=Object.getOwnPropertyDescriptor(s.props,"ref")?.get,i=t&&"isReactWarning"in t&&t.isReactWarning;return i?s.ref:(t=Object.getOwnPropertyDescriptor(s,"ref")?.get,i=t&&"isReactWarning"in t&&t.isReactWarning,i?s.props.ref:s.props.ref||s.ref)}wn(k0,"getElementRef");function j0(s){return b.isValidElement(s)&&typeof s.type=="function"&&"__radixId"in s.type&&s.type.__radixId===v0}wn(j0,"isSlottable");var wN=Symbol.for("react.lazy");function fh(s){return s!=null&&typeof s=="object"&&"$$typeof"in s&&s.$$typeof===wN&&"_payload"in s&&S0(s._payload)}wn(fh,"isLazyComponent");function S0(s){return typeof s=="object"&&s!==null&&"then"in s}wn(S0,"isPromiseLike");function N0(s){let t=s;for(;fh(t)&&typeof Vl=="function";)t=Vl(t._payload);return t}wn(N0,"useUnwrappedLazy");function T0(...s){const t=new Set;for(const i of s)if(typeof i=="string")for(const a of String(i).trim().split(/\s+/))a&&t.add(a);return t.size>0?Array.from(t).join(" "):void 0}wn(T0,"concatAriaDescribedby");var kN=wn(s=>`${s} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),jN=wn(s=>`${s} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Vl=Uk[" use ".trim().toString()];function A0(s){var t,i,a="";if(typeof s=="string"||typeof s=="number")a+=s;else if(typeof s=="object")if(Array.isArray(s)){var l=s.length;for(t=0;t<l;t++)s[t]&&(i=A0(s[t]))&&(a&&(a+=" "),a+=i)}else for(i in s)s[i]&&(a&&(a+=" "),a+=i);return a}function C0(){for(var s,t,i=0,a="",l=arguments.length;i<l;i++)(s=arguments[i])&&(t=A0(s))&&(a&&(a+=" "),a+=t);return a}const dy=s=>typeof s=="boolean"?`${s}`:s===0?"0":s,fy=C0,SN=(s,t)=>i=>{var a;if(t?.variants==null)return fy(s,i?.class,i?.className);const{variants:l,defaultVariants:u}=t,d=Object.keys(l).map(p=>{const x=i?.[p],y=u?.[p];if(x===null)return null;const w=dy(x)||dy(y);return l[p][w]}),h=i&&Object.entries(i).reduce((p,x)=>{let[y,w]=x;return w===void 0||(p[y]=w),p},{}),m=t==null||(a=t.compoundVariants)===null||a===void 0?void 0:a.reduce((p,x)=>{let{class:y,className:w,...k}=x;return Object.entries(k).every(j=>{let[S,A]=j;return Array.isArray(A)?A.includes({...u,...h}[S]):{...u,...h}[S]===A})?[...p,y,w]:p},[]);return fy(s,d,m,i?.class,i?.className)},NN=(s,t)=>{const i=new Array(s.length+t.length);for(let a=0;a<s.length;a++)i[a]=s[a];for(let a=0;a<t.length;a++)i[s.length+a]=t[a];return i},TN=(s,t)=>({classGroupId:s,validator:t}),E0=(s=new Map,t=null,i)=>({nextPart:s,validators:t,classGroupId:i}),Kl="-",hy=[],AN="arbitrary..",CN=s=>{const t=MN(s),{conflictingClassGroups:i,conflictingClassGroupModifiers:a}=s;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return EN(d);const h=d.split(Kl),m=h[0]===""&&h.length>1?1:0;return M0(h,m,t)},getConflictingClassGroupIds:(d,h)=>{if(h){const m=a[d],p=i[d];return m?p?NN(p,m):m:p||hy}return i[d]||hy}}},M0=(s,t,i)=>{if(s.length-t===0)return i.classGroupId;const l=s[t],u=i.nextPart.get(l);if(u){const p=M0(s,t+1,u);if(p)return p}const d=i.validators;if(d===null)return;const h=t===0?s.join(Kl):s.slice(t).join(Kl),m=d.length;for(let p=0;p<m;p++){const x=d[p];if(x.validator(h))return x.classGroupId}},EN=s=>s.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=s.slice(1,-1),i=t.indexOf(":"),a=t.slice(0,i);return a?AN+a:void 0})(),MN=s=>{const{theme:t,classGroups:i}=s;return zN(i,t)},zN=(s,t)=>{const i=E0();for(const a in s){const l=s[a];hh(l,i,a,t)}return i},hh=(s,t,i,a)=>{const l=s.length;for(let u=0;u<l;u++){const d=s[u];RN(d,t,i,a)}},RN=(s,t,i,a)=>{if(typeof s=="string"){_N(s,t,i);return}if(typeof s=="function"){LN(s,t,i,a);return}ON(s,t,i,a)},_N=(s,t,i)=>{const a=s===""?t:z0(t,s);a.classGroupId=i},LN=(s,t,i,a)=>{if(DN(s)){hh(s(a),t,i,a);return}t.validators===null&&(t.validators=[]),t.validators.push(TN(i,s))},ON=(s,t,i,a)=>{const l=Object.entries(s),u=l.length;for(let d=0;d<u;d++){const[h,m]=l[d];hh(m,z0(t,h),i,a)}},z0=(s,t)=>{let i=s;const a=t.split(Kl),l=a.length;for(let u=0;u<l;u++){const d=a[u];let h=i.nextPart.get(d);h||(h=E0(),i.nextPart.set(d,h)),i=h}return i},DN=s=>"isThemeGetter"in s&&s.isThemeGetter===!0,qN=s=>{if(s<1)return{get:()=>{},set:()=>{}};let t=0,i=Object.create(null),a=Object.create(null);const l=(u,d)=>{i[u]=d,t++,t>s&&(t=0,a=i,i=Object.create(null))};return{get(u){let d=i[u];if(d!==void 0)return d;if((d=a[u])!==void 0)return l(u,d),d},set(u,d){u in i?i[u]=d:l(u,d)}}},Tf="!",my=":",BN=[],py=(s,t,i,a,l)=>({modifiers:s,hasImportantModifier:t,baseClassName:i,maybePostfixModifierPosition:a,isExternal:l}),$N=s=>{const{prefix:t,experimentalParseClassName:i}=s;let a=l=>{const u=[];let d=0,h=0,m=0,p;const x=l.length;for(let S=0;S<x;S++){const A=l[S];if(d===0&&h===0){if(A===my){u.push(l.slice(m,S)),m=S+1;continue}if(A==="/"){p=S;continue}}A==="["?d++:A==="]"?d--:A==="("?h++:A===")"&&h--}const y=u.length===0?l:l.slice(m);let w=y,k=!1;y.endsWith(Tf)?(w=y.slice(0,-1),k=!0):y.startsWith(Tf)&&(w=y.slice(1),k=!0);const j=p&&p>m?p-m:void 0;return py(u,k,w,j)};if(t){const l=t+my,u=a;a=d=>d.startsWith(l)?u(d.slice(l.length)):py(BN,!1,d,void 0,!0)}if(i){const l=a;a=u=>i({className:u,parseClassName:l})}return a},UN=s=>{const t=new Map;return s.orderSensitiveModifiers.forEach((i,a)=>{t.set(i,1e6+a)}),i=>{const a=[];let l=[];for(let u=0;u<i.length;u++){const d=i[u],h=d[0]==="[",m=t.has(d);h||m?(l.length>0&&(l.sort(),a.push(...l),l=[]),a.push(d)):l.push(d)}return l.length>0&&(l.sort(),a.push(...l)),a}},HN=s=>({cache:qN(s.cacheSize),parseClassName:$N(s),sortModifiers:UN(s),postfixLookupClassGroupIds:IN(s),...CN(s)}),IN=s=>{const t=Object.create(null),i=s.postfixLookupClassGroups;if(i)for(let a=0;a<i.length;a++)t[i[a]]=!0;return t},GN=/\s+/,YN=(s,t)=>{const{parseClassName:i,getClassGroupId:a,getConflictingClassGroupIds:l,sortModifiers:u,postfixLookupClassGroupIds:d}=t,h=[],m=s.trim().split(GN);let p="";for(let x=m.length-1;x>=0;x-=1){const y=m[x],{isExternal:w,modifiers:k,hasImportantModifier:j,baseClassName:S,maybePostfixModifierPosition:A}=i(y);if(w){p=y+(p.length>0?" "+p:p);continue}let R=!!A,q;if(R){const Q=S.substring(0,A);q=a(Q);const C=q&&d[q]?a(S):void 0;C&&C!==q&&(q=C,R=!1)}else q=a(S);if(!q){if(!R){p=y+(p.length>0?" "+p:p);continue}if(q=a(S),!q){p=y+(p.length>0?" "+p:p);continue}R=!1}const O=k.length===0?"":k.length===1?k[0]:u(k).join(":"),L=j?O+Tf:O,B=L+q;if(h.indexOf(B)>-1)continue;h.push(B);const _=l(q,R);for(let Q=0;Q<_.length;++Q){const C=_[Q];h.push(L+C)}p=y+(p.length>0?" "+p:p)}return p},VN=(...s)=>{let t=0,i,a,l="";for(;t<s.length;)(i=s[t++])&&(a=R0(i))&&(l&&(l+=" "),l+=a);return l},R0=s=>{if(typeof s=="string")return s;let t,i="";for(let a=0;a<s.length;a++)s[a]&&(t=R0(s[a]))&&(i&&(i+=" "),i+=t);return i},KN=(s,...t)=>{let i,a,l,u;const d=m=>{const p=t.reduce((x,y)=>y(x),s());return i=HN(p),a=i.cache.get,l=i.cache.set,u=h,h(m)},h=m=>{const p=a(m);if(p)return p;const x=YN(m,i);return l(m,x),x};return u=d,(...m)=>u(VN(...m))},FN=[],Ot=s=>{const t=i=>i[s]||FN;return t.isThemeGetter=!0,t.themeKey=s,t},_0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,L0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,XN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,PN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,QN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,WN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,ZN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,JN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ks=s=>XN.test(s),Ye=s=>!!s&&!Number.isNaN(Number(s)),Pn=s=>!!s&&Number.isInteger(Number(s)),Qd=s=>s.endsWith("%")&&Ye(s.slice(0,-1)),ps=s=>PN.test(s),O0=()=>!0,e3=s=>QN.test(s)&&!WN.test(s),mh=()=>!1,t3=s=>ZN.test(s),n3=s=>JN.test(s),s3=s=>!ke(s)&&!je(s),i3=s=>s.startsWith("@container")&&(s[10]==="/"&&s[11]!==void 0||s[11]==="s"&&s[16]!==void 0&&s.startsWith("-size/",10)||s[11]==="n"&&s[18]!==void 0&&s.startsWith("-normal/",10)),a3=s=>ii(s,B0,mh),ke=s=>_0.test(s),Si=s=>ii(s,$0,e3),gy=s=>ii(s,h3,Ye),r3=s=>ii(s,H0,O0),o3=s=>ii(s,U0,mh),xy=s=>ii(s,D0,mh),l3=s=>ii(s,q0,n3),Cl=s=>ii(s,I0,t3),je=s=>L0.test(s),Ur=s=>Hi(s,$0),c3=s=>Hi(s,U0),yy=s=>Hi(s,D0),u3=s=>Hi(s,B0),d3=s=>Hi(s,q0),El=s=>Hi(s,I0,!0),f3=s=>Hi(s,H0,!0),ii=(s,t,i)=>{const a=_0.exec(s);return a?a[1]?t(a[1]):i(a[2]):!1},Hi=(s,t,i=!1)=>{const a=L0.exec(s);return a?a[1]?t(a[1]):i:!1},D0=s=>s==="position"||s==="percentage",q0=s=>s==="image"||s==="url",B0=s=>s==="length"||s==="size"||s==="bg-size",$0=s=>s==="length",h3=s=>s==="number",U0=s=>s==="family-name",H0=s=>s==="number"||s==="weight",I0=s=>s==="shadow",m3=()=>{const s=Ot("color"),t=Ot("font"),i=Ot("text"),a=Ot("font-weight"),l=Ot("tracking"),u=Ot("leading"),d=Ot("breakpoint"),h=Ot("container"),m=Ot("spacing"),p=Ot("radius"),x=Ot("shadow"),y=Ot("inset-shadow"),w=Ot("text-shadow"),k=Ot("drop-shadow"),j=Ot("blur"),S=Ot("perspective"),A=Ot("aspect"),R=Ot("ease"),q=Ot("animate"),O=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],B=()=>[...L(),je,ke],_=()=>["auto","hidden","clip","visible","scroll"],Q=()=>["auto","contain","none"],C=()=>[je,ke,m],Y=()=>[Ks,"full","auto",...C()],H=()=>[Pn,"none","subgrid",je,ke],fe=()=>["auto",{span:["full",Pn,je,ke]},Pn,je,ke],ee=()=>[Pn,"auto",je,ke],xe=()=>["auto","min","max","fr",je,ke],re=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],de=()=>["start","end","center","stretch","center-safe","end-safe"],U=()=>["auto",...C()],Z=()=>[Ks,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],oe=()=>[h,Ks,"screen","full","dvw","lvw","svw","min","max","fit",...C()],ge=()=>[Ks,"screen","full","lh","dvh","lvh","svh","min","max","fit",...C()],T=()=>[s,je,ke],z=()=>[...L(),yy,xy,{position:[je,ke]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],J=()=>["auto","cover","contain",u3,a3,{size:[je,ke]}],le=()=>[Qd,Ur,Si],ne=()=>["","none","full",p,je,ke],ce=()=>["",Ye,Ur,Si],ve=()=>["solid","dashed","dotted","double"],Re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Me=()=>[Ye,Qd,yy,xy],Qe=()=>["","none",j,je,ke],Ue=()=>["none",Ye,je,ke],et=()=>["none",Ye,je,ke],Fe=()=>[Ye,je,ke],be=()=>[Ks,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ps],breakpoint:[ps],color:[O0],container:[ps],"drop-shadow":[ps],ease:["in","out","in-out"],font:[s3],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ps],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ps],shadow:[ps],spacing:["px",Ye],text:[ps],"text-shadow":[ps],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ks,ke,je,A]}],container:["container"],"container-type":[{"@container":["","normal","size",je,ke]}],"container-named":[i3],columns:[{columns:[Ye,"auto",ke,je,h]}],"break-after":[{"break-after":O()}],"break-before":[{"break-before":O()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:B()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:Q()}],"overscroll-x":[{"overscroll-x":Q()}],"overscroll-y":[{"overscroll-y":Q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Y()}],"inset-x":[{"inset-x":Y()}],"inset-y":[{"inset-y":Y()}],start:[{"inset-s":Y(),start:Y()}],end:[{"inset-e":Y(),end:Y()}],"inset-bs":[{"inset-bs":Y()}],"inset-be":[{"inset-be":Y()}],top:[{top:Y()}],right:[{right:Y()}],bottom:[{bottom:Y()}],left:[{left:Y()}],visibility:["visible","invisible","collapse"],z:[{z:[Pn,"auto",je,ke]}],basis:[{basis:[Ks,"full","auto",h,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ye,Ks,"auto","initial","none",ke]}],grow:[{grow:["",Ye,je,ke]}],shrink:[{shrink:["",Ye,je,ke]}],order:[{order:[Pn,"first","last","none",je,ke]}],"grid-cols":[{"grid-cols":H()}],"col-start-end":[{col:fe()}],"col-start":[{"col-start":ee()}],"col-end":[{"col-end":ee()}],"grid-rows":[{"grid-rows":H()}],"row-start-end":[{row:fe()}],"row-start":[{"row-start":ee()}],"row-end":[{"row-end":ee()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":xe()}],"auto-rows":[{"auto-rows":xe()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...re(),"normal"]}],"justify-items":[{"justify-items":[...de(),"normal"]}],"justify-self":[{"justify-self":["auto",...de()]}],"align-content":[{content:["normal",...re()]}],"align-items":[{items:[...de(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...de(),{baseline:["","last"]}]}],"place-content":[{"place-content":re()}],"place-items":[{"place-items":[...de(),"baseline"]}],"place-self":[{"place-self":["auto",...de()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:U()}],mx:[{mx:U()}],my:[{my:U()}],ms:[{ms:U()}],me:[{me:U()}],mbs:[{mbs:U()}],mbe:[{mbe:U()}],mt:[{mt:U()}],mr:[{mr:U()}],mb:[{mb:U()}],ml:[{ml:U()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],"inline-size":[{inline:["auto",...oe()]}],"min-inline-size":[{"min-inline":["auto",...oe()]}],"max-inline-size":[{"max-inline":["none",...oe()]}],"block-size":[{block:["auto",...ge()]}],"min-block-size":[{"min-block":["auto",...ge()]}],"max-block-size":[{"max-block":["none",...ge()]}],w:[{w:[h,"screen",...Z()]}],"min-w":[{"min-w":[h,"screen","none",...Z()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[d]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh","none",...Z()]}],"font-size":[{text:["base",i,Ur,Si]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,f3,r3]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Qd,ke]}],"font-family":[{font:[c3,o3,t]}],"font-features":[{"font-features":[ke]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[l,je,ke]}],"line-clamp":[{"line-clamp":[Ye,"none",je,gy]}],leading:[{leading:["none",u,...C()]}],"list-image":[{"list-image":["none",je,ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",je,ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ve(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ye,"from-font","auto",je,Si]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[Ye,"auto",je,ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"tab-size":[{tab:[Pn,je,ke]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",je,ke]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",je,ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:z()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:J()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Pn,je,ke],radial:["",je,ke],conic:["",Pn,je,ke]},d3,l3]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:ne()}],"rounded-s":[{"rounded-s":ne()}],"rounded-e":[{"rounded-e":ne()}],"rounded-t":[{"rounded-t":ne()}],"rounded-r":[{"rounded-r":ne()}],"rounded-b":[{"rounded-b":ne()}],"rounded-l":[{"rounded-l":ne()}],"rounded-ss":[{"rounded-ss":ne()}],"rounded-se":[{"rounded-se":ne()}],"rounded-ee":[{"rounded-ee":ne()}],"rounded-es":[{"rounded-es":ne()}],"rounded-tl":[{"rounded-tl":ne()}],"rounded-tr":[{"rounded-tr":ne()}],"rounded-br":[{"rounded-br":ne()}],"rounded-bl":[{"rounded-bl":ne()}],"border-w":[{border:ce()}],"border-w-x":[{"border-x":ce()}],"border-w-y":[{"border-y":ce()}],"border-w-s":[{"border-s":ce()}],"border-w-e":[{"border-e":ce()}],"border-w-bs":[{"border-bs":ce()}],"border-w-be":[{"border-be":ce()}],"border-w-t":[{"border-t":ce()}],"border-w-r":[{"border-r":ce()}],"border-w-b":[{"border-b":ce()}],"border-w-l":[{"border-l":ce()}],"divide-x":[{"divide-x":ce()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ce()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ve(),"hidden","none"]}],"divide-style":[{divide:[...ve(),"hidden","none"]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-bs":[{"border-bs":T()}],"border-color-be":[{"border-be":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:[...ve(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ye,je,ke]}],"outline-w":[{outline:["",Ye,Ur,Si]}],"outline-color":[{outline:T()}],shadow:[{shadow:["","inner","none",x,El,Cl]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":["none",y,El,Cl]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:ce()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[Ye,Si]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":ce()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":["none",w,El,Cl]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[Ye,je,ke]}],"mix-blend":[{"mix-blend":[...Re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ye]}],"mask-image-linear-from-pos":[{"mask-linear-from":Me()}],"mask-image-linear-to-pos":[{"mask-linear-to":Me()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":Me()}],"mask-image-t-to-pos":[{"mask-t-to":Me()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":Me()}],"mask-image-r-to-pos":[{"mask-r-to":Me()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":Me()}],"mask-image-b-to-pos":[{"mask-b-to":Me()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":Me()}],"mask-image-l-to-pos":[{"mask-l-to":Me()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":Me()}],"mask-image-x-to-pos":[{"mask-x-to":Me()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":Me()}],"mask-image-y-to-pos":[{"mask-y-to":Me()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[je,ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":Me()}],"mask-image-radial-to-pos":[{"mask-radial-to":Me()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":L()}],"mask-image-conic-pos":[{"mask-conic":[Ye]}],"mask-image-conic-from-pos":[{"mask-conic-from":Me()}],"mask-image-conic-to-pos":[{"mask-conic-to":Me()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:z()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:J()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",je,ke]}],filter:[{filter:["","none",je,ke]}],blur:[{blur:Qe()}],brightness:[{brightness:[Ye,je,ke]}],contrast:[{contrast:[Ye,je,ke]}],"drop-shadow":[{"drop-shadow":["","none",k,El,Cl]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:["",Ye,je,ke]}],"hue-rotate":[{"hue-rotate":[Ye,je,ke]}],invert:[{invert:["",Ye,je,ke]}],saturate:[{saturate:[Ye,je,ke]}],sepia:[{sepia:["",Ye,je,ke]}],"backdrop-filter":[{"backdrop-filter":["","none",je,ke]}],"backdrop-blur":[{"backdrop-blur":Qe()}],"backdrop-brightness":[{"backdrop-brightness":[Ye,je,ke]}],"backdrop-contrast":[{"backdrop-contrast":[Ye,je,ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ye,je,ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ye,je,ke]}],"backdrop-invert":[{"backdrop-invert":["",Ye,je,ke]}],"backdrop-opacity":[{"backdrop-opacity":[Ye,je,ke]}],"backdrop-saturate":[{"backdrop-saturate":[Ye,je,ke]}],"backdrop-sepia":[{"backdrop-sepia":["",Ye,je,ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",je,ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ye,"initial",je,ke]}],ease:[{ease:["linear","initial",R,je,ke]}],delay:[{delay:[Ye,je,ke]}],animate:[{animate:["none",q,je,ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[S,je,ke]}],"perspective-origin":[{"perspective-origin":B()}],rotate:[{rotate:Ue()}],"rotate-x":[{"rotate-x":Ue()}],"rotate-y":[{"rotate-y":Ue()}],"rotate-z":[{"rotate-z":Ue()}],scale:[{scale:et()}],"scale-x":[{"scale-x":et()}],"scale-y":[{"scale-y":et()}],"scale-z":[{"scale-z":et()}],"scale-3d":["scale-3d"],skew:[{skew:Fe()}],"skew-x":[{"skew-x":Fe()}],"skew-y":[{"skew-y":Fe()}],transform:[{transform:[je,ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:B()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:be()}],"translate-x":[{"translate-x":be()}],"translate-y":[{"translate-y":be()}],"translate-z":[{"translate-z":be()}],"translate-none":["translate-none"],zoom:[{zoom:[Pn,je,ke]}],accent:[{accent:T()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",je,ke]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":T()}],"scrollbar-track-color":[{"scrollbar-track":T()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",je,ke]}],fill:[{fill:["none",...T()]}],"stroke-w":[{stroke:[Ye,Ur,Si,gy]}],stroke:[{stroke:["none",...T()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},p3=KN(m3);function I(...s){return p3(C0(s))}const g3=SN("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-45 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground border border-border hover:bg-accent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",ghost:"hover:bg-accent hover:text-accent-foreground",destructive:"bg-destructive/15 text-destructive border border-destructive/40 hover:bg-destructive/25",link:"text-highlight underline-offset-4 hover:underline"},size:{default:"h-9 px-4",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 px-5",icon:"size-9","icon-sm":"size-7 rounded-md"}},defaultVariants:{variant:"default",size:"default"}});function we({className:s,variant:t,size:i,asChild:a=!1,type:l,...u}){const d=a?yN:"button";return o.jsx(d,{"data-slot":"button",type:a?void 0:l??"button",className:I(g3({variant:t,size:i}),s),...u})}const G0="w-full min-w-0 rounded-md border border-input bg-background/60 px-3 text-sm text-foreground placeholder:text-muted-foreground/80 outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive";function Zn({className:s,type:t="text",...i}){return o.jsx("input",{"data-slot":"input",type:t,className:I(G0,"h-9",s),...i})}function ph({className:s,children:t,...i}){return o.jsx("select",{"data-slot":"select",className:I(G0,"h-9 appearance-none pr-8",s),style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2395a39a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.6rem center",backgroundSize:"16px",backgroundRepeat:"no-repeat"},...i,children:t})}function ro({className:s,...t}){return o.jsx("label",{"data-slot":"label",className:I("text-xs font-medium text-muted-foreground",s),...t})}function Ft({className:s,label:t}){return o.jsxs("span",{role:"status",className:I("inline-flex items-center gap-2 text-muted-foreground",s),children:[o.jsx(uc,{"aria-hidden":!0,className:"size-4 animate-spin"}),t?o.jsx("span",{children:t}):o.jsx("span",{className:"sr-only",children:"Loading"})]})}const Y0=b.createContext(null);function x3({controller:s,children:t}){return o.jsx(Y0.Provider,{value:s,children:t})}function Oe(){const s=b.useContext(Y0);if(!s)throw new Error("useController outside ControllerProvider");return s}function Ee(){const s=Oe();return b.useSyncExternalStore(b.useCallback(t=>s.subscribe(t),[s]),()=>s.getState())}function V0(s){const[t,i]=b.useState(!1),[a,l]=b.useState(null);return{run:b.useCallback(async(...d)=>{i(!0),l(null);try{return await s(...d),!0}catch(h){return l(h instanceof Error?h.message:String(h)),!1}finally{i(!1)}},[s]),pending:t,error:a,clearError:()=>l(null)}}const y3="M1196 972L1193 1004L1180 1053L1163 1087L1141 1117L1114 1143L1079 1166L1052 1178L1011 1189L970 1193L284 1193L217 1183L158 1156L113 1117L89 1084L68 1036L59 988L58 284L62 246L72 208L86 177L108 145L132 120L168 94L197 80L237 68L284 63L970 63L1030 71L1086 94L1123 121L1160 164L1182 208L1193 252L1196 285Z",b3="M717 377L693 495L641 803L566 803L566 801L644 371L717 371ZM594 443L531 803L462 803L469 764L447 780L424 792L402 800L371 806L345 807L309 803L278 794L256 784L238 773L216 755L202 740L184 714L170 684L163 659L160 637L160 607L164 582L171 559L180 539L196 514L231 479L250 466L280 451L313 441L345 437L377 438L405 443L431 452L463 469L483 484L509 511L522 439L589 438L594 439ZM1092 639L1086 671L1077 696L1067 715L1047 742L1031 758L1001 780L967 796L937 804L908 807L872 805L832 795L804 782L779 765L759 747L737 887L669 888L665 887L665 880L737 439L803 439L797 478L809 468L836 452L857 444L885 438L915 437L941 440L974 449L996 459L1031 483L1050 502L1071 533L1083 561L1089 584L1092 604ZM223 616L223 639L227 661L236 683L249 702L262 715L282 729L307 740L335 746L369 746L385 743L403 737L431 721L455 698L466 682L478 654L482 633L482 609L477 583L465 556L454 541L436 524L409 508L384 500L362 497L336 498L314 503L289 514L271 526L254 542L239 563L228 589ZM772 613L772 640L775 657L784 681L798 702L812 716L829 728L859 741L885 746L918 746L934 743L952 737L984 718L1004 698L1015 682L1027 654L1031 631L1031 610L1026 583L1015 558L1002 540L978 519L958 508L933 500L912 497L886 498L863 503L838 514L820 526L803 542L785 568L777 588Z";function K0({className:s}){return o.jsxs("svg",{viewBox:"0 0 1254 1254","aria-hidden":!0,className:I("shrink-0",s),children:[o.jsx("defs",{children:o.jsxs("linearGradient",{id:"alp-logo-tile",x1:"180",y1:"120",x2:"1080",y2:"1160",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{stopColor:"#1d1e20"}),o.jsx("stop",{offset:"1",stopColor:"#111214"})]})}),o.jsx("path",{fill:"url(#alp-logo-tile)",d:y3}),o.jsx("path",{fill:"#fff",fillRule:"evenodd",d:b3})]})}const F0="alp-web:gateway",X0=!1;function v3(){let s=null;try{s=window.localStorage.getItem(F0)}catch{}return Y2({location:window.location,remembered:s,dev:X0})}function w3(){const s=Oe(),{connection:t}=Ee();return o.jsx("main",{className:"flex min-h-full items-center justify-center bg-[radial-gradient(ellipse_at_top,_var(--glow)_0%,_var(--background)_55%)] px-4 py-10",children:o.jsxs("div",{className:"w-full max-w-md space-y-4","data-testid":"link-connecting",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(K0,{className:"size-10"}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"ALP"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Opening ALP on this machine"})]})]}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Ft,{label:"Connecting…"}),t.attempt>1?o.jsxs("span",{children:["Waiting for alp web (attempt ",t.attempt,")"]}):null]}),t.error?o.jsx("p",{className:"text-sm text-muted-foreground",children:t.error.message}):null,o.jsx(we,{size:"sm",variant:"ghost",onClick:()=>s.disconnect(),children:"Use another access token"})]})})}function k3(){const s=Oe(),{connection:t}=Ee(),[i,a]=b.useState(()=>t.gateway||v3()),[l,u]=b.useState(""),d=t.phase==="connecting",h=t.phase==="failed"?t.error:void 0;if(d&&t.link)return o.jsx(w3,{});const m=p=>{p.preventDefault();try{window.localStorage.setItem(F0,i.trim())}catch{}s.connect({url:i,token:l})};return o.jsx("main",{className:"flex min-h-full items-center justify-center bg-[radial-gradient(ellipse_at_top,_var(--glow)_0%,_var(--background)_55%)] px-4 py-10",children:o.jsxs("div",{className:"w-full max-w-md",children:[o.jsxs("div",{className:"mb-8 flex items-center gap-3",children:[o.jsx(K0,{className:"size-10"}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"ALP"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect to your agents on an ALP host"})]})]}),o.jsxs("form",{onSubmit:m,className:"space-y-5 rounded-xl border border-border bg-card/80 p-6 shadow-xl shadow-[var(--shadow)] backdrop-blur","aria-describedby":h?"connect-error":void 0,children:[o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ro,{htmlFor:"gateway",children:"Gateway address"}),o.jsx(Zn,{id:"gateway",name:"gateway",inputMode:"url",autoComplete:"url",spellCheck:!1,value:i,onChange:p=>a(p.target.value),placeholder:"https://alp.example.com",required:!0,disabled:d})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx(ro,{htmlFor:"token",children:"Access token"}),o.jsx(Zn,{id:"token",name:"token",type:"password",autoComplete:"off",spellCheck:!1,value:l,onChange:p=>u(p.target.value),placeholder:"alpgw1.…",required:!0,disabled:d}),o.jsxs("p",{className:"flex items-start gap-1.5 text-xs text-muted-foreground",children:[o.jsx(dc,{"aria-hidden":!0,className:"mt-0.5 size-3.5 shrink-0 text-highlight"}),"Kept in this tab's memory only. Reloading or disconnecting forgets it."]})]}),h?o.jsx("div",{id:"connect-error",role:"alert",className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h.message}):null,o.jsx(we,{type:"submit",className:"w-full",disabled:d||!i.trim()||!l.trim(),children:d?o.jsx(Ft,{className:"text-primary-foreground",label:"Connecting…"}):o.jsxs(o.Fragment,{children:[o.jsx(eN,{"aria-hidden":!0})," Connect"]})})]}),o.jsxs("details",{className:"mt-5 rounded-lg border border-border/70 bg-card/40 px-4 py-3 text-sm text-muted-foreground",children:[o.jsxs("summary",{className:"flex cursor-pointer items-center gap-2 font-medium text-foreground/90",children:[o.jsx(HS,{"aria-hidden":!0,className:"size-4"})," Getting a token"]}),o.jsxs("div",{className:"mt-3 space-y-2",children:[Cb({location:window.location,dev:X0})?o.jsxs(o.Fragment,{children:[o.jsxs("p",{children:["On this machine, run ",o.jsx("code",{className:"font-mono",children:"alp web"}),": it opens this page with a link that signs you in. ",o.jsx("code",{className:"font-mono",children:"alp web --print"})," prints the link instead, and ",o.jsx("code",{className:"font-mono",children:"alp web rotate"})," replaces its token, signing out every open page."]}),o.jsx("p",{children:"To use a standalone gateway instead, create a token for the workspaces you want to open, then start the gateway with this page's address as an allowed origin:"})]}):o.jsx("p",{children:"On the ALP host, create a token for the workspaces you want to open here, then start the gateway with this page's address as an allowed origin:"}),o.jsx("pre",{className:"overflow-x-auto rounded-md bg-background px-3 py-2 font-mono text-xs text-foreground/90",children:`alp-gateway credential create --label web \\
19
+ --workspace /path/to/project
20
+ alp-gateway serve --origin ${typeof window>"u"?"http://127.0.0.1:7435":window.location.origin}`}),o.jsx("p",{children:"From another machine, use the host's HTTPS address, or an SSH tunnel to the gateway's port (127.0.0.1:7434 by default)."})]})]})]})})}function ai({open:s,onClose:t,title:i,description:a,children:l,className:u,footer:d}){const h=b.useRef(null),m=b.useId();return b.useEffect(()=>{const p=h.current;p&&(s&&!p.open&&p.showModal(),!s&&p.open&&p.close())},[s]),o.jsx("dialog",{ref:h,"aria-labelledby":m,onCancel:p=>{p.preventDefault(),t()},onClick:p=>{p.target===h.current&&t()},className:I("m-auto w-[min(92vw,32rem)] max-h-[88dvh] overflow-hidden rounded-xl border border-border bg-popover p-0 text-popover-foreground shadow-2xl shadow-[var(--shadow)]",u),children:s?o.jsxs("div",{className:"flex max-h-[88dvh] flex-col",children:[o.jsxs("header",{className:"flex items-start justify-between gap-4 border-b border-border px-5 py-4",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{id:m,className:"text-base font-semibold",children:i}),a?o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a}):null]}),o.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Close",onClick:t,children:o.jsx(en,{})})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:l}),d?o.jsx("footer",{className:"flex flex-wrap justify-end gap-2 border-t border-border px-5 py-3",children:d}):null]}):null})}function Dt(s){const t=s.replace(/[\\/]+$/,"");return t.split(/[\\/]/).pop()||t||s}function Ri(s,t=Date.now()){if(!s)return"";const i=Date.parse(s);if(Number.isNaN(i))return"";const a=Math.max(0,Math.round((t-i)/1e3));if(a<45)return"just now";const l=Math.round(a/60);if(l<60)return`${l} min ago`;const u=Math.round(l/60);if(u<24)return`${u} h ago`;const d=Math.round(u/24);return d<7?`${d} d ago`:new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function P0(s){if(!s)return"";const t=Date.parse(s);return Number.isNaN(t)?"":new Date(t).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}const j3={"read-only":"Read only","workspace-write":"Workspace write","full-access":"Full access"},Fl=s=>s?j3[s]??s:"";function Wn(s,t){return s?.title?s.title:`Session ${(s?.id??t??"").replace(/^(web_|ses_)/,"").slice(0,6)}`}function S3(s,t=Date.now()){const i=Date.parse(s??"");if(!Number.isFinite(i))return"";const a=Math.max(0,t-i);if(a<6e4)return"now";if(a<36e5)return`${Math.floor(a/6e4)}m`;if(a<864e5)return`${Math.floor(a/36e5)}h`;if(a<7*864e5)return`${Math.floor(a/864e5)}d`;const l=new Date(i);return`${l.toLocaleDateString("en-US",{month:"short"})} ${l.getDate()}`}function N3({session:s,onClose:t}){const i=Oe(),[a,l]=b.useState(s?.title??""),[u,d]=b.useState(s);s!==u&&(d(s),l(s?.title??""));const h=V0(b.useCallback((m,p)=>i.renameSession(m,p),[i]));return b.useEffect(()=>{s&&h.clearError()},[s]),o.jsx(ai,{open:!!s,onClose:t,title:"Rename session",footer:o.jsxs(o.Fragment,{children:[o.jsx(we,{variant:"ghost",onClick:t,children:"Cancel"}),o.jsx(we,{type:"submit",form:"rename-session",disabled:h.pending||!a.trim(),children:"Save"})]}),children:o.jsxs("form",{id:"rename-session",className:"space-y-1.5",onSubmit:async m=>{m.preventDefault(),s&&await h.run(s.id,a.trim())&&t()},children:[o.jsx(ro,{htmlFor:"rename-title",children:"Title"}),o.jsx(Zn,{id:"rename-title",value:a,onChange:m=>l(m.target.value),maxLength:200,autoFocus:!0}),h.error?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:h.error}):null]})})}function T3({session:s,onClose:t}){const i=Oe(),a=V0(b.useCallback(l=>i.archiveSession(l),[i]));return b.useEffect(()=>{s&&a.clearError()},[s]),o.jsx(ai,{open:!!s,onClose:t,title:"Archive session?",description:o.jsxs(o.Fragment,{children:["“",Wn(s??void 0),"” stops and leaves the list. Its history stays on the host."]}),footer:o.jsxs(o.Fragment,{children:[o.jsx(we,{variant:"ghost",onClick:t,children:"Cancel"}),o.jsx(we,{variant:"destructive",disabled:a.pending,onClick:async()=>{s&&await a.run(s.id)&&t()},children:"Archive"})]}),children:a.error?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:a.error}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"Running work in this session is stopped."})})}function Q0({version:s,connection:t,principal:i,preferences:a,browser:l={}}){const u=h=>h===void 0?"unknown":h?"yes":"no",d=h=>h?.length?[...h].sort().join(", "):"none";return[{title:"App",rows:[["Version",`ALP web v${s}`],["Theme",a.theme],["Content width",a.contentMaxWidth===null?"default":`${a.contentMaxWidth}px`],["Chat display",a.chatDisplay],["Default send",a.sendBehavior]]},{title:"Browser",rows:[["User agent",l.userAgent??"unknown"],["Language",l.language??"unknown"],["Online",u(l.online)],["Secure context",u(l.secure)],["Viewport",l.viewport??"unknown"],["Color scheme",l.colorScheme??"unknown"]]},{title:"Connection",rows:[["Gateway",t.gateway],["State",t.phase==="reconnecting"?`reconnecting (attempt ${t.attempt})`:t.phase],["Host",t.hostname??"unknown"],["ALP on the host",t.daemonVersion??"unknown"],["Capabilities",d(t.capabilities)]]},{title:"Access token",rows:[["Name",i?.label??"unknown"],["Id",i?.id??"unknown"],["Permissions",d(i?.permissions)],["Modes",i?.modes?d(i.modes):"any"],["Projects",String(i?.workspaces?.length??0)]]}]}function A3(s){const t=[`ALP web diagnostics, ${(s.now??new Date).toISOString()}`];for(const i of Q0(s)){t.push("",`## ${i.title}`);for(const[a,l]of i.rows)t.push(`${a}: ${l}`)}return t.join(`
21
+ `)}const C3="modulepreload",E3=function(s){return"/"+s},by={},W0=function(t,i,a){let l=Promise.resolve();if(i&&i.length>0){let m=function(p){return Promise.all(p.map(x=>Promise.resolve(x).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),h=d?.nonce||d?.getAttribute("nonce");l=m(i.map(p=>{if(p=E3(p),p in by)return;by[p]=!0;const x=p.endsWith(".css"),y=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${y}`))return;const w=document.createElement("link");if(w.rel=x?"stylesheet":C3,x||(w.as="script"),w.crossOrigin="",w.href=p,h&&w.setAttribute("nonce",h),document.head.appendChild(w),x)return new Promise((k,j)=>{w.addEventListener("load",k),w.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${p}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return l.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return t().catch(u)})},M3={keyword:"#ff7b72",comment:"#8b949e",string:"#a5d6ff",number:"#79c0ff",literal:"#79c0ff",function:"#d2a8ff",definition:"#d2a8ff",class:"#ffa657",type:"#ff7b72",tag:"#7ee787",attribute:"#79c0ff",property:"#79c0ff",variable:"#c9d1d9",operator:"#79c0ff",punctuation:"#c9d1d9",regexp:"#a5d6ff",escape:"#79c0ff",meta:"#8b949e",heading:"#79c0ff",link:"#a5d6ff"},z3={keyword:"#cf222e",comment:"#6e7781",string:"#0a3069",number:"#0550ae",literal:"#0550ae",function:"#8250df",definition:"#8250df",class:"#953800",type:"#cf222e",tag:"#116329",attribute:"#0550ae",property:"#0550ae",variable:"#24292f",operator:"#0550ae",punctuation:"#24292f",regexp:"#0a3069",escape:"#0550ae",meta:"#6e7781",heading:"#0550ae",link:"#0a3069"},R3=[{id:"github",label:"GitHub"},{id:"catppuccin",label:"Catppuccin"},{id:"dracula",label:"Dracula"},{id:"tokyo-night",label:"Tokyo Night"},{id:"one",label:"One"},{id:"nord",label:"Nord"},{id:"gruvbox",label:"Gruvbox"},{id:"solarized",label:"Solarized"}];function Ni(s){return{keyword:s.keyword,comment:s.comment,string:s.string,number:s.number,literal:s.number,function:s.function,definition:s.function,class:s.type,type:s.type,tag:s.tag,attribute:s.attribute,property:s.attribute,variable:s.base,operator:s.operator,punctuation:s.base,regexp:s.string,escape:s.number,meta:s.comment,heading:s.function,link:s.string}}const _3={base:"#4c4f69",keyword:"#8839ef",comment:"#8c8fa1",string:"#40a02b",number:"#fe640b",function:"#1e66f5",type:"#df8e1d",tag:"#8839ef",attribute:"#df8e1d",operator:"#04a5e5"},L3={base:"#cdd6f4",keyword:"#cba6f7",comment:"#9399b2",string:"#a6e3a1",number:"#fab387",function:"#89b4fa",type:"#f9e2af",tag:"#cba6f7",attribute:"#f9e2af",operator:"#89dceb"},O3={base:"#f8f8f2",keyword:"#ff79c6",comment:"#6272a4",string:"#f1fa8c",number:"#bd93f9",function:"#50fa7b",type:"#8be9fd",tag:"#ff79c6",attribute:"#50fa7b",operator:"#ff79c6"},D3={base:"#3760bf",keyword:"#9854f1",comment:"#848cb5",string:"#587539",number:"#b15c00",function:"#2e7de9",type:"#007197",tag:"#f52a65",attribute:"#8c6c3e",operator:"#006a83"},q3={base:"#c0caf5",keyword:"#bb9af7",comment:"#565f89",string:"#9ece6a",number:"#ff9e64",function:"#7aa2f7",type:"#2ac3de",tag:"#f7768e",attribute:"#e0af68",operator:"#89ddff"},B3={base:"#383a42",keyword:"#a626a4",comment:"#a0a1a7",string:"#50a14f",number:"#986801",function:"#4078f2",type:"#c18401",tag:"#e45649",attribute:"#986801",operator:"#0184bc"},$3={base:"#abb2bf",keyword:"#c678dd",comment:"#5c6370",string:"#98c379",number:"#d19a66",function:"#61afef",type:"#e5c07b",tag:"#e06c75",attribute:"#d19a66",operator:"#56b6c2"},U3={base:"#2e3440",keyword:"#5e81ac",comment:"#6b7280",string:"#4f6f3a",number:"#8f5e91",function:"#2e6f8e",type:"#3b7f87",tag:"#5e81ac",attribute:"#8f5e91",operator:"#5e81ac"},H3={base:"#d8dee9",keyword:"#81a1c1",comment:"#616e88",string:"#a3be8c",number:"#b48ead",function:"#88c0d0",type:"#8fbcbb",tag:"#81a1c1",attribute:"#8fbcbb",operator:"#81a1c1"},I3={base:"#3c3836",keyword:"#9d0006",comment:"#928374",string:"#79740e",number:"#8f3f71",function:"#427b58",type:"#b57614",tag:"#076678",attribute:"#b57614",operator:"#af3a03"},G3={base:"#ebdbb2",keyword:"#fb4934",comment:"#928374",string:"#b8bb26",number:"#d3869b",function:"#8ec07c",type:"#fabd2f",tag:"#83a598",attribute:"#fabd2f",operator:"#fe8019"},Y3={base:"#657b83",keyword:"#859900",comment:"#93a1a1",string:"#2aa198",number:"#d33682",function:"#268bd2",type:"#b58900",tag:"#268bd2",attribute:"#b58900",operator:"#859900"},V3={base:"#839496",keyword:"#859900",comment:"#586e75",string:"#2aa198",number:"#d33682",function:"#268bd2",type:"#b58900",tag:"#268bd2",attribute:"#b58900",operator:"#859900"};function K3(s,t){const i=t==="dark";switch(s){case"github":return i?M3:z3;case"catppuccin":return Ni(i?L3:_3);case"dracula":return Ni(O3);case"tokyo-night":return Ni(i?q3:D3);case"one":return Ni(i?$3:B3);case"nord":return Ni(i?H3:U3);case"gruvbox":return Ni(i?G3:I3);case"solarized":return Ni(i?V3:Y3)}}const vy={typescript:"ts",javascript:"js",python:"py",rust:"rs",golang:"go","c++":"cpp",csharp:"cs","c#":"cs",objc:"m","objective-c":"m",markdown:"md",elixir:"ex"};function F3(s){const t=s?.trim().split(/\s+/)[0]?.toLowerCase().replace(/^\./,"");return t?`code.${Object.hasOwn(vy,t)?vy[t]:t}`:null}const X3=R3.map(s=>({value:s.id,label:s.label}));let Af=null,wy=null;const Cf=new Set;function P3(){return wy??=W0(()=>import("./highlighter-BnicKQ_d.js"),[]).then(s=>{Af=s;for(const t of Cf)t();return s}),wy}function Q3(){const[,s]=b.useReducer(t=>t+1,0);return b.useEffect(()=>{if(!Af)return Cf.add(s),P3(),()=>{Cf.delete(s)}},[]),Af}const W3=768*1024;function mc(s,t){const i=Q3();return b.useMemo(()=>{if(!i||!t||s.length>W3||!i.isLanguageSupported(t))return null;try{return i.highlightCode(s,t)}catch{return null}},[i,s,t])}function pc({tokens:s}){return b.createElement(b.Fragment,null,s.map((t,i)=>t.style?b.createElement("span",{key:i,style:{color:`var(--syntax-${t.style})`}},t.text):t.text))}const Z3=["keyword","comment","string","number","literal","function","definition","class","type","tag","attribute","property","variable","operator","punctuation","regexp","escape","meta","heading","link"];function J3(s,t){const i=K3(s,t),a=document.documentElement.style;for(const l of Z3)a.setProperty(`--syntax-${l}`,i[l])}const Wd=[{value:"light",label:"Light",group:"primary",swatch:"#ffffff"},{value:"dark",label:"Dark",group:"primary",swatch:"#2D8B62"},{value:"system",label:"System",group:"primary"},{value:"zinc",label:"Zinc",group:"variant",swatch:"#808080"},{value:"midnight",label:"Midnight",group:"variant",swatch:"#4A6BA8"},{value:"claude",label:"Claude",group:"variant",swatch:"#D97757"},{value:"ghostty",label:"Ghostty",group:"variant",swatch:"#8caaee"},{value:"pureBlack",label:"Pure black",group:"variant",swatch:"#000000"}],ky={light:"#ffffff",dark:"#181b1a",zinc:"#18181b",midnight:"#161820",claude:"#1f1f1e",ghostty:"#282c34",pureBlack:"#000000"};function e4(s,t="one"){const i=document.documentElement,a=typeof window.matchMedia=="function"?window.matchMedia("(prefers-color-scheme: light)"):null,l=()=>{const u=s==="system"?a?.matches?"light":"dark":s,d=u==="light"?"light":"dark";i.dataset.theme=u,i.classList.toggle("dark",d==="dark"),i.style.colorScheme=d,document.querySelector('meta[name="color-scheme"]')?.setAttribute("content",d),document.querySelector('meta[name="theme-color"]')?.setAttribute("content",ky[u]??ky.dark),J3(t,d)};return l(),s!=="system"||!a?()=>{}:(a.addEventListener("change",l),()=>a.removeEventListener("change",l))}const Z0='"Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',J0='"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';function e1(s){return s.contentMaxWidth??On.contentMaxWidth[2]}function t4(s){const t=document.documentElement.style;t.setProperty("--app-font-sans",s.uiFontFamily||Z0),t.setProperty("--app-font-mono",s.monoFontFamily||J0),t.setProperty("--ui-scale",String(s.uiFontSize/On.uiFontSize[2])),t.setProperty("--content-font-size",`${s.contentFontSize}px`),t.setProperty("--code-font-size",`${s.codeFontSize}px`),t.setProperty("--content-width",`${e1(s)}px`)}const n4={red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#9333ea",cyan:"#0891b2",white:"#ffffff",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#f59e0b",brightBlue:"#3b82f6",brightMagenta:"#a855f7",brightCyan:"#06b6d4",brightWhite:"#fafafa"},s4={red:"#e07070",green:"#5dba80",yellow:"#d4a44a",blue:"#6a9de0",magenta:"#b07ad0",cyan:"#4aabb8",white:"#d4d4d8",brightRed:"#e89090",brightGreen:"#7ecf9a",brightYellow:"#e0be6e",brightBlue:"#8ab4e8",brightMagenta:"#c49ae0",brightCyan:"#6ec2cc",brightWhite:"#f0f0f2"};function PC(){const s=document.documentElement,t=getComputedStyle(s),i=d=>t.getPropertyValue(d).trim(),a=s.dataset.theme==="light",l=i("--background"),u=i("--foreground");return{background:l,foreground:u,cursor:u,cursorAccent:l,selectionBackground:a?"rgba(0, 0, 0, 0.15)":"rgba(255, 255, 255, 0.2)",selectionForeground:u,black:i("--terminal-black"),brightBlack:i("--terminal-bright-black"),...a?n4:s4}}function t1({checked:s,onCheckedChange:t,className:i,...a}){return o.jsx("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>t(!s),"data-slot":"switch",className:I("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s?"bg-primary":"bg-input",i),...a,children:o.jsx("span",{"aria-hidden":!0,className:I("pointer-events-none block size-4 rounded-full bg-white shadow transition-transform",s?"translate-x-4":"translate-x-0.5")})})}const Ef=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,n1=s=>s.replace(/\t/g," ").match(/^ */)[0].length,jy=s=>s.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim());function s1(s,t,i){const a=Ef.exec(s[t]),l=/\d/.test(a[2]),u=[];let d=t;for(;d<s.length;){const h=s[d],m=Ef.exec(h),p=n1(h);if(m&&p===i&&/\d/.test(m[2])===l){u.push({text:m[3],children:[]}),d++;continue}if(m&&p>i&&u.length){const x=s1(s,d,p);u.at(-1).children.push(x.block),d=x.next;continue}if(!m&&h.trim()&&p>i&&u.length){const x=u.at(-1);if(x.children.length)break;x.text+=` ${h.trim()}`,d++;continue}break}return{block:{kind:"list",ordered:l,start:l&&Number.parseInt(a[2],10)||1,items:u},next:d}}function i4(s){const t=s.replace(/\r\n?/g,`
22
+ `).split(`
23
+ `),i=[];let a=[];const l=()=>{a.length&&i.push({kind:"paragraph",text:a.join(`
24
+ `)}),a=[]};for(let u=0;u<t.length;u++){const d=t[u],h=/^\s*(```+|~~~+)\s*([\w+-]*)\s*$/.exec(d);if(h){l();const x=[];let y=u+1;for(;y<t.length&&!t[y].trim().startsWith(h[1]);)x.push(t[y++]);i.push({kind:"code",lang:h[2],text:x.join(`
25
+ `)}),u=y;continue}const m=/^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(d);if(m){l(),i.push({kind:"heading",level:m[1].length,text:m[2]});continue}if(/^\s{0,3}([-*_])(\s*\1){2,}\s*$/.test(d)){l(),i.push({kind:"rule"});continue}if(d.trim().startsWith("|")&&u+1<t.length&&/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(t[u+1])){l();const x=jy(d),y=[];let w=u+2;for(;w<t.length&&t[w].trim().startsWith("|");)y.push(jy(t[w++]));i.push({kind:"table",head:x,rows:y}),u=w-1;continue}if(Ef.test(d)){l();const{block:x,next:y}=s1(t,u,n1(d));i.push(x),u=y-1;continue}const p=/^\s*>\s?(.*)$/.exec(d);if(p){l();const x=i.at(-1);x?.kind==="quote"?x.text+=`
26
+ ${p[1]}`:i.push({kind:"quote",text:p[1]});continue}if(!d.trim()){l();continue}a.push(d)}return l(),i}const i1=String.raw`(?!\))[^()\s]{0,2048}(?:\([^()\s]{0,2048}\)[^()\s]{0,2048})?`,a1=String.raw`[^[\]\n]{1,1000}`,a4=new RegExp(["(`[^`\\n]{1,1000}`)",String.raw`(\*\*[^*\n]{1,1000}?\*\*|__[^_\n]{1,1000}?__)`,String.raw`(~~[^~\n]{1,1000}?~~)`,String.raw`(\[${a1}\]\(${i1}\))`,String.raw`((?:https?:\/\/|mailto:)[^\s<>()]{0,2048}[^\s<>().,;:!?'"`+"`"+String.raw`*])`,String.raw`(\*[^*\s][^*\n]{0,1000}?\*|(?<![\w])_[^_\s][^_\n]{0,1000}?_(?![\w]))`].join("|")),r4=new RegExp(String.raw`^\[(${a1})\]\((${i1})\)$`);function o4(s){const t=r4.exec(s);return t?{text:t[1],href:t[2]}:void 0}const gc=b.createContext(null),l4="cursor-pointer text-highlight underline-offset-2 hover:underline focus-visible:underline outline-none";function Sy({target:s,links:t,children:i,title:a}){return o.jsx("button",{type:"button",className:I("inline break-words text-left [overflow-wrap:anywhere]",l4),title:a,"data-testid":"chat-file-link","data-path":s.path,onClick:()=>t.open(s),children:o.jsx(gc.Provider,{value:null,children:i})})}const r1=s=>/^(https?:\/\/|mailto:)/i.test(s)?s:void 0;function Ny({href:s,children:t}){const i=r1(s);return i?o.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"break-words text-highlight [overflow-wrap:anywhere] hover:underline",children:o.jsx(gc.Provider,{value:null,children:t})}):o.jsx(o.Fragment,{children:t})}function Un({text:s}){const t=b.useContext(gc),i=[];let a=s,l=0;for(;a;){const u=a4.exec(a);if(!u){i.push(a);break}u.index&&i.push(a.slice(0,u.index));const[d,h,m,p,x,y,w]=u;if(h){const k=h.slice(1,-1),j=t?.resolve(k,"code"),S=o.jsx("code",{className:I("rounded-md bg-muted px-1 py-0.5 font-mono text-(length:--code-font-size)",j?"text-highlight":"text-foreground"),children:k});i.push(j&&t?o.jsx(Sy,{target:j,links:t,title:`Open ${j.path}${j.line?`:${j.line}`:""}`,children:S},l++):o.jsx(b.Fragment,{children:S},l++))}else if(m)i.push(o.jsx("strong",{className:"font-semibold text-foreground",children:o.jsx(Un,{text:m.slice(2,-2)})},l++));else if(p)i.push(o.jsx("s",{className:"text-muted-foreground",children:o.jsx(Un,{text:p.slice(2,-2)})},l++));else if(x){const k=o4(x),j=!k||r1(k.href)?void 0:t?.resolve(k.href,"href");k?i.push(j&&t?o.jsx(Sy,{target:j,links:t,title:`Open ${j.path}${j.line?`:${j.line}`:""}`,children:o.jsx(Un,{text:k.text})},l++):o.jsx(Ny,{href:k.href,children:o.jsx(Un,{text:k.text})},l++)):i.push(x)}else y?i.push(o.jsx(Ny,{href:y,children:y},l++)):w&&i.push(o.jsx("em",{className:"italic",children:o.jsx(Un,{text:w.slice(1,-1)})},l++));a=a.slice(u.index+d.length)}return o.jsx(o.Fragment,{children:i})}const c4=["","mt-6 mb-3 border-b border-border pb-2 text-[1.867em] leading-[1.286] font-bold","mt-6 mb-3 border-b border-border pb-2 text-[1.6em] leading-[1.292] font-bold","mt-4 mb-2 text-[1.4em] leading-[1.333] font-semibold","mt-4 mb-2 text-[1.267em] leading-[1.316] font-semibold","mt-3 mb-1 text-[1.133em] leading-[1.294] font-semibold","mt-3 mb-1 text-[1.133em] leading-[1.294] font-semibold uppercase tracking-[0.5px] text-muted-foreground"];function o1({blocks:s,nested:t}){return o.jsx(o.Fragment,{children:s.map((i,a)=>{const l=s[a+1];switch(i.kind){case"code":return o.jsx(u4,{text:i.text,lang:i.lang},a);case"heading":{const u=`h${Math.min(i.level+1,6)}`;return o.jsx(u,{className:I("text-foreground first:mt-0",c4[i.level]),children:o.jsx(Un,{text:i.text})},a)}case"list":{const u=i.ordered?"ol":"ul",d=t?"mb-0":l?l.kind==="list"?"mb-2":"mb-4":"mb-0";return o.jsx(u,{className:I("mt-1 pl-2.5",d),...i.ordered&&i.start!==1?{start:i.start}:{},children:i.items.map((h,m)=>o.jsxs("li",{className:"mb-1 flex items-start",children:[o.jsx("span",{"aria-hidden":!0,className:I("mr-1 shrink-0 select-none text-muted-foreground",i.ordered&&"min-w-3"),children:i.ordered?`${i.start+m}.`:"•"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx(Un,{text:h.text}),h.children.length?o.jsx(o1,{blocks:h.children,nested:!0}):null]})]},m))},a)}case"quote":return o.jsx("blockquote",{className:"my-3 whitespace-pre-wrap rounded-r-md border-l-4 border-muted bg-card px-4 py-3 text-foreground/80",children:o.jsx(Un,{text:i.text})},a);case"table":return o.jsx("div",{className:"my-3 overflow-x-auto rounded-md border border-border",children:o.jsxs("table",{className:"w-full border-collapse text-left",children:[o.jsx("thead",{className:"bg-muted",children:o.jsx("tr",{children:i.head.map((u,d)=>o.jsx("th",{className:"border-b border-r border-border p-2 font-semibold last:border-r-0",children:o.jsx(Un,{text:u})},d))})}),o.jsx("tbody",{children:i.rows.map((u,d)=>o.jsx("tr",{className:"border-b border-border last:border-b-0",children:i.head.map((h,m)=>o.jsx("td",{className:"border-r border-border p-2 align-top last:border-r-0",children:o.jsx(Un,{text:u[m]??""})},m))},d))})]})},a);case"rule":return o.jsx("hr",{className:"my-2.5 border-0 border-t border-border"},a);default:return o.jsx("p",{className:I("whitespace-pre-wrap",t?"mb-0":"mb-3"),children:o.jsx(Un,{text:i.text})},a)}})})}function u4({text:s,lang:t}){const i=mc(s,F3(t));return o.jsx("pre",{className:"my-3 overflow-x-auto rounded-md border border-border bg-muted p-3 font-mono text-(length:--code-font-size) leading-[1.5] text-foreground","data-language":t||void 0,children:o.jsx("code",{children:i?i.map((a,l)=>o.jsxs(b.Fragment,{children:[l?`
27
+ `:null,o.jsx(pc,{tokens:a})]},l)):s})})}function fo({text:s,className:t}){const i=b.useMemo(()=>i4(s),[s]);return o.jsx("div",{className:I("min-w-0 break-words text-(length:--content-font-size) leading-[1.4] text-foreground [overflow-wrap:anywhere]",t),children:o.jsx(o1,{blocks:i})})}const Xl="‹hidden on the host›",d4=new Set(["instructions","body","houseRules"]),f4={instructions:"AGENT.md",config:"agent.json",body:"SKILL.md",server:"Server",hook:"Hook",team:"team.json",houseRules:"HOUSE_RULES.md",provider:"Provider"},Ty=s=>s!==null&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length===1&&s.$secret==="keep";function h4(s){const t=[];for(const[i,a]of Object.entries(s??{})){const l=f4[i]??i;if(d4.has(i)&&typeof a=="string"){t.push({key:i,label:l,kind:"text",text:a});continue}if(a===void 0)continue;const u=Ty(a)?Xl:JSON.stringify(a,(d,h)=>Ty(h)?Xl:h,2);t.push({key:i,label:l,kind:"json",text:u})}return t}const Ml={none:"/favicon.svg",running:"/favicon-running.svg",attention:"/favicon-attention.svg"},Ay=220;function m4({status:s,waiting:t=!1,reason:i}){return t?"needs_input":s==="error"||i==="error"?"failed":s==="running"||s==="initializing"?"running":i==="finished"?"attention":"done"}function p4(s,t=!1){return s.includes("running")?"running":t||s.includes("needs_input")||s.includes("attention")?"attention":"none"}function g4({root:s,name:t,reason:i,message:a}){const l=i==="error"?(a?l1(a):"")||"Encountered an error.":"Finished working.";return{title:i==="finished"?"Agent finished":"Agent needs attention",body:`${t}: ${l}`,tag:`alp-${i}-${s}`}}function x4(s,t){return Object.entries(t).filter(([i,a])=>a.at!==s[i]?.at).map(([i])=>i)}function l1(s){const t=s.replace(/```[\s\S]*?```/g," ").replace(/[`*_>#~[\]]/g,"").replace(/\s+/g," ").trim();return t.length>Ay?`${t.slice(0,Ay-3).trimEnd()}...`:t}function y4(s,t){return Object.entries(t).filter(([i,a])=>a>0&&a>(s[i]??0)).map(([i])=>i)}const Cy=(s,t)=>s.visible&&s.focused&&s.shown===t,c1="fixed z-50 max-h-[min(60vh,28rem)] min-w-40 max-w-[min(92vw,26rem)] overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-xl shadow-[var(--shadow)]";function Mf({items:s,close:t,openPage:i}){return o.jsx(o.Fragment,{children:s.map(a=>o.jsxs(b.Fragment,{children:[a.group?o.jsx("div",{role:"separator",className:"-mx-1 my-1 h-px bg-border"}):null,o.jsxs("button",{type:"button",role:a.checked===void 0?"menuitem":a.keepOpen?"menuitemcheckbox":"menuitemradio","aria-checked":a.checked,disabled:a.disabled,title:a.title,"data-testid":a.testId,"aria-haspopup":a.page?"menu":void 0,onClick:l=>{if(l.stopPropagation(),a.page&&i){i(a.page);return}a.keepOpen||t(),a.onSelect()},className:I("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm outline-none hover:bg-accent focus-visible:bg-accent disabled:opacity-45 [&_svg]:size-3.5",a.destructive?"text-destructive":"text-foreground"),children:[a.icon,o.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.label}),a.indicator?o.jsx("span",{"aria-label":"On",className:"size-1.5 shrink-0 rounded-full bg-highlight"}):null,a.hint?o.jsx("span",{className:"ml-3 font-mono text-xs text-muted-foreground",children:a.hint}):null,a.value?o.jsx("span",{className:"ml-3 max-w-[50%] truncate text-xs text-muted-foreground",children:a.value}):null,a.page?o.jsx(Jn,{"aria-hidden":!0,className:"text-muted-foreground"}):null,a.checked?o.jsx(oc,{"aria-hidden":!0,className:"ml-2 text-foreground"}):null]})]},a.id??a.label))})}function u1(s,t){return i=>{const a=Array.from(s.current?.querySelectorAll('[role^="menuitem"]:not([disabled])')??[]),l=a.indexOf(document.activeElement);i.key==="Escape"?(i.preventDefault(),i.stopPropagation(),t()):i.key==="ArrowDown"?(i.preventDefault(),a[(l+1)%a.length]?.focus()):i.key==="ArrowUp"?(i.preventDefault(),a[(l-1+a.length)%a.length]?.focus()):i.key==="Home"?(i.preventDefault(),a[0]?.focus()):i.key==="End"?(i.preventDefault(),a.at(-1)?.focus()):i.key==="Tab"&&t(!1)}}function d1({label:s,at:t,items:i,onClose:a,testId:l,fallbackFocus:u}){const d=b.useRef(null),[h,m]=b.useState({visibility:"hidden"}),p=b.useRef(null),x=b.useCallback((y=!0)=>{if(a(),!y)return;const w=p.current;w?.focus(),setTimeout(()=>{w&&!w.isConnected&&u?.()?.focus()},0)},[a,u]);return b.useLayoutEffect(()=>{if(!t)return;p.current=document.activeElement;const y=d.current?.offsetWidth??0,w=d.current?.offsetHeight??0;m({left:Math.max(8,Math.min(t.x,window.innerWidth-y-8)),top:Math.max(8,Math.min(t.y,window.innerHeight-w-8))})},[t]),b.useLayoutEffect(()=>{t&&h.visibility!=="hidden"&&d.current?.querySelector('[role^="menuitem"]:not([disabled])')?.focus()},[h]),b.useEffect(()=>{if(!t)return;const y=()=>x(!1),w=k=>{d.current?.contains(k.target)||x(!1)};return window.addEventListener("resize",y),window.addEventListener("scroll",y,!0),window.addEventListener("blur",y),document.addEventListener("pointerdown",w,!0),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",y,!0),window.removeEventListener("blur",y),document.removeEventListener("pointerdown",w,!0)}},[t,x]),t?o.jsx("div",{ref:d,role:"menu","aria-label":s,"data-testid":l,onKeyDown:u1(d,x),onContextMenu:y=>y.preventDefault(),style:h,className:c1,children:o.jsx(Mf,{items:i,close:()=>x()})}):null}function Kt({label:s,title:t,trigger:i,triggerClassName:a,items:l,pages:u,width:d,align:h="end",onOpenChange:m,disabled:p,openRequest:x,onOpenRequestHandled:y,testId:w}){const[k,j]=b.useState(!1),[S,A]=b.useState(null),[R,q]=b.useState({}),O=b.useRef(null),L=b.useRef(null),B=b.useId(),_=b.useCallback(ee=>{j(ee),ee||A(null),m?.(ee)},[m]);b.useEffect(()=>{x&&(p||_(!0),y?.())},[x]);const Q=()=>Array.from(L.current?.querySelectorAll('[role^="menuitem"]:not([disabled])')??[]);b.useLayoutEffect(()=>{if(!k||!O.current)return;const ee=O.current.getBoundingClientRect(),xe=L.current?.offsetHeight??0,re=ee.bottom+4+xe<=window.innerHeight-8;q({top:re?ee.bottom+4:Math.max(8,ee.top-4-xe),...h==="end"?{right:Math.max(8,window.innerWidth-ee.right)}:{left:Math.max(8,ee.left)}})},[k,h]),b.useEffect(()=>{k&&Q()[0]?.focus()},[k,S]),b.useEffect(()=>{if(!k)return;const ee=()=>_(!1),xe=de=>{de.target instanceof Node&&de.target.contains(O.current)&&_(!1)};window.addEventListener("resize",ee),window.addEventListener("scroll",xe,!0);const re=de=>{!L.current?.contains(de.target)&&!O.current?.contains(de.target)&&_(!1)};return document.addEventListener("pointerdown",re),()=>{document.removeEventListener("pointerdown",re),window.removeEventListener("resize",ee),window.removeEventListener("scroll",xe,!0)}},[k,_]);const C=(ee=!0)=>{_(!1),ee&&O.current?.focus()},Y=S?u?.[S]:void 0,H=u1(L,C),fe=ee=>{if(Y&&(ee.key==="Escape"||ee.key==="ArrowLeft")){ee.preventDefault(),ee.stopPropagation(),A(null);return}H(ee)};return o.jsxs(o.Fragment,{children:[o.jsx("button",{ref:O,type:"button","aria-label":s,title:t??s,disabled:p,"aria-haspopup":"menu","aria-expanded":k,"aria-controls":k?B:void 0,"data-testid":w,onClick:ee=>{ee.stopPropagation(),_(!k)},onKeyDown:ee=>{ee.key==="ArrowDown"&&!k&&(ee.preventDefault(),_(!0))},className:a,children:i}),k?o.jsx("div",{ref:L,id:B,role:"menu","aria-label":Y?Y.title:s,onKeyDown:fe,style:d?{...R,width:d}:R,className:c1,"data-page":S??void 0,children:Y?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",role:"menuitem",onClick:ee=>{ee.stopPropagation(),A(null)},"aria-label":`Back from ${Y.title}`,className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent [&_svg]:size-3.5",children:[o.jsx(nh,{"aria-hidden":!0}),Y.title]}),o.jsx("div",{role:"separator",className:"-mx-1 my-1 h-px bg-border"}),o.jsx(Mf,{items:Y.items,close:()=>C()})]}):o.jsx(Mf,{items:l,close:()=>C(),openPage:u?A:void 0})}):null]})}const b4=[{id:"general",title:"General"},{id:"workspaces",title:"Projects & Workspaces"},{id:"tabs-panes",title:"Tabs & Panes"},{id:"layout",title:"Layout"},{id:"agent-input",title:"Agent Input"}],xc=[{action:"command-center.toggle",combo:"Mod+K",section:"general",label:"Toggle command center"},{action:"command-center.files",combo:"Mod+P",section:"general",label:"Search files"},{action:"shortcuts.toggle",combo:"Shift+?",section:"general",label:"Show keyboard shortcuts",scope:"other",note:"Available when focus is not in a text field."},{action:"settings.toggle",combo:"Mod+,",section:"general",label:"Toggle settings"},{action:"session.new",combo:"Mod+N",section:"workspaces",label:"New session"},{action:"session.archive",combo:"Mod+Shift+Backspace",section:"workspaces",label:"Archive session"},{action:"session.index",combo:"Alt+Digit",section:"workspaces",label:"Jump to session",display:["alt","1-9"]},{action:"session.relative",combo:"Alt+[",delta:-1,section:"workspaces",label:"Previous session"},{action:"session.relative",combo:"Alt+]",delta:1,section:"workspaces",label:"Next session"},{action:"tab.menu",combo:"Mod+T",section:"tabs-panes",label:"New tab"},{action:"tab.agent",combo:"Mod+Shift+A",section:"tabs-panes",label:"New agent"},{action:"tab.changes",combo:"Mod+Shift+G",section:"tabs-panes",label:"Changes"},{action:"tab.files",combo:"Mod+Shift+E",section:"tabs-panes",label:"Files"},{action:"tab.terminal",combo:"Mod+Shift+T",section:"tabs-panes",label:"New terminal"},{action:"tab.close",combo:"Alt+Shift+W",section:"tabs-panes",label:"Close current tab"},{action:"tab.index",combo:"Alt+Shift+Digit",section:"tabs-panes",label:"Jump to tab",display:["alt","shift","1-9"]},{action:"tab.relative",combo:"Alt+Shift+[",delta:-1,section:"tabs-panes",label:"Previous tab"},{action:"tab.relative",combo:"Alt+Shift+]",delta:1,section:"tabs-panes",label:"Next tab"},{action:"pane.split.right",combo:"Cmd+\\",section:"tabs-panes",label:"Split pane right",mac:!0},{action:"pane.split.down",combo:"Cmd+Shift+\\",section:"tabs-panes",label:"Split pane down",mac:!0},{action:"pane.focus.left",combo:"Cmd+Shift+ArrowLeft",section:"tabs-panes",label:"Focus pane left",mac:!0,scope:"other"},{action:"pane.focus.right",combo:"Cmd+Shift+ArrowRight",section:"tabs-panes",label:"Focus pane right",mac:!0,scope:"other"},{action:"pane.focus.up",combo:"Cmd+Shift+ArrowUp",section:"tabs-panes",label:"Focus pane up",mac:!0,scope:"other"},{action:"pane.focus.down",combo:"Cmd+Shift+ArrowDown",section:"tabs-panes",label:"Focus pane down",mac:!0,scope:"other"},{action:"pane.move.left",combo:"Cmd+Alt+Shift+ArrowLeft",section:"tabs-panes",label:"Move tab left",mac:!0},{action:"pane.move.right",combo:"Cmd+Alt+Shift+ArrowRight",section:"tabs-panes",label:"Move tab right",mac:!0},{action:"pane.move.up",combo:"Cmd+Alt+Shift+ArrowUp",section:"tabs-panes",label:"Move tab up",mac:!0},{action:"pane.move.down",combo:"Cmd+Alt+Shift+ArrowDown",section:"tabs-panes",label:"Move tab down",mac:!0},{action:"pane.close",combo:"Cmd+Shift+W",section:"tabs-panes",label:"Close pane",mac:!0,note:"Some browsers keep this key to close the window."},{action:"sidebar.left",combo:"Mod+B",section:"layout",label:"Toggle left sidebar"},{action:"sidebar.right",combo:"Mod+E",section:"layout",label:"Toggle Explorer sidebar"},{action:"sidebar.right",combo:"Ctrl+`"},{action:"sidebar.both",combo:"Mod+.",section:"layout",label:"Toggle both sidebars"},{action:"composer.focus",combo:"Mod+L",section:"agent-input",label:"Focus message input",handledElsewhere:!0},{action:"composer.mode",combo:"Shift+Tab",section:"agent-input",label:"Cycle agent mode",handledElsewhere:!0},{action:"agent.interrupt",combo:"Escape",section:"agent-input",label:"Interrupt agent",handledElsewhere:!0}],Ey={"[":"BracketLeft","]":"BracketRight",",":"Comma",".":"Period","`":"Backquote","?":"Slash","\\":"Backslash"};function f1(s,t){const i=s.split("+"),a=i.pop()??"",l={meta:!1,ctrl:!1,alt:!1,shift:!1};for(const u of i)u==="Mod"?l[t?"meta":"ctrl"]=!0:u==="Cmd"?l.meta=!0:u==="Ctrl"?l.ctrl=!0:u==="Alt"?l.alt=!0:u==="Shift"&&(l.shift=!0);return{key:a,mods:l}}function v4(s,{mac:t,editable:i=!1,bindings:a=xc}){for(const l of a){if(l.handledElsewhere||l.mac&&!t||l.scope==="other"&&i)continue;const{key:u,mods:d}=f1(l.combo,t);if(!(s.metaKey!==d.meta||s.ctrlKey!==d.ctrl||s.altKey!==d.alt||s.shiftKey!==d.shift)){if(u==="Digit"){const h=/^Digit([1-9])$/.exec(s.code);if(h)return{binding:l,index:Number(h[1])};continue}if(u.length===1&&/[A-Za-z]/.test(u)?s.code===`Key${u.toUpperCase()}`:Ey[u]&&s.code===Ey[u]||s.key===u)return{binding:l}}}return null}function gh(s,t){if(s.display)return s.display;const{key:i,mods:a}=f1(s.combo,t),l=[];return a.ctrl&&l.push("ctrl"),a.meta&&l.push("mod"),a.alt&&l.push("alt"),a.shift&&i!=="?"&&l.push("shift"),l.push(i),l}const w4={Backspace:"⌫",Enter:"⏎",Escape:"Esc",Space:"␣",ArrowLeft:"←",ArrowRight:"→",ArrowUp:"↑",ArrowDown:"↓"};function xh(s,t){const i=l=>w4[l]??(l.length===1?l.toUpperCase():l);if(t){const l=["ctrl","alt","shift","mod"],u={ctrl:"⌃",alt:"⌥",shift:"⇧",mod:"⌘"};return l.filter(d=>s.includes(d)).map(d=>u[d]).join("")+s.filter(d=>!l.includes(d)).map(i).join("")}const a={mod:"Ctrl",ctrl:"Ctrl",alt:"Alt",shift:"Shift"};return s.map(l=>a[l]??i(l)).join("+")}function Pl(s,t){const i=xc.find(a=>a.action===s&&a.label&&(!a.mac||t));return i?xh(gh(i,t),t):""}function k4(s,t=""){const i=t.trim().toLowerCase();return b4.map(a=>({...a,rows:xc.filter(l=>l.section===a.id&&l.label&&(!l.mac||s)).map(l=>({id:`${l.action}:${l.combo}`,label:l.label,keys:xh(gh(l,s),s),...l.note?{note:l.note}:{}})).filter(l=>!i||l.label.toLowerCase().includes(i)||l.keys.toLowerCase().includes(i))})).filter(a=>a.rows.length)}function h1(s){const t=s;if(!t||typeof t.closest!="function")return!1;if(t.isContentEditable)return!0;const i=String(t.tagName??"").toLowerCase();return i==="textarea"||i==="select"?!0:i!=="input"?!1:!["button","checkbox","radio","submit","reset","range","color","file"].includes(String(t.type??"").toLowerCase())}function ho(){const s=globalThis.navigator;return/Mac|iPhone|iPad/.test(String(s?.platform||s?.userAgent||""))}const j4=[["needs_input","Needs input"],["failed","Failed"],["attention","Ready to review"],["running","Working"],["done","Done"]],S4=7,My=s=>{const t=Date.parse(s??"");return Number.isFinite(t)?t:0};function zy(s,t){const i=a=>My(t==="lastPrompt"?a.updatedAt??a.createdAt:a.createdAt);return[...s].sort((a,l)=>i(l)-i(a)||a.id.localeCompare(l.id))}function N4(s,t,i){const a=s.filter((l,u)=>u<S4||i(l)!=="done");return{visible:t?[...s]:a,canToggle:a.length<s.length}}function T4(s,t){return j4.map(([i,a])=>({bucket:i,label:a,sessions:s.filter(l=>t(l)===i)})).filter(i=>i.sessions.length>0)}function m1(s,t){return s.filter(i=>t.includes(i))}function A4(s,t){const i=m1(t,s);return i.length?s.filter(a=>i.includes(a)):[...s]}function p1(){return o.jsxs("span",{"aria-hidden":!0,className:"relative flex size-[14px] items-center justify-center",children:[o.jsx("span",{className:"absolute inset-[1px] rounded-full border-[1.5px] border-dot-running opacity-30"}),o.jsx("span",{className:"absolute inset-[1px] animate-spin rounded-full border-[1.5px] border-transparent border-t-dot-running opacity-90 [animation-duration:900ms]"}),o.jsx("span",{className:"size-1.5 rounded-full bg-dot-running"})]})}function yh({bucket:s}){const t=s==="running"?"Running":s==="needs_input"?"Waiting for your answer":s==="failed"?"Failed":s==="attention"?"Finished":"Idle";return o.jsxs("span",{className:"flex h-5 w-4 shrink-0 items-center justify-center",title:t,"data-status":s,children:[s==="running"?o.jsx(p1,{}):s==="needs_input"?o.jsx(si,{"aria-hidden":!0,className:"size-3 fill-dot-warning text-sidebar"}):o.jsx("span",{"aria-hidden":!0,className:I("size-1.5 rounded-full",s==="failed"?"bg-dot-danger":s==="attention"?"bg-dot-success":"bg-extra-muted opacity-30")}),o.jsx("span",{className:"sr-only",children:t})]})}function C4({workspaceId:s,managed:t,online:i,open:a,onClose:l}){const u=Oe(),[d,h]=b.useState(!1),m=R=>{l()},[p,x]=b.useState([]),[y,w]=b.useState(""),[k,j]=b.useState(""),S=async()=>{if(j(""),!t){h(!0);try{const R=await u.worktreeOptions(s);x(R),w(R[0]??"")}catch(R){j(R instanceof Error?R.message:String(R))}finally{h(!1)}}},A=async()=>{h(!0);try{await u.mutateWorktree(t?"remove":"create",s,t?void 0:y)?(m(!1),j("")):j("The operation is not confirmed. Retry to reconcile.")}finally{h(!1)}};return b.useEffect(()=>{a&&S()},[a]),o.jsxs(ai,{open:a,onClose:()=>{d||m()},title:t?"Remove managed worktree":"Create managed worktree",children:[o.jsx("p",{children:t?"Delete this checkout’s files. Its Git branch remains. Saved sessions, active work, claims, leases, results and dirty files prevent removal.":"Create a clean checkout from the current committed HEAD in a host-approved destination."}),t?null:p.length?o.jsxs("label",{className:"mt-2 block",children:["Destination",o.jsx("select",{"aria-label":"Worktree destination",className:"mt-1 w-full rounded border border-border bg-background p-1",value:y,onChange:R=>w(R.target.value),children:p.map(R=>o.jsx("option",{children:R},R))})]}):o.jsx("p",{className:"mt-2",children:d?"Loading destinations…":"Ask the host owner to configure a destination mapping and grant its ID to this credential."}),k?o.jsx("p",{role:"alert",className:"mt-2",children:k}):null,o.jsxs("div",{className:"mt-3 flex gap-3",children:[o.jsx("button",{type:"button",disabled:d||!i||!t&&!y,onClick:()=>{A()},children:d?"Working…":t?"Delete checkout files":"Create checkout"}),o.jsx("button",{type:"button",disabled:d,onClick:()=>m(),children:"Cancel"})]})]})}const Ry=["#7a6aa8","#3d7ea6","#388068","#a4673a","#b05c80","#6a70b8","#368080","#b06260","#8f7838","#5179b0"];function E4(s){let t=0;for(const i of s)t=t*31+i.charCodeAt(0)>>>0;return Ry[t%Ry.length]}const Dn="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",Ql="hover:bg-sidebar-hover active:bg-secondary",M4="https://github.com/phucanh08/alp/issues/new",z4="https://github.com/phucanh08/alp/releases";function ql({icon:s,label:t,onClick:i,disabled:a,title:l,active:u,shortcut:d,testId:h}){return o.jsx("div",{className:"px-2",children:o.jsxs("button",{type:"button",onClick:i,disabled:a,title:l,"aria-current":u?"page":void 0,"data-testid":h,className:I("group flex min-h-9 w-full items-center gap-2 rounded-lg px-2 py-1 md:min-h-7 text-left text-sm text-muted-foreground hover:text-foreground disabled:pointer-events-none disabled:opacity-45",Ql,u&&"bg-sidebar-hover text-foreground",Dn),children:[o.jsx(s,{"aria-hidden":!0,className:"size-[18px] shrink-0 md:size-3.5"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),d?o.jsx("kbd",{"aria-hidden":!0,className:"hidden rounded-md bg-secondary/50 px-1 py-px font-sans text-[length:calc(11px*var(--ui-scale))] leading-4 text-muted-foreground md:group-hover:inline",children:d}):null]})})}function R4({query:s,onQuery:t,open:i,onOpen:a,onClose:l,focusRequest:u,shortcut:d}){const h=b.useRef(null);return b.useEffect(()=>{i&&h.current?.focus()},[i,u]),i?o.jsx("div",{className:"px-2",children:o.jsxs("div",{className:"flex min-h-9 w-full items-center gap-2 rounded-lg bg-sidebar-hover px-2 py-1 md:min-h-7 focus-within:ring-1 focus-within:ring-border",children:[o.jsx(ti,{"aria-hidden":!0,className:"size-[18px] shrink-0 text-foreground md:size-3.5"}),o.jsx("input",{ref:h,type:"search",value:s,onChange:m=>t(m.target.value),"aria-label":"Search sessions",placeholder:"Search sessions…",onKeyDown:m=>{m.key==="Escape"&&(m.preventDefault(),l())},onBlur:()=>{s.trim()||l()},className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden"}),o.jsx("button",{type:"button","aria-label":"Clear search",title:"Clear search",onMouseDown:m=>m.preventDefault(),onClick:l,className:I("-mr-1 flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-secondary hover:text-foreground",Dn),children:o.jsx(en,{"aria-hidden":!0,className:"size-3.5"})})]})}):o.jsx(ql,{icon:ti,label:"Search",onClick:a,shortcut:d})}function bh(s,t,i){return m4({status:s.status,waiting:t,reason:i})}function Zd({title:s,children:t,testId:i}){return o.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-2 pl-2 pr-1 md:min-h-9","data-testid":i,children:[o.jsx("h2",{className:"select-none text-xs text-muted-foreground",children:s}),t]})}function _4({session:s,title:t,meta:i,trailing:a,bucket:l,selected:u,canWrite:d,onSelect:h,onRename:m,onArchive:p}){const[x,y]=b.useState(!1),w=s.status==="closed"?"Closed":`Updated ${Ri(s.updatedAt??s.createdAt)}`;return o.jsxs("li",{className:I("group relative mb-0.5 rounded-lg",u?"bg-sidebar-selected":"hover:bg-sidebar-hover active:bg-secondary",x&&!u&&"bg-sidebar-hover"),children:[o.jsxs("button",{type:"button",onClick:h,"aria-current":u?"true":void 0,"data-testid":"session-row",title:`${t} · ${w}`,className:I("flex min-h-11 w-full min-w-0 items-start gap-2 rounded-lg py-2 pl-4 pr-3 text-left md:min-h-9",d&&"max-md:pr-8",Dn),children:[o.jsx(yh,{bucket:l}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx("span",{className:I("min-w-0 flex-1 truncate text-sm leading-5 text-foreground",u||x?"opacity-100":"opacity-[0.76] group-hover:opacity-100"),children:t}),a?o.jsx("span",{className:I("shrink-0 text-xs text-muted-foreground tabular-nums",d&&"md:group-hover:invisible",x&&"invisible"),"data-testid":"sidebar-workspace-timestamp",children:a}):null]}),i.length?o.jsx("span",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground","data-testid":"sidebar-row-meta",children:i.map(k=>o.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1","data-meta":k.key,children:[o.jsx(k.icon,{"aria-hidden":!0,className:"size-3 shrink-0"}),o.jsx("span",{className:"truncate",children:k.text})]},k.key))}):null]})]}),d?o.jsxs("div",{className:I("absolute right-[5px] top-[13px] flex opacity-100 md:top-[9px] md:opacity-0 group-hover:opacity-100 group-focus-within:opacity-100",x&&"opacity-100"),children:[o.jsx("span",{"aria-hidden":!0,className:I("pointer-events-none absolute inset-y-0 right-full hidden w-6 bg-linear-to-r md:block from-transparent",u?"to-sidebar-selected":"to-sidebar-hover")}),o.jsx(Kt,{label:`Actions for ${t}`,onOpenChange:y,trigger:o.jsx(_S,{"aria-hidden":!0,className:"size-3.5"}),triggerClassName:I("flex size-[18px] items-center justify-center rounded text-muted-foreground hover:bg-secondary hover:text-foreground",u?"bg-sidebar-selected":"bg-sidebar-hover",Dn),items:[{label:"Rename",icon:o.jsx(Ui,{"aria-hidden":!0}),onSelect:m},{label:"Archive",icon:o.jsx(ac,{"aria-hidden":!0}),onSelect:p,destructive:!0}]})]}):null]})}function L4({path:s,name:t,worktree:i,expanded:a,canWrite:l,actions:u,onToggle:d,onNewSession:h}){const[m,p]=b.useState(!1);return o.jsxs("div",{className:I("group relative mb-1 flex min-h-11 items-center rounded-lg md:min-h-9",Ql,m&&"bg-sidebar-hover"),children:[o.jsxs("button",{type:"button",onClick:d,"aria-expanded":a,title:s,"data-testid":"project-row","data-workspace":s,className:I("flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-lg p-2 pr-16 text-left md:min-h-9",Dn),children:[o.jsxs("span",{"aria-hidden":!0,className:"flex h-5 w-4 shrink-0 items-center justify-center",children:[i?o.jsx(Qs,{className:"size-3.5 text-muted-foreground group-hover:hidden group-focus-within:hidden"}):o.jsx("span",{className:"flex size-4 items-center justify-center rounded-[4px] text-[length:calc(9px*var(--ui-scale))] font-medium leading-none text-white group-hover:hidden group-focus-within:hidden",style:{backgroundColor:E4(s)},children:t.slice(0,1).toUpperCase()}),o.jsx("span",{className:I("hidden size-3.5 text-muted-foreground group-hover:block group-focus-within:block transition-transform",a?"rotate-90":""),children:"›"})]}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-muted-foreground",children:t})]}),o.jsxs("div",{className:I("absolute right-1.5 flex items-center gap-0.5 md:opacity-0 group-hover:opacity-100 group-focus-within:opacity-100",m&&"opacity-100"),children:[u.length?o.jsx(Kt,{label:`Project actions for ${t}`,title:"Project actions",onOpenChange:p,testId:"project-actions",trigger:o.jsx(sh,{"aria-hidden":!0,className:"size-[15px]"}),items:u,triggerClassName:I("flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground",Dn)}):null,l?o.jsx("button",{type:"button",onClick:h,"aria-label":`Start a session in ${t}`,title:`New session in ${t}`,className:I("flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground",Dn),children:o.jsx(ks,{"aria-hidden":!0,className:"size-[15px]"})}):null]})]})}const zf=I("relative flex size-11 items-center justify-center rounded-md text-muted-foreground hover:text-foreground md:size-7 [&_svg]:size-5 md:[&_svg]:size-4",Dn);function Jd({label:s,title:t,onClick:i,children:a,testId:l}){return o.jsx("button",{type:"button","aria-label":s,title:t??s,onClick:i,"data-testid":l,className:zf,children:a})}function O4({display:s,projects:t,onChange:i}){const a=m1(s.projectFilters,t),l=h=>i({projectFilters:a.includes(h)?a.filter(m=>m!==h):[...a,h]}),u={grouping:{title:"Grouping",items:[{label:"Project",icon:o.jsx(Da,{"aria-hidden":!0}),checked:s.grouping==="project",onSelect:()=>i({grouping:"project"}),testId:"sidebar-grouping-project"},{label:"Status",icon:o.jsx(t0,{"aria-hidden":!0}),checked:s.grouping==="status",onSelect:()=>i({grouping:"status"}),testId:"sidebar-grouping-status"}]},sort:{title:"Sort",items:[{label:"Created",checked:s.sort==="created",onSelect:()=>i({sort:"created"}),testId:"sidebar-sort-created"},{label:"Last prompt",checked:s.sort==="lastPrompt",onSelect:()=>i({sort:"lastPrompt"}),testId:"sidebar-sort-lastPrompt"}]},titleSource:{title:"Title",items:[{label:"Title",icon:o.jsx(hN,{"aria-hidden":!0}),checked:s.titleSource==="title",onSelect:()=>i({titleSource:"title"}),testId:"sidebar-workspace-title-source-title"},{label:"Branch name",icon:o.jsx(Qs,{"aria-hidden":!0}),checked:s.titleSource==="branch",onSelect:()=>i({titleSource:"branch"}),testId:"sidebar-workspace-title-source-branch"}]},show:{title:"Show",items:[...[["branch","Branch",Qs],["project","Project",Da],["host","Host",Qr],["labels","Labels",h0]].map(([h,m,p])=>({label:m,icon:o.jsx(p,{"aria-hidden":!0}),checked:s.rowItems[h],keepOpen:!0,testId:`sidebar-row-item-${h}`,onSelect:()=>i({rowItems:{...s.rowItems,[h]:!s.rowItems[h]}})})),{label:"Last activity",icon:o.jsx(ES,{"aria-hidden":!0}),checked:s.trailing==="timestamp",keepOpen:!0,group:!0,testId:"sidebar-workspace-trailing-timestamp",onSelect:()=>i({trailing:s.trailing==="timestamp"?"none":"timestamp"})}]},projectFilter:{title:"Project",items:[{label:"All projects",checked:a.length===0,keepOpen:!0,onSelect:()=>i({projectFilters:[]}),testId:"sidebar-project-filter-all"},...t.map((h,m)=>({id:h,label:Dt(h),title:h,checked:a.includes(h),keepOpen:!0,group:m===0,onSelect:()=>l(h),testId:"sidebar-project-filter-item"}))]}},d=[{label:"Grouping",page:"grouping",value:s.grouping==="project"?"Project":"Status",onSelect:()=>{},testId:"sidebar-display-grouping"},...s.grouping==="project"?[{label:"Sort",page:"sort",value:s.sort==="created"?"Created":"Last prompt",onSelect:()=>{},testId:"sidebar-display-sort"}]:[],{label:"Title",page:"titleSource",value:s.titleSource==="title"?"Title":"Branch name",onSelect:()=>{},testId:"sidebar-display-title-source"},{label:"Show",page:"show",onSelect:()=>{},testId:"sidebar-display-show"},...t.length>1?[{label:"Project",page:"projectFilter",indicator:a.length>0,group:!0,onSelect:()=>{},testId:"sidebar-display-project-filter"}]:[]];return o.jsx(Kt,{label:"Display preferences",align:"end",width:232,items:d,pages:u,testId:"sidebar-display-preferences-menu",trigger:o.jsx(iN,{"aria-hidden":!0,className:"size-3.5"}),triggerClassName:I("flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-sidebar-hover hover:text-foreground",Dn)})}function D4({open:s,onClose:t,unregistered:i}){const a=Oe(),{principal:l,connection:u,registry:d}=Ee(),[h,m]=b.useState("");b.useEffect(()=>{s&&m(i[0]??"")},[s]);const p=Te(l??void 0,"workspace.write"),x=u.capabilities.includes("workspace.registry"),y=async()=>{h&&(await a.registerProject(h),t())};return o.jsx(ai,{open:s,onClose:t,title:"Add project",description:"A project is a directory the host owner granted to this access token. Adding it puts it in the host's shared workspace list. For another directory, the owner grants it first (alp-gateway credential create --workspace).",footer:x&&p&&i.length?o.jsxs(o.Fragment,{children:[o.jsx(we,{variant:"ghost",onClick:t,children:"Cancel"}),o.jsx(we,{disabled:!h||u.phase!=="open"||!!d.loading,onClick:()=>{y()},children:"Register project"})]}):o.jsx(we,{variant:"secondary",onClick:t,children:"Close"}),children:x?p?i.length?o.jsxs("label",{className:"flex flex-col gap-1 text-sm",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Existing granted directory"}),o.jsx("select",{"aria-label":"Existing granted directory",value:h,onChange:w=>m(w.target.value),className:"w-full rounded-md border border-input bg-background p-2 text-sm",children:i.map(w=>o.jsx("option",{value:w,children:w},w))})]}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"Every directory this token grants is already a project."}):o.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Ask the host owner to add workspace.write to your credential."}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"This host does not list its workspaces. Update ALP on the host."})})}function q4({row:s,onClose:t}){const i=Oe(),[a,l]=b.useState("");b.useEffect(()=>{l(s?.title??"")},[s]);const u=async()=>{s&&await i.renameWorkspace(s.id,a)&&t()};return o.jsx(ai,{open:!!s,onClose:t,title:"Rename workspace",footer:o.jsxs(o.Fragment,{children:[o.jsx(we,{variant:"ghost",onClick:t,children:"Cancel"}),o.jsx(we,{onClick:()=>{u()},children:"Rename"})]}),children:o.jsx("form",{onSubmit:d=>{d.preventDefault(),u()},children:o.jsx(Zn,{"aria-label":"Workspace name",value:a,maxLength:200,placeholder:s?Dt(s.directory):"",onChange:d=>l(d.target.value),autoFocus:!0})})})}function B4({onNewSession:s,onRename:t,onArchive:i,onSettings:a,onShortcuts:l,onNavigate:u,onClose:d,onHistory:h,historyOpen:m,onTasks:p,tasksOpen:x,onOpenSession:y,searchRequest:w,onSearchRequestHandled:k}){const j=Oe(),S=Ee(),{principal:A,workspace:R,sessions:q,selected:O,connection:L,preferences:B}=S,_=B.sidebarDisplay,Q=b.useMemo(()=>ho(),[]),[C,Y]=b.useState(!1),[H,fe]=b.useState(!1),[ee,xe]=b.useState(""),[re,de]=b.useState({}),[U,Z]=b.useState(!1),[oe,ge]=b.useState(null),[T,z]=b.useState(null),F=Te(A??void 0,"session.write"),J=Te(A??void 0,"workspace.write"),le=L.capabilities.includes("workspace.worktree")&&Te(A??void 0,"workspace.manage"),ne=L.phase==="open",ce=S.registry,ve=E=>ce.workspaces.filter(V=>!V.archivedAt&&(V.directory===E||A?.workspaceRoots?.some(ue=>ue.path===E&&ue.canonical===V.directory))).sort((V,ue)=>V.createdAt.localeCompare(ue.createdAt)||V.id.localeCompare(ue.id)),Re=[...new Set([...A?.workspaces??[],...ce.workspaces.filter(E=>E.managedWorktree&&!E.archivedAt).map(E=>E.directory)])],Me=A4(Re,_.projectFilters),Qe=Me.filter(E=>!!ve(E)[0]?.pinnedAt),Ue=Me.filter(E=>!Qe.includes(E)),et=(A?.workspaces??[]).filter(E=>!ve(E).length),Fe=ee.trim().toLowerCase(),be=E=>!Fe||Wn(E).toLowerCase().includes(Fe),[ye,Ae]=b.useState({}),Ne=Re.filter(E=>E!==R).join(`
28
+ `);b.useEffect(()=>{if(_.grouping!=="status"||!ne)return;let E=!0;const V=()=>{j.listWorkspaceSessions(Ne?Ne.split(`
29
+ `):[]).then(he=>{E&&Ae(he)})};V();const ue=setInterval(V,15e3);return()=>{E=!1,clearInterval(ue)}},[j,_.grouping,ne,Ne]);const Ht=E=>j.updatePreferences({sidebarDisplay:{..._,...E}}),cn=E=>{if(E===R){Y(V=>!V);return}Y(!1),j.selectWorkspace(E)},ze=E=>{E!==R&&(Y(!1),j.selectWorkspace(E)),s(),u()},ut=(E,V)=>{E!==R&&j.selectWorkspace(E),j.selectSession(V),y(),u()},At=()=>{xe(""),fe(!1)},[Rt,In]=b.useState(0);b.useEffect(()=>{w&&(fe(!0),Y(!1),In(E=>E+1),k?.())},[w]);const kn=L.hostname??L.gateway.replace(/^https?:\/\//,""),Qt=(E,V)=>{navigator.clipboard?.writeText(E).then(()=>j.notify("info",`${V} copied`),()=>j.notify("error",`Could not copy the ${V.toLowerCase()}.`))},Je=E=>ve(E)[0],jt=E=>Je(E)?.title||Dt(E),St=(E,V)=>{const ue=Je(E),he=ue?.branch||void 0,pe=[];return _.rowItems.branch&&he&&pe.push({key:"branch",icon:Qs,text:he}),_.rowItems.project&&pe.push({key:"project",icon:Da,text:jt(E)}),_.rowItems.host&&pe.push({key:"host",icon:Qr,text:kn}),_.rowItems.labels&&ue?.labels.length&&pe.push({key:"labels",icon:h0,text:ue.labels.join(", ")}),{title:_.titleSource==="branch"&&he?he:Wn(V),meta:pe,trailing:_.trailing==="timestamp"?S3(V.updatedAt??V.createdAt):""}},un=E=>bh(E,ic(S,E.id),ao(S,E.id)),Gn=(E,V)=>{const ue=St(E,V);return o.jsx(_4,{session:V,title:ue.title,meta:ue.meta,trailing:ue.trailing,selected:V.id===O&&!m,canWrite:F,bucket:un(V),onSelect:()=>ut(E,V.id),onRename:()=>t(V),onArchive:()=>i(V)},V.id)},js=E=>{const V=Je(E),ue=[];if(V){const he=J?void 0:"Ask the host owner for workspace.write to change shared pins and names.";ue.push({label:V.pinnedAt?"Unpin":"Pin to top",icon:V.pinnedAt?o.jsx(JS,{"aria-hidden":!0}):o.jsx(u0,{"aria-hidden":!0}),disabled:!J||!ne,title:he,onSelect:()=>{j.pinWorkspace(V.id,!V.pinnedAt)},testId:V.pinnedAt?"project-unpin":"project-pin"},{label:"Rename workspace",icon:o.jsx(Ui,{"aria-hidden":!0}),disabled:!J||!ne,title:he,onSelect:()=>ge(V),testId:"project-rename"})}else L.capabilities.includes("workspace.registry")&&J&&(A?.workspaces??[]).includes(E)&&ue.push({label:"Add to projects",icon:o.jsx(cy,{"aria-hidden":!0}),disabled:!ne,onSelect:()=>{j.registerProject(E)},testId:"project-register"});return ue.push({label:"Copy path",icon:o.jsx(ws,{"aria-hidden":!0}),group:ue.length>0,onSelect:()=>Qt(E,"Path"),testId:"project-copy-path"}),V?.branch&&ue.push({label:"Copy branch name",icon:o.jsx(Qs,{"aria-hidden":!0}),onSelect:()=>Qt(V.branch,"Branch name"),testId:"project-copy-branch"}),V&&le&&ue.push({label:V.managedWorktree?"Remove worktree":"Create worktree",icon:o.jsx(Qs,{"aria-hidden":!0}),group:!0,disabled:!ne,onSelect:()=>z({row:V}),testId:V.managedWorktree?"project-remove-worktree":"project-create-worktree"}),ue.push({label:"Open project settings",icon:o.jsx(DS,{"aria-hidden":!0}),group:!0,onSelect:()=>a("projects"),testId:"project-settings"}),ue},dn=E=>{const V=E===R&&(!C||!!Fe),ue=Je(E),he=zy(q.list.filter(be),_.sort),pe=N4(he,!!re[E]||!!Fe,un);return o.jsxs("div",{className:I(V&&"pb-3"),"data-testid":"sidebar-project","data-path":E,"data-workspace-id":ue?.id,"data-pinned":ue?.pinnedAt?"true":void 0,"data-branch":ue?.branch??void 0,"data-worktree":ue?.managedWorktree?"true":void 0,children:[o.jsx(L4,{path:E,name:jt(E),worktree:!!ue?.managedWorktree,expanded:V,canWrite:F&&ne,actions:js(E),onToggle:()=>cn(E),onNewSession:()=>ze(E)}),V?o.jsxs("div",{children:[q.status==="loading"&&!q.list.length?o.jsx("div",{className:"py-2 pl-4",children:o.jsx(Ft,{label:"Loading sessions…",className:"text-xs"})}):null,q.status==="error"?o.jsxs("div",{className:"mx-1 mb-1 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs text-destructive",role:"alert",children:[q.error?.message," ",o.jsx("button",{type:"button",className:"text-highlight underline-offset-4 hover:underline",onClick:()=>{j.refreshSessions()},children:"Try again"})]}):null,q.status==="ready"&&!q.list.length?F&&ne?o.jsxs("button",{type:"button",onClick:()=>ze(E),"aria-label":`Start a session in ${jt(E)}`,className:I("group mb-0.5 flex min-h-11 w-full items-center md:min-h-9 gap-2 rounded-lg py-2 pl-4 pr-3 text-left text-sm text-muted-foreground hover:text-foreground",Ql,Dn),children:[o.jsx("span",{className:"flex h-5 w-4 shrink-0 items-center justify-center",children:o.jsx(ks,{"aria-hidden":!0,className:"size-3.5"})}),o.jsx("span",{className:"truncate",children:"New session"})]}):o.jsx("p",{className:"flex min-h-9 items-center py-2 pl-10 pr-3 text-sm text-muted-foreground",children:"No sessions yet"}):null,Fe&&q.list.length&&!he.length?o.jsxs("p",{className:"flex min-h-9 items-center py-2 pl-10 pr-3 text-sm text-muted-foreground",children:["No sessions match “",ee.trim(),"”"]}):null,o.jsx("ul",{children:pe.visible.map($e=>Gn(E,$e))}),pe.canToggle||re[E]?o.jsx("button",{type:"button",onClick:()=>de($e=>({...$e,[E]:!$e[E]})),"data-testid":"sidebar-show-more",className:I("flex min-h-9 w-full items-center rounded-lg py-1 pl-10 pr-3 text-left text-xs text-muted-foreground hover:text-foreground",Ql,Dn),children:re[E]?"Show less":"Show more"}):null]}):null]},E)},fn=()=>{const E=[...R?q.list.map(he=>({path:R,session:he})):[],...Object.entries(ye).filter(([he])=>Me.includes(he)&&he!==R).flatMap(([he,pe])=>pe.map($e=>({path:he,session:$e})))].filter(he=>Me.includes(he.path)&&be(he.session)),V=zy(E.map(he=>he.session),"lastPrompt").map(he=>E.find(pe=>pe.session===he)),ue=T4(V.map(he=>he.session),un);return ue.length?ue.map(he=>o.jsxs("div",{"data-testid":`sidebar-status-${he.bucket}`,children:[o.jsx(Zd,{title:he.label}),o.jsx("ul",{children:he.sessions.map(pe=>{const $e=V.find(We=>We.session===pe);return Gn($e.path,pe)})})]},he.bucket)):o.jsx("p",{className:"px-2 py-3 text-sm text-muted-foreground",children:Fe?`No sessions match “${ee.trim()}”`:"No sessions yet"})},Ct=E=>{switch(E){case"new-session":return o.jsx(ql,{icon:ks,label:"New session",onClick:()=>{s(),u()},disabled:!R||!F||!ne,title:F?void 0:"Your access token cannot start sessions.",shortcut:Pl("session.new",Q)});case"history":return o.jsx(ql,{icon:cc,label:"History",onClick:()=>{h(),u()},active:m,disabled:!R,testId:"sidebar-history"});case"search":return o.jsx(R4,{query:ee,onQuery:xe,open:H,onOpen:()=>{fe(!0),Y(!1)},onClose:At,focusRequest:Rt});case"tasks":return o.jsx(ql,{icon:oh,label:"Tasks",onClick:()=>{p?.(),u()},active:x,disabled:!R||!p,testId:"sidebar-tasks"})}},jn=B.sidebar.footer.filter(E=>E.visible);return o.jsxs("nav",{"aria-label":"Workspaces and sessions",className:"relative flex h-full min-h-0 flex-col bg-sidebar",children:[o.jsx("div",{className:"flex shrink-0 flex-col gap-0.5 border-b border-border pb-1.5 pt-2",children:B.sidebar.header.filter(E=>E.visible).map(E=>o.jsx(b.Fragment,{children:Ct(E.id)},E.id))}),d?o.jsx("button",{type:"button","aria-label":"Close sessions",onClick:d,className:I("absolute right-[9.5px] top-3 z-10 flex size-8 items-center justify-center rounded-lg bg-sidebar text-muted-foreground hover:text-foreground",Dn),children:o.jsx(en,{"aria-hidden":!0,className:"size-4"})}):null,o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 pb-4 pt-0.5",children:[_.grouping==="project"&&Qe.length?o.jsxs("div",{"data-testid":"sidebar-pinned",children:[o.jsx(Zd,{title:"Pinned",testId:"sidebar-pinned-header"}),Qe.map(dn)]}):null,o.jsx(Zd,{title:"Workspaces",children:o.jsx(O4,{display:_,projects:Re,onChange:Ht})}),ce.error?o.jsxs("p",{role:"alert",className:"px-2 pb-2 text-xs text-destructive",children:[ce.error," ",o.jsx("button",{type:"button",className:"underline",onClick:()=>{j.refreshRegistry()},children:"Retry"})]}):null,Re.length?_.grouping==="status"?fn():Ue.map(dn):o.jsxs("div",{className:"mt-1 px-2 py-3 text-sm","data-testid":"sidebar-no-projects",children:[o.jsx("p",{className:"text-foreground",children:"No projects yet"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This access token grants no workspace. The host owner adds one with alp-gateway credential create --workspace."})]})]}),jn.length?o.jsx("div",{className:"flex shrink-0 flex-col gap-0.5 border-t border-border py-1.5","data-testid":"sidebar-footer-items",children:jn.map(E=>o.jsx(b.Fragment,{children:Ct(E.id)},E.id))}):null,o.jsxs("div",{className:"flex shrink-0 items-center border-t border-border px-2 py-1.5","data-testid":"sidebar-footer-bottom-line",children:[o.jsx(Jd,{label:"Add project",onClick:()=>Z(!0),testId:"sidebar-add-project",children:o.jsx(cy,{"aria-hidden":!0})}),o.jsx(Jd,{label:"Usage",onClick:()=>a("usage"),testId:"sidebar-usage-icon",children:o.jsx(TS,{"aria-hidden":!0})}),o.jsx(Kt,{label:"Hosts",title:`${A?.label??"Access token"} · ${kn}${ne?"":" · reconnecting"}`,align:"start",testId:"sidebar-hosts-trigger",trigger:o.jsxs(o.Fragment,{children:[o.jsx(Qr,{"aria-hidden":!0,className:"!size-[19px] md:!size-[15px]"}),o.jsx("span",{"aria-hidden":!0,className:I("absolute bottom-[11px] right-[11px] size-1.5 md:bottom-[5px] md:right-[5px] rounded-full ring-2 ring-sidebar",ne?"bg-dot-success":"bg-dot-warning")})]}),triggerClassName:zf,items:[{label:kn,icon:o.jsx(Qr,{"aria-hidden":!0}),hint:ne?"Online":"Reconnecting",onSelect:()=>a("host"),testId:"sidebar-host-option"},{label:"Connections",icon:o.jsx(c0,{"aria-hidden":!0}),onSelect:()=>a("connections")},{label:"Disconnect",icon:o.jsx(VS,{"aria-hidden":!0}),destructive:!0,group:!0,onSelect:()=>j.disconnect(),testId:"sidebar-disconnect"}]}),o.jsx("span",{className:"flex-1"}),o.jsx(Kt,{label:"Help and support",align:"start",testId:"sidebar-help-trigger",trigger:o.jsx(AS,{"aria-hidden":!0}),triggerClassName:zf,items:[{label:"Run diagnostics",onSelect:()=>a("diagnostics")},...l?[{label:"Keyboard shortcuts",hint:Pl("shortcuts.toggle",Q)||void 0,onSelect:l}]:[],{label:"Report an issue",group:!0,onSelect:()=>{window.open(M4,"_blank","noopener,noreferrer")}},{label:"What's new",onSelect:()=>{window.open(z4,"_blank","noopener,noreferrer")}}]}),o.jsx(Jd,{label:"Settings",onClick:()=>a(),testId:"sidebar-settings",children:o.jsx(ch,{"aria-hidden":!0})})]}),o.jsx(D4,{open:U,onClose:()=>Z(!1),unregistered:et}),o.jsx(q4,{row:oe,onClose:()=>ge(null)}),T?o.jsx(C4,{workspaceId:T.row.id,managed:!!T.row.managedWorktree,online:ne,open:!0,onClose:()=>z(null)}):null]})}const $4=6e3,Wr=()=>typeof window<"u"&&"Notification"in window;function U4(){const[s,t]=b.useState(()=>Wr()?Notification.permission:"unsupported");b.useEffect(()=>{if(!Wr())return;const a=()=>t(Notification.permission);return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[]);const i=b.useCallback(async()=>{if(Wr())try{t(await Notification.requestPermission())}catch{t(Notification.permission)}},[]);return{permission:s,request:i}}function H4({onOpenSession:s}){const t=Ee(),i=Oe(),{workspace:a,sessions:l,tree:u,attention:d,selected:h,focus:m}=t,p=b.useMemo(()=>fS(t),[t.turnAttention,l,u]);b.useEffect(()=>{const O=()=>i.setPresence({visible:document.visibilityState==="visible",focused:document.hasFocus()});return O(),window.addEventListener("focus",O),window.addEventListener("blur",O),document.addEventListener("visibilitychange",O),()=>{window.removeEventListener("focus",O),window.removeEventListener("blur",O),document.removeEventListener("visibilitychange",O)}},[i]);const x=p4(l.list.map(O=>bh(O,ic(t,O.id),ao(t,O.id))),Object.keys(p).length>0);b.useEffect(()=>{let O=document.querySelector('link[rel="icon"]');O||(O=document.createElement("link"),O.rel="icon",document.head.append(O)),O.type="image/svg+xml",O.href=Ml[x],O.dataset.status=x},[x]),b.useEffect(()=>()=>{const O=document.querySelector('link[rel="icon"]');O&&(O.href=Ml.none,O.dataset.status="none")},[]);const y=u?.rootId,w=y?l.list.find(O=>O.id===y):void 0,k=y?Wn({id:y,title:u?.projection.sessions[y]?.title??w?.title}):a?Dt(a):"ALP";b.useEffect(()=>(document.title=k,()=>{document.title="ALP"}),[k]);const j=b.useRef({attention:d,live:{}}),S=b.useMemo(()=>{const O=j.current;O.attention!==d&&(O.live={}),O.attention=d;const L={...d};for(const[B,_]of Object.entries(O.live))L[B]=Math.max(L[B]??0,_);if(u){const B=Object.keys(u.projection.questions).length;L[u.rootId]=u.status==="attached"?B:Math.max(B,d[u.rootId]??0),u.status==="attached"&&(O.live[u.rootId]=B)}return L},[d,u]),A=b.useRef({workspace:null,since:Date.now(),counts:{}}),R=b.useRef(s);R.current=s,b.useEffect(()=>{const O=A.current;if(O.workspace!==a){A.current={workspace:a,since:Date.now(),counts:S};return}const L=y4(O.counts,S);if(O.counts=S,!L.length||!Wr()||Notification.permission!=="granted")return;const B=Date.now()-O.since<$4,_={visible:document.visibilityState==="visible",focused:document.hasFocus(),shown:m??h};for(const Q of L){const Y=(u?.rootId===Q?Object.values(u.projection.questions):[]).sort((fe,ee)=>(Date.parse(ee.askedAt??"")||0)-(Date.parse(fe.askedAt??"")||0))[0];if(B&&!(Y&&(Date.parse(Y.askedAt??"")||0)>=O.since)||Cy(_,Q)||Y?.sessionId&&Cy(_,Y.sessionId))continue;const H=Wn(l.list.find(fe=>fe.id===Q)??{id:Q,title:u?.rootId===Q?u.projection.sessions[Q]?.title:void 0});try{const fe=new Notification("Agent needs attention",{body:`${H}: ${Y?.body?l1(Y.body):"Waiting for your answer."}`,tag:`alp-question-${Q}`,icon:Ml.attention});fe.onclick=()=>{window.focus(),R.current(Q),fe.close()}}catch{}}},[S,a,u,l,h,m]);const q=b.useRef({workspace:a,entries:p});b.useEffect(()=>{const O=q.current,L=O.workspace===a?x4(O.entries,p):[];if(q.current={workspace:a,entries:p},!(!L.length||!Wr()||Notification.permission!=="granted"))for(const B of L){const _=p[B];if(!_)continue;const Q=Wn(l.list.find(fe=>fe.id===B)??{id:B,title:u?.rootId===B?u.projection.sessions[B]?.title:void 0}),{title:C,body:Y,tag:H}=g4({root:B,name:Q,reason:_.reason,message:_.message});try{const fe=new Notification(C,{body:Y,tag:H,icon:Ml.attention});fe.onclick=()=>{window.focus(),R.current(B),fe.close()}}catch{}}},[p,a,l,u])}const g1=[{id:"general",label:"General",icon:ch},{id:"appearance",label:"Appearance",icon:QS},{id:"sidebar",label:"Sidebar",icon:$a},{id:"chat",label:"Chat",icon:FS},{id:"terminal",label:"Terminal",icon:hc},{id:"editor",label:"Editor",icon:MS},{id:"files",label:"Files",icon:ah},{id:"diagnostics",label:"Diagnostics",icon:dN},{id:"about",label:"About",icon:rh}],x1=[{id:"host",label:"Overview",icon:Qr},{id:"projects",label:"Projects",icon:ly},{id:"connections",label:"Connections",icon:c0},{id:"pair-device",label:"Pair device",icon:oN},{id:"alp-templates",label:"Templates",icon:Yl},{id:"alp-agents",label:"Agents",icon:Oa},{id:"alp-skills",label:"Skills",icon:jS},{id:"alp-hooks",label:"Hooks",icon:mN},{id:"alp-mcp",label:"MCP servers",icon:tN},{id:"metadata",label:"Metadata",icon:cN},{id:"voice",label:"Voice",icon:XS},{id:"workspaces",label:"Workspaces",icon:ly},{id:"providers",label:"Providers",icon:SS},{id:"usage",label:"Usage",icon:BS},{id:"terminals",label:"Terminals",icon:hc},{id:"plugins",label:"Plugins",icon:kS}],I4=Object.fromEntries([...g1,...x1].map(s=>[s.id,s.label])),G4={"new-session":{label:"New session",icon:ks},history:{label:"History",icon:cc},search:{label:"Search",icon:ti},tasks:{label:"Tasks",icon:oh}},Y4="Readable **content** and `code` preview.\n\n```ts\n// The highlight theme, code font and code size\nexport function greet(name: string): string {\n return `Hello, ${name}!`;\n}\n```";function V4(){return o.jsx("section",{className:"mb-6 rounded-lg border border-border bg-background p-4","aria-label":"Live preview of content typography, syntax theme, and code font","data-testid":"appearance-preview",children:o.jsx(fo,{text:Y4})})}const yc="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset";function rt({title:s,action:t,children:i}){return o.jsxs("section",{className:"mb-6",children:[s||t?o.jsxs("div",{className:"mb-3 ml-1 flex items-center justify-between gap-2",children:[s?o.jsx("h3",{className:"text-xs font-normal text-muted-foreground",children:s}):o.jsx("span",{}),t]}):null,o.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-card",children:i})]})}function He({title:s,hint:t,children:i,first:a}){return o.jsxs("div",{className:I("flex flex-wrap items-center justify-between gap-3 p-4",!a&&"border-t border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm text-foreground",children:s}),t?o.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:t}):null]}),i!==void 0?o.jsx("div",{className:"min-w-0 max-w-full text-sm text-muted-foreground",children:i}):null]})}function ln({what:s,why:t}){return o.jsx(rt,{children:o.jsxs("div",{className:"flex items-start gap-3 p-4",role:"note",children:[o.jsx(rc,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),o.jsxs("div",{children:[o.jsxs("p",{className:"text-sm",children:[s," is not available in this beta"]}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t})]})]})})}function La({label:s,value:t,options:i,onChange:a}){return o.jsx(ph,{"aria-label":s,value:t,onChange:l=>a?.(l.target.value),disabled:!a,className:"h-8 w-auto rounded-lg border-border bg-transparent pl-3 text-sm text-foreground disabled:cursor-default disabled:opacity-100",children:i.map(l=>o.jsx("option",{value:l.value,children:l.label},l.value))})}function K4(){const{permission:s,request:t}=U4(),i=s==="unsupported"?"This browser cannot show notifications.":s==="denied"?"Blocked in this browser. Allow notifications for this site in the browser settings to get them.":s==="granted"?"On: a notification when a session waits for your answer while you are elsewhere. The tab icon shows it too.":"Get a notification when a session waits for your answer while you are elsewhere. The browser asks first.";return o.jsx(He,{title:"Notifications",hint:i,children:s==="default"?o.jsx(we,{size:"sm",variant:"secondary",onClick:()=>{t()},children:"Enable"}):o.jsx("span",{className:"text-sm text-muted-foreground","data-testid":"notification-permission",children:s==="granted"?"Allowed":s==="denied"?"Blocked":"Unavailable"})})}function F4(s,t,i){return t==="mod-enter"?s==="interrupt"?`When the agent is running, ${i}+Enter interrupts. Enter inserts a new line.`:s==="queue"?`When the agent is running, ${i}+Enter queues. Enter inserts a new line.`:`When the agent is running, ${i}+Enter steers the active turn. Enter inserts a new line.`:s==="interrupt"?"When the agent is running, Enter interrupts. Command/Ctrl+Enter queues.":s==="queue"?"When the agent is running, Enter queues. Command/Ctrl+Enter submits.":"When the agent is running, Enter steers the active turn. Command/Ctrl+Enter queues."}const _y=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent)?"⌘":"Ctrl";function X4({mobile:s}){const t=Oe(),{preferences:i}=Ee();return o.jsxs(o.Fragment,{children:[o.jsx(rt,{title:"General",children:o.jsx(He,{first:!0,title:"Language",hint:"App language. This beta speaks English; the agents' language is a host setting (Host › Overview).",children:o.jsx(La,{label:"Language",value:"system",options:[{value:"system",label:"System"}]})})}),o.jsxs(rt,{title:"Sending",children:[s?null:o.jsx(He,{first:!0,title:"Send shortcut",children:o.jsx(La,{label:"Send shortcut",value:i.sendShortcut,onChange:a=>t.updatePreferences({sendShortcut:a}),options:[{value:"enter",label:"Enter"},{value:"mod-enter",label:`${_y}+Enter`}]})}),o.jsx(He,{first:s,title:"Default send",hint:F4(i.sendBehavior,s?"enter":i.sendShortcut,_y),children:o.jsx(La,{label:"Default send",value:i.sendBehavior,onChange:a=>t.setSendBehavior(a),options:[{value:"interrupt",label:"Interrupt"},{value:"steer",label:"Steer"},{value:"queue",label:"Queue"}]})})]}),o.jsxs(rt,{title:"This browser",children:[o.jsx(He,{first:!0,title:"Saved settings",hint:"Every App setting and your last New session choices (team, model, thinking, permissions) stay in this browser. The access token never does.",children:o.jsx(we,{size:"sm",variant:"secondary",onClick:()=>t.resetPreferences(),children:"Reset"})}),o.jsx(K4,{})]})]})}function Zr({label:s,value:t,placeholder:i,numeric:a,limits:l,width:u="w-28",onCommit:d}){const[h,m]=b.useState(t);b.useEffect(()=>m(t),[t]);const p=()=>{if(!a||!l){h.trim()!==t?d(h.trim()):m(t);return}const x=Number.parseInt(h,10);if(!Number.isFinite(x)){m(t);return}const y=String(Math.min(l[1],Math.max(l[0],x)));m(y),y!==t&&d(y)};return o.jsx(Zn,{"aria-label":s,value:h,placeholder:i,inputMode:a?"numeric":void 0,onChange:x=>m(a?x.target.value.replace(/[^\d]/g,""):x.target.value),onBlur:p,onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),p())},onFocus:x=>x.target.select(),className:I("h-8",u,a&&"text-right tabular-nums")})}function ef({title:s,hint:t,label:i,value:a,limits:l,onCommit:u}){return o.jsx(He,{title:s,hint:t,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(Zr,{label:i,value:String(a),numeric:!0,limits:l,width:"w-16",onCommit:d=>u(Number(d))}),o.jsx("span",{className:"text-xs",children:"px"})]})})}function P4(){const s=Oe(),{preferences:t}=Ee(),i=Wd.find(a=>a.value===t.theme)?.swatch;return o.jsxs(o.Fragment,{children:[o.jsx(rt,{title:"Theme",children:o.jsx(He,{first:!0,title:"Theme",children:o.jsxs("span",{className:"flex items-center gap-2",children:[i?o.jsx("span",{"aria-hidden":!0,className:"size-3 rounded-full border border-border",style:{backgroundColor:i},"data-testid":"theme-swatch"}):null,o.jsxs(ph,{"aria-label":"Theme",value:t.theme,onChange:a=>s.setTheme(a.target.value),className:"h-8 w-auto rounded-lg border-border bg-transparent pl-3 text-sm text-foreground",children:[Wd.filter(a=>a.group==="primary").map(a=>o.jsx("option",{value:a.value,children:a.label},a.value)),o.jsx("option",{disabled:!0,children:"──────"}),Wd.filter(a=>a.group==="variant").map(a=>o.jsx("option",{value:a.value,children:a.label},a.value))]})]})})}),o.jsxs(rt,{title:"Fonts",children:[o.jsx(He,{first:!0,title:"Interface font",hint:"Used across the app. Leave empty for the system default",children:o.jsx(Zr,{label:"Interface font family",value:t.uiFontFamily,placeholder:Z0,width:"w-64 max-w-full",onCommit:a=>s.updatePreferences({uiFontFamily:a})})}),o.jsx(ef,{title:"Interface size",hint:"Used for navigation, controls, and labels",label:"Interface font size",value:t.uiFontSize,limits:On.uiFontSize,onCommit:a=>s.updatePreferences({uiFontSize:a})}),o.jsx(ef,{title:"Content size",hint:"Used for chat text and rendered Markdown",label:"Content font size",value:t.contentFontSize,limits:On.contentFontSize,onCommit:a=>s.updatePreferences({contentFontSize:a})}),o.jsx(He,{title:"Code font",hint:"Used in code, diffs, and the terminal output. Leave empty for the system default",children:o.jsx(Zr,{label:"Code font family",value:t.monoFontFamily,placeholder:J0,width:"w-64 max-w-full",onCommit:a=>s.updatePreferences({monoFontFamily:a})})}),o.jsx(ef,{title:"Code size",hint:"Used for code, diffs, and terminal output",label:"Code font size",value:t.codeFontSize,limits:On.codeFontSize,onCommit:a=>s.updatePreferences({codeFontSize:a})})]}),o.jsx(rt,{title:"Layout",children:o.jsx(He,{first:!0,title:"Content width",hint:"Max width of chat and Markdown files on wide screens",children:o.jsxs("span",{className:"flex items-center gap-2",children:[t.contentMaxWidth!==null?o.jsx(we,{size:"sm",variant:"ghost","aria-label":"Reset content width to default",onClick:()=>s.updatePreferences({contentMaxWidth:null}),children:"Reset"}):null,o.jsx(Zr,{label:"Content width in pixels",value:String(e1(t)),numeric:!0,limits:On.contentMaxWidth,width:"w-20",onCommit:a=>s.updatePreferences({contentMaxWidth:Number(a)})}),o.jsx("span",{className:"text-xs",children:"px"})]})})}),o.jsx(rt,{title:"Syntax",children:o.jsx(He,{first:!0,title:"Highlight theme",hint:"Colors for code, independent of the app theme",children:o.jsx(La,{label:"Highlight theme",value:t.syntaxTheme,onChange:a=>s.updatePreferences({syntaxTheme:a}),options:X3})})}),o.jsx(V4,{})]})}function Q4(){const s=Oe(),{preferences:t}=Ee(),i=(u,d)=>s.updatePreferences({sidebar:{...t.sidebar,[u]:d}}),a=(u,d,h)=>{const m=[...t.sidebar[u]];[m[d],m[d+h]]=[m[d+h],m[d]],i(u,m)},l=(u,d,h)=>o.jsxs(rt,{title:d,children:[o.jsx("p",{className:"px-4 pt-3 text-xs text-muted-foreground",children:h}),t.sidebar[u].map((m,p,x)=>{const y=G4[m.id];return o.jsxs("div",{className:I("flex items-center gap-2 p-4",p>0&&"border-t border-border"),"data-testid":`sidebar-nav-item-${m.id}`,children:[o.jsx(y.icon,{"aria-hidden":!0,strokeWidth:1.75,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-foreground",children:y.label}),o.jsx(we,{size:"icon",variant:"ghost",className:"size-7","aria-label":`Move ${y.label} up`,disabled:p===0,onClick:()=>a(u,p,-1),children:o.jsx(Dl,{"aria-hidden":!0})}),o.jsx(we,{size:"icon",variant:"ghost",className:"size-7","aria-label":`Move ${y.label} down`,disabled:p===x.length-1,onClick:()=>a(u,p,1),children:o.jsx(vS,{"aria-hidden":!0})}),o.jsx(t1,{checked:m.visible,"aria-label":y.label,onCheckedChange:w=>i(u,x.map(k=>k.id===m.id?{...k,visible:w}:k))})]},m.id)})]});return o.jsxs(o.Fragment,{children:[l("header","Header","Choose which items appear at the top of the sidebar and in what order"),l("footer","Footer","Choose which rows appear at the bottom of the sidebar and in what order. The host and Settings row always shows")]})}function W4(){const s=Oe(),{preferences:t}=Ee();return o.jsxs(o.Fragment,{children:[o.jsxs(rt,{title:"Detail level",children:[o.jsx(He,{first:!0,title:"Chat display",hint:"How much of an agent's work the chat shows",children:o.jsx(La,{label:"Chat display",value:t.chatDisplay,onChange:i=>s.updatePreferences({chatDisplay:i}),options:[{value:"full",label:"Full"},{value:"collapseToolCalls",label:"Collapse tool calls"},{value:"collapseTurns",label:"Collapse turns"}]})}),o.jsx(He,{title:"Chat outline",hint:"Show an outline for jumping between prompts",children:o.jsx(t1,{checked:t.chatOutline,"aria-label":"Chat outline",onCheckedChange:i=>s.updatePreferences({chatOutline:i})})})]}),o.jsx(ln,{what:"Always expand reasoning",why:"ALP's hosts do not send the agents' reasoning, so there is nothing to expand."})]})}function Z4(){const s=Oe(),{preferences:t}=Ee();return o.jsx(rt,{title:"Terminal",children:o.jsx(He,{first:!0,title:"Terminal scrollback",hint:"Lines kept in the built-in terminal buffer",children:o.jsx(Zr,{label:"Terminal scrollback lines",value:String(t.terminalScrollback),numeric:!0,limits:On.terminalScrollback,onCommit:i=>s.updatePreferences({terminalScrollback:Number(i)})})})})}function J4(){return o.jsx(rt,{title:"Files",children:o.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground","data-testid":"file-panel-settings-empty",children:"File panels appear here when a plugin adds one"})})}function eT(){const s=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: light)").matches;return{userAgent:navigator.userAgent,language:navigator.language,online:navigator.onLine,secure:window.isSecureContext,viewport:`${window.innerWidth}×${window.innerHeight} @${window.devicePixelRatio}x`,colorScheme:s?"light":"dark"}}function tT(){const{connection:s,principal:t,preferences:i}=Ee(),[a,l]=b.useState(null),[u,d]=b.useState("idle"),h=()=>{d("idle"),l({version:"0.0.1-beta.8",connection:s,principal:t,preferences:i,browser:eT(),now:new Date})},m=async()=>{if(a)try{await navigator.clipboard.writeText(A3(a)),d("copied")}catch{d("failed")}};return o.jsxs(o.Fragment,{children:[o.jsx(rt,{title:"Diagnostics",children:o.jsx(He,{first:!0,title:"App diagnostic",hint:"Collect connection, host and browser details. Providers, logs and the daemon itself: run alp doctor on the host.",children:o.jsx(we,{size:"sm",variant:"secondary","data-testid":"settings-diagnostics-run",onClick:h,children:a?"Refresh":"Run"})})}),a?o.jsxs(o.Fragment,{children:[o.jsxs(rt,{title:`Diagnostic, ${a.now?.toLocaleTimeString()??""}`,action:o.jsx(we,{size:"sm",variant:"ghost",className:"h-7 text-xs","data-testid":"settings-diagnostics-copy",onClick:()=>{m()},children:u==="copied"?"Copied":"Copy diagnostic"}),children:[u==="failed"?o.jsx("p",{role:"alert",className:"px-4 py-3 text-xs text-destructive",children:"Failed to copy diagnostic. Select the values below instead."}):null,o.jsx("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"It holds no access token, prompts or files."})]}),Q0(a).map(p=>o.jsx(rt,{title:p.title,children:p.rows.map(([x,y],w)=>o.jsx(He,{first:w===0,title:x,children:o.jsx("span",{className:"break-all font-mono text-xs","data-testid":`diagnostics-${x.toLowerCase().replace(/\W+/g,"-")}`,children:y})},x))},p.title))]}):null]})}function y1(s){return s.hostname??s.gateway.replace(/^https?:\/\//,"")}const Ly=s=>s?.trim().replace(/^v/i,"")||null,nT="https://github.com/phucanh08/alp/releases";function sT(){const{connection:s}=Ee(),t=y1(s),i=Ly(s.daemonVersion),a=s.phase!=="open",l=!!i&&i!==Ly("0.0.1-beta.8");return o.jsxs(o.Fragment,{children:[o.jsxs(rt,{title:"About",children:[o.jsxs(He,{first:!0,title:"App version",hint:"This device",children:["v","0.0.1-beta.8"]}),o.jsx("a",{href:nT,target:"_blank",rel:"noopener noreferrer","data-testid":"settings-whats-new",className:I("block hover:bg-sidebar-hover",yc),children:o.jsx(He,{title:"What's new",hint:"Release notes for every version",children:o.jsx(Jn,{"aria-hidden":!0,className:"size-4"})})})]}),o.jsx(rt,{title:"Connected hosts",children:o.jsx(He,{first:!0,title:t,hint:a?"Offline":l?"Version differs from this device":"ALP on the host, through the gateway (ALP JSON-RPC v1)",children:o.jsx("span",{"data-testid":"connected-host-version",children:i?`v${i}`:"unknown"})})})]})}function iT(){const s=Oe(),{principal:t,connection:i,settings:a}=Ee(),[l,u]=b.useState(!1);b.useEffect(()=>{s.loadSettings()},[s]);const d=["session.read","session.write","project.read","project.write","workspace.write","workspace.manage","files.read","library.write","terminal.exec"];return o.jsxs(o.Fragment,{children:[o.jsxs(rt,{title:"Host",children:[o.jsx(He,{first:!0,title:"Machine",hint:"The host's name, as it reports it.",children:i.hostname??"unknown"}),o.jsx(He,{title:"ALP",children:i.daemonVersion??"unknown"}),o.jsx(He,{title:"Gateway",children:o.jsx("span",{className:"break-all font-mono text-xs",children:i.gateway})}),o.jsx(He,{title:"Agents' language",hint:"Set on the host with alp; read only here.",children:a.status==="loading"?o.jsx(Ft,{label:"Loading…",className:"text-xs"}):a.language?`${a.language.applies}${a.language.language?"":" (default)"}`:"Not available"}),a.status==="error"?o.jsx("p",{role:"alert",className:"border-t border-border px-4 py-3 text-xs text-destructive",children:a.error?.message}):null]}),o.jsx(rt,{title:`Models new sessions can pick${a.models.length?` (${a.models.length})`:""}`,action:s.hasCapability("catalog.live")?o.jsx(we,{size:"sm",variant:"ghost",className:"h-7 text-xs","data-testid":"settings-models-refresh",disabled:l,onClick:()=>{u(!0),s.refreshModels().catch(()=>{}).finally(()=>u(!1))},children:l?"Refreshing…":"Refresh"}):void 0,children:a.models.length?o.jsx("ul",{className:"max-h-72 divide-y divide-border overflow-y-auto",children:a.models.map(h=>o.jsxs("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-sm",children:[o.jsx("span",{className:"min-w-0 truncate",children:h.label}),o.jsx("span",{className:"shrink-0 font-mono text-[length:calc(11px*var(--ui-scale))] text-muted-foreground",children:h.id})]},h.id))}):o.jsx(He,{first:!0,title:a.status==="ready"?"None listed":"Loading…"})}),o.jsxs(rt,{title:"Access token",children:[o.jsxs(He,{first:!0,title:"Name",children:[t?.label??"—"," ",o.jsxs("span",{className:"font-mono text-xs",children:["(",t?.id,")"]})]}),o.jsx(He,{title:"Allows",children:o.jsx("span",{className:"flex flex-wrap justify-end gap-1",children:d.map(h=>{const m=Te(t??void 0,h);return o.jsxs("span",{className:I("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs [&_svg]:size-3",m?"bg-primary/15 text-highlight":"bg-secondary text-muted-foreground"),children:[m?o.jsx(lc,{"aria-hidden":!0}):o.jsx(rc,{"aria-hidden":!0}),h]},h)})})}),o.jsx(He,{title:"Modes",hint:"Permissions a session may run with.",children:t?.modes?t.modes.map(Fl).join(", "):"Any"})]})]})}function aT(){const{principal:s,registry:t}=Ee();return b.useCallback(i=>t.workspaces.filter(a=>!a.archivedAt&&(a.directory===i||s?.workspaceRoots?.some(l=>l.path===i&&l.canonical===a.directory))),[s,t])}function b1(s,t){if(!s)return"This host does not list its workspaces. Update ALP on the host.";if(!Te(t??void 0,"project.read"))return"Your access token cannot read the host's workspace list (it needs project.read)."}function rT(){const s=Oe(),{principal:t,workspace:i,registry:a,connection:l}=Ee(),u=aT(),[d,h]=b.useState(""),m=t?.workspaces??[],p=b1(s.hasCapability("workspace.registry"),t);b.useEffect(()=>{p||s.refreshRegistry()},[s,p]);const x=p?[]:m.filter(k=>!u(k).length),y=Te(t??void 0,"workspace.write"),w=l.phase==="open";return o.jsxs(o.Fragment,{children:[o.jsx(rt,{title:"Projects this token opens",children:m.length?m.map((k,j)=>o.jsx(He,{first:j===0,title:Dt(k),hint:o.jsx("span",{className:"break-all font-mono",children:k}),children:o.jsxs("span",{className:"flex items-center gap-2",children:[p?null:o.jsx("span",{className:"text-xs","data-testid":"project-registered",children:u(k).length?"Registered":"Not registered"}),k===i?o.jsx("span",{className:"text-highlight","data-testid":"project-current",children:"Current"}):o.jsx(we,{size:"sm",variant:"secondary",onClick:()=>s.selectWorkspace(k),children:"Open"})]})},k)):o.jsx(He,{first:!0,title:"No projects",hint:"This access token grants no workspace."})}),p?null:o.jsxs(rt,{title:"Register a project",children:[o.jsx(He,{first:!0,title:"Granted directory",hint:y?"Registering adds a granted directory to the host's shared workspace list, so terminals, Git and worktrees can use it. It changes no files.":"Ask the host owner to add workspace.write to your credential to register projects.",children:y&&x.length?o.jsxs("form",{className:"flex flex-wrap items-center gap-2",onSubmit:k=>{k.preventDefault(),d&&s.registerProject(d).then(()=>h(""))},children:[o.jsx(La,{label:"Directory to register",value:d,onChange:h,options:[{value:"",label:"Choose a directory"},...x.map(k=>({value:k,label:Dt(k)}))]}),o.jsx(we,{size:"sm",type:"submit",disabled:!d||!w||a.loading,children:"Register"})]}):y?o.jsx("span",{className:"text-xs",children:"Every granted directory is registered"}):null}),a.error?o.jsx("p",{role:"alert",className:"border-t border-border px-4 py-3 text-xs text-destructive",children:a.error}):null]}),o.jsx(ln,{what:"Granting or removing projects",why:"The access token decides which projects you can open. The host owner grants them with alp-gateway credential create --workspace."})]})}function oT({row:s,first:t,writable:i,online:a,busy:l}){const u=Oe(),{workspace:d,principal:h}=Ee(),[m,p]=b.useState(!1),[x,y]=b.useState(s.title??""),w=s.title||Dt(s.directory),k=h?.workspaces?.some(A=>A===s.directory||h.workspaceRoots?.some(R=>R.path===A&&R.canonical===s.directory))||s.managedWorktree,j=h?.workspaceRoots?.find(A=>A.canonical===s.directory)?.path??s.directory,S=async()=>{await u.renameWorkspace(s.id,x)&&p(!1)};return o.jsxs("div",{className:I("flex flex-col gap-2 p-4",!t&&"border-t border-border"),"data-testid":"settings-workspace-row","data-workspace-id":s.id,children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[o.jsx("span",{className:"truncate",children:w}),s.pinnedAt?o.jsx(u0,{"aria-label":"Pinned",className:"size-3 shrink-0 text-muted-foreground"}):null,s.managedWorktree?o.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-[length:calc(11px*var(--ui-scale))] text-muted-foreground",children:"Worktree"}):null]}),o.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:s.directory}),s.branch!==void 0?o.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s.branch||"Detached HEAD"}):null]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(we,{size:"sm",variant:"ghost","aria-pressed":!!s.pinnedAt,disabled:!i||!a||l,onClick:()=>{u.pinWorkspace(s.id,!s.pinnedAt)},"aria-label":`${s.pinnedAt?"Unpin":"Pin"} workspace ${w}`,children:s.pinnedAt?"Unpin":"Pin"}),o.jsx(we,{size:"sm",variant:"ghost",disabled:!i||!a||l,onClick:()=>{y(s.title??""),p(A=>!A)},"aria-label":`Rename workspace ${w}`,children:"Rename"}),k?j===d?o.jsx("span",{className:"text-xs text-highlight",children:"Open"}):o.jsx(we,{size:"sm",variant:"secondary",onClick:()=>u.selectWorkspace(j),children:"Open"}):null]})]}),m?o.jsxs("form",{className:"flex flex-wrap items-center gap-2",onSubmit:A=>{A.preventDefault(),S()},children:[o.jsx(Zn,{"aria-label":`New name for ${w}`,value:x,maxLength:200,onChange:A=>y(A.target.value),placeholder:Dt(s.directory),className:"h-8 min-w-0 flex-1",autoFocus:!0}),o.jsx(we,{size:"sm",type:"submit",disabled:!a||l,children:"Save"}),o.jsx(we,{size:"sm",variant:"ghost",type:"button",onClick:()=>p(!1),children:"Cancel"})]}):null]})}function lT(){const s=Oe(),{principal:t,registry:i,connection:a}=Ee(),l=b1(s.hasCapability("workspace.registry"),t);if(b.useEffect(()=>{l||s.refreshRegistry()},[s,l]),l)return o.jsx(ln,{what:"Workspace settings",why:l});const u=Te(t??void 0,"workspace.write"),d=a.phase==="open",h=i.workspaces.filter(m=>!m.archivedAt).sort((m,p)=>+!!p.pinnedAt-+!!m.pinnedAt||(m.title||Dt(m.directory)).localeCompare(p.title||Dt(p.directory))||m.id.localeCompare(p.id));return o.jsxs(o.Fragment,{children:[o.jsxs(rt,{title:`Shared with every client of this host${h.length?` (${h.length})`:""}`,action:o.jsx(we,{size:"sm",variant:"ghost",className:"h-7 text-xs",disabled:i.loading||!d,onClick:()=>{s.refreshRegistry()},children:i.loading?"Refreshing…":"Refresh"}),children:[i.error?o.jsx("p",{role:"alert",className:"px-4 py-3 text-xs text-destructive",children:i.error}):null,h.length?h.map((m,p)=>o.jsx(oT,{row:m,first:p===0&&!i.error,writable:u,online:d,busy:!!i.loading},m.id)):o.jsx(He,{first:!i.error,title:i.loading?"Loading…":"No workspaces",hint:i.loading?void 0:"Register a granted directory under Host › Projects."})]}),u?null:o.jsx(rt,{children:o.jsx(He,{first:!0,title:"Read only",hint:"Pins and names are shared with every client of this host. Ask the host owner to add workspace.write to your credential to change them."})}),o.jsx(ln,{what:"Archiving workspaces, labels and placement",why:"The host's owner manages them with alp on the host."})]})}function cT({onNavigate:s}){const t=Ee(),i=t.connection.capabilities.includes("terminal"),a=Te(t.principal??void 0,"terminal.exec"),l=Pb(t),u=!l.ok&&l.reasons.includes("unregistered"),d=Te(t.principal??void 0,"workspace.write"),h=(m,p)=>o.jsxs("span",{className:I("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs [&_svg]:size-3",m?"bg-primary/15 text-highlight":"bg-secondary text-muted-foreground"),children:[m?o.jsx(lc,{"aria-hidden":!0}):o.jsx(rc,{"aria-hidden":!0}),p]});return o.jsxs(o.Fragment,{children:[o.jsxs(rt,{title:"Remote terminals",children:[o.jsx(He,{first:!0,title:"Host",hint:i?"The host's owner allowed remote terminals.":io.capability,children:o.jsx("span",{"data-testid":"terminals-host",children:h(i,i?"Allowed":"Not allowed")})}),o.jsx(He,{title:"Access token",hint:a?"Your access token may open terminals (terminal.exec).":io.permission,children:o.jsx("span",{"data-testid":"terminals-token",children:h(a,a?"terminal.exec":"No terminal.exec")})}),o.jsx(He,{title:"This workspace",hint:l.ok?"A terminal can open here from the + menu (Terminal).":[...l.messages,u?d?"Register it under Host › Projects; the terminal opens once it is in the list.":"Registering it needs workspace.write: ask the host owner to register it, or to add workspace.write to your credential.":""].filter(Boolean).join(" "),children:o.jsxs("span",{className:"flex items-center gap-2",children:[u&&d?o.jsx(we,{size:"sm",variant:"secondary","data-testid":"terminals-register",onClick:()=>s("projects"),children:"Register in Projects"}):null,o.jsx("span",{"data-testid":"terminals-workspace",children:h(l.ok,l.ok?"Ready":"Not available")})]})})]}),o.jsx(ln,{what:"Changing the host's terminal switch",why:"Only the host's owner turns remote terminals on or off, on the host: alp terminal allow --yes, alp terminal deny, alp terminal status. Font and colors are under App › Terminal."})]})}function uT(){const s=Oe(),{connection:t}=Ee(),i=t.gateway.startsWith("https:");return o.jsxs(rt,{title:"This connection",children:[o.jsx(He,{first:!0,title:"Gateway",children:o.jsx("span",{className:"break-all font-mono text-xs",children:t.gateway})}),o.jsx(He,{title:"State",children:t.phase==="open"?"Connected":t.phase==="reconnecting"?`Reconnecting (attempt ${t.attempt})`:t.phase}),o.jsx(He,{title:"Transport",hint:i?"TLS to the gateway.":"Plain HTTP, allowed only on this machine (loopback or an SSH tunnel).",children:i?"HTTPS / WSS":"Loopback HTTP / WS"}),o.jsx(He,{title:"Access token",hint:"Kept in this tab's memory only. Disconnecting forgets it.",children:o.jsx(we,{size:"sm",variant:"destructive",onClick:()=>s.disconnect(),children:"Disconnect"})})]})}function dT({kind:s,name:t,onClose:i}){const a=Oe(),[l,u]=b.useState({status:"loading"});b.useEffect(()=>{let h=!0;return u({status:"loading"}),a.getLibraryEntry(s,t).then(m=>{h&&u({status:"ready",entry:m})},m=>{h&&u({status:"error",error:Be(m).message})}),()=>{h=!1}},[a,s,t]);const d=l.entry;return o.jsx(rt,{title:t,action:o.jsx(we,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:i,children:"Close"}),children:o.jsxs("div",{"data-testid":"library-entry","aria-label":`${t} content`,role:"group",children:[l.status==="loading"?o.jsx("div",{className:"p-4",children:o.jsx(Ft,{label:"Loading…",className:"text-xs"})}):null,l.status==="error"?o.jsx("p",{role:"alert",className:"p-4 text-xs text-destructive",children:l.error}):null,d?o.jsxs(o.Fragment,{children:[o.jsx(He,{first:!0,title:"Source",hint:d.usedBy.length?`Used by ${d.usedBy.join(", ")}`:void 0,children:o.jsxs("span",{className:"text-xs",children:[d.source,d.overrides?` · overrides ${d.overrides}`:""]})}),d.librarySkills?.length?o.jsx(He,{title:"Skills the library gives it",children:d.librarySkills.join(", ")}):null,h4(d.content).map(h=>o.jsxs("div",{className:"border-t border-border p-4",children:[o.jsx("div",{className:"mb-2 font-mono text-xs text-muted-foreground",children:h.label}),o.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md bg-secondary p-3 font-mono text-xs text-foreground",children:h.text})]},h.key)),d.secrets.length?o.jsxs("p",{className:"border-t border-border px-4 py-3 text-xs text-muted-foreground",children:[d.secrets.length===1?"One value that can hold a secret is":`${d.secrets.length} values that can hold secrets are`," shown as ",Xl,": the gateway keeps them on the host."]}):null]}):null]})})}function fT({kind:s,selected:t,onChanged:i}){const a=Oe(),[l,u]=b.useState(""),[d,h]=b.useState(""),[m,p]=b.useState(""),[x,y]=b.useState(null),[w,k]=b.useState(!1),[j,S]=b.useState(!1),[A,R]=b.useState(null),[q,O]=b.useState(null);b.useEffect(()=>{let B=!0;return k(!1),R(null),O(null),h(""),t?a.getLibraryEntry(s,t).then(_=>{if(B){if(_.source!=="project"||_.overrides||_.secrets.length||_.revision===void 0){O("This entry holds configuration the host runs or values kept on the host, so it is read only here.");return}u(t),y(_.revision),p(JSON.stringify(_.content,null,2)),k(!0)}},_=>{B&&R(Be(_).message)}):(u(""),y(null),p(JSON.stringify(s==="skills"?{body:""}:{instructions:"",config:{description:""}},null,2)),k(!0)),()=>{B=!1}},[a,s,t]);const L=async B=>{S(!0),R(null);try{const _=B==="save"?{name:l,content:JSON.parse(m),revision:x}:B==="delete"?{name:l,revision:x}:{from:l,to:d},Q=await a.writeLibrary(B,s,_);B==="save"&&y(Q.revision),(B==="delete"||B==="rename")&&k(!1),i()}catch(_){R(Be(_).message)}finally{S(!1)}};return o.jsx(rt,{title:t?"Edit project instructions":"New project instructions",children:o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents and skills only. Host entries, executable configuration, references and extra files cannot be changed here."}),A?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:A}):null,q?o.jsx("p",{role:"note",className:"text-xs text-muted-foreground",children:q}):null,w?o.jsxs(o.Fragment,{children:[o.jsx(Zn,{"aria-label":"Entry name",value:l,onChange:B=>u(B.target.value),disabled:j||!!t,placeholder:"Entry name"}),o.jsx("textarea",{"aria-label":"Instruction entry JSON",className:"min-h-48 rounded border border-border bg-background p-2 font-mono text-xs",value:m,onChange:B=>p(B.target.value),disabled:j}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(we,{size:"sm",disabled:j||!l.trim(),onClick:()=>{L("save")},children:"Save project entry"}),t?o.jsx(we,{size:"sm",variant:"secondary",disabled:j,onClick:()=>{L("delete")},children:"Delete project entry"}):null]}),t?o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(Zn,{"aria-label":"New entry name",value:d,onChange:B=>h(B.target.value),placeholder:"New name",disabled:j}),o.jsx(we,{size:"sm",variant:"secondary",disabled:j||!d.trim(),onClick:()=>{L("duplicate")},children:"Duplicate"}),o.jsx(we,{size:"sm",variant:"secondary",disabled:j||!d.trim(),onClick:()=>{L("rename")},children:"Rename"})]}):null]}):null]})})}function Ta({kind:s,noun:t}){const i=Oe(),{workspace:a}=Ee(),[l,u]=b.useState({status:"loading",entries:[]}),[d,h]=b.useState(null),m=i.libraryBlock(),p=b.useCallback(()=>{let w=!0;return u(k=>({...k,status:"loading",error:void 0})),i.listLibrary(s).then(k=>{w&&u({status:"ready",entries:k})},k=>{w&&u({status:"error",entries:[],error:Be(k).message})}),()=>{w=!1}},[i,s]);if(b.useEffect(()=>m?void 0:p(),[p,m,a]),b.useEffect(()=>{h(null)},[s,a]),m)return o.jsx(ln,{what:`Listing ${t}`,why:m});const x=d?l.entries.find(w=>w.name===d):void 0,y=x&&x.source==="project"&&!x.overrides?x.name:null;return o.jsxs(o.Fragment,{children:[o.jsxs(rt,{title:a?`As ${Dt(a)} sees them`:void 0,action:o.jsx(we,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>p(),children:"Refresh"}),children:[l.status==="loading"&&!l.entries.length?o.jsx("div",{className:"p-4",children:o.jsx(Ft,{label:"Loading…",className:"text-xs"})}):null,l.status==="error"?o.jsx("p",{role:"alert",className:"p-4 text-xs text-destructive",children:l.error}):null,l.status==="ready"&&!l.entries.length?o.jsx(He,{first:!0,title:`No ${t}`}):null,l.entries.map((w,k)=>o.jsx("button",{type:"button",onClick:()=>h(j=>j===w.name?null:w.name),"aria-expanded":d===w.name,"data-testid":`library-row-${w.name}`,className:I("block w-full text-left hover:bg-sidebar-hover",yc,d===w.name&&"bg-sidebar-hover"),children:o.jsx(He,{first:k===0,title:o.jsx("span",{className:"font-mono text-[length:calc(13px*var(--ui-scale))]",children:w.name}),hint:[w.description,w.usedBy?.length?`Used by ${w.usedBy.join(", ")}`:""].filter(Boolean).join(" · ")||void 0,children:o.jsxs("span",{className:"text-xs",children:[w.source,w.overrides?` · overrides ${w.overrides}`:""]})})},`${w.source}:${w.name}`))]}),i.libraryWriteBlock(s)?null:o.jsx(fT,{kind:s,selected:y,onChanged:()=>p()},`${s}:${a}:${y??"new"}`),d?o.jsx(dT,{kind:s,name:d,onClose:()=>h(null)}):null,i.libraryWriteBlock(s)?o.jsx(ln,{what:`Editing ${t}`,why:`${i.libraryWriteBlock(s)} Open an entry to read it. Values that can hold secrets (environment, headers, MCP URLs and arguments, hook commands) show as ${Xl}. Changes configure commands the host runs, so edit them on the host with alp.`}):null]})}function hT({page:s,mobile:t,onNavigate:i}){switch(s){case"general":return o.jsx(X4,{mobile:t});case"appearance":return o.jsx(P4,{});case"sidebar":return o.jsx(Q4,{});case"chat":return o.jsx(W4,{});case"terminal":return o.jsx(Z4,{});case"files":return o.jsx(J4,{});case"editor":return o.jsx(ln,{what:"Editor",why:"This app opens a workspace's files read only (the Files panel); changing them is the agents' work, or yours on the host."});case"diagnostics":return o.jsx(tT,{});case"about":return o.jsx(sT,{});case"host":return o.jsx(iT,{});case"projects":return o.jsx(rT,{});case"connections":return o.jsx(uT,{});case"alp-templates":return o.jsx(Ta,{kind:"teams",noun:"templates"});case"alp-agents":return o.jsx(Ta,{kind:"agents",noun:"agents"});case"alp-skills":return o.jsx(Ta,{kind:"skills",noun:"skills"});case"alp-hooks":return o.jsx(Ta,{kind:"hooks",noun:"hooks"});case"alp-mcp":return o.jsx(Ta,{kind:"mcp",noun:"MCP servers"});case"providers":return o.jsxs(o.Fragment,{children:[o.jsx(Ta,{kind:"providers",noun:"providers"}),o.jsx(ln,{what:"Adding, testing or diagnosing providers",why:"Tests run commands on the host; they are not offered remotely."})]});case"pair-device":return o.jsx(ln,{what:"Pairing a device",why:"This app is the remote client: open it on the other device and connect with an access token."});case"voice":return o.jsx(ln,{what:"Voice",why:"Paseo's dictation and voice mode turn speech into prompts with a speech provider set up on the host. ALP's agents take text, and its hosts have no speech provider to set up."});case"metadata":return o.jsx(ln,{what:"Metadata generation",why:"A host setting the gateway does not expose."});case"workspaces":return o.jsx(lT,{});case"usage":return o.jsx(ln,{what:"Usage and limits",why:"Account-wide on the host; check with alp usage there."});case"terminals":return o.jsx(cT,{onNavigate:i});case"plugins":return o.jsx(ln,{what:"Plugins",why:"Installing plugins changes the host; not offered remotely."})}}function Oy({page:s,label:t,icon:i,selected:a,onSelect:l,mobile:u}){return o.jsxs("button",{type:"button",onClick:()=>l(s),"aria-current":a?"page":void 0,"data-testid":`settings-${s}`,className:I("flex min-h-7 w-full items-center gap-2 rounded-lg px-2 py-1 text-left text-sm text-muted-foreground hover:bg-sidebar-hover hover:text-foreground",yc,a&&"bg-sidebar-hover text-foreground",u&&"min-h-10"),children:[o.jsx(i,{"aria-hidden":!0,strokeWidth:1.75,className:"size-4 shrink-0"}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),u?o.jsx(Jn,{"aria-hidden":!0,className:"size-4 text-extra-muted"}):null]})}function Dy({page:s,onSelect:t,mobile:i}){const{connection:a}=Ee(),l=y1(a);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-2",children:[o.jsx("p",{className:"px-2 py-1 text-sm text-extra-muted",children:"App"}),g1.map(u=>o.jsx(Oy,{page:u.id,label:u.label,icon:u.icon,selected:s===u.id,onSelect:t,mobile:i},u.id))]}),o.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-2",children:[o.jsx("p",{className:"px-2 py-1 text-sm text-extra-muted",children:"Host"}),o.jsxs("div",{className:"flex min-h-7 items-center gap-2 px-2 py-1 text-sm",title:a.gateway,"data-testid":"settings-host-label",children:[o.jsx("span",{className:"flex size-4 items-center justify-center",children:o.jsx("span",{className:I("size-2 rounded-full",a.phase==="open"?"bg-dot-success":"bg-dot-warning")})}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:l})]}),x1.map(u=>o.jsx(Oy,{page:u.id,label:u.label,icon:u.icon,selected:s===u.id,onSelect:t,mobile:i},u.id))]})]})}function mT({onClose:s,mobile:t,initialPage:i}){const[a,l]=b.useState(i??(t?null:"general"));b.useEffect(()=>{const h=m=>{m.key==="Escape"&&!(m.target instanceof HTMLElement&&m.target.closest('[role="menu"],dialog'))&&s()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[s]);const u=(h,m)=>o.jsx("div",{className:"flex h-14 shrink-0 items-center gap-2 border-b border-border px-2 md:h-9",children:o.jsxs("button",{type:"button",onClick:m,className:I("flex min-h-7 items-center gap-2 rounded-lg px-2 py-1 text-sm text-muted-foreground hover:bg-sidebar-hover hover:text-foreground",yc),children:[o.jsx(th,{"aria-hidden":!0,className:"size-4"}),h]})}),d=a?o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto w-full max-w-[720px] p-4 pt-14",children:[o.jsx("h2",{className:"mb-6 ml-1 text-[length:calc(26px*var(--ui-scale))] font-semibold text-foreground","data-testid":"settings-detail-header-title",children:I4[a]}),o.jsx(hT,{page:a,mobile:t,onNavigate:l})]})}):null;return t?o.jsxs("div",{role:"region","aria-label":"Settings",className:"flex h-dvh flex-col bg-background",children:[a?u("Settings",()=>l(null)):u("Back",s),a?d:o.jsx("nav",{"aria-label":"Settings",className:"min-h-0 flex-1 overflow-y-auto",children:o.jsx(Dy,{page:null,onSelect:l,mobile:!0})})]}):o.jsxs("div",{role:"region","aria-label":"Settings",className:"flex h-dvh overflow-hidden bg-background",children:[o.jsxs("nav",{"aria-label":"Settings",className:"flex w-[320px] shrink-0 flex-col border-r border-border bg-sidebar","data-testid":"settings-sidebar",children:[u("Back",s),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsx(Dy,{page:a,onSelect:l,mobile:!1})})]}),o.jsx("main",{className:"flex min-w-0 flex-1 flex-col","data-testid":"settings-detail-pane",children:d})]})}const pT=[{key:"list",label:"List"},{key:"board",label:"Board"},{key:"epics",label:"Epics"}],gT=["open","ready","closed","all"],Wl=(s,t)=>s.priority-t.priority||s.id.localeCompare(t.id),v1=(s,t)=>(t.closed?.at??t.updatedAt??"").localeCompare(s.closed?.at??s.updatedAt??"")||s.id.localeCompare(t.id);function vh(s){return s.status==="closed"?"closed":s.approvals?.length?"approve":s.status==="review"?"review":s.status==="in_progress"?"progress":s.type==="epic"?s.progress?.done?"progress":"ready":s.ready?"ready":"blocked"}const qy={approve:"Needs approval",review:"In review",progress:"In progress",ready:"Ready",blocked:"Blocked",closed:"Closed"},w1=s=>!!s.ready&&s.status!=="closed";function xT(s){const t=s.filter(i=>i.status==="closed").length;return{open:s.length-t,ready:s.filter(w1).length,closed:t,all:s.length}}function yT(s,t,i=""){const a=i.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.filter(l=>{if(t==="open"&&l.status==="closed"||t==="ready"&&!w1(l)||t==="closed"&&l.status!=="closed")return!1;if(!a.length)return!0;const u=[l.id,l.title,l.type??"",l.assignee??"",...l.labels??[]].join(" ").toLowerCase();return a.every(d=>u.includes(d))})}const bT=[{key:"approve",title:"Waiting for your approval"},{key:"review",title:"In review"},{key:"progress",title:"In progress"},{key:"ready",title:"Ready"},{key:"waiting",title:"Blocked or waiting"},{key:"epics",title:"Epics"},{key:"closed",title:"Closed"}];function vT(s){return s.status==="closed"?"closed":s.approvals?.length?"approve":s.status==="review"?"review":s.status==="in_progress"?"progress":s.type==="epic"?"epics":s.ready?"ready":"waiting"}function wT(s){return bT.map(t=>{const i=s.filter(a=>vT(a)===t.key);return{...t,tasks:i.sort(t.key==="closed"?v1:Wl)}}).filter(t=>t.tasks.length)}const kT=[{key:"approve",title:"Needs approval"},{key:"blocked",title:"Blocked"},{key:"ready",title:"Ready"},{key:"progress",title:"In progress"},{key:"review",title:"In review"},{key:"closed",title:"Closed"}];function jT(s){return kT.map(t=>({...t,tasks:s.filter(i=>i.type!=="epic"&&vh(i)===t.key).sort(t.key==="closed"?v1:Wl)})).filter(t=>t.tasks.length||t.key==="blocked"||t.key==="ready"||t.key==="progress")}function ST(s,t){return t.filter(i=>i.type==="epic"||i.progress).sort(Wl).map(i=>{const a=s.filter(d=>d.parent===i.id).sort(Wl),l=i.progress?.done??a.filter(d=>d.status==="closed").length,u=i.progress?.total??a.length;return{epic:i,children:a,done:l,total:u,percent:u?Math.round(l/u*100):0}})}function k1(s,t=Date.now()){const i=s?Date.parse(s):NaN;if(Number.isNaN(i))return"";const a=Math.max(0,Math.floor((t-i)/6e4));return a<60?`${a}m`:a<1440?`${Math.floor(a/60)}h`:a<1440*14?`${Math.floor(a/1440)}d`:`${Math.floor(a/10080)}w`}const oo="main",j1=5,Gr=.1,zl=.15,By=.4,NT=16,TT=1030,$y=()=>({root:{kind:"pane",id:oo},focused:oo,assign:{},actives:{}});function Vt(s){return s.kind==="pane"?[s.id]:s.children.flatMap(Vt)}function S1(s){return s.kind==="pane"?1:1+Math.max(...s.children.map(S1))}const N1=s=>s.kind==="pane"?[s.id]:[s.id,...s.children.flatMap(N1)];function Uy(s,t){const i=new Set(N1(s));let a=1;for(;i.has(`${t}-${a}`);)a+=1;return`${t}-${a}`}function Ti(s,t){const i=Vt(s.root),a=s.assign[t];return a&&i.includes(a)?a:i.includes(s.focused)?s.focused:i[0]}function AT(s,t,i){const a=Object.fromEntries(Vt(s.root).map(l=>[l,[]]));for(const l of t)a[Ti(s,i(l))].push(l);return a}function bc(s,t){if(s.kind==="pane")return s.id===t?[]:null;for(let i=0;i<s.children.length;i+=1){const a=bc(s.children[i],t);if(a)return[i,...a]}return null}const wh=(s,t)=>t.reduce((i,a)=>i.children[a],s);function Zl(s,t,i){if(!t.length)return i(s);const a=s,[l,...u]=t;return{...a,children:a.children.map((d,h)=>h===l?Zl(d,u,i):d)}}function Rf(s,{target:t,position:i,key:a}){const l=bc(s.root,t);if(!l)return null;const u=i==="left"||i==="right"?"horizontal":"vertical",d=i==="right"||i==="bottom",h=Uy(s.root,"pane"),m={kind:"pane",id:h},p=l.slice(0,-1),x=l.length?wh(s.root,p):null,y=l[l.length-1]??0;let w;if(x&&x.direction===u){const k=x.sizes[y]??0,j=d?y+1:y,S=x.sizes.slice();S.splice(j,0,k/2),S[y+(d?0:1)]=k/2;const A=x.children.slice();A.splice(j,0,m),w=Zl(s.root,p,()=>({...x,children:A,sizes:S}))}else{const k=Uy(s.root,"group");w=Zl(s.root,l,j=>({kind:"group",id:k,direction:u,children:d?[j,m]:[m,j],sizes:[.5,.5]}))}return S1(w)>j1?null:{...s,root:w,focused:h,assign:a?{...s.assign,[a]:h}:s.assign}}function T1(s,t){const i=bc(s,t);if(!i||!i.length)return null;for(let a=i.length-1;a>=0;a-=1){const l=wh(s,i.slice(0,a)),u=i[a];for(let d=u-1;d>=0;d-=1){const h=Vt(l.children[d]);if(h.length)return h[h.length-1]}for(let d=u+1;d<l.children.length;d+=1){const h=Vt(l.children[d]);if(h.length)return h[0]}}return null}function Hy(s,t){const i=bc(s.root,t);if(!i||!i.length)return null;const a=T1(s.root,t),l=i.slice(0,-1),u=wh(s.root,l),d=i[i.length-1],h=u.children.filter((j,S)=>S!==d),m=u.sizes.filter((j,S)=>S!==d),p=m.reduce((j,S)=>j+S,0)||1,x=Zl(s.root,l,()=>h.length===1?h[0]:{...u,children:h,sizes:m.map(j=>j/p)}),y=Object.fromEntries(Object.entries(s.assign).filter(([,j])=>j!==t)),w=Object.fromEntries(Object.entries(s.actives).filter(([j])=>j!==t)),k=s.focused===t?a??Vt(x)[0]:s.focused;return{root:x,focused:k,assign:y,actives:w}}function CT(s,t,i){return Vt(s.root).includes(i)?{...s,focused:i,assign:{...s.assign,[t]:i},actives:{...s.actives,[i]:t}}:s}function A1(s){const t=s.length;if(!t)return[];if(t===1)return[1];if(t*Gr>1)return s.map(()=>1/t);const i=s.map(m=>Number.isFinite(m)&&m>0?m:0),a=i.reduce((m,p)=>m+p,0),l=a>0?i.map(m=>m/a):i.map(()=>1/t),u=l.map(()=>0),d=new Set(l.map((m,p)=>p));let h=1;for(;d.size;){let m=0;for(const x of d)m+=l[x];if(m<=0){for(const x of d)u[x]=h/d.size;break}const p=[...d].filter(x=>l[x]/m*h<Gr);if(!p.length){for(const x of d)u[x]=l[x]/m*h;break}for(const x of p)u[x]=Gr,d.delete(x),h-=Gr}return u}function ET(s,t,i){const a=l=>l.kind==="pane"?l:l.id===t&&i.length===l.children.length?{...l,sizes:A1(i)}:{...l,children:l.children.map(a)};return{...s,root:a(s.root)}}function _f(s,t={left:0,top:0,right:1,bottom:1}){if(s.kind==="pane")return[{id:s.id,...t}];const i=[];let a=0;for(let l=0;l<s.children.length;l+=1){const u=s.sizes[l]??0;if(s.direction==="horizontal"){const d=t.right-t.left;i.push(..._f(s.children[l],{...t,left:t.left+d*a,right:t.left+d*(a+u)}))}else{const d=t.bottom-t.top;i.push(..._f(s.children[l],{...t,top:t.top+d*a,bottom:t.top+d*(a+u)}))}a+=u}return i}function Iy(s,t,i){const a=_f(s),l=a.find(p=>p.id===t);if(!l)return null;const u=i==="left"||i==="right",d=(p,x,y,w)=>x<y?y-x:w<p?p-w:0,h=(p,x,y,w)=>Math.max(0,Math.min(x,w)-Math.max(p,y)),m=a.filter(p=>p.id!==t).map(p=>{const x=i==="left"?l.left-p.right:i==="right"?p.left-l.right:i==="up"?l.top-p.bottom:p.top-l.bottom;if(x<-1e-6)return null;const[y,w,k,j]=u?[p.top,p.bottom,l.top,l.bottom]:[p.left,p.right,l.left,l.right],S=Math.abs(u?(p.top+p.bottom)/2-(l.top+l.bottom)/2:(p.left+p.right)/2-(l.left+l.right)/2);return{id:p.id,primary:x,secondary:d(y,w,k,j),overlap:h(y,w,k,j),center:S}}).filter(p=>!!p);return m.sort((p,x)=>p.primary-x.primary||p.secondary-x.secondary||x.overlap-p.overlap||p.center-x.center||String(p?.id).localeCompare(String(x?.id))),m[0]?.id??null}function MT({width:s,height:t,x:i,y:a}){const l=s*((1-By)/2),u=t*((1-By)/2);if(i>=l&&i<=s-l&&a>=u&&a<=t-u)return"center";if(i<=s*zl)return"left";if(i>=s-s*zl)return"right";if(a<=t*zl)return"top";if(a>=t-t*zl)return"bottom";const d=[["left",i],["right",s-i],["top",a],["bottom",t-a]];return d.sort((h,m)=>h[1]-m[1]),d[0][0]}const Lf=s=>!!s&&typeof s=="object"&&!Array.isArray(s),Bl=s=>typeof s=="string"&&!!s.trim()&&s.length<=TT;function C1(s,t,i){if(!Lf(s)||i>j1)return null;const a=s;if(!Bl(a.id)||t.has(a.id))return null;if(t.add(a.id),a.kind==="pane")return{kind:"pane",id:a.id};if(a.kind!=="group"||a.direction!=="horizontal"&&a.direction!=="vertical"||!Array.isArray(a.children)||!Array.isArray(a.sizes)||a.children.length!==a.sizes.length||a.children.length<2)return null;const l=[];for(const d of a.children){const h=C1(d,t,i+1);if(!h)return null;l.push(h)}const u=a.sizes.map(d=>typeof d=="number"&&Number.isFinite(d)&&d>0?d:0);return{kind:"group",id:a.id,direction:a.direction,children:l,sizes:A1(u)}}function zT(s){if(!Lf(s))return;const t=s,i=C1(t.root,new Set,1);if(!i||i.kind==="pane")return;const a=Vt(i);if(a.length>NT)return;const l=(m,p)=>{const x={};if(!Lf(m))return x;for(const[y,w]of Object.entries(m).slice(0,100))Bl(y)&&Bl(w)&&p(y,w)&&(x[y]=w);return x},u=l(t.assign,(m,p)=>a.includes(p)),d=l(t.actives,m=>a.includes(m)),h=Bl(t.focused)&&a.includes(t.focused)?t.focused:a[0];return{root:i,focused:h,assign:u,actives:d}}const E1="alp-web:layout",Of=1,RT=["changes","terminal","diff","files","agents","tasks"],M1=Object.freeze({initial:320,min:200,max:600}),z1=Object.freeze({initial:320,min:240,max:720}),_T=20,LT=50,R1=300,_1=1024,OT=_1+5,Df=s=>!!s&&typeof s=="object"&&!Array.isArray(s),L1=s=>typeof s=="string"&&s.trim()&&s.length<=R1?s:void 0,DT=s=>typeof s=="string"&&s.trim()&&s.length<=_1?s:void 0,Gy=s=>typeof s=="string"&&s.trim()&&s.length<=OT?s:void 0,Hr=(s,t=()=>!0,i=L1)=>Array.isArray(s)?[...new Set(s.map(i).filter(a=>!!a&&t(a)))].slice(0,LT):[];function Jl(s,t){if(!(typeof s!="number"||!Number.isFinite(s)))return Math.round(Math.min(t.max,Math.max(t.min,s)))}const qT=(s,t)=>`${s}
30
+ ${t}`;function BT(s){if(!Df(s))return;const t=s,i=L1(t.session),a=Gy(t.active),l=zT(t.panes),u=Hr(t.files,d=>Js(d)===d&&!$i(d),DT);return{...i?{session:i}:{},agents:i?Hr(t.agents,d=>d!==i):[],tasks:Hr(t.tasks),panels:Hr(t.panels,d=>RT.includes(d)),order:Hr(t.order,void 0,Gy),...u.length?{files:u}:{},...a?{active:a}:{},...l?{panes:l}:{},at:typeof t.at=="number"&&Number.isFinite(t.at)?t.at:0}}function O1(s){const t={workspaces:{}};if(typeof s!="string"||!s)return t;let i;try{i=JSON.parse(s)}catch{return t}if(!Df(i)||i.v!==Of)return t;const a={};if(Df(i.workspaces)){const d=Object.entries(i.workspaces).map(([h,m])=>[h,BT(m)]).filter(([h,m])=>h.length<=2*R1&&m).sort((h,m)=>(m[1]?.at??0)-(h[1]?.at??0)).slice(0,_T);for(const[h,m]of d)m&&(a[h]=m)}const l=Jl(i.sidebarWidth,M1),u=Jl(i.dockWidth,z1);return{...l?{sidebarWidth:l}:{},...u?{dockWidth:u}:{},workspaces:a}}function $T(s){const t=O1(JSON.stringify({...s,v:Of}));return JSON.stringify({v:Of,...t})}function kh(s){if(!s)return{workspaces:{}};try{return O1(s.getItem(E1))}catch{return{workspaces:{}}}}function D1(s,t){if(!s)return!1;try{return s.setItem(E1,$T(t(kh(s)))),!0}catch{return!1}}const UT=(s,t)=>s.workspaces[t];function q1(s,t,i){const a=new Map(i.map((l,u)=>[l,u]));return s.map((l,u)=>({tab:l,index:u,rank:a.get(t(l))??i.length+u})).sort((l,u)=>l.rank-u.rank).map(l=>l.tab)}function qf(s,t,i){if(s.indexOf(t)<0)return s;const l=s.filter(d=>d!==t),u=Math.max(0,Math.min(l.length,i));return[...l.slice(0,u),t,...l.slice(u)]}function ec(){try{return window.localStorage}catch{return}}const vn=s=>`${s.kind}:${s.id}`;function jh(s,t,i,a){const l=s.findIndex(d=>vn(d)===vn(t));if(l<0)return[];let u=i==="left"?s.slice(0,l):i==="right"?s.slice(l+1):s.filter((d,h)=>h!==l);return t.kind==="agent"&&t.id!==a&&(u=u.filter(d=>!(d.kind==="agent"&&d.id===a))),u}function Yy({tabs:s,active:t,selected:i,closing:a,keep:l}){const u=new Set(a.map(vn)),d=a.some(x=>x.kind==="agent"&&x.id===i),h=new Set(s.filter(x=>!u.has(vn(x))&&!(d&&x.kind==="agent")).map(vn)),m=!!t&&u.has(vn(t));let p=t&&!m?t:null;if(t&&m)if(l&&h.has(vn(l)))p=l;else{const x=s.findIndex(y=>vn(y)===vn(t));p=s.slice(x+1).find(y=>h.has(vn(y)))??s.slice(0,x).reverse().find(y=>h.has(vn(y)))??null}else p&&!h.has(vn(p))&&(p=s.find(x=>h.has(vn(x)))??null);return{closingRoot:d,next:p}}const tf=s=>s.kind==="draft"||s.kind==="launcher",nf={kind:"draft",id:"new"},qe=s=>`${s.kind}:${s.id}`,B1=b.createContext(null);function kt(){const s=b.useContext(B1);if(!s)throw new Error("useTabs outside TabsProvider");return s}const sf=s=>{if(!s)return null;const t=s.indexOf(":"),i=s.slice(0,t),a=s.slice(t+1);return a?i==="agent"||i==="task"?{kind:i,id:a}:i==="file"?Js(a)===a&&!$i(a)?{kind:i,id:a}:null:i==="panel"?{kind:i,id:a}:null:null};function HT({children:s}){const t=Oe(),{selected:i,focus:a,workspace:l,connection:u,sessions:d,tree:h}=Ee(),[m,p]=b.useState([]),[x,y]=b.useState([]),[w,k]=b.useState([]),[j,S]=b.useState({}),[A,R]=b.useState([]),[q,O]=b.useState(!1),[L,B]=b.useState([]),[_,Q]=b.useState(null),[C,Y]=b.useState([]),[H,fe]=b.useState($y),[ee,xe]=b.useState(null),re=l?qT(u.gateway,l):null,[de,U]=b.useState(null),Z=b.useRef(null),[oe,ge]=b.useState(!1),T=b.useCallback(()=>{Z.current=null,ge(!1)},[]),z=()=>{const E=Z.current;return new Set(E?[E.session,...E.agents].map(V=>`agent:${V}`):[])},F=b.useRef(null),J=b.useCallback(E=>{const V=t.getState().focus;t.focusSession(E);const ue=t.getState().focus;ue!==V&&(F.current=ue)},[t]);b.useEffect(()=>{const E=Z.current;E&&(i?E.session!==i:E.attempted)&&T(),p(i?[i]:[]),Q(V=>{if(V?.kind==="draft"&&t.getState().busy.create)return V;if(i&&E?.session===i&&E.active){const ue=sf(E.active);if(ue&&ue.kind!=="agent")return ue}return i&&E?.session===i&&!E.active&&V?.kind==="launcher"?V:i?{kind:"agent",id:i}:V&&V.kind!=="agent"?V:null})},[i,t,T]),b.useEffect(()=>{const E=re?UT(kh(ec()),re):void 0;y(E?.tasks??[]),k(E?.files??[]),S({}),R(E?.panels??[]),Y(E?.order??[]);const V=E?.panes??$y(),ue=new Set(Object.values(V.assign)),he=Vt(V.root).length>1?Vt(V.root).filter(We=>!ue.has(We)).map((We,ft)=>({pane:We,id:`n${ft+1}`})):[];fe(he.length?{...V,assign:{...V.assign,...Object.fromEntries(he.map(We=>[`launcher:${We.id}`,We.pane]))}}:V),xe(null),O(!1),B(he.map(We=>We.id));const pe=sf(E?.active);Z.current=E?.session?{session:E.session,agents:E.agents,active:E.active}:null,ge(!!E?.session);const $e=he.find(We=>We.pane===V.focused);Q(We=>pe&&pe.kind!=="agent"&&(pe.kind==="task"?E?.tasks.includes(pe.id):pe.kind==="file"?E?.files?.includes(pe.id):E?.panels.includes(pe.id))?pe:(We&&We.kind!=="agent"?null:We)??($e?{kind:"launcher",id:$e.id}:null)),U(re)},[re]),b.useEffect(()=>{const E=Z.current;!E||E.attempted||i||d.status!=="ready"||(_?.kind!=="draft"&&d.list.some(V=>V.id===E.session)?(E.attempted=!0,t.selectSession(E.session)):T())},[d,i,_,t,T]),b.useEffect(()=>{const E=Z.current;if(!E||!h||h.rootId!==i||E.session!==i)return;if(h.status==="gone"||h.status==="error"){T();return}if(h.status!=="attached")return;T();const V=E.agents.filter(he=>h.projection.sessions[he]);if(!V.length)return;p(he=>[...he,...V.filter(pe=>!he.includes(pe))]);const ue=sf(E.active);ue?.kind==="agent"&&V.includes(ue.id)&&(t.focusSession(ue.id),Q(ue))},[h,i,t,T]),b.useEffect(()=>{if(!(!a||!i)){if(p(E=>E.includes(a)?E:[...E,a]),F.current===a){F.current=null;return}Q(E=>E?.kind==="draft"&&t.getState().busy.create||E&&Z.current?.session===i&&a===i&&E.kind!=="agent"?E:{kind:"agent",id:a})}},[a,i,t]);const le=b.useMemo(()=>q1([...m.map(E=>({kind:"agent",id:E})),...x.map(E=>({kind:"task",id:E})),...w.map(E=>({kind:"file",id:E})),...A.map(E=>({kind:"panel",id:E})),...q?[nf]:[],...L.map(E=>({kind:"launcher",id:E}))],qe,C),[m,x,w,A,q,L,C]),ne=b.useMemo(()=>Vt(H.root),[H.root]),ce=b.useMemo(()=>AT(H,le,qe),[H,le]),ve=_?Ti(H,qe(_)):ne.includes(H.focused)?H.focused:ne[0],Re=ce[ve]??[],Me=b.useCallback(E=>{if(E===ve)return _;const V=ce[E]??[],ue=H.actives[E];return V.find(he=>qe(he)===ue)??V[0]??null},[ve,_,ce,H.actives]);b.useEffect(()=>{de===re&&fe(E=>{const V=new Set(le.map(qe)),ue=z(),he=Vt(E.root);let pe=!1;const $e={};for(const[W,me]of Object.entries(E.assign))(V.has(W)||ue.has(W))&&he.includes(me)?$e[W]=me:pe=!0;for(const W of V)$e[W]||($e[W]=ve,pe=!0);let We=E.actives;const ft=_?qe(_):null;return ft&&V.has(ft)&&We[ve]!==ft&&(We={...We,[ve]:ft},pe=!0),E.focused!==ve&&(pe=!0),pe?{...E,focused:ve,assign:$e,actives:We}:E})},[de,re,le,_,ve]),b.useEffect(()=>{if(de!==re||oe||ne.length<2)return;const E=ne.filter(V=>!(ce[V]??[]).length);E.length&&fe(V=>{let ue=V;for(const he of E)ue=Hy(ue,he)??ue;return ue})},[de,re,oe,ne,ce]),b.useEffect(()=>{ee&&(!ne.includes(ee)||ne.length<2)&&xe(null)},[ee,ne]),b.useEffect(()=>{if(!re||de!==re)return;const E=i??Z.current?.session,V=le.filter(pe=>!tf(pe)).map(qe),ue=new Set([...V,...z()]),he=ne.length>1?{root:H.root,focused:ve,assign:Object.fromEntries(Object.entries(H.assign).filter(([pe])=>ue.has(pe))),actives:Object.fromEntries(Object.entries(H.actives).filter(([,pe])=>ue.has(pe)))}:void 0;D1(ec(),pe=>({...pe,workspaces:{...pe.workspaces,[re]:{...E?{session:E}:{},agents:E?[...m.filter($e=>$e!==E),...Z.current?.agents??[]]:[],tasks:x,files:w,panels:A,order:V,..._&&!tf(_)?{active:qe(_)}:Z.current?.active?{active:Z.current.active}:{},...he?{panes:he}:{},at:Date.now()}}}))},[re,de,i,m,x,w,A,le,_,ne,H,ve]);const Qe=E=>{const V=Z.current;V&&!tf(E)&&(V.active=qe(E))},Ue=b.useCallback(E=>{E.kind==="agent"&&t.focusSession(E.id),Qe(E),Q(E)},[t]),et=b.useCallback((E,V)=>{const ue=!!t.getState().busy.create;let he=E;if(ue&&he.some(W=>W.kind==="draft")&&(t.notify("info","The new session is still starting. Its tab opens once it is ready."),he=he.filter(W=>W.kind!=="draft")),!he.length)return;const pe=new Set(he.map(qe));let $e=!1;const We={};for(const W of ne){const me=ce[W]??[],ht=W===ve?_:Me(W),Wt=Yy({tabs:me,active:ht,selected:i,closing:he,keep:V&&me.some(mt=>qe(mt)===qe(V))?V:void 0});$e||=Wt.closingRoot,We[W]=Wt.next}let ft=We[ve]??null;if(!ft&&ne.length>1){const W=T1(H.root,ve);ft=(W?We[W]:null)??ne.map(me=>We[me]).find(Boolean)??null}T(),p(W=>$e?[]:W.filter(me=>!pe.has(`agent:${me}`))),y(W=>W.filter(me=>!pe.has(`task:${me}`))),k(W=>W.filter(me=>!pe.has(`file:${me}`))),R(W=>W.filter(me=>!pe.has(`panel:${me}`))),pe.has("panel:terminal")&&t.closeTerminal(),pe.has(qe(nf))&&O(!1),B(W=>W.filter(me=>!pe.has(`launcher:${me}`))),fe(W=>({...W,actives:Object.fromEntries(ne.flatMap(me=>We[me]?[[me,qe(We[me])]]:[]))})),$e?t.selectSession(null):ft?.kind==="agent"?t.focusSession(ft.id):a&&pe.has(`agent:${a}`)&&i&&J(i),Q(ft)},[ne,ce,ve,_,Me,H.root,i,a,t,J,T]),Fe=b.useCallback(E=>et([E]),[et]),be=b.useCallback((E,V,ue)=>{const he=jh(ue??ce[Ti(H,qe(E))]??[],E,V,i);he.length&&et(he,E)},[ce,H,i,et]),ye=b.useCallback((E,V,ue)=>{const he=qe(E),pe=le.map(qe),$e=new Set((ce[V]??[]).map(qe));$e.delete(he);const We=qf([...pe.filter(mt=>$e.has(mt)),he],he,ue),ft=pe.filter(mt=>mt!==he),W=ft.flatMap((mt,bt)=>$e.has(mt)?[bt]:[]),me=W.length?W[W.length-1]+1:ft.length,ht=[...ft.slice(0,me),he,...ft.slice(me)];let Wt=0;return ht.map(mt=>mt===he||$e.has(mt)?We[Wt++]:mt)},[le,ce]),Ae=b.useCallback((E,V,ue)=>{Y(ue?qf(le.map(qe),qe(E),V):ye(E,Ti(H,qe(E)),V))},[le,ye,H]),Ne=b.useCallback(E=>{if(E===ve||!ne.includes(E))return;const V=Me(E);V?Ue(V):(fe(ue=>({...ue,focused:E})),Q(null))},[ve,ne,Me,Ue]),Ht=b.useCallback((E,V)=>{const ue=Ti(E,qe(V)),he=Me(ue);if(!he||qe(he)!==qe(V))return E;const pe=Yy({tabs:ce[ue]??[],active:V,selected:null,closing:[V]}).next,$e={...E.actives};return pe?$e[ue]=qe(pe):delete $e[ue],{...E,actives:$e}},[Me,ce]),cn=b.useCallback((E,V,ue)=>{if(!ne.includes(V))return;const he=(ce[V]??[]).filter(pe=>qe(pe)!==qe(E));Y(ye(E,V,ue??he.length)),fe(pe=>CT(Ht(pe,E),qe(E),V)),Ue(E)},[ne,ce,ye,Ht,Ue]),ze=b.useCallback((E,V,ue)=>{const he=Ti(H,qe(E));if(he===V&&(ce[he]??[]).length<2)return;const pe=Rf(Ht(H,E),{target:V,position:ue,key:qe(E)});pe&&(fe(pe),Ue(E))},[H,ce,Ht,Ue]),ut=!!l,At=b.useCallback((E,V=ve)=>{if(!ut)return;const ue=new Set(L);let he=1;for(;ue.has(`n${he}`);)he+=1;const pe={kind:"launcher",id:`n${he}`},$e=Rf(H,{target:V,position:E,key:qe(pe)});$e&&(fe($e),B(We=>[...We,pe.id]),Q(pe))},[ut,L,H,ve]),Rt=b.useCallback((E,V)=>{const ue=`launcher:${E}`,he=Ti(H,ue);fe(pe=>({...pe,focused:he})),B(pe=>pe.filter($e=>$e!==E)),V()},[H]),In=b.useCallback(E=>{if(ne.length<2||!ne.includes(E))return;const V=ce[E]??[];V.length?et(V):fe(ue=>Hy(ue,E)??ue)},[ne,ce,et]),kn=b.useCallback(E=>{const V=Iy(H.root,ve,E);return V?(Ne(V),!0):!1},[H.root,ve,Ne]),Qt=b.useCallback(E=>{const V=Iy(H.root,ve,E);return!V||!_?!1:(cn(_,V),!0)},[H.root,ve,_,cn]),Je=b.useCallback((E,V)=>fe(ue=>ET(ue,E,V)),[]),jt=b.useCallback(E=>xe(V=>V===E?null:E),[]),St=b.useCallback(E=>{y(V=>V.includes(E)?V:[...V,E]),Qe({kind:"task",id:E}),Q({kind:"task",id:E})},[]),un=b.useCallback((E,V)=>{const ue=Js(E);!ue||$i(ue)||(k(he=>he.includes(ue)?he:[...he,ue]),S(he=>({...he,[ue]:{...V?{line:V}:{},nonce:(he[ue]?.nonce??0)+1}})),Qe({kind:"file",id:ue}),Q({kind:"file",id:ue}))},[]),Gn=b.useCallback(E=>j[E],[j]),js=b.useCallback(E=>{t.focusSession(E),p(V=>V.includes(E)?V:[...V,E]),Qe({kind:"agent",id:E}),Q({kind:"agent",id:E})},[t]),dn=b.useCallback(E=>{R(V=>V.includes(E)?V:[...V,E]),Qe({kind:"panel",id:E}),Q({kind:"panel",id:E})},[]),fn=b.useCallback(()=>{O(!0),Q(nf)},[]),Ct=b.useCallback(E=>{O(!1),Q(V=>V?.kind!=="draft"?V:t.getState().selected===E?{kind:"agent",id:E}:null)},[t]),jn=b.useMemo(()=>({tabs:le,row:Re,active:_,panes:H,byPane:ce,focusedPane:ve,activeOf:Me,focusPane:Ne,splitEmpty:At,canSplitEmpty:ut,launch:Rt,splitWith:ze,moveTabToPane:cn,closePane:In,focusAdjacent:kn,moveTabAdjacent:Qt,resize:Je,maximized:ee,toggleMaximized:jt,activate:Ue,close:Fe,closeOthers:be,move:Ae,openTask:St,openFile:un,fileTarget:Gn,openAgent:js,openPanel:dn,openDraft:fn,finishDraft:Ct}),[le,Re,_,H,ce,ve,Me,Ne,At,ut,Rt,ze,cn,In,kn,Qt,Je,ee,jt,Ue,Fe,be,Ae,St,un,Gn,js,dn,fn,Ct]);return o.jsx(B1.Provider,{value:jn,children:s})}const Ws="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",IT=I("flex w-full min-w-0 items-start gap-2 rounded-lg py-2 pl-2 pr-3 text-left",Ws),GT=[0,1,2,3,4],YT={list:YS,board:zS,epics:uh},VT={approve:l0,review:lo,progress:uc,ready:lc,waiting:s0,epics:uh,closed:t0},KT={approve:"bg-dot-warning",review:"bg-dot-running",progress:"border-2 border-dot-warning",ready:"bg-dot-success",blocked:"bg-dot-danger",closed:"border-2 border-border"},FT={blocked:"border-l-dot-danger",ready:"border-l-dot-success",approve:"border-l-dot-warning"};function Sh({state:s}){return o.jsx("span",{role:"img","aria-label":qy[s],title:qy[s],className:I("inline-block size-[9px] shrink-0 rounded-full",KT[s])})}function $1({value:s}){return o.jsxs("span",{className:I("shrink-0 rounded border px-1 text-[length:calc(10.5px*var(--ui-scale))] font-semibold tabular-nums leading-4",s===0?"border-destructive text-destructive":s===1?"border-warning text-warning":"border-border text-muted-foreground"),children:["P",s]})}function U1({onPicked:s,onOpen:t,current:i}){const a=Oe(),{openTask:l,active:u}=kt(),d=C=>{(t??l)(C),s?.()},{tasks:h,principal:m,workspace:p}=Ee(),[x,y]=b.useState(""),[w,k]=b.useState(2),[j,S]=b.useState({view:"list",filter:"open",query:""}),A=a.tasksBlock(),R=Te(m??void 0,"project.write");b.useEffect(()=>(a.setTasksVisible(!0),()=>a.setTasksVisible(!1)),[a]);const q=h.rows,O=b.useMemo(()=>xT(q),[q]),L=b.useMemo(()=>yT(q,j.filter,j.query),[q,j.filter,j.query]);if(!p)return o.jsx("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:"Choose a workspace to see its tasks."});if(A)return o.jsxs("p",{className:"flex items-start gap-2 px-4 py-6 text-sm text-muted-foreground",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),A]});const B=C=>t?i===C:u?.kind==="task"&&u.id===C,_=C=>S(Y=>({...Y,view:C})),Q=h.status==="ready"||q.length>0;return o.jsxs("div",{className:"@container flex min-h-0 flex-col gap-2 p-2","data-testid":"task-board","data-view":j.view,children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-1 pt-1",children:[o.jsx("h2",{className:"text-sm font-semibold",children:"Tasks"}),Q?o.jsxs("span",{className:"text-xs text-muted-foreground","data-testid":"tasks-open-count",children:[O.open," open"]}):null,o.jsx("span",{className:"flex-1"}),o.jsx("div",{role:"group","aria-label":"Task view",className:"flex rounded-lg border border-border bg-card p-0.5",children:pT.map(C=>{const Y=YT[C.key],H=j.view===C.key;return o.jsxs("button",{type:"button","aria-pressed":H,title:C.label,onClick:()=>_(C.key),className:I("flex h-6 items-center gap-1 rounded-md px-1.5 text-xs",H?"bg-secondary font-semibold text-foreground":"text-muted-foreground hover:text-foreground",Ws),children:[o.jsx(Y,{"aria-hidden":!0,className:"size-3.5"}),o.jsx("span",{className:"sr-only @[340px]:not-sr-only",children:C.label})]},C.key)})}),o.jsx("button",{type:"button","aria-label":"Refresh tasks",title:"Refresh tasks",onClick:()=>{a.refreshTasks()},className:I("flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-sidebar-hover hover:text-foreground",Ws),children:o.jsx(co,{"aria-hidden":!0,className:I("size-3.5",h.status==="loading"&&"animate-spin")})})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-1",children:[o.jsx("div",{role:"group","aria-label":"Task filter",className:"flex flex-wrap gap-1",children:gT.map(C=>{const Y=j.filter===C;return o.jsxs("button",{type:"button","aria-pressed":Y,onClick:()=>S(H=>({...H,filter:C})),"data-testid":`tasks-filter-${C}`,className:I("h-6 rounded-full border px-2.5 text-xs",Y?"border-foreground bg-foreground font-semibold text-background":"border-border text-foreground hover:bg-secondary",Ws),children:[C[0].toUpperCase()+C.slice(1)," ",o.jsx("span",{className:"text-[length:calc(11px*var(--ui-scale))] opacity-60",children:O[C]})]},C)})}),o.jsxs("label",{className:"flex h-7 min-w-[160px] flex-1 items-center gap-1.5 rounded-lg border border-border bg-card px-2 focus-within:border-ring",children:[o.jsx(ti,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground"}),o.jsx("input",{type:"text",role:"searchbox",value:j.query,onChange:C=>S(Y=>({...Y,query:C.target.value})),"aria-label":"Filter tasks",placeholder:"Filter by id, title, label, agent",className:"min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-muted-foreground"})]})]}),R?o.jsxs("form",{className:"flex gap-1.5 px-1",onSubmit:C=>{C.preventDefault(),x.trim()&&(a.createTask({title:x,priority:w}),y(""))},children:[o.jsx(ro,{htmlFor:"task-title",className:"sr-only",children:"New task"}),o.jsx(Zn,{id:"task-title",value:x,onChange:C=>y(C.target.value),placeholder:"New task…",maxLength:200,className:"h-8 min-w-0 flex-1"}),o.jsx(ro,{htmlFor:"task-priority",className:"sr-only",children:"Priority"}),o.jsx(ph,{id:"task-priority",value:w,onChange:C=>k(Number(C.target.value)),className:"h-8 w-16 text-xs",children:GT.map(C=>o.jsxs("option",{value:C,children:["P",C]},C))}),o.jsx(we,{type:"submit",size:"icon-sm",className:"size-8","aria-label":"Add task",title:"Add task",disabled:!x.trim(),children:o.jsx(ks,{"aria-hidden":!0})})]}):o.jsx("p",{className:"px-2 text-xs text-muted-foreground",children:"Your access token can read tasks but not change them."}),h.creates.map(C=>o.jsx("div",{role:C.status==="creating"?"status":"alert",className:I("mx-1 rounded-lg border px-3 py-2 text-xs",C.status==="creating"?"border-border text-muted-foreground":C.status==="unknown"?"border-warning/40 bg-warning/5 text-warning":"border-destructive/40 bg-destructive/5 text-destructive"),children:C.status==="creating"?o.jsx(Ft,{label:`Creating “${C.title}”…`}):o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"mb-1.5 font-medium text-foreground",children:["“",C.title,"”"]}),o.jsx("p",{children:C.error}),C.match?o.jsxs("p",{className:"mt-1 text-foreground/90",children:["A task with this title is in the list (",C.match,"); it was probably created."]}):null,o.jsxs("div",{className:"mt-2 flex gap-2",children:[o.jsxs(we,{size:"sm",variant:"secondary",onClick:()=>{a.retryTaskCreate(C.requestId)},children:[o.jsx(uo,{"aria-hidden":!0})," Create again"]}),o.jsx(we,{size:"sm",variant:"ghost",onClick:()=>a.dismissTaskCreate(C.requestId),children:"Dismiss"})]})]})},C.requestId)),h.message?o.jsx("p",{role:h.message.level==="error"?"alert":"status",className:I("mx-1 rounded-md px-3 py-1.5 text-xs",h.message.level==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-highlight"),children:h.message.text}):null,h.status==="loading"&&!q.length?o.jsx(Ft,{label:"Loading tasks…",className:"px-2 text-xs"}):null,h.status==="error"?o.jsx("p",{role:"alert",className:"mx-1 rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:h.error?.message}):null,h.unreadable?o.jsxs("p",{className:"px-2 text-xs text-warning",children:[h.unreadable," task file(s) on the host could not be read."]}):null,h.status==="ready"&&!q.length?o.jsx(Bf,{text:"No tasks yet. Add one here, with alp task add, or ask main to plan the work."}):null,q.length&&!L.length?o.jsx(Bf,{text:j.query.trim()?"No tasks match.":j.filter==="open"?"All tasks are closed.":j.filter==="ready"?"No task is ready.":"No closed tasks."}):null,L.length&&j.view==="list"?o.jsx(XT,{tasks:L,isCurrent:B,onOpen:d,canWrite:R}):null,L.length&&j.view==="board"?o.jsx(PT,{tasks:L,isCurrent:B,onOpen:d}):null,L.length&&j.view==="epics"?o.jsx(QT,{all:q,shown:L,isCurrent:B,onOpen:d}):null]})}function Bf({text:s}){return o.jsx("p",{role:"status",className:"mx-1 rounded-lg border border-dashed border-border px-4 py-5 text-center text-xs text-muted-foreground",children:s})}function H1({task:s,isCurrent:t,onOpen:i,testId:a="task-row"}){const l=t(s.id),u=vh(s),d=s.blockedBy?.length?`after ${s.blockedBy.join(", ")}`:"",h=s.waits?.length&&!s.approvals?.length?`waits on ${s.waits.join("; ")}`:"";return o.jsx("div",{className:I("rounded-lg",l?"bg-sidebar-selected":"hover:bg-sidebar-hover"),"data-testid":a,children:o.jsxs("button",{type:"button",className:IT,onClick:()=>i(s.id),"aria-current":l?"true":void 0,title:s.title,children:[o.jsx("span",{className:"flex h-5 w-4 shrink-0 items-center justify-center",children:o.jsx(Sh,{state:u})}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:I("line-clamp-2 text-sm leading-5",s.status==="closed"?"text-muted-foreground line-through":"text-foreground/90"),children:s.title}),o.jsxs("span",{className:"mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground",children:[o.jsx("span",{className:"font-mono",children:s.id}),o.jsxs("span",{children:["P",s.priority]}),s.type&&s.type!=="task"?o.jsx("span",{children:s.type}):null,o.jsx("span",{children:String(s.status).replace("_"," ")}),s.assignee?o.jsxs("span",{children:["· @",s.assignee]}):null,s.progress?o.jsxs("span",{children:["· ",s.progress.done,"/",s.progress.total]}):null,s.approvals?.length?o.jsx("span",{className:"text-dot-warning",children:"· needs approval"}):null,d?o.jsxs("span",{className:"text-dot-danger",children:["· ",d]}):null,h?o.jsxs("span",{children:["· ",h]}):null,s.parent?o.jsxs("span",{children:["· in ",s.parent]}):null,(s.labels??[]).map(m=>o.jsxs("span",{className:"text-info",children:["#",m]},m)),o.jsx("span",{className:"ml-auto tabular-nums",children:k1(s.status==="closed"?s.closed?.at:s.updatedAt)})]})]})]})})}function XT({tasks:s,isCurrent:t,onOpen:i,canWrite:a}){const l=Oe(),{tasks:u}=Ee(),d=b.useMemo(()=>wT(s),[s]),[h,m]=b.useState({});return o.jsx("div",{className:"space-y-1","data-testid":"tasks-list-view",children:d.map(p=>{const x=h[p.key]??!1,y=VT[p.key]??CS;return o.jsxs("section",{"aria-label":p.title,"data-testid":`tasks-section-${p.key}`,children:[o.jsxs("button",{type:"button","aria-expanded":!x,onClick:()=>m(w=>({...w,[p.key]:!x})),className:I("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:text-foreground",Ws),children:[x?o.jsx(Jn,{"aria-hidden":!0,className:"size-3.5"}):o.jsx(Qn,{"aria-hidden":!0,className:"size-3.5"}),o.jsx(y,{"aria-hidden":!0,className:"size-3.5"}),o.jsx("span",{className:"font-semibold",children:p.title}),o.jsx("span",{className:"tabular-nums opacity-70",children:p.tasks.length})]}),x?null:o.jsx("ul",{"aria-label":p.title,children:p.tasks.map(w=>o.jsxs("li",{className:"mb-0.5",children:[o.jsx(H1,{task:w,isCurrent:t,onOpen:i}),p.key==="approve"&&a?w.approvals.map(k=>o.jsxs("div",{className:"ml-8 mr-2 mb-1 flex items-center gap-2 rounded-md bg-warning/[0.06] px-2 py-1 text-xs",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:k.note||"Waiting for your approval"}),k.options?.length?k.options.map(j=>o.jsx(we,{size:"sm",className:"h-6 px-2 text-xs",disabled:!!u.busy[w.id],"aria-label":`Approve ${w.id}: ${j}`,onClick:()=>{l.changeTask(w,{gate:k.gate,choice:j})},children:j},j)):o.jsx(we,{size:"sm",className:"h-6 px-2 text-xs",disabled:!!u.busy[w.id],"aria-label":`Approve ${w.id}`,onClick:()=>{l.changeTask(w,{gate:k.gate})},children:"Approve"}),k.rejected?null:o.jsx(we,{size:"sm",variant:"secondary",className:"h-6 px-2 text-xs",disabled:!!u.busy[w.id],"aria-label":`Reject ${w.id}`,onClick:()=>{l.changeTask(w,{gate:k.gate,reject:!0})},children:"Reject"})]},k.gate)):null]},w.id))})]},p.key)})})}function PT({tasks:s,isCurrent:t,onOpen:i}){const a=b.useMemo(()=>jT(s),[s]);return o.jsx("div",{className:"flex items-start gap-2.5 overflow-x-auto px-1 pb-2","data-testid":"tasks-board-view",children:a.map(l=>o.jsxs("section",{"aria-label":l.title,"data-testid":`tasks-column-${l.key}`,className:"flex max-h-[640px] w-[248px] shrink-0 flex-col rounded-[10px] border border-border bg-card",children:[o.jsxs("h3",{className:"flex items-center gap-2 border-b border-border px-3 py-2 text-xs font-semibold",children:[o.jsx(Sh,{state:l.key}),o.jsx("span",{className:"flex-1",children:l.title}),o.jsx("span",{className:"font-normal tabular-nums text-muted-foreground",children:l.tasks.length})]}),o.jsxs("ul",{className:"min-h-0 space-y-2 overflow-y-auto p-2",children:[l.tasks.map(u=>{const d=t(u.id);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>i(u.id),"aria-current":d?"true":void 0,title:u.title,"data-testid":"task-card",className:I("flex w-full flex-col gap-1 rounded-lg border border-l-[3px] border-border bg-background p-2.5 text-left hover:border-muted-foreground",FT[l.key],d&&"bg-sidebar-selected",Ws),children:[o.jsxs("span",{className:"flex w-full items-center gap-1.5 text-xs text-muted-foreground",children:[o.jsx($1,{value:u.priority}),o.jsx("span",{className:"font-mono",children:u.id}),o.jsx("span",{className:"flex-1"}),o.jsx("span",{className:"tabular-nums",children:k1(l.key==="closed"?u.closed?.at:u.updatedAt)})]}),o.jsx("span",{className:I("line-clamp-3 text-[length:calc(13px*var(--ui-scale))] leading-[18px]",l.key==="closed"&&"text-muted-foreground"),children:u.title}),u.assignee?o.jsxs("span",{className:"truncate text-xs text-muted-foreground",children:["@",u.assignee]}):null,u.blockedBy?.length?o.jsxs("span",{className:"truncate text-xs text-dot-danger",children:["after ",u.blockedBy.join(", ")]}):null,u.labels?.length?o.jsx("span",{className:"flex flex-wrap gap-1.5 text-xs text-info",children:u.labels.map(h=>o.jsxs("span",{children:["#",h]},h))}):null]})},u.id)}),l.tasks.length?null:o.jsx("li",{className:"px-1 py-2 text-xs text-muted-foreground",children:"Nothing here"})]})]},l.key))})}function QT({all:s,shown:t,isCurrent:i,onOpen:a}){const l=b.useMemo(()=>ST(s,t),[s,t]),[u,d]=b.useState({});return l.length?o.jsx("ul",{className:"space-y-2 px-1","data-testid":"tasks-epics-view",children:l.map(({epic:h,children:m,done:p,total:x,percent:y})=>{const w=u[h.id]??h.status!=="closed",k=i(h.id);return o.jsxs("li",{className:"rounded-[10px] border border-border bg-card p-3","data-testid":"epic",children:[o.jsxs("button",{type:"button",onClick:()=>a(h.id),"aria-current":k?"true":void 0,title:h.title,className:I("flex w-full min-w-0 items-center gap-2 rounded-md text-left",k&&"text-highlight",Ws),children:[o.jsx(Sh,{state:vh(h)}),o.jsx(uh,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground"}),o.jsx($1,{value:h.priority}),o.jsx("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:h.id}),o.jsx("span",{className:I("min-w-0 flex-1 truncate text-sm",h.status==="closed"&&"text-muted-foreground line-through"),children:h.title}),o.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground","data-testid":"epic-progress",children:[p,"/",x]})]}),o.jsx("div",{role:"progressbar","aria-label":`${h.id} progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":y,className:"mt-2 h-1.5 overflow-hidden rounded-full bg-secondary",children:o.jsx("div",{className:"h-full rounded-full bg-dot-success",style:{width:`${y}%`}})}),m.length?o.jsxs("button",{type:"button","aria-expanded":w,onClick:()=>d(j=>({...j,[h.id]:!w})),className:I("mt-2 flex items-center gap-1 rounded-md text-xs text-muted-foreground hover:text-foreground",Ws),children:[w?o.jsx(Qn,{"aria-hidden":!0,className:"size-3"}):o.jsx(Jn,{"aria-hidden":!0,className:"size-3"}),m.length," ",m.length===1?"task":"tasks"]}):null,w&&m.length?o.jsx("ul",{className:"mt-1 border-l border-border pl-2","aria-label":`Tasks of ${h.id}`,children:m.map(j=>o.jsx("li",{children:o.jsx(H1,{task:j,isCurrent:i,onOpen:a,testId:"epic-task"})},j.id))}):null]},h.id)})}):o.jsx(Bf,{text:"No epics here. An epic is a task other tasks name as their parent."})}const I1="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",af=I("flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground [&_svg]:size-4",I1);function rf({testId:s,children:t}){return o.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-2 p-6 text-center",role:"note","data-testid":s,children:[o.jsx(ah,{"aria-hidden":!0,strokeWidth:1.5,className:"size-6 text-extra-muted"}),t]})}function WT({onPicked:s}){const t=Oe(),{workspace:i,connection:a,principal:l}=Ee(),{openFile:u,active:d}=kt(),h=a.capabilities.includes("workspace.files.read"),m=Te(l??void 0,"files.read"),[p,x]=b.useState({}),[y,w]=b.useState([]),[k,j]=b.useState("name"),[S,A]=b.useState(!1),R=b.useRef(0),q=b.useCallback((H,fe)=>{const ee=R.current;x(xe=>({...xe,[H]:xe[H]?.status==="ready"?xe[H]:{status:"loading"}})),t.listWorkspaceFiles({...H?{path:H}:{},includeIgnored:fe}).then(xe=>{R.current===ee&&x(re=>({...re,[H]:{status:"ready",entries:xe.entries,truncated:xe.truncated}}))},xe=>{R.current===ee&&x(re=>({...re,[H]:{status:"error",error:xe instanceof Ei||xe instanceof Error?xe.message:"Could not list this folder."}}))})},[t]),O=`${a.gateway}
31
+ ${i??""}`,L=b.useRef(O),B=b.useRef(y);if(B.current=y,b.useEffect(()=>{if(!h||!m||!i||a.phase!=="open")return;R.current+=1;const H=L.current===O;if(L.current=O,x({}),H||w([]),q("",S),H)for(const fe of B.current)q(fe,S)},[h,m,i,O,a.phase,S,q]),!h)return o.jsx(rf,{testId:"files-unavailable",children:o.jsx("p",{className:"max-w-[300px] text-sm text-muted-foreground",children:Qb})});if(!m)return o.jsxs(rf,{testId:"files-forbidden",children:[o.jsxs("p",{className:"flex max-w-[300px] items-start gap-2 text-sm text-foreground",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),kf]}),o.jsxs("p",{className:"max-w-[300px] text-xs leading-5 text-muted-foreground",children:["File reading is never granted by default. The host owner can create a token that allows it: ",o.jsx("code",{className:"font-mono",children:"alp-gateway credential create --permission files.read"})," (with the other permissions it needs)."]})]});if(!i)return o.jsx(rf,{testId:"files-no-workspace",children:o.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a workspace to browse its files."})});const _=w2(p,y,{sort:k,showHidden:S}),Q=H=>{const fe=!y.includes(H);w(ee=>v2(ee,H)),fe&&p[H]?.status!=="ready"&&q(H,S)},C=()=>{R.current+=1,x({}),q("",S);for(const H of y)q(H,S)},Y=d?.kind==="file"?d.id:void 0;return o.jsxs("div",{className:"flex min-h-full flex-col","data-testid":"files-panel",children:[o.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2 py-1",children:[o.jsxs("span",{className:"min-w-0 flex-1 truncate px-1 text-xs text-muted-foreground",children:["Sorted by ",Id[k].toLowerCase()]}),o.jsx("button",{type:"button",className:af,onClick:()=>j(Ex),"aria-label":`Sort by ${Id[Ex(k)].toLowerCase()}`,title:`Sort: ${Id[k]}`,"data-testid":"files-sort","data-sort":k,children:o.jsx(bS,{"aria-hidden":!0})}),o.jsx("button",{type:"button",className:af,onClick:()=>A(H=>!H),"aria-pressed":S,"aria-label":"Show hidden files",title:S?"Hide hidden files":"Show hidden files","data-testid":"files-show-hidden",children:S?o.jsx(lo,{"aria-hidden":!0}):o.jsx(LS,{"aria-hidden":!0})}),o.jsx("button",{type:"button",className:af,onClick:C,"aria-label":"Refresh files",title:"Refresh","data-testid":"files-refresh",children:o.jsx(co,{"aria-hidden":!0})})]}),o.jsx("ul",{className:"py-1",role:"tree","aria-label":"Workspace files",children:_.map(H=>{const fe={paddingLeft:8+H.depth*14};if(H.kind==="status"){const U=H.status==="loading"?"Loading…":H.status==="empty"?H.path?"Empty folder":"No files to show":H.status==="truncated"?"Only the first 1000 entries are shown.":H.message??"Could not list this folder.";return o.jsxs("li",{role:"none",style:fe,className:I("py-1 pr-3 text-xs",H.status==="error"?"text-destructive":"text-muted-foreground"),"data-testid":`files-${H.status}`,children:[U,H.status==="error"?o.jsx("button",{type:"button",className:"ml-2 text-highlight hover:underline",onClick:()=>q(H.path,S),children:"Retry"}):null]},`status:${H.path}`)}const{entry:ee}=H,xe=ee.kind==="directory",re=!xe&&Y===ee.path,de=xe?H.open?qS:Da:r0;return o.jsx("li",{role:"treeitem","aria-expanded":xe?H.open:void 0,"aria-selected":re||void 0,children:o.jsxs("button",{type:"button",style:fe,title:ee.path,onClick:()=>{xe?Q(ee.path):(u(ee.path),s?.())},className:I("flex w-full min-w-0 items-center gap-1.5 py-1 pr-3 text-left text-[length:calc(13px*var(--ui-scale))]",re?"bg-sidebar-selected text-foreground":"text-foreground/85 hover:bg-sidebar-hover",I1),"data-testid":"files-entry","data-path":ee.path,"data-kind":ee.kind,children:[o.jsx(Jn,{"aria-hidden":!0,className:I("size-3.5 shrink-0 text-extra-muted transition-transform",!xe&&"invisible",H.open&&"rotate-90")}),o.jsx(de,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"truncate",children:ee.name})]})},ee.path)})})]})}const ZT=Object.freeze(["shell","read","edit","write","search","fetch","sub_agent","plan","plain_text","unknown"]),Hn=400,JT=1e6,Nh=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),Ln=s=>typeof s=="string"?s:"",za=s=>s.split(`
32
+ `).find(t=>t.trim())?.trim()??"";function G1(s){const t=Nh(s)?s.type:void 0;return typeof t=="string"&&ZT.includes(t)?t:"unknown"}function $l(s,t=[]){if(!s)return s;const i=s.replace(/\\/g,"/");for(const a of t){if(!a)continue;const l=a.replace(/\\/g,"/").replace(/\/+$/,"");if(l){if(i===l)return".";if(i.startsWith(`${l}/`))return i.slice(l.length+1)}}return s}function Vy(s){const t=String(s??"").trim();return t?/[:./]/.test(t)||t.includes("__")?t:t.replace(/[._-]+/g," ").split(" ").filter(Boolean).join(" ").toLowerCase().replace(/^./,i=>i.toUpperCase()):"Tool"}function e5(s){if(typeof s=="string")return za(s);if(Nh(s)){const t=Object.values(s).find(i=>typeof i=="string"&&i.trim());if(typeof t=="string")return za(t)}return""}const t5={shell:"terminal",read:"eye",edit:"pencil",write:"pencil",search:"search",fetch:"search",sub_agent:"bot",plan:"brain",plain_text:"wrench",unknown:"wrench"};function n5(s,t=[]){const i=typeof s?.name=="string"?s.name:"",a=G1(s?.detail),l=Nh(s?.detail)?s.detail:{},d=i.trim().toLowerCase()==="task"||i==="alp_delegate"?"bot":t5[a];switch(a){case"shell":return{kind:a,label:"Shell",secondary:za(Ln(l.command)),icon:d};case"read":return{kind:a,label:"Read",secondary:$l(Ln(l.filePath),t),icon:d};case"edit":return{kind:a,label:"Edit",secondary:$l(Ln(l.filePath),t),icon:d};case"write":return{kind:a,label:"Write",secondary:$l(Ln(l.filePath),t),icon:d};case"search":return{kind:a,label:"Search",secondary:za(Ln(l.query)),icon:d};case"fetch":return{kind:a,label:"Fetch",secondary:Ln(l.url),icon:d};case"sub_agent":return{kind:a,label:Ln(l.subAgentType).trim()||"Task",secondary:za(Ln(l.description)),icon:d};case"plan":return{kind:a,label:"Plan",secondary:"",icon:d};case"plain_text":return{kind:a,label:Vy(i),secondary:za(Ln(l.label)),icon:d};default:{if(i==="alp_delegate")return{kind:a,label:"Delegate",secondary:`to ${l.input?.agent??"an agent"}`,icon:d};const h=i.startsWith("alp_")?i.replace(/^alp_/,"").replace(/^\w/,m=>m.toUpperCase()):Vy(i);return{kind:a,label:h,secondary:e5(l.input),icon:d}}}}function tc(s){if(!s)return[];const t=s.replace(/\r\n?/g,`
33
+ `).split(`
34
+ `);return t.length>1&&t.at(-1)===""&&t.pop(),t}function Y1(s,t=Hn){const i=Math.max(0,Math.floor(t));return s.length>i?{shown:s.slice(0,i),hidden:s.length-i}:{shown:s,hidden:0}}function s5(s){const t=tc(s),i=[],a=[],l=[];let u=0,d=0,h=0,m=0,p="";for(const x of t){if(h>0||m>0){if(x.startsWith("+")){i.push({type:"add",text:x.slice(1),newLine:d++}),m--;continue}if(x.startsWith("-")){i.push({type:"remove",text:x.slice(1),oldLine:u++}),h--;continue}if(x.startsWith("\\")){i.push({type:"meta",text:x});continue}if(x.startsWith(" ")||x===""){i.push({type:"context",text:x.slice(1),oldLine:u++,newLine:d++}),h--,m--;continue}h=0,m=0}const w=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/.exec(x);if(w){u=Number(w[1]),d=Number(w[3]),h=w[2]===void 0?1:Number(w[2]),m=w[4]===void 0?1:Number(w[4]),p&&(a.push(p),l.push(i.length),p=""),i.push({type:"hunk",text:x});continue}if(x.startsWith("diff --git ")){p=x.replace(/^diff --git a\/(.*?) b\/.*$/,"$1");continue}if(x.startsWith("+++ ")){const k=x.slice(4).replace(/^b\//,"").replace(/\t.*$/,"");k!=="/dev/null"&&(p=k);continue}if(x.startsWith("--- ")){const k=x.slice(4).replace(/^a\//,"").replace(/\t.*$/,"");k!=="/dev/null"&&!p&&(p=k);continue}if(!(x.startsWith("index ")||/^(new|deleted) file mode /.test(x)||/^(similarity|rename|old mode|new mode)/.test(x))){if(x.startsWith("@@")){i.push({type:"hunk",text:x});continue}x.startsWith("+")?i.push({type:"add",text:x.slice(1)}):x.startsWith("-")?i.push({type:"remove",text:x.slice(1)}):x.startsWith("\\")?i.push({type:"meta",text:x}):i.push({type:"context",text:x.startsWith(" ")?x.slice(1):x})}}if(a.length>1)for(let x=a.length-1;x>=0;x--)i.splice(l[x],0,{type:"file",text:a[x]});return i}function i5(s,t,{cellLimit:i=JT}={}){const a=tc(s),l=tc(t);let u=0;for(;u<a.length&&u<l.length&&a[u]===l[u];)u++;let d=0;for(;d<a.length-u&&d<l.length-u&&a[a.length-1-d]===l[l.length-1-d];)d++;const h=[];for(let y=0;y<u;y++)h.push({type:"context",text:a[y],oldLine:y+1,newLine:y+1});const m=a.length-u-d,p=l.length-u-d;let x=!0;if(m&&p&&m*p<=i){const y=p+1,w=new Uint32Array((m+1)*y);for(let S=m-1;S>=0;S--)for(let A=p-1;A>=0;A--)w[S*y+A]=a[u+S]===l[u+A]?w[(S+1)*y+A+1]+1:Math.max(w[(S+1)*y+A],w[S*y+A+1]);let k=0,j=0;for(;k<m&&j<p;)a[u+k]===l[u+j]?(h.push({type:"context",text:a[u+k],oldLine:u+k+1,newLine:u+j+1}),k++,j++):w[(k+1)*y+j]>=w[k*y+j+1]?(h.push({type:"remove",text:a[u+k],oldLine:u+k+1}),k++):(h.push({type:"add",text:l[u+j],newLine:u+j+1}),j++);for(;k<m;k++)h.push({type:"remove",text:a[u+k],oldLine:u+k+1});for(;j<p;j++)h.push({type:"add",text:l[u+j],newLine:u+j+1})}else{x=!(m&&p);for(let y=0;y<m;y++)h.push({type:"remove",text:a[u+y],oldLine:u+y+1});for(let y=0;y<p;y++)h.push({type:"add",text:l[u+y],newLine:u+y+1})}for(let y=d;y>0;y--)h.push({type:"context",text:a[a.length-y],oldLine:a.length-y+1,newLine:l.length-y+1});return{lines:h,exact:x}}function V1(s,t){const i=Ln(s?.unifiedDiff);if(i){const u=s5(i);return{lines:u,numbered:u.some(d=>d.type==="hunk"&&/^@@ -\d/.test(d.text)),exact:!0}}const{lines:a,exact:l}=i5(Ln(s?.oldString),Ln(s?.newString),t);return{lines:a,numbered:!1,exact:l}}function a5(s){let t=0,i=0;for(const a of s)a.type==="add"?t++:a.type==="remove"&&i++;return{added:t,removed:i}}function r5(s){if(!(typeof s!="string"||!s.trim()))try{const t=new URL(s.trim());return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function nc(s){if(s==null)return"";if(typeof s=="string")return s;try{return JSON.stringify(s,null,2)??String(s)}catch{return String(s)}}const Di=(()=>{let s={mode:"uncommitted",ignoreWhitespace:!1,focus:null,focusScope:""};const t=new Set;return{get:()=>s,set(i){s={...s,...i};for(const a of[...t])a()},subscribe(i){return t.add(i),()=>{t.delete(i)}}}})(),o5=()=>b.useSyncExternalStore(Di.subscribe,Di.get,Di.get);function Ky(s,t=""){Di.set({focus:s,focusScope:t})}const l5=15e3,vc="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",$f=I("flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground disabled:opacity-50 [&_svg]:size-4",vc);function Fy({testId:s,reason:t,children:i}){return o.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-2 p-6 text-center",role:"note","data-testid":s,"data-reason":t,children:[o.jsx(Sf,{"aria-hidden":!0,strokeWidth:1.5,className:"size-6 text-extra-muted"}),i]})}function c5(s,t){const i=Oe(),[a,l]=b.useState({loading:!1,at:0}),u=b.useRef(0),d=b.useCallback(()=>{const h=++u.current;l(m=>({...m,loading:!0})),i.gitStatus().then(m=>{u.current===h&&l({status:m,loading:!1,at:Date.now()})},m=>{if(u.current===h){const p=_i(m);l({error:p.message,reason:p.reason,loading:!1,at:Date.now()})}})},[i]);return b.useEffect(()=>{s?d():(u.current++,l({loading:!1,at:0}))},[s,t,d]),{...a,load:d}}function u5(s,t,i){const a=Oe(),[l,u]=b.useState({loading:!1,more:!1}),d=b.useRef(0),h=b.useRef(i);h.current=i;const m=b.useCallback(x=>{const y=++d.current,{path:w,...k}=h.current;u(j=>({...j,loading:!0,error:void 0,notice:x})),a.gitDiff({compare:k,...w?{path:w}:{}}).then(j=>{d.current===y&&u({diff:_x(void 0,j),loading:!1,more:!1,notice:x})},j=>{d.current===y&&u({error:_i(j).message,loading:!1,more:!1,notice:x})})},[a]),p=b.useCallback(()=>{const x=l.diff?.nextCursor;if(!x||l.more)return;const y=d.current,{path:w,...k}=h.current;u(j=>({...j,more:!0})),a.gitDiff({compare:k,...w?{path:w}:{},cursor:x}).then(j=>{d.current===y&&u(S=>({...S,diff:_x(S.diff,j),more:!1}))},j=>{if(d.current===y){if(lj(j)){m(_i(j).reason==="stale_snapshot"?Gl.stale_snapshot:Gl.invalid_cursor);return}u(S=>({...S,more:!1,error:_i(j).message}))}})},[a,l.diff?.nextCursor,l.more,m]);return b.useEffect(()=>{s?m():(d.current++,u({loading:!1,more:!1}))},[s,t,m]),{...l,load:m,loadMore:p}}function d5(s,t,i){const a=b.useRef({refresh:s,lastAt:t,enabled:i});a.current={refresh:s,lastAt:t,enabled:i},b.useEffect(()=>{const l=()=>{const{refresh:u,lastAt:d,enabled:h}=a.current;h&&document.visibilityState!=="hidden"&&Date.now()-d>l5&&u()};return window.addEventListener("focus",l),document.addEventListener("visibilitychange",l),()=>{window.removeEventListener("focus",l),document.removeEventListener("visibilitychange",l)}},[])}function K1({additions:s,deletions:t,testId:i}){return o.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs tabular-nums","data-testid":i,children:[o.jsxs("span",{className:"text-dot-success",children:["+",Lx(s)]}),o.jsxs("span",{className:"text-destructive",children:["-",Lx(t)]})]})}const Xy={add:"bg-[rgba(46,160,67,0.15)]",remove:"bg-[rgba(248,81,73,0.15)]",context:"",hunk:"bg-muted/60 text-muted-foreground"},f5={add:"+",remove:"-",context:" "};function h5({file:s}){const t=b.useMemo(()=>dj(s),[s]),[i,a]=b.useState(Hn),{shown:l,hidden:u}=Y1(t,i);if(s.kind!=="text")return o.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-file-kind","data-kind":s.kind,children:Mb[s.kind]});if(!t.length&&s.change==="renamed"&&s.oldPath)return o.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-file-rename",children:["Renamed ",s.oldPath," → ",s.path]});if(!t.length)return o.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-file-empty",children:"No changes to display"});const d=String(Math.max(0,...t.map(m=>"oldLine"in m?Math.max(m.oldLine??0,m.newLine??0):0))).length,h=m=>o.jsx("span",{"aria-hidden":!0,className:"shrink-0 select-none pr-2 text-right text-muted-foreground tabular-nums",style:{minWidth:`${d+1}ch`},children:m??""});return o.jsxs("div",{className:"overflow-auto bg-card font-mono text-(length:--code-font-size) leading-[1.5] text-foreground","data-testid":"git-hunks",children:[o.jsx("div",{className:"min-w-max py-1",children:l.map((m,p)=>m.type==="hunk"?o.jsx("div",{className:I("whitespace-pre px-3",Xy.hunk),"data-diff":"hunk",children:m.text},p):o.jsxs("div",{className:I("flex whitespace-pre px-3",Xy[m.type]),"data-diff":m.type,children:[h(m.oldLine),h(m.newLine),o.jsx("span",{"aria-hidden":!0,className:I("w-[2ch] shrink-0 select-none",m.type==="add"?"text-dot-success":m.type==="remove"?"text-destructive":"text-muted-foreground"),children:f5[m.type]}),o.jsx("span",{children:m.text||" "}),m.noNewline?o.jsx("span",{className:"ml-2 select-none text-muted-foreground",title:"No newline at end of file",children:"⏎̸"}):null]},p))}),u?o.jsxs("button",{type:"button","data-testid":"git-hunks-more",onClick:()=>a(m=>m+Hn),className:"sticky left-0 block px-3 py-1.5 font-sans text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[`Show ${Math.min(u,Hn)} more line${Math.min(u,Hn)===1?"":"s"}`,u>Hn?` (${u} hidden)`:""]}):null]})}function F1({change:s}){const t=s==="deleted"?"text-destructive":s==="added"||s==="untracked"?"text-dot-success":s==="conflicted"?"text-destructive":"text-highlight";return o.jsx("span",{"aria-label":Rx[s],title:Rx[s],className:I("w-3 shrink-0 text-center font-mono text-[length:calc(11px*var(--ui-scale))] font-semibold",t),children:oj[s]})}function X1({path:s,oldPath:t}){const i=s.lastIndexOf("/");return o.jsxs("span",{className:"min-w-0 flex-1 truncate text-[length:calc(13px*var(--ui-scale))]",title:t?`${t} → ${s}`:s,children:[t?o.jsxs("span",{className:"text-muted-foreground",children:[t," → "]}):null,o.jsx("span",{className:"text-foreground",children:i>=0?s.slice(i+1):s}),i>=0?o.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:s.slice(0,i)}):null]})}function m5({file:s,open:t,onToggle:i,onOpenDiff:a}){return o.jsxs("li",{className:"border-b border-border/60","data-testid":"git-file","data-path":s.path,"data-kind":s.kind,"data-change":s.change,children:[o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",onClick:i,"aria-expanded":t,className:I("flex min-w-0 flex-1 items-center gap-1.5 py-1.5 pl-2 pr-1 text-left hover:bg-sidebar-hover",vc),"data-testid":"git-file-toggle",children:[o.jsx(Jn,{"aria-hidden":!0,className:I("size-3.5 shrink-0 text-extra-muted transition-transform",t&&"rotate-90")}),o.jsx(F1,{change:s.change}),o.jsx(X1,{path:s.path,oldPath:s.oldPath}),s.kind==="text"?o.jsx(K1,{additions:s.additions,deletions:s.deletions}):o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:Mb[s.kind].split(":")[0]})]}),a?o.jsx("button",{type:"button",className:I($f,"mr-1"),onClick:a,"aria-label":`Open ${s.path} in Diff`,title:"Open in Diff","data-testid":"git-file-open-diff",children:o.jsx($S,{"aria-hidden":!0})}):null]}),t?o.jsx(h5,{file:s}):null]})}function p5({file:s}){return o.jsxs("li",{className:"flex items-center gap-1.5 border-b border-border/60 py-1.5 pl-7 pr-2","data-testid":"git-status-file","data-path":s.path,"data-change":s.change,children:[o.jsx(F1,{change:s.change}),o.jsx(X1,{path:s.path,oldPath:s.oldPath}),o.jsx("span",{className:"shrink-0 text-[length:calc(11px*var(--ui-scale))] text-muted-foreground",children:[s.staged?"staged":"",s.unstaged?"unstaged":""].filter(Boolean).join(" · ")})]})}function Py({count:s}){return s?o.jsxs("p",{className:"flex items-center gap-1.5 px-3 py-2 text-xs text-muted-foreground","data-testid":"git-hidden",children:[o.jsx(qa,{"aria-hidden":!0,className:"size-3.5"}),`${s} changed file${s===1?" is":"s are"} not shown remotely (secrets, keys, .git or ALP configuration).`]}):null}function Qy({status:s,mode:t}){return o.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 border-b border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"git-branch",children:[o.jsx(Qs,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),o.jsxs("span",{className:"min-w-0 flex-1 truncate",title:Ox(s),children:[o.jsx("span",{className:"text-foreground","data-testid":"git-branch-name",children:Ox(s)}),t==="base"?o.jsxs("span",{children:[` → ${hj(s.baseRef)}`,s.aheadBehind?` (${s.aheadBehind.ahead} ahead, ${s.aheadBehind.behind} behind)`:""]}):null]}),o.jsx("span",{className:"shrink-0",title:"Commit, push, pull, merge and branch switching are not available remotely; use Git on the host.","data-testid":"git-read-only",children:"Read only"})]})}function g5({mode:s,setMode:t,content:i,ignoreWhitespace:a,totals:l,refreshing:u,onRefresh:d,testId:h}){return o.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-2 py-1","data-testid":h,children:[i?o.jsx("select",{"aria-label":"Diff mode",value:s,onChange:m=>t(m.target.value),"data-testid":"git-mode",className:I("h-7 rounded-md bg-transparent px-1 text-xs text-foreground hover:bg-secondary",vc),children:Eb.map(m=>o.jsx("option",{value:m.id,children:m.label},m.id))}):o.jsx("span",{className:"px-1 text-xs text-muted-foreground",children:"Uncommitted"}),o.jsx("span",{className:"min-w-0 flex-1"}),l?o.jsx(K1,{additions:l.additions,deletions:l.deletions,testId:"git-totals"}):null,i?o.jsx("button",{type:"button",className:I($f,a&&"bg-secondary text-foreground"),onClick:()=>Di.set({ignoreWhitespace:!a}),"aria-pressed":a,"aria-label":a?"Show whitespace":"Hide whitespace",title:a?"Show whitespace":"Hide whitespace","data-testid":"git-whitespace",children:o.jsx(lN,{"aria-hidden":!0})}):null,o.jsx("button",{type:"button",className:$f,onClick:d,disabled:u,"aria-label":u?"Refreshing":"Refresh",title:u?"Refreshing":"Refresh","data-testid":"git-refresh",children:o.jsx(co,{"aria-hidden":!0,className:I(u&&"animate-spin")})})]})}function P1({variant:s,onOpenDiff:t}){const i=Oe(),a=Ee(),l=i.gitAccess,u=o5(),d=a.connection.phase==="open",h=`${a.connection.gateway}
35
+ ${a.workspace??""}
36
+ ${l.status?l.workspaceId:""}`,m=s==="diff"&&u.focusScope===h?u.focus:null,p=c5(d&&l.status,h),x=p.status?.state==="repository",y=l.status&&l.content,w={mode:u.mode,baseRef:u.mode==="base"?p.status?.baseRef??null:null,ignoreWhitespace:u.ignoreWhitespace,...m?{path:m}:{}},k=`${h}
37
+ ${w.mode}
38
+ ${w.baseRef??""}
39
+ ${w.ignoreWhitespace}
40
+ ${m??""}
41
+ ${p.at}`,j=u5(d&&!!y&&x,k,w),[S,A]=b.useState([]);b.useEffect(()=>A([]),[h,u.mode]);const R=b.useCallback(()=>{p.load()},[p.load]);d5(R,p.at,d&&l.status);const q=`${s}-panel`;if(!l.status)return o.jsx(Fy,{testId:`panel-unavailable-${s}`,reason:l.reason,children:l.reason==="projectRead"?o.jsxs("p",{className:"flex max-w-[300px] items-start gap-2 text-sm text-foreground",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),l.message]}):o.jsx("p",{className:"max-w-[300px] text-sm text-muted-foreground",children:l.message})});const O=C=>o.jsx(g5,{mode:u.mode,setMode:Y=>Di.set({mode:Y}),content:!!y,ignoreWhitespace:u.ignoreWhitespace,totals:C,refreshing:p.loading||j.loading,onRefresh:R,testId:`${s}-toolbar`});if(!p.status)return o.jsxs("div",{className:"flex min-h-full flex-col","data-testid":q,children:[O(),p.error?o.jsxs("p",{className:"px-3 py-4 text-sm text-destructive",role:"alert","data-testid":"git-error",children:[p.error," ",o.jsx("button",{type:"button",className:"ml-1 text-highlight hover:underline",onClick:R,children:"Retry"})]}):o.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground","data-testid":"git-loading",children:"Checking repository..."})]});if(p.status.state!=="repository")return o.jsxs(Fy,{testId:"changes-not-git",reason:p.status.state,children:[o.jsx("p",{className:"max-w-[300px] text-sm text-muted-foreground",children:p.status.state==="unsupported"?"This workspace is inside a Git repository but is not its top level, so its changes are not shown.":"Not a git repository"}),o.jsx("button",{type:"button",className:"text-xs text-highlight hover:underline",onClick:R,children:"Refresh"})]});if(!y){const C=p.status.files;return o.jsxs("div",{className:"flex min-h-full flex-col","data-testid":q,"data-content":"none",children:[O(),o.jsx(Qy,{status:p.status,mode:"uncommitted"}),o.jsxs("p",{className:"flex items-start gap-1.5 px-3 py-2 text-xs text-muted-foreground","data-testid":"git-content-forbidden",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-3.5 shrink-0"}),l.contentMessage]}),C.length?o.jsx("ul",{"aria-label":"Changed files",children:C.map(Y=>o.jsx(p5,{file:Y},`${Y.oldPath??""}
42
+ ${Y.path}`))}):o.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground","data-testid":"git-empty",children:"No changes to display"}),o.jsx(Py,{count:p.status.hiddenCount}),p.status.truncated?o.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-truncated",children:["Only the first ",C.length," changed files are shown."]}):null]})}const L=j.diff?.files??[],B=C=>s==="diff"||S.includes(C),_=C=>A(Y=>Y.includes(C)?Y.filter(H=>H!==C):[...Y,C]),Q=u.mode==="uncommitted"?"base":"uncommitted";return o.jsxs("div",{className:"flex min-h-full flex-col","data-testid":q,"data-content":"diff",children:[O(j.diff?fj(L):void 0),o.jsx(Qy,{status:p.status,mode:u.mode}),m?o.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1 text-xs text-muted-foreground","data-testid":"git-focus",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),o.jsx("button",{type:"button",className:"text-highlight hover:underline",onClick:()=>Ky(null),"data-testid":"git-focus-clear",children:"All files"})]}):null,j.notice?o.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground",role:"status","data-testid":"git-notice",children:j.notice}):null,j.error?o.jsxs("p",{className:"px-3 py-2 text-sm text-destructive",role:"alert","data-testid":"git-error",children:[j.error," ",o.jsx("button",{type:"button",className:"ml-1 text-highlight hover:underline",onClick:()=>j.load(),children:"Retry"})]}):null,j.loading&&!j.diff?o.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground","data-testid":"git-loading",children:"Loading changes…"}):null,j.diff&&!L.length&&!j.error?o.jsxs("div",{className:"flex flex-col items-center gap-2 px-3 py-6 text-center","data-testid":"git-empty",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"No changes to display"}),!m&&!u.ignoreWhitespace?o.jsx("button",{type:"button",className:"text-xs text-highlight hover:underline",onClick:()=>Di.set({mode:Q}),"data-testid":"changes-empty-switch-mode",children:Q==="base"?"See committed changes":"See uncommitted changes"}):null]}):null,L.length?o.jsx("ul",{"aria-label":s==="diff"?"Diff":"Changed files",children:L.map(C=>o.jsx(m5,{file:C,open:B(C.path),onToggle:()=>_(C.path),onOpenDiff:s==="changes"&&t?()=>{Ky(C.path,h),t()}:void 0},`${C.oldPath??""}
43
+ ${C.path}`))}):null,o.jsx(Py,{count:j.diff?.hiddenCount??0}),j.diff?.nextCursor?o.jsx("button",{type:"button",onClick:j.loadMore,disabled:j.more,className:I("mx-3 my-2 self-start rounded-md px-2 py-1 text-xs text-highlight hover:bg-secondary disabled:opacity-60",vc),"data-testid":"git-load-more",children:j.more?"Loading…":"Load more"}):j.diff?.truncated?o.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground","data-testid":"git-truncated",children:"Only some untracked files are shown: the host limits how many it reads."}):null]})}function x5({onOpenDiff:s}){return o.jsx(P1,{variant:"changes",onOpenDiff:s})}function y5(){return o.jsx(P1,{variant:"diff"})}const b5=b.lazy(()=>W0(()=>import("./TerminalPanel-BbYa_Xkd.js"),__vite__mapDeps([0,1])).then(s=>({default:s.TerminalPanel}))),ni={changes:{label:"Changes",icon:Sf},terminal:{label:"Terminal",icon:hc},diff:{label:"Diff",icon:Sf},files:{label:"Files",icon:ah},agents:{label:"Agents",icon:Oa},tasks:{label:"Tasks",icon:Bi}},v5="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",w5=I("flex w-full min-w-0 items-start gap-2 rounded-lg py-2 pl-2 pr-3 text-left",v5);function k5({onPicked:s}){const{openAgent:t,active:i}=kt(),{tree:a}=Ee();if(!a)return o.jsx("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:"Open a session to see its agents."});const l=Bb(a.projection),u=new Set(Object.values(a.projection.questions).map(d=>d.sessionId));return o.jsx("ul",{className:"p-2","aria-label":"Agents in this session",children:l.map(d=>{const h=d.session,m=d.id===a.rootId,p=i?.kind==="agent"&&i.id===d.id,x=u.has(d.id)?"needs_input":d.running?"running":"done";return o.jsx("li",{className:I("mb-0.5 rounded-lg",p?"bg-sidebar-selected":"hover:bg-sidebar-hover",!m&&"ml-4"),children:o.jsxs("button",{type:"button",onClick:()=>{t(d.id),s?.()},"aria-current":p?"true":void 0,className:w5,"data-testid":"agent-row",children:[o.jsx(yh,{bucket:x}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{className:I("truncate text-sm leading-5",p?"text-foreground":"text-foreground/80"),children:h?.agent??(m?"main":"agent")}),o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:d.closed?"closed":d.running?"working":"idle"})]}),o.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:[m?"main conversation":"assignment",Fl(h?.mode),h?.model].filter(Boolean).join(" · ")})]})]})},d.id)})})}function j5({kind:s}){const t=ni[s];return o.jsxs("div",{className:"flex min-h-full flex-col items-center justify-center gap-2 p-6 text-center",role:"note","data-testid":`panel-unavailable-${s}`,children:[o.jsx(t.icon,{"aria-hidden":!0,strokeWidth:1.5,className:"size-6 text-extra-muted"}),o.jsxs("p",{className:"text-sm text-foreground",children:[t.label," is not available in this beta"]}),o.jsx("p",{className:"max-w-[300px] text-xs leading-5 text-muted-foreground",children:t.unavailable})]})}function Q1({kind:s,onPicked:t}){const{openPanel:i}=kt();return s==="agents"?o.jsx(k5,{onPicked:t}):s==="tasks"?o.jsx(U1,{onPicked:t}):s==="files"?o.jsx(WT,{onPicked:t}):s==="changes"?o.jsx(x5,{onOpenDiff:()=>{i("diff"),t?.()}}):s==="diff"?o.jsx(y5,{}):s==="terminal"?o.jsx(b.Suspense,{fallback:o.jsx("p",{className:"px-4 py-6 text-sm text-muted-foreground",children:"Loading the terminal…"}),children:o.jsx(b5,{})}):o.jsx(j5,{kind:s})}const Wy="outline-none focus-visible:ring-2 focus-visible:ring-ring";function W1({label:s,icon:t,title:i,badge:a,active:l,onSelect:u,onClose:d,testId:h,tabRef:m,onMenu:p,dragging:x,wrapper:y,...w}){return o.jsxs("div",{role:"presentation",...y,onContextMenu:p?k=>{k.preventDefault(),p({x:k.clientX,y:k.clientY})}:void 0,className:I("group relative mx-0.5 flex h-7 max-w-[220px] shrink-0 items-center rounded-md",l?"bg-secondary":"hover:bg-card",x&&"z-10 opacity-80 ring-1 ring-border"),children:[o.jsxs("button",{ref:m,type:"button",role:"tab","aria-selected":l,onClick:u,title:i,"data-testid":h,...w,onKeyDown:k=>{if(d&&(k.key==="Delete"||k.key==="Backspace")&&!k.repeat)k.preventDefault(),d();else if(p&&(k.key==="ContextMenu"||k.key==="F10"&&k.shiftKey)){k.preventDefault();const j=k.currentTarget.getBoundingClientRect();p({x:j.left,y:j.bottom+4})}},className:I("flex h-7 min-w-0 items-center gap-1 rounded-md pl-2 text-sm",d?"pr-7":"pr-2",Wy,l?"text-foreground":"text-muted-foreground"),children:[o.jsx("span",{className:"flex size-3.5 shrink-0 items-center justify-center text-muted-foreground",children:t}),o.jsx("span",{className:"truncate",children:s}),a?o.jsx("span",{className:"ml-0.5 rounded-full bg-background/60 px-1.5 text-[length:calc(11px*var(--ui-scale))] leading-4 text-muted-foreground",children:a}):null]}),d?o.jsx("button",{type:"button","aria-label":`Close ${s}`,title:"Close tab",onClick:d,className:I("absolute right-1 flex size-[18px] items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:opacity-100",Wy,l?"opacity-100":"opacity-0 group-hover:opacity-100"),children:o.jsx(en,{"aria-hidden":!0,className:"size-3"})}):null]})}const S5="outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",N5=["changes","diff","files","agents","tasks"],Z1=new Set(["files","changes"]);function T5(s=["files","changes"]){const[t,i]=b.useState(()=>({tabs:s.map(d=>({id:d,kind:d})),active:s[0]??null})),a=b.useCallback(d=>i(h=>({...h,active:d})),[]),l=b.useCallback(d=>i(h=>{if(Z1.has(d))return h;const m=h.tabs.findIndex(y=>y.id===d),p=h.tabs.filter(y=>y.id!==d),x=h.active!==d?h.active:p[Math.min(m,p.length-1)]?.id??null;return{tabs:p,active:x}}),[]),u=b.useCallback(d=>i(h=>h.tabs.some(m=>m.id===d)?{...h,active:d}:{tabs:[...h.tabs,{id:d,kind:d}],active:d}),[]);return b.useMemo(()=>({...t,select:a,close:l,launch:u}),[t,a,l,u])}function A5({dock:s,onClose:t}){const{tree:i,tasks:a}=Ee(),l=i?Object.keys(i.projection.running).length:0,u=a.rows.filter(w=>w.status!=="closed").length,d={agents:l,tasks:u},h=b.useRef({}),m=s.tabs.find(w=>w.id===s.active)??null,p=N5.filter(w=>!s.tabs.some(k=>k.kind===w)),x=w=>{const k=w.key==="ArrowRight"?1:w.key==="ArrowLeft"?-1:0;if(!k||!s.tabs.length||!(w.target instanceof HTMLElement)||w.target.getAttribute("role")!=="tab")return;w.preventDefault();const j=s.tabs.findIndex(A=>A.id===s.active),S=s.tabs[(j+k+s.tabs.length)%s.tabs.length].id;s.select(S),h.current[S]?.focus()},y=I("flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-card hover:text-foreground",S5);return o.jsxs("aside",{"aria-label":"Explorer",className:"flex h-full min-h-0 flex-col bg-sidebar","data-testid":"workspace-explorer-sidebar",children:[o.jsxs("div",{className:"relative flex h-14 shrink-0 items-center border-b border-border md:h-9",children:[o.jsxs("div",{role:"tablist","aria-label":"Explorer tabs",onKeyDown:x,className:"flex min-w-0 flex-1 items-center overflow-x-auto px-1 [scrollbar-width:none]",children:[s.tabs.map(w=>{const k=ni[w.kind];return o.jsx(W1,{tabRef:j=>{h.current[w.id]=j},id:`dock-tab-${w.id}`,"aria-controls":"dock-panel",tabIndex:w.id===s.active?0:-1,testId:"explorer-tab","data-tab":w.id,label:k.label,icon:o.jsx(k.icon,{"aria-hidden":!0,className:"size-3.5"}),badge:d[w.kind],active:w.id===s.active,onSelect:()=>s.select(w.id),onClose:Z1.has(w.kind)?void 0:()=>s.close(w.id)},w.id)}),o.jsx(Kt,{label:"New explorer tab",title:"New tab",align:"start",testId:"workspace-new-tab-button",disabled:!p.length,trigger:o.jsx(ks,{"aria-hidden":!0,className:"size-3.5"}),triggerClassName:I(y,"mx-1 text-extra-muted"),items:p.map(w=>{const k=ni[w];return{label:k.label,icon:o.jsx(k.icon,{"aria-hidden":!0}),testId:`workspace-new-tab-menu-${w}`,onSelect:()=>s.launch(w)}})})]}),t?o.jsx("button",{type:"button","aria-label":"Close panel",onClick:t,className:I(y,"mr-1.5 size-8 rounded-lg"),children:o.jsx(en,{"aria-hidden":!0,className:"size-4"})}):null]}),o.jsx("div",{...m?{role:"tabpanel","aria-labelledby":`dock-tab-${m.id}`}:{},id:"dock-panel",className:"min-h-0 flex-1 overflow-y-auto",children:m?o.jsx(Q1,{kind:m.kind,onPicked:t}):null})]})}const C5=[{id:"today",label:"Today"},{id:"yesterday",label:"Yesterday"},{id:"thisWeek",label:"This week"},{id:"thisMonth",label:"This month"},{id:"older",label:"Older"}],E5=1440*60*1e3;function M5(s,t=new Date){const i=s?Date.parse(s):NaN;if(Number.isNaN(i))return"older";const a=new Date(i),l=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime(),u=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime();if(u>=l)return"today";if(u>=new Date(t.getFullYear(),t.getMonth(),t.getDate()-1).getTime())return"yesterday";const d=Math.round((l-u)/E5);return d<=7?"thisWeek":d<=30?"thisMonth":"older"}function z5(s,t="",i=new Date){const a=t.toLowerCase().split(/\s+/).filter(Boolean),l=a.length?s.filter(d=>a.every(h=>`${d.title??""}
44
+ ${d.id}`.toLowerCase().includes(h))):s,u=new Map;for(const d of l){const h=M5(d.updatedAt??d.createdAt,i);u.set(h,[...u.get(h)??[],d])}return C5.filter(d=>u.has(d.id)).map(d=>({...d,sessions:u.get(d.id)}))}const Th="outline-none focus-visible:ring-2 focus-visible:ring-ring",Zy=I("flex size-8 shrink-0 items-center justify-center rounded-lg text-extra-muted hover:bg-secondary hover:text-foreground [&_svg]:size-[18px]",Th),Jy={initializing:"Starting",idle:"Idle",running:"Running",error:"Error",closed:"Closed"};function R5(s,t){return s.tree?.rootId===t&&s.tree.status==="attached"?Object.keys(s.tree.projection.questions).length:Math.max(s.attention[t]??0,s.tree?.rootId===t?Object.keys(s.tree.projection.questions).length:0,1)}function of({children:s,tone:t="muted",icon:i,testId:a}){return o.jsxs("span",{"data-testid":a,className:I("inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-px text-xs leading-5",t==="warning"?"bg-dot-warning/15 text-dot-warning":t==="success"?"bg-dot-success/15 text-dot-success":t==="danger"?"bg-dot-danger/15 text-dot-danger":"bg-secondary text-muted-foreground"),children:[i,s]})}function _5({session:s,project:t,selected:i,waiting:a,reason:l,onOpen:u}){const d=Wn(s),h=Ri(s.updatedAt??s.createdAt);return o.jsxs("button",{type:"button",onClick:u,"data-testid":"history-row","data-session":s.id,"aria-current":i?"true":void 0,className:I("flex w-full min-w-0 items-center gap-3 rounded-lg px-3 py-2 text-left text-sm md:rounded-none",i?"bg-secondary":"hover:bg-card active:bg-secondary",Th),children:[o.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5 md:flex-row md:items-center md:gap-2",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx("span",{className:"shrink-0 truncate text-foreground max-md:hidden md:max-w-[320px]",children:t}),o.jsx(Jn,{"aria-hidden":!0,className:"size-3 shrink-0 text-muted-foreground max-md:hidden"}),o.jsx(Oa,{"aria-hidden":!0,className:"size-3.5 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"min-w-0 truncate text-muted-foreground max-md:text-foreground","data-testid":"history-row-title",children:d}),s.archived?o.jsx(of,{icon:o.jsx(ac,{"aria-hidden":!0,className:"size-3"}),children:"Archived"}):null,a?o.jsxs(of,{tone:"warning",children:[a," pending"]}):null,!a&&l?o.jsx(of,{tone:l==="error"?"danger":"success",testId:"history-row-attention",children:l==="error"?"Needs attention":"Finished"}):null]}),o.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground md:hidden",children:[o.jsx("span",{className:"truncate",children:t}),o.jsx("span",{className:"opacity-70",children:"·"}),o.jsx("span",{className:"truncate",children:Jy[s.status]??s.status}),o.jsx("span",{className:"opacity-70",children:"·"}),o.jsx("span",{className:"shrink-0",children:h})]})]}),o.jsxs("span",{className:"hidden shrink-0 items-center gap-3 text-muted-foreground md:flex",children:[o.jsx("span",{className:"w-[132px] truncate",children:s.teamLabel??""}),o.jsx("span",{className:"w-[72px] truncate",children:Jy[s.status]??s.status}),o.jsx("span",{className:"w-[72px] truncate text-right",children:h})]})]})}function L5({navOpen:s,onToggleNav:t,onOpen:i,onBack:a}){const l=Oe(),u=Ee(),{history:d,workspace:h,selected:m,connection:p}=u,[x,y]=b.useState(""),[w,k]=b.useState(""),j=p.phase==="open",S=p.capabilities.includes("session.list.page");b.useEffect(()=>{const L=setTimeout(()=>k(x),200);return()=>clearTimeout(L)},[x]);const A=S?w.trim():"";b.useEffect(()=>{h&&j&&l.loadHistory({quiet:d.status==="ready"&&d.query===A,query:A})},[h,j,l,A]);const R=b.useMemo(()=>z5(d.list,S?"":w),[d.list,w,S]),q=h?Dt(h):"",O=!!w.trim();return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"history-screen",children:[o.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-1 border-b border-border bg-background px-2 md:h-9 md:gap-2 md:px-3",children:[o.jsx("button",{type:"button","aria-label":s?"Close sessions":"Open sessions","aria-expanded":s,title:"Toggle sidebar",onClick:t,className:I(Zy,"md:-ml-1.5"),children:o.jsx($a,{"aria-hidden":!0,strokeWidth:1.5})}),o.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-normal text-foreground md:font-light",children:"History"}),o.jsx("button",{type:"button","aria-label":"Refresh history",title:"Refresh",onClick:()=>{l.loadHistory()},disabled:!j,className:I(Zy,"md:-mr-1.5 disabled:opacity-45"),children:o.jsx(co,{"aria-hidden":!0,strokeWidth:1.5,className:I(d.status==="loading"&&"animate-spin")})})]}),o.jsx("div",{className:"px-3 pt-4 md:px-6",children:o.jsxs("div",{className:"flex h-9 w-full max-w-md items-center gap-2 rounded-lg border border-border bg-card px-2.5 focus-within:ring-1 focus-within:ring-ring",children:[o.jsx(ti,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("input",{type:"search",value:x,onChange:L=>y(L.target.value),placeholder:"Search history","aria-label":"Search history","data-testid":"history-search",className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden"}),x?o.jsx("button",{type:"button","aria-label":"Clear search",onClick:()=>y(""),className:I("flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",Th),children:o.jsx(en,{"aria-hidden":!0,className:"size-3.5"})}):null]})}),o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6 pt-4 md:px-6",children:[d.status==="loading"&&!d.list.length?o.jsx("div",{className:"flex justify-center py-16",children:o.jsx(Ft,{label:"Loading history…"})}):null,d.status==="error"&&!d.list.length?o.jsxs("div",{role:"alert",className:"flex flex-col items-center gap-4 py-16 text-sm text-muted-foreground",children:[o.jsxs("span",{children:["Unable to load sessions",d.error?.message?`: ${d.error.message}`:""]}),o.jsx(we,{variant:"ghost",onClick:()=>{l.loadHistory()},children:"Try again"})]}):null,d.status!=="loading"&&d.status!=="error"&&!R.length?o.jsxs("div",{className:"flex flex-col items-center gap-6 py-16 text-sm text-muted-foreground","data-testid":"history-empty",children:[o.jsx("span",{children:O?"No sessions match":"No sessions yet"}),O?o.jsx(we,{variant:"ghost",onClick:()=>y(""),children:"Clear search"}):o.jsxs(we,{variant:"ghost",onClick:a,children:[o.jsx(nh,{"aria-hidden":!0})," Back"]})]}):null,R.map(L=>o.jsxs("section",{"aria-label":L.label,className:"mb-2",children:[o.jsx("h2",{className:"mb-2 mt-2 px-3 text-sm font-medium text-muted-foreground",children:L.label}),o.jsx("div",{className:"flex flex-col gap-1 md:gap-0",children:L.sessions.map(B=>o.jsx(_5,{session:B,project:q,selected:B.id===m,waiting:B.archived||!ic(u,B.id)?0:R5(u,B.id),reason:B.archived?void 0:ao(u,B.id),onOpen:()=>{l.selectSession(B.id),i()}},B.id))})]},L.id)),S&&d.nextCursor&&d.status==="ready"?o.jsxs("div",{className:"flex items-center justify-center gap-3 py-4","data-testid":"history-more",children:[o.jsx(we,{variant:"ghost",onClick:()=>{l.loadMoreHistory()},disabled:d.more==="loading"||!j,children:d.more==="loading"?"Loading...":"Load more"}),d.more==="error"?o.jsx("span",{role:"alert",className:"text-sm text-destructive",children:"Unable to load more sessions"}):null]}):null]})]})}function O5({sessionId:s}){const t=Oe(),{connection:i}=Ee(),[a,l]=b.useState(!1),[u,d]=b.useState(null),h=async()=>{l(!0),d(null);try{await t.restoreSession(s)}catch(m){d(m instanceof Error?m.message:String(m))}finally{l(!1)}};return o.jsx("div",{className:"px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:px-4 md:pb-4",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-(--content-width) flex-col gap-2",children:[o.jsxs("div",{className:"flex items-center justify-center gap-3 rounded-2xl border border-border bg-card px-4 py-3 md:px-6 md:py-4","data-testid":"archived-callout",children:[o.jsx("span",{className:"text-(length:--content-font-size) text-muted-foreground",children:"This session is archived"}),o.jsx(we,{size:"sm",variant:"secondary",disabled:a||i.phase!=="open",onClick:()=>{h()},children:"Unarchive"})]}),u?o.jsx("p",{role:"alert",className:"text-center text-sm text-destructive",children:u}):null]})})}function D5(s,{enabled:t=!0,allowInModal:i=[]}={}){const a=b.useRef(s);a.current=s;const l=b.useMemo(()=>ho(),[]);b.useEffect(()=>{if(!t)return;const u=d=>{if(d.defaultPrevented||d.isComposing||d.repeat)return;const h=v4(d,{mac:l,editable:h1(d.target)});!h||(document.querySelector("dialog[open]")||document.querySelector("[data-modal-overlay]"))&&!i.includes(h.binding.action)||a.current(h.binding,h.index)!==!1&&(d.preventDefault(),d.stopPropagation())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[t,l,i.join(",")])}function q5({open:s,onClose:t}){const[i,a]=b.useState(""),l=b.useMemo(()=>ho(),[]);b.useEffect(()=>{s||a("")},[s]);const u=k4(l,i);return o.jsx(ai,{open:s,onClose:t,title:"Shortcuts",className:"w-[min(92vw,36rem)]",children:o.jsxs("div",{className:"space-y-4","data-testid":"keyboard-shortcuts-dialog",children:[o.jsxs("div",{className:"flex h-9 items-center gap-2 rounded-lg border border-border bg-card px-2.5 focus-within:ring-1 focus-within:ring-ring",children:[o.jsx(ti,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("input",{type:"search",autoFocus:!0,value:i,onChange:d=>a(d.target.value),placeholder:"Search shortcuts",onKeyDown:d=>{d.key==="Escape"&&(d.preventDefault(),t())},"aria-label":"Search shortcuts",className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden"})]}),u.map(d=>o.jsxs("section",{"aria-label":d.title,className:"space-y-2",children:[o.jsx("h3",{className:"text-xs font-medium text-muted-foreground",children:d.title}),o.jsx("div",{className:"overflow-hidden rounded-lg border border-secondary",children:d.rows.map(h=>o.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-secondary px-4 py-2.5 last:border-b-0","data-testid":"shortcut-row",children:[o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block text-sm text-foreground",children:h.label}),"note"in h&&h.note?o.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:h.note}):null]}),o.jsx("kbd",{className:"shrink-0 rounded-md bg-secondary/60 px-1.5 py-0.5 font-sans text-xs text-muted-foreground",children:h.keys})]},h.id))})]},d.id)),u.length?null:o.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"No results"})]})})}const B5=5,$5=5,eb=10,U5=s=>s.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);function H5(s,t){let i=0;for(const a of t)a===s[i]&&(i+=1);return i===s.length}function tb(s,t){const i=t.toLowerCase();if(!i)return;if(i===s)return 0;const a=U5(i);if(a.includes(s))return 1;if(i.startsWith(s))return 2;if(a.some(l=>l.startsWith(s)))return 3;if(i.includes(s))return 4;if(H5(s,i))return 6}function Uf(s,t,i=[]){const a=s.toLowerCase().split(/\s+/).filter(Boolean);let l=0;for(const u of a){let d;for(const h of t){const m=tb(u,h);m!==void 0&&(d===void 0||m<d)&&(d=m)}if(d===void 0)for(const h of i){const m=tb(u,h);m!==void 0&&(d===void 0||m+eb<d)&&(d=m+eb)}if(d===void 0)return;l+=d}return l}const nb=s=>s.bucket==="needs_input"?0:s.attention?1:s.bucket==="running"?2:3;function I5(s){return s.map((t,i)=>({session:t,index:i})).sort((t,i)=>nb(t.session)-nb(i.session)||(Date.parse(i.session.updatedAt??"")||0)-(Date.parse(t.session.updatedAt??"")||0)||t.index-i.index).map(t=>t.session)}function G5(s){const t=String(s).replace(/\\/g,"/"),i=t.lastIndexOf("/");return{path:t,title:i>=0?t.slice(i+1):t,subtitle:i>=0?t.slice(0,i):""}}function Y5(s,t=null){return s.map(i=>{const l=i.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||i;return{path:i,title:l,subtitle:i,...i===t?{current:!0}:{}}})}const V5=(s,t)=>s.title.localeCompare(t.title,void 0,{numeric:!0,sensitivity:"base"})||s.subtitle.localeCompare(t.subtitle);function K5(s,t){const i=[...s].sort(V5),a=t.trim();return a?i.map((l,u)=>({workspace:l,index:u,score:Uf(a,[l.title,l.subtitle])})).filter(l=>l.score!==void 0).sort((l,u)=>l.score-u.score||l.index-u.index).map(l=>l.workspace):i.slice(0,$5)}function F5({actions:s,sessions:t,query:i,workspaces:a=[],files:l,scope:u=null}){const d=i.trim(),h={id:"files",title:"Files",rows:(l??[]).map(S=>({kind:"file",item:S}))};if(u==="files")return l?.length?[h]:[];const m=[{id:"workspace",title:"Workspace actions",rank:-1,rows:[]},{id:"actions",title:"Actions",rank:0,rows:[]},{id:"alp",title:"ALP",rank:1,rows:[]}];for(const S of s){const A=m.find(q=>q.id===S.group);if(!A)continue;if(!d){S.always&&A.rows.push({row:{kind:"action",item:S},score:0});continue}const R=Uf(d,[S.label],S.keywords);R!==void 0&&A.rows.push({row:{kind:"action",item:S},score:R})}const p=S=>S.reduce((A,R)=>Math.min(A,R.score),1/0),y=m.filter(S=>S.rows.length).map(S=>({...S,rows:[...S.rows].sort((A,R)=>A.score-R.score)})).sort((S,A)=>d&&p(S.rows)-p(A.rows)||S.rank-A.rank).map(S=>({id:S.id,title:S.title,rows:S.rows.map(A=>A.row)})),w=I5(t),k=d?w.map((S,A)=>({session:S,index:A,score:Uf(d,[S.title],[S.id,S.subtitle??""])})).filter(S=>S.score!==void 0).sort((S,A)=>S.score-A.score||S.index-A.index).map(S=>S.session):w.slice(0,B5),j=K5(a,d);return j.length&&y.push({id:"workspaces",title:"Workspaces",rows:j.map(S=>({kind:"workspace",item:S}))}),k.length&&y.push({id:"sessions",title:"Sessions",rows:k.map(S=>({kind:"session",item:S}))}),d&&l?.length&&y.push(h),y}const X5=100,Jr=Object.freeze({entries:[],loading:!1,error:null,truncated:!1});class P5{state=Jr;#e=null;#j=null;#p=0;#n;#i;#m;#o;constructor({search:t,onChange:i=()=>{},debounceMs:a=X5}){this.#i=t,this.#m=i,this.#o=a}#f(t){this.state=t,this.#m(t)}update({enabled:t,source:i,query:a}){const l=t&&i?`${i}\0${a}`:null;if(l===this.#j)return;if(this.#j=l,this.#a(),!l){this.#e=null,this.state!==Jr&&this.#f(Jr);return}const u=this.#e===i;this.#e=i;const d=++this.#p;this.#f({entries:u?this.state.entries:[],loading:!0,error:null,truncated:u?this.state.truncated:!1});const h=async()=>{this.#n=void 0;try{const m=await this.#i(a);if(d!==this.#p)return;this.#f({entries:(m?.files??[]).map(p=>G5(p.path)),loading:!1,error:null,truncated:m?.truncated===!0})}catch(m){if(d!==this.#p)return;this.#f({entries:[],loading:!1,error:Be(m).message,truncated:!1})}};this.#n=setTimeout(()=>{h()},a.trim()?this.#o:0)}#a(){this.#n!==void 0&&clearTimeout(this.#n),this.#n=void 0,this.#p+=1}dispose(){this.#a(),this.#j=null}}function Q5({enabled:s,source:t,query:i,search:a}){const[l,u]=b.useState(Jr),d=b.useRef(a);d.current=a;const h=b.useRef(null);return h.current||(h.current=new P5({search:m=>d.current(m),onChange:u})),b.useEffect(()=>{h.current?.update({enabled:s,source:t,query:i})},[s,t,i]),b.useEffect(()=>()=>{h.current?.dispose()},[]),s&&t?l:Jr}function W5({open:s,scope:t=null,onClose:i,actions:a,sessions:l,workspaces:u=[],files:d,onOpenSession:h,onSelectWorkspace:m,onPickFile:p,mac:x}){const y=b.useRef(null),w=b.useRef(null),k=b.useRef(null),j=b.useRef(null),[S,A]=b.useState(""),[R,q]=b.useState(t),[O,L]=b.useState(0),B=b.useId(),_=!!d?.available,Q=Q5({enabled:s&&_&&(R==="files"||!!S.trim()),source:d?.source??null,query:S,search:d?.search??(()=>Promise.resolve({files:[]}))});b.useEffect(()=>{const T=y.current;if(T&&(s&&!T.open&&(j.current=document.activeElement,A(""),q(t),L(0),T.showModal(),w.current?.focus()),!s&&T.open)){T.close(),A("");const z=j.current;j.current=null,z?.isConnected&&z.focus()}},[s]),b.useEffect(()=>{s&&t&&q(t)},[s,t]);const C=b.useMemo(()=>s?F5({actions:a.filter(T=>!T.disabled),sessions:l,query:S,workspaces:u,scope:R,..._?{files:Q.entries}:{}}):[],[s,a,l,S,u,R,_,Q.entries]),Y=C.flatMap(T=>T.rows),H=Math.min(O,Math.max(0,Y.length-1)),fe=new Map(a.map(T=>[T.id,T]));b.useEffect(()=>{k.current?.querySelector(`[data-index="${H}"]`)?.scrollIntoView({block:"nearest"})},[H]);const ee=T=>{const z=Y[T];z&&(i(),z.kind==="session"?h(z.item.id):z.kind==="workspace"?m?.(z.item.path):z.kind==="file"?p?.(z.item.path):setTimeout(()=>fe.get(z.item.id)?.run(),0))},xe=T=>{if(T.key==="ArrowDown"||T.key==="ArrowUp"){if(T.preventDefault(),!Y.length)return;const z=T.key==="ArrowDown"?1:-1;L((H+z+Y.length)%Y.length)}else T.key==="Enter"&&!T.nativeEvent.isComposing?(T.preventDefault(),ee(H)):T.key==="Backspace"&&!S.trim()&&R?(T.preventDefault(),q(null),L(0)):T.key.toLowerCase()==="k"&&(x?T.metaKey:T.ctrlKey)&&!T.shiftKey&&!T.altKey?(T.preventDefault(),i()):T.code==="KeyP"&&(x?T.metaKey:T.ctrlKey)&&!T.shiftKey&&!T.altKey&&(T.preventDefault(),q("files"),L(0))},re=R==="files",de=re?"Search files...":_?"Search commands, files, workspaces, and agents...":"Search commands, workspaces, sessions and agents...",U=_&&Q.loading,Z=re&&!_?"This host does not offer file search. Update ALP on the host to search the workspace's files.":(re||S.trim())&&Q.error?Q.error:null,oe=re?U?"":_&&!Q.error?"No files":"":"No matches";let ge=-1;return o.jsx("dialog",{ref:y,"aria-label":"Command center","data-testid":"command-center-panel",onCancel:T=>{T.preventDefault(),i()},onClick:T=>{T.target===y.current&&i()},className:"mx-auto mt-12 mb-auto w-[min(92vw,640px)] max-h-[min(80dvh,560px)] overflow-hidden rounded-lg border border-border bg-popover p-0 text-popover-foreground shadow-2xl shadow-[var(--shadow)] backdrop:bg-black/50",children:s?o.jsxs("div",{className:"flex max-h-[min(80dvh,560px)] flex-col",onKeyDown:xe,children:[o.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-4 py-3","data-testid":"command-center-header",children:[re?o.jsxs("button",{type:"button","aria-label":"Files",title:"Remove the Files scope","data-testid":"command-center-files-scope",onClick:()=>{q(null),L(0),w.current?.focus()},className:"flex h-7 shrink-0 items-center gap-1 rounded-md bg-secondary px-2 text-sm text-foreground hover:bg-secondary/80 outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[o.jsx(Da,{"aria-hidden":!0,className:"size-3.5"}),o.jsx("span",{children:"Files"}),o.jsx(en,{"aria-hidden":!0,className:"size-3"})]}):null,o.jsx("input",{ref:w,type:"text",role:"combobox","aria-expanded":!0,"aria-controls":B,"aria-activedescendant":Y.length?`${B}-${H}`:void 0,"aria-label":re?"Search files":"Search commands and sessions",placeholder:de,value:S,autoComplete:"off",spellCheck:!1,onChange:T=>{A(T.target.value),L(0)},"data-testid":"command-center-input",className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"}),o.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center","data-testid":"command-center-file-search-status",children:U?o.jsx("span",{role:"progressbar","aria-label":"Searching files...",title:"Searching files...","data-testid":"command-center-file-search-loading",children:o.jsx(uc,{"aria-hidden":!0,className:"size-3.5 animate-spin text-muted-foreground"})}):null})]}),Z?o.jsx("p",{role:Q.error?"alert":"note",className:"shrink-0 border-b border-border px-4 py-2 text-xs text-muted-foreground","data-testid":"command-center-file-search-error",children:Z}):null,o.jsx("div",{ref:k,id:B,role:"listbox","aria-label":"Results",className:"min-h-0 flex-1 overflow-y-auto py-1","data-testid":"command-center-results",children:Y.length===0?oe?o.jsx("p",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:oe}):null:C.map((T,z)=>o.jsxs("div",{role:"group","aria-label":T.title,className:I(z>0&&"mt-1 border-t border-border pt-1"),children:[o.jsx("div",{className:"px-4 pb-1 pt-2 text-xs text-muted-foreground","aria-hidden":!0,children:T.title}),T.rows.map(F=>{ge+=1;const J=ge,le=J===H;if(F.kind==="session")return o.jsxs("div",{id:`${B}-${J}`,role:"option","aria-selected":le,"data-index":J,"data-testid":`command-center-session-${F.item.id}`,onMouseMove:()=>{le||L(J)},onClick:()=>ee(J),className:I("flex min-h-14 cursor-pointer items-center gap-3 px-4 py-2",le&&"bg-secondary"),children:[o.jsx(yh,{bucket:F.item.bucket}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm leading-[18px] text-foreground",children:F.item.title}),F.item.subtitle?o.jsx("div",{className:"truncate text-xs leading-4 text-muted-foreground","data-testid":"command-center-session-subtitle",children:F.item.subtitle}):null]})]},`session:${F.item.id}`);if(F.kind==="workspace"||F.kind==="file"){const ve=F.item,Re=F.kind==="workspace"?Da:r0,Me=F.kind==="workspace"&&F.item.current;return o.jsxs("div",{id:`${B}-${J}`,role:"option","aria-selected":le,"data-index":J,"data-testid":`command-center-${F.kind}`,"data-path":ve.path,"aria-current":Me?"true":void 0,onMouseMove:()=>{le||L(J)},onClick:()=>ee(J),className:I("flex min-h-11 cursor-pointer items-center gap-3 px-4 py-2",le&&"bg-secondary"),children:[o.jsx("span",{className:"flex w-4 shrink-0 justify-center text-muted-foreground",children:o.jsx(Re,{"aria-hidden":!0,className:"size-4"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm leading-[18px] text-foreground",children:ve.title}),ve.subtitle?o.jsx("div",{className:"truncate text-xs leading-4 text-muted-foreground",children:ve.subtitle}):null]}),Me?o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"Current"}):null]},`${F.kind}:${ve.path}`)}const ce=fe.get(F.item.id)?.icon;return o.jsxs("div",{id:`${B}-${J}`,role:"option","aria-selected":le,"data-index":J,"data-testid":`command-center-action-${F.item.id}`,onMouseMove:()=>{le||L(J)},onClick:()=>ee(J),className:I("flex min-h-9 cursor-pointer items-center gap-3 px-4 py-2",le&&"bg-secondary"),children:[o.jsx("span",{className:"flex w-4 shrink-0 justify-center text-muted-foreground",children:ce?o.jsx(ce,{"aria-hidden":!0,className:"size-4"}):null}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm leading-[18px] text-foreground",children:F.item.label}),F.item.shortcut?o.jsx("kbd",{className:"shrink-0 rounded bg-secondary px-1.5 py-px font-sans text-xs text-muted-foreground",children:F.item.shortcut}):null]},`action:${F.item.id}`)})]},T.id))})]}):null})}function J1(s){const t=/^\/(\S*)$/.exec(s);return t?t[1]:null}function Z5(s,t){const i=J1(t);if(i===null)return null;const a=i.toLowerCase(),l=u=>{const d=u.name.toLowerCase();return d.startsWith(a)?0:d.slice(d.indexOf(":")+1).startsWith(a)?1:d.includes(a)?2:-1};return s.map((u,d)=>({command:u,index:d,rank:l(u)})).filter(u=>u.rank>=0).sort((u,d)=>u.rank-d.rank||u.index-d.index).map(u=>u.command)}const J5=s=>`/${s.name} `,Ah=b.createContext({id:oo,focused:!0}),eA=()=>b.useContext(Ah).focused,Rl=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);function ev({meter:s,imageLimits:t,images:i=!1,imagesUnavailable:a,files:l=!1,fileLimits:u,filesUnavailable:d,onSend:h,onQueue:m,onInterruptSend:p,onStop:x,queued:y,onEditQueued:w,onSendQueued:k,running:j,stopping:S,blocked:A,disabledReason:R,placeholder:q,controls:O,tracks:L,onCycleMode:B,sendBehavior:_="steer",sendShortcut:Q="enter",startLabel:C,startHold:Y,initialText:H,addText:fe,autoFocus:ee,inputId:xe,commands:re}){const[de,U]=b.useState(H??"");b.useEffect(()=>{fe&&U(W=>W.trim()?`${W.replace(/\s+$/,"")}
45
+
46
+ ${fe.text}`:fe.text)},[fe]);const[Z,oe]=b.useState(null),[ge,T]=b.useState([]),[z,F]=b.useState([]),J=b.useRef(null),le=b.useRef(null),ne=A??R,ce=!!de.trim()||ge.length>0||z.length>0,ve=!ge.length&&!z.length,Re=j&&_==="queue"&&ve,Me=j&&_==="interrupt"&&ve&&!!p,Qe=b.useRef(ge),Ue=b.useRef(t);Ue.current=t;const et=W=>{Qe.current=W,T(W)},Fe=b.useRef(z),be=b.useRef(u??Ps);be.current=u??Ps;const ye=W=>{Fe.current=W,F(W)},Ae=async W=>{if(!W.length||ne)return;const me=[],ht=[];let Wt=null;for(const bt of W)i&&(Rb(bt)||!l&&bt.type.startsWith("image/"))?me.push(bt):l?ht.push(bt):Wt??=!i&&bt.type.startsWith("image/")?a??"This session takes no images.":d??a??"This session takes no files.";let mt=null;if(me.length){const{added:bt,error:gt}=await xj(Qe.current,me,Ue.current),{attachments:Et,error:Sn}=Xr(Qe.current,bt,Ue.current);et(Et),mt??=gt??Sn}if(ht.length){const{added:bt,error:gt}=await Nj(Fe.current,ht,be.current),{attachments:Et,error:Sn}=Ol(Fe.current,bt,be.current);ye(Et),mt??=gt??Sn}oe(Wt??mt)},[Ne,Ht]=b.useState(!1),[cn,ze]=b.useState([]),[ut,At]=b.useState(0),[Rt,In]=b.useState(null),kn=!!re&&J1(de)!==null,Qt=b.useRef(re);Qt.current=re,b.useEffect(()=>{if(!kn||!Qt.current)return;let W=!0;return Qt.current().then(me=>{W&&ze(me)},()=>{}),()=>{W=!1}},[kn]);const Je=kn&&Rt!==de&&!ne?Z5(cn,de)??[]:[],jt=Je.length?Math.min(ut,Je.length-1):0;b.useEffect(()=>{At(0)},[de]);const St=W=>{U(J5(W)),le.current?.focus()},un=`${b.useId()}-commands`,Gn=eA(),js=b.useId(),dn=xe??`composer-${js}`,fn=b.useRef({running:j,stopping:S,blocked:A,onStop:x,paneFocused:Gn});fn.current={running:j,stopping:S,blocked:A,onStop:x,paneFocused:Gn},b.useEffect(()=>{const W=me=>{if(me.defaultPrevented||me.isComposing||!fn.current.paneFocused)return;if(me.key.toLowerCase()==="l"&&(Rl?me.metaKey&&!me.ctrlKey:me.ctrlKey&&!me.metaKey)&&!me.altKey&&!me.shiftKey){if(!le.current||le.current.disabled)return;me.preventDefault(),le.current.focus();return}if(me.key!=="Escape")return;const{running:ht,stopping:Wt,blocked:mt,onStop:bt}=fn.current,gt=me.target,Et=gt===le.current,Sn=gt===document.body||gt===document.documentElement||gt===null;!ht||Wt||mt||!(Et||Sn)||document.querySelector('[role="dialog"], [role="menu"]')||bt()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[]),b.useLayoutEffect(()=>{const W=le.current;W&&(W.style.height="auto",W.style.height=`${Math.min(W.scrollHeight,280)}px`)},[de]);const Ct=async()=>{const W=de.trim(),me=Qe.current,ht=Fe.current;if(!W&&!me.length&&!ht.length&&!C||ne||C&&Y)return;const Wt=Xr([],me,Ue.current);if(Wt.error){oe(Wt.error);return}if(ht.length){if(!l){oe(d??"This session takes no files.");return}const mt=Ol([],ht,be.current);if(mt.error){oe(mt.error);return}}U(""),et([]),ye([]),oe(null);try{await h(W,me,ht)}catch(mt){U(W),et(Xr(me,Qe.current,Ue.current).attachments),ye(Ol(ht,Fe.current,be.current).attachments),oe(mt instanceof Error?mt.message:String(mt))}},jn=()=>{const W=de.trim();if(Qe.current.length||Fe.current.length)return void Ct();if(!(!W||ne))try{m(W),U(""),oe(null)}catch(me){oe(me instanceof Error?me.message:String(me))}},E=()=>{const W=de.trim();if(Qe.current.length||Fe.current.length||!p)return void Ct();if(!(!W||ne))try{p(W),U(""),oe(null)}catch(me){oe(me instanceof Error?me.message:String(me))}},V=()=>j?_==="queue"?jn():_==="interrupt"?E():void Ct():void Ct(),ue=()=>_==="queue"?void Ct():jn(),he=Rl?"⌘":"Ctrl",pe=j?Re?"Queue message":Me?"Interrupt and send":"Send and steer":"Send",$e=!j||Q==="mod-enter"?pe:`${pe} (${he}+Enter ${_==="queue"?"sends and steers":"queues"})`,We=W=>{const me=w(W);me!=null&&(U(ht=>ht.trim()?`${ht}
47
+ ${me}`:me),le.current?.focus())},ft="inline-flex size-7 shrink-0 items-center justify-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4";return o.jsx("div",{className:"px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:px-4 md:pb-4",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-(--content-width) flex-col gap-3",children:[L?o.jsx("div",{className:"-mb-1 flex min-w-0 flex-wrap items-center gap-2","data-testid":"composer-tracks",children:L}):null,y.length?o.jsx("ul",{"aria-label":"Queued messages",className:"flex flex-col gap-2",children:y.map(W=>o.jsxs("li",{"data-testid":"queued-message",className:"flex items-center justify-between gap-2 rounded-lg border border-border bg-card px-3 py-2",children:[o.jsx("span",{className:"line-clamp-2 min-w-0 flex-1 whitespace-pre-wrap text-sm text-foreground [overflow-wrap:anywhere]",children:W.text}),o.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[o.jsx("button",{type:"button","aria-label":"Edit queued message",title:"Edit",onClick:()=>We(W.id),className:"flex size-8 items-center justify-center rounded-full bg-muted text-foreground outline-none hover:bg-bubble focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",children:o.jsx(Ui,{"aria-hidden":!0})}),o.jsx("button",{type:"button","aria-label":"Send queued message now",title:"Send now",disabled:!!ne,onClick:()=>k(W.id),className:"flex size-8 items-center justify-center rounded-full bg-primary text-primary-foreground outline-none hover:bg-primary/85 focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-3.5",children:o.jsx(Dl,{"aria-hidden":!0})})]})]},W.id))}):null,A?o.jsx("p",{className:"px-1 text-sm text-warning",role:"note",children:A}):null,Z?o.jsx("p",{className:"px-1 text-sm text-destructive",role:"alert",children:Z}):null,o.jsxs("div",{className:I("relative flex flex-col gap-3 rounded-2xl border border-input bg-card px-3 py-2 transition-colors duration-200 focus-within:border-[var(--input-focus)] md:px-4 md:pb-3 md:pt-4",ne&&"border-dotted"),"data-testid":"composer-box",onDragOver:W=>{Array.from(W.dataTransfer?.types??[]).includes("Files")&&W.preventDefault()},onDrop:W=>{const me=Dx(W.dataTransfer);me.length&&(W.preventDefault(),Ae(me))},children:[ge.length?o.jsx("ul",{"aria-label":"Attached images",className:"flex flex-wrap gap-2",children:ge.map(W=>o.jsxs("li",{"data-testid":"composer-attachment",className:"relative size-16 overflow-hidden rounded-lg border border-border bg-muted",children:[o.jsx("img",{src:Lb(W),alt:W.name,title:W.name,className:"size-full object-cover"}),o.jsx("button",{type:"button","aria-label":`Remove ${W.name}`,title:"Remove",onClick:()=>et(Qe.current.filter(me=>me.id!==W.id)),className:"absolute right-0.5 top-0.5 flex size-5 items-center justify-center rounded-full bg-background/90 text-foreground outline-none hover:bg-background focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3",children:o.jsx(en,{"aria-hidden":!0})})]},W.id))}):null,z.length?o.jsx("ul",{"aria-label":"Attached files",className:"flex flex-wrap gap-2",children:z.map(W=>o.jsxs("li",{"data-testid":"composer-file",className:"flex h-9 max-w-[16rem] items-center gap-2 rounded-lg border border-border bg-muted pl-2 pr-1 text-[length:calc(13px*var(--ui-scale))] text-foreground",children:[o.jsx(ih,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"min-w-0 truncate",title:W.name,children:W.name}),o.jsx("span",{className:"shrink-0 text-muted-foreground",children:Ob(W.size)}),o.jsx("button",{type:"button","aria-label":`Remove ${W.name}`,title:"Remove",onClick:()=>ye(Fe.current.filter(me=>me.id!==W.id)),className:"flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none hover:bg-background hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3",children:o.jsx(en,{"aria-hidden":!0})})]},W.id))}):null,!Ne&&!de&&!ne?o.jsxs("span",{"aria-hidden":!0,className:"pointer-events-none absolute right-4 top-3 hidden text-xs text-muted-foreground/80 [@media(pointer:fine)]:md:block","data-testid":"composer-focus-hint",children:[Rl?"⌘L":"Ctrl+L"," to focus"]}):null,Je.length?o.jsx("ul",{id:un,role:"listbox","aria-label":"Commands and skills","data-testid":"composer-commands",className:"absolute inset-x-0 bottom-full z-20 mb-2 max-h-72 overflow-y-auto rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-lg",children:Je.map((W,me)=>o.jsxs("li",{id:`${un}-${me}`,role:"option","aria-selected":me===jt,"data-testid":"composer-command",onMouseDown:ht=>{ht.preventDefault(),St(W)},onMouseEnter:()=>At(me),className:I("flex cursor-pointer items-baseline gap-2 rounded-lg px-2 py-1.5 text-sm",me===jt&&"bg-muted"),children:[o.jsxs("span",{className:"shrink-0 font-medium text-foreground",children:["/",W.name]}),W.argumentHint?o.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:W.argumentHint}):null,o.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",title:W.description,children:W.description}),o.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground/80",children:W.kind==="skill"?"skill":"command"})]},W.name))}):null,o.jsx("label",{htmlFor:dn,className:"sr-only",children:"Message"}),o.jsx("textarea",{id:dn,ref:le,rows:1,value:de,disabled:!!ne,placeholder:ne&&!A?ne:q,onChange:W=>U(W.target.value),onPaste:W=>{const me=Dx(W.clipboardData).filter(ht=>l||ht.type.startsWith("image/"));me.length&&(W.preventDefault(),Ae(me))},onFocus:()=>Ht(!0),onBlur:()=>Ht(!1),autoFocus:ee,"aria-keyshortcuts":Rl?"Meta+L":"Control+L",role:re?"combobox":void 0,"aria-expanded":re?Je.length>0:void 0,"aria-controls":Je.length?un:void 0,"aria-autocomplete":re?"list":void 0,"aria-activedescendant":Je.length?`${un}-${jt}`:void 0,onKeyDown:W=>{if(Je.length&&!W.nativeEvent.isComposing){if(W.key==="ArrowDown"||W.key==="ArrowUp"){W.preventDefault(),At((jt+(W.key==="ArrowDown"?1:Je.length-1))%Je.length);return}if(W.key==="Enter"&&!W.shiftKey&&!W.metaKey&&!W.ctrlKey||W.key==="Tab"&&!W.shiftKey){W.preventDefault(),St(Je[jt]);return}if(W.key==="Escape"){W.preventDefault(),W.stopPropagation(),W.nativeEvent.stopImmediatePropagation(),In(de);return}}if(W.key==="Tab"&&W.shiftKey&&B&&!W.nativeEvent.isComposing){W.preventDefault(),W.repeat||B();return}if(W.key!=="Enter"||W.shiftKey||W.nativeEvent.isComposing)return;const me=W.metaKey||W.ctrlKey;Q==="mod-enter"&&!me||(W.preventDefault(),Q==="enter"&&me&&j?ue():V())},className:"max-h-[280px] min-h-[21px] w-full resize-none bg-transparent text-(length:--content-font-size) leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed"}),o.jsxs("div",{className:"-mx-1.5 flex min-h-7 shrink-0 items-end justify-between",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-end",children:[l||i&&!C?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button","aria-label":l?"Attach files":"Attach images",title:l?"Attach files":"Attach images",disabled:!!ne,onClick:()=>J.current?.click(),className:I(ft,"mr-1 text-muted-foreground hover:bg-muted hover:text-foreground"),"data-testid":"composer-attach",children:o.jsx(ks,{"aria-hidden":!0})}),o.jsx("input",{ref:J,type:"file",accept:l?void 0:zb.join(","),multiple:!0,hidden:!0,"data-testid":"composer-attach-input",onChange:W=>{const me=Array.from(W.target.files??[]);W.target.value="",Ae(me)}})]}):null,O]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,C?o.jsx("button",{type:"button","aria-label":C,title:Y??C,onClick:()=>{Ct()},disabled:!!ne||!!Y,className:I(ft,"ml-1 bg-primary text-primary-foreground hover:bg-primary/85"),"data-testid":"composer-start",children:o.jsx(Dl,{"aria-hidden":!0})}):ce?o.jsx("button",{type:"button","aria-label":pe,title:$e,onClick:V,disabled:!!ne,className:I(ft,"ml-1 bg-primary text-primary-foreground hover:bg-primary/85"),children:o.jsx(Dl,{"aria-hidden":!0})}):j?o.jsx("button",{type:"button","aria-label":"Interrupt agent",title:"Interrupt agent",onClick:x,disabled:S||!!A,className:I(ft,"ml-1 bg-[#dc2626] text-white hover:bg-[#dc2626]/85"),children:o.jsx(uN,{"aria-hidden":!0,className:"fill-current"})}):null]})]})]})]})})}const sb=["approve","review","progress","ready","blocked"];function ib(s){return s.status==="closed"?"closed":s.approvals?.length?"approve":s.status==="review"?"review":s.status==="in_progress"?"progress":s.type==="epic"?s.progress?.done?"progress":"ready":s.ready?"ready":"blocked"}function tA(s,t){const i=new Map(t.map(p=>[p.id,p])),a=s.map(p=>{const x=i.get(p.id),y=x?ib(x):p.status==="completed"?"closed":p.status==="in_progress"?"progress":"ready";return{id:p.id,title:x?.title??p.text,state:y}}),l=new Set(a.map(p=>p.id)),u=t.filter(p=>p.status!=="closed"&&p.type!=="epic").map(p=>({id:String(p.id),title:String(p.title??p.id),state:ib(p),priority:typeof p.priority=="number"?p.priority:9})).sort((p,x)=>sb.indexOf(p.state)-sb.indexOf(x.state)||p.priority-x.priority||p.id.localeCompare(x.id)).map(({id:p,title:x,state:y})=>({id:p,title:x,state:y})),d=a.filter(p=>p.state==="closed").length,h=a.length?`Tasks · ${d}/${a.length}`:u.length?`Tasks · ${u.length}`:"Tasks",m=a.length?`ALP tasks: ${d} of ${a.length} done in this session, ${u.length} open`:u.length?`ALP tasks: ${u.length} open`:"ALP tasks";return{label:h,title:m,mine:a.length,lines:[...a,...u.filter(p=>!l.has(p.id))]}}const ab={approve:{label:"Approve",icon:l0},review:{label:"Review",icon:lo},progress:{label:"In progress",icon:uc},ready:{label:"Ready",icon:lc},blocked:{label:"Blocked",icon:s0},closed:{label:"Done",icon:NS}},rb=8,nA=2e4,sA="inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border border-border bg-card px-3 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-muted aria-expanded:text-foreground [&_svg]:size-3.5 [&_svg]:shrink-0";function iA({worked:s}){const t=Oe(),{tasks:i}=Ee(),{openTask:a,openPanel:l}=kt(),u=t.tasksBlock();if(b.useEffect(()=>{if(u)return;t.refreshTasks({quiet:!0});const p=window.setInterval(()=>{t.getState().connection.phase==="open"&&t.refreshTasks({quiet:!0})},nA);return()=>window.clearInterval(p)},[t,u]),u)return null;const d=tA(s,i.rows),h=d.lines.slice(0,rb),m=d.lines.length-rb;return o.jsx(Kt,{label:"Tasks",title:d.title,align:"start",triggerClassName:I(sA),onOpenChange:p=>{p&&t.refreshTasks({quiet:!0})},trigger:o.jsxs(o.Fragment,{children:[o.jsx(Bi,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"tasks-pill-label",children:d.label})]}),items:[...h.map((p,x)=>{const y=ab[p.state].icon;return{id:`task:${p.id}`,label:`${ab[p.state].label} · ${p.title}`,icon:o.jsx(y,{"aria-hidden":!0}),onSelect:()=>a(p.id),group:x===d.mine&&x>0}}),{id:"all-tasks",label:m>0?`All tasks (${m} more)`:"All tasks",icon:o.jsx(Bi,{"aria-hidden":!0}),onSelect:()=>l("tasks"),group:h.length>0}]})}const eo=s=>typeof s=="number"&&Number.isFinite(s)&&s>=0?s:null;function tv(s){const t=eo(s?.contextWindowUsedTokens),i=eo(s?.contextWindowMaxTokens);if(t===null||i===null||i<=0)return null;const a=t/i*100;return{percentage:Math.round(a),share:a,usedTokens:t,maxTokens:i}}const aA=s=>Math.max(0,Math.min(100,s));function ob(s){return s>90?"danger":s>=70?"warning":"normal"}function to(s){return s>=1e6?`${Math.round(s/1e6)}m`:s>=1e3?`${Math.round(s/1e3)}k`:Math.round(s).toString()}function rA(s){return typeof s!="number"||!Number.isFinite(s)||s<=0?null:s<.01?`$${s.toFixed(4)}`:`$${s.toFixed(2)}`}function oA(s){const t=eo(s?.inputTokens),i=eo(s?.cachedInputTokens),a=eo(s?.outputTokens),l=[];return t!==null&&l.push(`${to(t)} input${i?` (${to(i)} cached)`:""}`),a!==null&&l.push(`${to(a)} output`),l.length?l.join(" · "):null}function lA(s){const t=tv(s);return t?`Context window ${t.percentage}% used`:"Context window: No context data"}const Ca=14,Hf=2,If=(Ca-Hf)/2,lf=2*Math.PI*If,cA={normal:"text-muted-foreground",warning:"text-warning",danger:"text-destructive"};function lb({usage:s,className:t}){const[i,a]=b.useState(!1),l=b.useId(),u=tv(s),d=rA(s?.totalCostUsd),h=oA(s),m=u?aA(u.share):0,p=Ca/2;return o.jsxs("div",{className:I("relative flex",t),onPointerEnter:x=>{x.pointerType==="mouse"&&a(!0)},onPointerLeave:x=>{x.pointerType==="mouse"&&a(!1)},children:[o.jsx("button",{type:"button","aria-label":lA(s),"aria-describedby":i?l:void 0,"data-testid":"context-window-meter","data-level":u?ob(u.share):"none",onFocus:()=>a(!0),onBlur:()=>a(!1),onClick:()=>a(!0),onKeyDown:x=>{x.key==="Escape"&&i&&(x.preventDefault(),a(!1))},className:"inline-flex size-7 shrink-0 items-center justify-center rounded-full outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",children:o.jsxs("svg",{width:Ca,height:Ca,viewBox:`0 0 ${Ca} ${Ca}`,"aria-hidden":!0,children:[o.jsx("circle",{cx:p,cy:p,r:If,fill:"none",stroke:"currentColor",strokeWidth:Hf,className:"text-muted"}),u?o.jsx("circle",{cx:p,cy:p,r:If,fill:"none",stroke:"currentColor",strokeWidth:Hf,strokeLinecap:"round",strokeDasharray:lf,strokeDashoffset:lf-m/100*lf,transform:`rotate(-90 ${p} ${p})`,className:cA[ob(u.share)],"data-testid":"context-window-ring"}):null]})}),i?o.jsxs("div",{role:"tooltip",id:l,"data-testid":"context-window-details",className:"absolute bottom-full right-0 z-50 mb-2 flex w-max min-w-[200px] max-w-[300px] flex-col gap-1.5 rounded-lg border border-border bg-popover px-2 py-1 text-popover-foreground shadow-md",children:[o.jsx("span",{className:"text-sm text-foreground",children:"Context window"}),u?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-sm text-foreground",children:[u.percentage,"% used"]}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[to(u.usedTokens)," / ",to(u.maxTokens)," tokens"]})]}):o.jsx("span",{className:"text-xs text-muted-foreground",children:"No context data"}),h?o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last reported ",h]}):null,d?o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Session cost ",d]}):null]}):null]})}function uA({question:s,onAnswer:t,onDecline:i,busy:a,blocked:l}){const[u,d]=b.useState(null),[h,m]=b.useState(""),[p,x]=b.useState(null);b.useEffect(()=>{a||x(null)},[a]);const y=a||!!l,w=b.useId(),k=s.options??[],j=h.trim()||(u!=null?k[u]:""),S=()=>{j&&!y&&(x("submit"),t(j))},A=()=>{y||(x("dismiss"),i())},R=s.agent&&s.agent!=="main"?s.agent:null;return o.jsxs("section",{"aria-label":`Question from ${s.agent}`,className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3","data-testid":"question",children:[o.jsxs("div",{className:"flex flex-col gap-1 px-3 pt-1",children:[R?o.jsxs("p",{className:"text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:[R," asks"]}):null,o.jsx("p",{className:"whitespace-pre-wrap text-(length:--content-font-size) leading-[1.467] text-foreground [overflow-wrap:anywhere]","data-testid":"question-text",children:s.body})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[k.length?o.jsx("div",{className:"flex flex-col gap-1",role:"radiogroup","aria-label":s.body,onKeyDown:q=>{if(!["ArrowDown","ArrowUp","ArrowRight","ArrowLeft"].includes(q.key))return;q.preventDefault();const O=q.key==="ArrowDown"||q.key==="ArrowRight"?1:-1,L=((u??(O>0?-1:0))+O+k.length)%k.length;d(L),m(""),q.currentTarget.querySelectorAll('[role="radio"]')[L]?.focus()},children:k.map((q,O)=>{const L=u===O;return o.jsxs("button",{type:"button",role:"radio","aria-checked":L,disabled:y,tabIndex:L||u==null&&O===0?0:-1,onClick:()=>{d(L?null:O),m("")},className:I("flex w-full items-center gap-3 rounded-md px-3 py-2 text-left text-(length:--content-font-size) leading-[1.467] outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring active:opacity-90 disabled:pointer-events-none disabled:opacity-50",L?"bg-muted text-foreground":"text-muted-foreground"),children:[o.jsx("span",{"aria-hidden":!0,className:I("flex size-[18px] shrink-0 items-center justify-center rounded-full border",L?"border-primary":"border-input"),children:L?o.jsx("span",{className:"size-2.5 rounded-full bg-primary"}):null}),o.jsx("span",{className:"min-w-0 flex-1 [overflow-wrap:anywhere]",children:q})]},`${O}:${q}`)})}):null,o.jsx("label",{htmlFor:w,className:"sr-only",children:k.length?"Other answer":"Your answer"}),o.jsx("input",{id:w,value:h,disabled:y,autoComplete:"off",onChange:q=>{m(q.target.value),q.target.value&&d(null)},onKeyDown:q=>{q.key==="Enter"&&!q.nativeEvent.isComposing&&(q.preventDefault(),S())},placeholder:k.length?"Other...":"Type your answer...",className:"w-full rounded-lg border border-transparent bg-muted p-3 text-(length:--content-font-size) text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-input disabled:cursor-not-allowed disabled:opacity-50"})]}),o.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[o.jsx("button",{type:"button",disabled:y,onClick:A,className:"flex min-h-9 items-center justify-center gap-2 rounded-md border border-input bg-card px-3 py-2 text-sm text-muted-foreground outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",children:p==="dismiss"&&a?o.jsx(Ft,{label:""}):o.jsxs(o.Fragment,{children:[o.jsx(en,{"aria-hidden":!0,className:"size-3.5"}),"Dismiss"]})}),o.jsx("button",{type:"button",disabled:y||!j,onClick:S,className:I("flex min-h-9 items-center justify-center gap-2 rounded-md border border-primary bg-primary px-3 py-2 text-sm text-primary-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring active:opacity-90",(y||!j)&&"pointer-events-none opacity-50"),children:p==="submit"&&a?o.jsx(Ft,{label:"",className:"text-primary-foreground"}):o.jsxs(o.Fragment,{children:[o.jsx(oc,{"aria-hidden":!0,className:"size-3.5"}),"Submit"]})})]}),l?o.jsx("p",{className:"px-1 text-xs text-muted-foreground",children:l}):null]})}const dA=/^(.+?):(\d+)(?::\d+)?(?:-(\d+)(?::\d+)?)?$/,fA=/^L(\d+)(?:C\d+)?(?:-L?(\d+)(?:C\d+)?)?$/i,hA=/^[a-z][a-z0-9+-]*:/i,mA=/\.[a-z0-9_+-]{1,12}$/i;function pA(s){try{return decodeURIComponent(s)}catch{return s}}function cb(s,t){const i=s?Number(s):void 0,a=t?Number(t):void 0;return i!==void 0&&(!Number.isSafeInteger(i)||i<=0)||a!==void 0&&(!Number.isSafeInteger(a)||i===void 0||a<i)?null:{...i?{line:i}:{},...a&&a!==i?{lineEnd:a}:{}}}const gA=s=>s.replace(/\/+$/,"");function xA(s,{roots:t,kind:i}){let a=String(s??"").trim().replace(/^['"`]+|['"`]+$/g,"");if(!a||a.length>4096||/\s/.test(a))return;if(i==="href"){if(/^file:\/\//i.test(a))a=a.replace(/^file:\/\/(localhost)?/i,"");else if(hA.test(a)&&!/^[a-zA-Z]:[\\/]/.test(a))return;a=pA(a)}else if(a.includes("://"))return;if(a.startsWith("~")||a.startsWith("#"))return;let l={};const u=a.indexOf("#");if(u>=0){const m=fA.exec(a.slice(u+1)),p=m?cb(m[1],m[2]):null;if(!p)return;l=p,a=a.slice(0,u)}else{const m=dA.exec(a);if(m){const p=cb(m[2],m[3]);if(!p)return;l=p,a=m[1]}}let d=a;if(d.startsWith("/")){const m=t.map(gA).filter(Boolean).find(p=>d.startsWith(`${p}/`));if(!m)return;d=d.slice(m.length+1)}const h=Js(d);if(!(!h||$i(h))&&!(i==="code"&&(!h.includes("/")&&!a.startsWith("./")||!mA.test(h.split("/").pop()??"")&&!("line"in l))))return{path:h,...l}}function nv(s){if(!Number.isFinite(s)||s<0)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const i=Math.floor(t/60);if(i<60)return t%60?`${i}m ${t%60}s`:`${i}m`;const a=Math.floor(i/60);return i%60?`${a}h ${i%60}m`:`${a}h`}const Gf=950,yA=[[1,0,.78,0,.56,.34],[.78,1,.56,0,.34,0],[.56,.78,.34,1,0,0],[.34,.56,0,.78,0,1],[0,.34,0,.56,1,.78],[0,0,1,.34,.78,.56]],ub=()=>Math.floor(Date.now()%Gf*6/Gf);function Ch({size:s=14,className:t}){const[i,a]=b.useState(ub);b.useEffect(()=>{if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const d=window.setInterval(()=>a(ub()),Gf/6);return()=>window.clearInterval(d)},[]);const l=Math.max(1,Math.round(s*.12)),u=Math.max(2,(s-l*2)/3);return o.jsx("span",{"aria-hidden":!0,className:I("relative inline-flex shrink-0 items-center justify-center",t),style:{width:s,height:s},children:o.jsx("span",{className:"relative",style:{width:u*2+l,height:u*3+l*2},children:yA[i].map((d,h)=>o.jsx("span",{className:"absolute rounded-full bg-current transition-opacity duration-100",style:{width:u,height:u,left:h%2*(u+l),top:Math.floor(h/2)*(u+l),opacity:d}},h))})})}function bA({since:s,className:t}){const[i,a]=b.useState(Date.now);return b.useEffect(()=>{const l=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(l)},[]),o.jsx("span",{className:I("tabular-nums",t),children:nv(i-s)})}function sv({text:s,label:t,className:i}){const[a,l]=b.useState(!1),u=b.useRef(void 0);return b.useEffect(()=>()=>window.clearTimeout(u.current),[]),o.jsx("button",{type:"button","aria-label":a?"Copied":t,title:a?"Copied":t,onClick:()=>{const d=s();d&&navigator.clipboard?.writeText(d).then(()=>{l(!0),window.clearTimeout(u.current),u.current=window.setTimeout(()=>l(!1),1500)}).catch(()=>{})},className:I("flex shrink-0 items-center justify-center rounded p-1 text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",i),children:a?o.jsx(oc,{"aria-hidden":!0}):o.jsx(ws,{"aria-hidden":!0})})}function db({children:s,tone:t}){return o.jsx("pre",{className:I("max-h-[360px] overflow-auto bg-card p-3 font-mono text-(length:--code-font-size) leading-[1.5] whitespace-pre",t==="error"?"text-destructive":"text-foreground"),children:s})}function iv(s){const[t,i]=b.useState(Hn),{shown:a,hidden:l}=Y1(s,t),u=l?o.jsxs("button",{type:"button","data-testid":"tool-detail-more",onClick:()=>i(d=>d+Hn),className:"sticky left-0 block px-3 py-1.5 font-sans text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",children:[`Show ${Math.min(l,Hn)} more line${Math.min(l,Hn)===1?"":"s"}`,l>Hn?` (${l} hidden)`:""]}):null;return{shown:a,more:u}}const av="max-h-[360px] overflow-auto bg-card font-mono text-(length:--code-font-size) leading-[1.5] text-foreground";function Zs({text:s,startLine:t,testId:i,filename:a}){const l=b.useMemo(()=>tc(s),[s]),u=mc(b.useMemo(()=>l.join(`
48
+ `),[l]),a),d=u?.length===l.length?u:null,{shown:h,more:m}=iv(l),p=t!=null?String(t+l.length-1).length:0;return o.jsxs("div",{className:av,"data-testid":i,children:[o.jsx("div",{className:"min-w-max py-2",children:h.map((x,y)=>o.jsxs("div",{className:"flex whitespace-pre px-3",children:[t!=null?o.jsx("span",{"aria-hidden":!0,className:"mr-3 shrink-0 select-none text-right text-muted-foreground tabular-nums",style:{minWidth:`${p}ch`},children:t+y}):null,o.jsx("span",{children:d?.[y]?.length?o.jsx(pc,{tokens:d[y]}):x||" "})]},y))}),m]})}const fb={add:"bg-[rgba(46,160,67,0.15)]",remove:"bg-[rgba(248,81,73,0.15)]",context:"",hunk:"bg-muted/60 text-muted-foreground",file:"bg-muted font-sans font-medium",meta:"text-muted-foreground italic"},vA={add:"+",remove:"-",context:" ",hunk:"",file:"",meta:""};function wA({detail:s}){const{lines:t,numbered:i}=b.useMemo(()=>V1(s),[s]),a=b.useMemo(()=>t.filter(x=>x.type==="add"||x.type==="remove"||x.type==="context"),[t]),l=mc(b.useMemo(()=>a.map(x=>x.text).join(`
49
+ `),[a]),typeof s?.filePath=="string"?s.filePath:null),u=b.useMemo(()=>{const x=new Map;return l?.length===a.length&&a.forEach((y,w)=>x.set(y,l[w])),x},[a,l]),{shown:d,more:h}=iv(t);if(!t.length)return o.jsx(rv,{children:"No changes to show."});const m=i?String(Math.max(0,...t.map(x=>Math.max(x.oldLine??0,x.newLine??0)))).length:0,p=x=>i?o.jsx("span",{"aria-hidden":!0,className:"shrink-0 select-none pr-2 text-right text-muted-foreground tabular-nums",style:{minWidth:`${m+1}ch`},children:x??""}):null;return o.jsxs("div",{className:av,"data-testid":"tool-diff",children:[o.jsx("div",{className:"min-w-max py-2",children:d.map((x,y)=>x.type==="hunk"||x.type==="file"||x.type==="meta"?o.jsx("div",{className:I("whitespace-pre px-3",fb[x.type],x.type==="file"&&y>0&&"mt-2"),"data-diff":x.type,children:x.text},y):o.jsxs("div",{className:I("flex whitespace-pre px-3",fb[x.type]),"data-diff":x.type,children:[p(x.oldLine),p(x.newLine),o.jsx("span",{"aria-hidden":!0,className:I("w-[2ch] shrink-0 select-none",x.type==="add"?"text-dot-success":x.type==="remove"?"text-destructive":"text-muted-foreground"),children:vA[x.type]}),o.jsx("span",{children:u.get(x)?.length?o.jsx(pc,{tokens:u.get(x)}):x.text||" "})]},y))}),h]})}function rv({children:s}){return o.jsx("p",{className:"bg-card px-3 py-2.5 text-sm text-muted-foreground",children:s})}function kA({title:s,children:t}){return o.jsxs("div",{children:[o.jsx("p",{className:"bg-card px-3 pt-2 text-xs font-medium text-muted-foreground",children:s}),t]})}function ov({url:s,children:t}){const i=r5(s);return i?o.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"break-all text-foreground underline decoration-muted-foreground underline-offset-2 hover:decoration-foreground",children:t??s}):o.jsx("span",{className:"break-all",children:t??s})}function jA({detail:s,roots:t}){const i=Array.isArray(s.filePaths)?s.filePaths.filter(d=>typeof d=="string"):[],a=Array.isArray(s.webResults)?s.webResults.filter(d=>d&&typeof d.url=="string"):[],l=[typeof s.numMatches=="number"?`${s.numMatches} match${s.numMatches===1?"":"es"}`:"",typeof s.numFiles=="number"?`${s.numFiles} file${s.numFiles===1?"":"s"}`:"",s.truncated?"truncated":""].filter(Boolean).join(" · "),u=typeof s.content=="string"?s.content:"";return o.jsxs(o.Fragment,{children:[l?o.jsx("p",{className:"bg-card px-3 pt-2 text-xs text-muted-foreground",children:l}):null,u?o.jsx(Zs,{text:u,testId:"tool-search-content"}):null,i.length?o.jsx(Zs,{text:i.map(d=>$l(d,t)).join(`
50
+ `),testId:"tool-search-files"}):null,a.length?o.jsx("ul",{className:"max-h-[360px] space-y-2 overflow-auto bg-card px-3 py-2.5 text-sm","data-testid":"tool-search-web",children:a.map((d,h)=>o.jsxs("li",{className:"min-w-0",children:[o.jsx(ov,{url:String(d.url),children:d.title?.trim()||d.url}),d.title?.trim()?o.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:d.url}):null]},h))}):null]})}function SA({detail:s}){const t=typeof s.result=="string"?s.result:"";return o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"bg-card px-3 py-2.5 font-mono text-(length:--code-font-size) leading-[1.5]",children:[o.jsx(ov,{url:String(s.url??"")}),typeof s.code=="number"?o.jsx("span",{className:"ml-2 text-muted-foreground",children:s.code}):null]}),typeof s.prompt=="string"&&s.prompt.trim()?o.jsx(kA,{title:"Prompt",children:o.jsx("p",{className:"bg-card px-3 pb-2.5 pt-1 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]",children:s.prompt})}):null,t?o.jsx(Zs,{text:t,testId:"tool-fetch-result"}):null]})}function NA({detail:s}){const t=nc(s?.input),i=nc(s?.output);return o.jsxs(o.Fragment,{children:[t?o.jsx(Zs,{text:t,testId:"tool-unknown-input"}):null,i?o.jsx(Zs,{text:i,testId:"tool-unknown-output"}):null]})}function gs(s,t){const i=a=>typeof a=="string"&&a.length>0;switch(s){case"shell":return!0;case"read":case"write":return i(t.content);case"edit":return i(t.unifiedDiff)||i(t.oldString)||i(t.newString);case"search":return i(t.content)||t.filePaths?.length>0||t.webResults?.length>0||typeof t.numFiles=="number"||typeof t.numMatches=="number";case"fetch":return i(t.url)||i(t.result);case"sub_agent":return i(t.description)||i(t.log);case"plan":return i(t.text)&&t.text.trim().length>0;case"plain_text":return i(t.text);default:return!!nc(t?.input)||!!nc(t?.output)}}function TA({item:s,roots:t}){const i=s.detail??{},a=G1(i),l=s.status;let u=null;switch(a){case"shell":{const d=String(i.output??"").replace(/^\n+/,"");u=o.jsxs(db,{children:[o.jsx("span",{className:"text-muted-foreground",children:"$ "}),String(i.command??"").replace(/\n+$/,""),d?`
51
+
52
+ ${d}`:l==="running"?`
53
+
54
+ Running…`:""]});break}case"read":gs(a,i)&&(u=o.jsx(Zs,{text:i.content,startLine:Number.isInteger(i.offset)&&i.offset>0?i.offset:1,testId:"tool-file-content",filename:i.filePath}));break;case"write":gs(a,i)&&(u=o.jsx(Zs,{text:i.content,startLine:1,testId:"tool-file-content",filename:i.filePath}));break;case"edit":gs(a,i)&&(u=o.jsx(wA,{detail:i}));break;case"search":gs(a,i)&&(u=o.jsx(jA,{detail:i,roots:t}));break;case"fetch":gs(a,i)&&(u=o.jsx(SA,{detail:i}));break;case"sub_agent":gs(a,i)&&(u=o.jsxs(o.Fragment,{children:[typeof i.description=="string"&&i.description.trim()?o.jsx("p",{className:"bg-card px-3 py-2.5 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]","data-testid":"tool-sub-agent-description",children:i.description}):null,typeof i.log=="string"&&i.log.trim()?o.jsx(Zs,{text:i.log.replace(/^\n+/,""),testId:"tool-sub-agent-log"}):null]}));break;case"plan":gs(a,i)&&(u=o.jsx("div",{className:"max-h-[480px] overflow-auto bg-card px-4 py-3","data-testid":"tool-plan",children:o.jsx(fo,{text:i.text,className:"text-sm leading-5"})}));break;case"plain_text":gs(a,i)&&(u=o.jsx("p",{className:"max-h-[360px] overflow-auto bg-card px-3 py-2.5 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]",children:i.text}));break;default:gs(a,i)&&(u=o.jsx(NA,{detail:i}))}return o.jsxs("div",{className:"divide-y divide-border",children:[u,s.error?o.jsx(db,{tone:"error",children:s.error}):null,!u&&!s.error?o.jsx(rv,{children:l==="running"?"Running…":"No output."}):null]})}const Fs=s=>s?.item?.kind,lv=s=>s.item?.detail??{};function AA(s){return Fs(s)==="tool_call"&&lv(s).type!=="plan"}const CA=s=>typeof s=="string"&&/(^|[_.\-\s])(grep|glob|search|find)$/i.test(s.trim());function cv(s){const t=new Set,i=new Set;let a=0,l=0,u=0;for(const d of s){if(Fs(d)!=="tool_call")continue;const h=lv(d);h.type==="edit"||h.type==="write"?t.add(h.filePath??d.key):h.type==="shell"?a+=1:h.type==="read"?i.add(h.filePath??d.key):h.type==="search"||CA(d.item.name)?l+=1:u+=1}return{editedFileCount:t.size,commandCount:a,readFileCount:i.size,searchCount:l,otherToolCount:u}}const EA=s=>Object.values(s).some(t=>t>0);function uv(s){const i=[[s.editedFileCount,"edited {n} file","edited {n} files"],[s.commandCount,"ran {n} command","ran {n} commands"],[s.readFileCount,"read {n} file","read {n} files"],[s.searchCount,"searched {n} time","searched {n} times"],[s.otherToolCount,"used {n} other tool","used {n} other tools"]].filter(([l])=>l>0).map(([l,u,d])=>(l===1?u:d).replace("{n}",String(l)));if(!i.length)return"";const a=i.length===1?i[0]:i.length===2?`${i[0]} and ${i[1]}`:`${i.slice(0,-1).join(", ")}, and ${i.at(-1)}`;return a[0].toLocaleUpperCase()+a.slice(1)}function MA(s,{display:t,running:i,expandedTurns:a=new Set,isBoundary:l=()=>!1}){const u=t==="collapseTurns"?zA(s,i,a,l):s.map(d=>({type:"entry",key:d.key,entry:d}));return t==="full"?u:RA(u)}function zA(s,t,i,a){const l=[],u=(h,m)=>m?{type:"entry",key:h.key,entry:h,nested:m}:{type:"entry",key:h.key,entry:h};let d=0;for(;d<s.length;){const h=s[d];if(Fs(h)!=="user_message"||a(h)){l.push(u(h)),d+=1;continue}let m=d;for(;m<s.length&&Fs(s[m])==="user_message"&&!a(s[m]);)m+=1;let p=m;for(;p<s.length&&Fs(s[p])!=="user_message"&&!a(s[p]);)p+=1;const x=s[m-1];for(let A=d;A<m;A+=1)l.push(u(s[A]));const y=s.slice(m,p),w=p<s.length||!t;let k=-1;for(let A=y.length-1;A>=0;A-=1)if(Fs(y[A])==="assistant_message"){k=A;break}const j=k>0?y.slice(0,k):[],S=cv(j);if(!w||k<=0||!EA(S)&&!j.some(A=>Fs(A)==="assistant_message"))for(const A of y)l.push(u(A));else{const A=i.has(x.key);l.push({type:"turn",key:`turn:${x.key}`,entries:j,summary:S,expanded:A});for(const R of j)(A||Fs(R)==="compaction")&&l.push(u(R,A));for(const R of y.slice(k))l.push(u(R))}d=p}return l}function RA(s){const t=[];let i=[];const a=()=>{if(i.length>1)t.push({type:"group",key:`group:${i[0].key}`,entries:i,summary:cv(i),loading:i.some(l=>l.item.status==="running")});else for(const l of i)t.push({type:"entry",key:l.key,entry:l});i=[]};for(const l of s){if(l.type==="entry"&&!l.nested&&AA(l.entry)){i.push(l.entry);continue}a(),t.push(l)}return a(),t}const dv=b.createContext(null),wc=()=>b.useContext(dv);function Eh(){const s=b.useRef(null);return{take:()=>s.current??=Qf(),settle:t=>{t||(s.current=null)},reset:()=>{s.current=null}}}function _A({entryKey:s}){const t=wc(),i=t?.turns.get(s);return!t||!t.rewind.shown||!i?.rewindable?null:o.jsxs("button",{type:"button","data-testid":"rewind-action","aria-label":"Rewind to here…",title:t.rewind.reason??"Rewind to here… (the conversation only; files are not changed)",disabled:!!t.rewind.reason,onClick:()=>t.askRewind(s),className:"flex shrink-0 items-center gap-1 rounded p-1 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-45 [&_svg]:size-3.5",children:[o.jsx(p0,{"aria-hidden":!0}),o.jsx("span",{children:"Rewind to here…"})]})}function LA({userKeys:s}){const t=wc();if(!t||!t.fork.shown)return null;const i=[...s].reverse().map(a=>t.turns.get(a)).find(Boolean);return i?.ended?o.jsxs("button",{type:"button","data-testid":"fork-action","aria-label":"Fork from here…",title:t.fork.reason??"Fork from here… (a new session with this conversation; files are not copied)",disabled:!!t.fork.reason,onClick:()=>t.askFork(i.turnId),className:"flex shrink-0 items-center gap-1 rounded p-1 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-45 [&_svg]:size-3.5",children:[o.jsx(o0,{"aria-hidden":!0}),o.jsx("span",{children:"Fork from here…"})]}):null}function OA({turn:s,onClose:t,onDone:i}){const a=Oe(),l=Eh(),[u,d]=b.useState(!1),[h,m]=b.useState(null);b.useEffect(()=>{m(null),l.reset()},[s?.turnId]);const p=()=>{u||t()},x=async()=>{if(s){d(!0),m(null);try{await a.rewindConversation({beforeTurnId:s.turnId,requestId:l.take()}),l.reset(),i(s.text)}catch(y){const w=ei(y);l.settle(w.retrySame),m(w.message)}finally{d(!1)}}};return o.jsx(ai,{open:!!s,onClose:p,title:"Rewind conversation",className:"w-[min(92vw,34rem)]",footer:o.jsxs(o.Fragment,{children:[o.jsx(we,{variant:"ghost",onClick:p,disabled:u,children:"Cancel"}),o.jsxs(we,{variant:"destructive",onClick:()=>{x()},disabled:u,"data-testid":"rewind-confirm",children:[o.jsx(p0,{"aria-hidden":!0}),u?"Rewinding…":h?"Try again":"Rewind"]})]}),children:s?o.jsxs("div",{className:"space-y-3 text-sm","data-testid":"rewind-dialog",children:[o.jsxs("p",{children:["The conversation goes back to ",o.jsx("strong",{children:"before this message"}),", under the same session. The agent continues from there and no longer sees what came after."]}),o.jsx("blockquote",{className:"max-h-28 overflow-y-auto whitespace-pre-wrap rounded-md border-l-2 border-border bg-muted/50 px-3 py-2 text-muted-foreground [overflow-wrap:anywhere]",children:s.text||"(no text)"}),o.jsxs("p",{children:["This message and what came after it (",aj(s.later),") move to a branch. The branch is kept: you can restore it as a new session from the timeline."]}),o.jsxs("p",{className:"rounded-md bg-[rgba(245,158,11,0.1)] px-3 py-2 font-medium","data-testid":"rewind-files-note",children:[F2," Undo file changes yourself if you need to."]}),o.jsx("p",{className:"text-muted-foreground",children:"The message is put back in the composer so you can edit and send it again."}),h?o.jsx("p",{role:"alert",className:"text-destructive",children:h}):null]}):null})}function DA({turnId:s,title:t,onClose:i}){const a=Oe(),{registry:l,connection:u}=Ee(),d=Eh(),[h,m]=b.useState(!1),[p,x]=b.useState(null),[y,w]=b.useState("tab"),[k,j]=b.useState(null),[S,A]=b.useState(""),[R,q]=b.useState(!1),O=a.worktreeForkSource(),L=b.useRef(null),B=!!O&&u.phase==="open";b.useEffect(()=>{if(x(null),w("tab"),q(!1),d.reset(),L.current=null,!s||!B)return;let Y=!0;return a.worktreeForkDestinations().then(H=>{Y&&(j(H),A(H[0]??""))},()=>{Y&&j([])}),()=>{Y=!1}},[s,B]);const _=()=>{h||i()},Q=async()=>{if(s){m(!0),x(null);try{if(y==="worktree"){const Y=d.take();L.current??=Y,await a.forkIntoWorktree({requestId:Y,worktreeKey:`${L.current}:${S}`,mappingId:S,boundary:{throughTurnId:s}})}else await a.forkConversation({requestId:d.take(),boundary:{throughTurnId:s}});d.reset(),q(!1),i()}catch(Y){const H=ei(Y);d.settle(H.retrySame),q(H.retrySame),x(H.message)}finally{m(!1)}}},C=(Y,H,fe,ee=R)=>o.jsxs("label",{className:I("flex cursor-pointer items-start gap-2 rounded-md border border-border p-2",y===Y&&"border-ring bg-accent/40",ee&&"cursor-not-allowed opacity-50"),children:[o.jsx("input",{type:"radio",name:"fork-target",className:"mt-1",checked:y===Y,disabled:ee||h,onChange:()=>w(Y),"aria-label":H}),o.jsxs("span",{children:[o.jsx("span",{className:"block font-medium",children:H}),o.jsx("span",{className:"block text-muted-foreground",children:fe})]})]});return o.jsx(ai,{open:!!s,onClose:_,title:"Fork conversation",className:"w-[min(92vw,34rem)]",footer:o.jsxs(o.Fragment,{children:[o.jsx(we,{variant:"ghost",onClick:_,disabled:h,children:"Cancel"}),o.jsxs(we,{onClick:()=>{Q()},disabled:h||y==="worktree"&&!S,"data-testid":"fork-confirm",children:[o.jsx(o0,{"aria-hidden":!0}),h?"Forking…":p?"Try again":"Fork"]})]}),children:s?o.jsxs("div",{className:"space-y-3 text-sm","data-testid":"fork-dialog",children:[o.jsx("p",{children:"A new session continues this conversation from the end of this turn. This session stays as it is."}),o.jsxs("div",{className:"space-y-2",role:"radiogroup","aria-label":"Where the fork runs",children:[C("tab","In a new tab","Same workspace: the new session opens in its own tab."),B?C("worktree","In a new worktree","A clean checkout of the last commit, made first; uncommitted changes here are not in it."):null]}),y==="worktree"?k===null?o.jsx("p",{className:"text-muted-foreground",children:"Loading destinations…"}):k.length?o.jsxs("label",{className:"block",children:["Destination",o.jsx("select",{"aria-label":"Worktree destination",className:"mt-1 w-full rounded border border-border bg-background p-1",value:S,onChange:Y=>A(Y.target.value),disabled:h||R,children:k.map(Y=>o.jsx("option",{children:Y},Y))})]}):o.jsx("p",{className:"text-muted-foreground",children:"Ask the host owner to configure a worktree destination and grant it to this credential."}):null,R?o.jsx("p",{className:"text-muted-foreground","data-testid":"fork-pinned",children:"Trying again sends the same fork to the same place, so where it runs cannot change now."}):null,o.jsxs("p",{className:"rounded-md bg-[rgba(147,197,253,0.1)] px-3 py-2 font-medium","data-testid":"fork-files-note",children:[X2," Only the conversation is forked."]}),p?o.jsx("p",{role:"alert",className:"text-destructive",children:p}):null]}):null})}function fv({children:s,testId:t}){return o.jsxs("div",{className:"flex items-center gap-2 px-1 py-3 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground","data-testid":t,role:"note",children:[o.jsx("span",{"aria-hidden":!0,className:"h-px min-w-6 flex-1 bg-border"}),o.jsx("span",{className:"flex min-w-0 flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center [&_svg]:size-3.5",children:s}),o.jsx("span",{"aria-hidden":!0,className:"h-px min-w-6 flex-1 bg-border"})]})}function qA({item:s,branchId:t}){const i=Oe(),a=wc(),l=i.rootSummary(a?.root),u=rj(s,l.branches,t),d=Eh(),[h,m]=b.useState(!1),[p,x]=b.useState(null),y=async()=>{m(!0),x(null);try{await i.forkConversation({requestId:d.take(),branchId:t,title:`${l.title||"Session"} (restored)`}),d.reset()}catch(w){const k=ei(w);d.settle(k.retrySame),x(k.message)}finally{m(!1)}};return o.jsxs("div",{className:"flex flex-col items-stretch pb-4","data-branch-id":t,children:[o.jsxs(fv,{testId:"rewind-marker",children:[o.jsx(cc,{"aria-hidden":!0}),o.jsxs("span",{children:["Conversation rewound here",typeof u=="number"?` — ${ij(u)} kept in a branch`:" — the later turns are kept in a branch",". Files were not changed."]}),a?.fork.shown?o.jsxs(we,{size:"sm",variant:"secondary",className:"h-7",disabled:h||!!a.fork.reason,title:a.fork.reason,onClick:()=>{y()},"data-testid":"restore-branch",children:[o.jsx(uo,{"aria-hidden":!0}),h?"Restoring…":"Restore as new session"]}):null]}),p?o.jsx("p",{role:"alert",className:"self-center pb-2 text-xs text-destructive",children:p}):null]})}function BA({item:s}){const t=Oe(),{sessions:i}=Ee(),a=wc(),l=t.rootSummary(a?.root).forkedFrom,u=l?i.list.find(h=>h.id===l.sessionId):void 0,d=l?.branchId?"a restored branch of":l?.boundary==="before"?"before a message of":l?.boundary==="through"?"a turn of":"the conversation of";return o.jsxs(fv,{testId:"fork-marker",children:[o.jsx(Qs,{"aria-hidden":!0}),l?o.jsxs("span",{children:["Forked from ",d," ",u?o.jsx("button",{type:"button",className:"text-highlight underline-offset-4 hover:underline",onClick:()=>t.selectSession(u.id),"data-testid":"fork-source",children:u.title||u.id}):o.jsx("span",{children:"another session"}),". Files were not copied."]}):o.jsx("span",{children:s.text||"Forked from another session. Files were not copied."})]})}function $A({item:s}){const t=Zf(s);return t?t.kind==="rewind"?o.jsx(qA,{item:s,branchId:t.branchId}):o.jsx(BA,{item:s}):null}function kc({icon:s,label:t,secondary:i,status:a,trailing:l,detail:u,testId:d,kind:h,open:m,onToggle:p}){const[x,y]=b.useState(!1),w=m??x,k=p??(()=>y(R=>!R)),j=b.useId(),S=a==="failed",A=a==="running";return o.jsxs("div",{className:"-mx-[13px]","data-testid":d,"data-tool-kind":h,children:[o.jsxs("button",{type:"button",onClick:k,"aria-expanded":w,"aria-controls":w&&u?j:void 0,className:I("group/badge flex w-full min-w-0 items-center rounded-lg border border-transparent px-2 py-1 text-left text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring active:opacity-90",w&&u&&"rounded-b-none border-border bg-card"),children:[o.jsxs("span",{"aria-hidden":!0,className:"relative mr-1 flex size-[22px] shrink-0 items-center justify-center",children:[o.jsx("span",{className:I("-ml-px flex",w?"hidden":"group-hover/badge:hidden"),children:S?o.jsx(m0,{className:"size-3 text-destructive opacity-80"}):o.jsx(s,{className:I("size-3",w?"text-foreground":"text-muted-foreground group-hover/badge:text-foreground")})}),o.jsx(Jn,{className:I("-ml-1 size-3 scale-[1.3] text-foreground",w?"block rotate-90":"hidden group-hover/badge:block")})]}),o.jsx("span",{className:I("shrink-0 text-muted-foreground",(w||A)&&"text-foreground",A&&"animate-pulse opacity-70","group-hover/badge:text-foreground"),children:t}),i?o.jsx("span",{className:I("ml-2 min-w-0 flex-1 truncate text-muted-foreground group-hover/badge:text-foreground",w&&"text-foreground"),children:i}):o.jsx("span",{className:"flex-1"}),l]}),w&&u?o.jsx("div",{id:j,className:"min-w-0 overflow-hidden rounded-b-lg border border-t-0 border-border",children:u()}):null]})}const UA={terminal:hc,eye:lo,pencil:Ui,search:ti,bot:Oa,brain:Pr,wrench:g0};function HA(){const{workspace:s,principal:t}=Ee();return b.useMemo(()=>s?[s,...(t?.workspaceRoots??[]).filter(i=>i.path===s).map(i=>i.canonical)]:[],[s,t])}function IA({detail:s}){const{added:t,removed:i}=b.useMemo(()=>a5(V1(s).lines),[s]);return!t&&!i?null:o.jsxs("span",{className:"ml-2 shrink-0 text-xs tabular-nums","data-testid":"tool-diff-stat",children:[o.jsxs("span",{className:"text-dot-success",children:["+",t]})," ",o.jsxs("span",{className:"text-destructive",children:["−",i]})]})}function hv({item:s}){const t=HA(),i=s.status,a=n5(s,t),l=a.kind==="shell"&&i!=="running"?s.detail.exitCode:null;return o.jsx(kc,{testId:"tool-call",kind:a.kind,icon:UA[a.icon],label:a.label,secondary:a.secondary,status:i,trailing:l!=null?o.jsxs("span",{className:I("ml-2 shrink-0 text-xs tabular-nums",l===0?"text-muted-foreground opacity-0 group-hover/badge:opacity-100 group-aria-expanded/badge:opacity-100":"text-destructive"),children:["exit ",l]}):a.kind==="edit"?o.jsx(IA,{detail:s.detail}):null,detail:()=>o.jsx(TA,{item:s,roots:t})})}function GA({item:s}){const t=s.items??[],i=t.filter(l=>l.status==="completed").length,a=t.find(l=>l.status==="in_progress");return o.jsx(kc,{icon:oh,label:"Tasks",secondary:a?a.text:`${i} of ${t.length} done`,detail:()=>o.jsx("ul",{className:"space-y-1 bg-card p-2 text-sm",children:t.length?t.map(l=>o.jsxs("li",{className:"flex items-start gap-2 px-1",children:[o.jsx("span",{"aria-hidden":!0,className:I("mt-[5px] size-2 shrink-0 rounded-full",l.status==="completed"?"bg-dot-success":l.status==="in_progress"?"bg-dot-warning":"border border-muted-foreground/60")}),o.jsx("span",{className:I("min-w-0",l.status==="completed"&&"text-muted-foreground line-through"),children:l.text})]},l.id)):o.jsx("li",{className:"px-1 text-muted-foreground",children:"No tasks."})})})}function Ul({level:s,children:t}){const i=s==="error"?si:s==="warning"?m0:rh;return o.jsxs("div",{className:I("flex items-start gap-2 rounded-md px-3 py-2.5 text-sm leading-5 text-foreground",s==="error"?"bg-[rgba(239,68,68,0.1)]":s==="warning"?"bg-[rgba(245,158,11,0.1)]":"bg-[rgba(147,197,253,0.1)]"),children:[o.jsx("span",{"aria-hidden":!0,className:"flex h-5 shrink-0 items-center",children:o.jsx(i,{className:I("size-4",s==="error"?"text-destructive":s==="warning"?"text-warning":"text-info")})}),o.jsx("span",{className:"min-w-0 flex-1 break-words",children:t})]})}function YA({icon:s,children:t}){return o.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:[o.jsx("span",{"aria-hidden":!0,className:"h-px flex-1 bg-border"}),o.jsxs("span",{className:"flex items-center gap-2 [&_svg]:size-3",children:[s,t]}),o.jsx("span",{"aria-hidden":!0,className:"h-px flex-1 bg-border"})]})}function VA({count:s}){return o.jsxs("span",{className:"mb-2 inline-flex items-center gap-1.5 rounded-full bg-muted px-2.5 py-1 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground","data-testid":"user-message-images",children:[o.jsx(US,{"aria-hidden":!0,className:"size-3.5"}),s===1?"1 image":`${s} images`]})}function mv({files:s,testId:t}){return o.jsx("ul",{"aria-label":"Attached files",className:"mb-2 flex max-w-full flex-wrap justify-end gap-2",children:s.map(i=>o.jsxs("li",{"data-testid":t,className:I("flex h-8 max-w-[18rem] items-center gap-1.5 rounded-full bg-muted px-2.5 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",i.failed&&"text-destructive"),children:[o.jsx(ih,{"aria-hidden":!0,className:"size-3.5 shrink-0"}),o.jsx("span",{className:"min-w-0 truncate text-foreground",title:i.name,children:i.name}),o.jsx("span",{className:"shrink-0",children:Ob(i.size)}),i.progress?o.jsx("span",{className:"shrink-0","data-testid":"file-progress",children:i.progress}):null]},i.key))})}function KA({text:s,ts:t,images:i,files:a=[],entryKey:l}){const u=!i&&!a.length;return o.jsxs("div",{className:"group/user flex flex-col items-end",children:[i?o.jsx(VA,{count:i}):null,a.length?o.jsx(mv,{testId:"user-message-file",files:a.map(d=>({key:d.attachmentId,name:d.name,size:d.size}))}):null,s||u?o.jsx("div",{className:"min-w-0 max-w-full rounded-2xl rounded-tr-sm bg-bubble p-4 text-(length:--content-font-size) leading-[1.4] text-foreground whitespace-pre-wrap [overflow-wrap:anywhere]","data-testid":"user-message",children:s}):null,o.jsxs("div",{className:"mt-2 flex h-6 items-center gap-2 opacity-0 transition-opacity group-hover/user:opacity-100 focus-within:opacity-100",children:[o.jsx("span",{className:"text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:P0(t)}),o.jsx(_A,{entryKey:l}),o.jsx(sv,{text:()=>s,label:"Copy message",className:"-mr-1"})]})]})}function FA(){const{workspace:s,principal:t,connection:i}=Ee(),{openFile:a}=kt(),l=i.capabilities.includes("workspace.files.read")&&Te(t??void 0,"files.read");return b.useMemo(()=>{if(!l||!s)return null;const u=[s,...(t?.workspaceRoots??[]).filter(d=>d.path===s).map(d=>d.canonical)];return{resolve:(d,h)=>xA(d,{roots:u,kind:h}),open:d=>a(d.path,d.line)}},[l,s,t,a])}function XA({text:s}){const t=FA();return o.jsx(gc.Provider,{value:t,children:o.jsx(fo,{text:s})})}function PA({row:s}){return o.jsx(kc,{testId:"tool-call-group",icon:g0,label:uv(s.summary),status:s.loading?"running":void 0,detail:()=>o.jsx("div",{className:"max-h-[400px] overflow-y-auto px-[13px] py-1",children:o.jsx("div",{className:"border-l border-border pl-3",children:s.entries.map(t=>o.jsx(hv,{item:t.item},t.key))})})})}function QA({row:s,onToggle:t}){return o.jsx(kc,{testId:"turn-summary",icon:GS,label:uv(s.summary)||"View turn details",open:s.expanded,onToggle:t})}function WA({entry:s,compactBottom:t}){const i=s.item;switch(i.kind){case"user_message":return o.jsx(KA,{entryKey:s.key,text:i.text,ts:s.ts,images:typeof i.images=="number"&&i.images>0?i.images:void 0,files:Cj(i.attachments)});case"assistant_message":return o.jsx("div",{className:I("pt-3",t?"pb-0":"pb-3"),"data-testid":"assistant-message",children:o.jsx(XA,{text:i.text})});case"tool_call":return o.jsx(hv,{item:i});case"todo":return o.jsx(GA,{item:i});case"notice":return Zf(i)?o.jsx($A,{item:i}):o.jsx(Ul,{level:i.level==="error"||i.level==="warning"?i.level:"info",children:i.text});case"compaction":return o.jsx(YA,{icon:i.status==="running"?o.jsx(Ch,{size:12}):i.status==="failed"?o.jsx(si,{className:"text-destructive"}):o.jsx(sN,{}),children:i.status==="running"?"Compacting context…":i.status==="failed"?"Compacting the context failed":"Context compacted"});case"turn_end":return i.state==="canceled"?o.jsxs("p",{className:"flex items-center gap-2 py-1 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:[o.jsx(rc,{"aria-hidden":!0,className:"size-3.5"}),"Stopped."]}):o.jsx(Ul,{level:"error",children:`The turn failed${i.error?`: ${i.error}`:"."}`});case"session_event":return o.jsx(Ul,{level:i.level==="error"?"error":i.level==="warning"?"warning":"info",children:i.text});default:return null}}function ZA({prompt:s,gap:t,onRetry:i,onDiscard:a}){return o.jsxs("div",{className:"flex flex-col items-end gap-2",style:t?{marginTop:t}:void 0,"data-testid":"pending-message","aria-busy":s.status==="sending",children:[s.images?.length?o.jsx("div",{className:"flex flex-wrap justify-end gap-2",children:s.images.map(l=>o.jsx("img",{src:Lb(l),alt:l.name,title:l.name,className:"size-16 rounded-lg border border-border object-cover"},l.id))}):null,s.files?.length?o.jsx(mv,{testId:"pending-file",files:s.files.map((l,u)=>({key:`${u}`,name:l.name,size:l.size,failed:!!l.error,progress:l.attachmentId?"Uploaded":l.error?"Not uploaded":s.status==="sending"?`${l.size?Math.floor((l.received??0)/l.size*100):0}%`:void 0}))}):null,s.text||!s.images?.length&&!s.files?.length?o.jsx("div",{className:I("min-w-0 max-w-full rounded-2xl rounded-tr-sm p-4 text-(length:--content-font-size) leading-[1.4] whitespace-pre-wrap [overflow-wrap:anywhere]",s.status==="sending"?"bg-bubble opacity-70":s.status==="failed"?"border border-destructive/40 bg-destructive/5":"border border-warning/40 bg-warning/5"),children:s.text}):null,s.status==="sending"?o.jsxs("span",{role:"status",className:"flex h-6 items-center gap-2 text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",children:[o.jsx(Ch,{size:12}),s.accepted?"Delivered":"Sending…"]}):o.jsxs("div",{className:"flex max-w-full flex-wrap items-center justify-end gap-2 text-[length:calc(13px*var(--ui-scale))]",role:"alert",children:[o.jsx("span",{className:s.status==="failed"?"text-destructive":"text-warning",children:s.status==="failed"?s.error??"Not sent.":`${s.error??"Not confirmed."}${s.retrySameId?" Sending it again is safe: the host ignores a repeat.":""}`}),o.jsxs(we,{size:"sm",variant:"secondary",onClick:i,children:[o.jsx(uo,{"aria-hidden":!0})," ",s.status==="failed"?"Retry":"Send again"]}),o.jsxs(we,{size:"sm",variant:"ghost",onClick:a,children:[o.jsx(fN,{"aria-hidden":!0})," Discard"]})]})]})}function JA({entries:s,startTs:t,userKeys:i}){const a=s.at(-1)?.ts,l=Date.parse(t??""),u=Date.parse(a??""),d=Number.isFinite(l)&&Number.isFinite(u)&&u>=l?`Worked for ${nv(u-l)}`:"",h=P0(a),m=d||h,p=()=>s.map(x=>x.item.kind==="assistant_message"?x.item.text:"").filter(Boolean).join(`
55
+
56
+ `);return o.jsx("div",{className:"mt-[13px] flex min-h-6 items-center self-start pb-8",children:o.jsxs("div",{className:"flex h-6 items-center gap-2",children:[o.jsx(sv,{text:p,label:"Copy turn",className:"-ml-1"}),o.jsx(LA,{userKeys:i}),m?o.jsxs("span",{className:"group/time relative text-[length:calc(13px*var(--ui-scale))] text-muted-foreground",title:d&&h?`Ended ${h}`:void 0,children:[o.jsx("span",{className:I(d&&h&&"group-hover/time:invisible"),children:m}),d&&h?o.jsx("span",{className:"invisible absolute left-0 top-0 whitespace-nowrap group-hover/time:visible",children:h}):null]}):null]})})}const vs=s=>{const t=s?.item?.kind;return t?t==="user_message"?"user":t==="assistant_message"?"assistant":t==="tool_call"||t==="todo"?"tool":"other":null};function pv(s,t){return!s||!t?0:s==="user"&&t==="user"?4:s==="user"&&t==="assistant"||s==="tool"&&t==="tool"?0:s==="user"&&t==="tool"?16:s==="assistant"&&t==="tool"||s==="tool"&&t==="assistant"?4:16}const gv=s=>!!Zf(s.item);function eC(s,t){const i=[];let a=[],l,u=null;const d=p=>{a.some(x=>vs(x)!=="user")&&i.push({type:"footer",key:p,entries:a.filter(x=>vs(x)!=="user"),startTs:l,userKeys:a.filter(x=>vs(x)==="user").map(x=>x.key)}),a=[]},h=p=>p?p.type==="entry"?vs(p.entry):"tool":null,m=p=>p?.type==="entry"&&gv(p.entry);return s.forEach((p,x)=>{const y=h(p);if(p.type==="entry"&&m(p)){d(`footer:${p.key}`),i.push({type:"entry",entry:p.entry,gap:0,compactBottom:!1}),u=null;return}y==="user"&&a.some(S=>vs(S)!=="user")&&(d(`footer:${p.key}`),u=null),p.type==="entry"&&y==="user"&&u!=="user"&&(l=p.entry.ts);const w=s[x+1],k=w?h(w)==="user"||m(w):!t,j=pv(u,y);p.type==="entry"?(i.push({type:"entry",entry:p.entry,gap:j,compactBottom:y==="assistant"&&k,nested:p.nested}),a.push(p.entry)):p.type==="group"?(i.push({type:"group",row:p,gap:j}),a.push(...p.entries)):(i.push({type:"turn",row:p,gap:j}),p.expanded||a.push(...p.entries.filter(S=>vs(S)!=="other"))),u=y}),t||d("footer:end"),i}function tC({prompts:s,active:t,onJump:i}){const[a,l]=b.useState(null);return s.length<2?null:o.jsx("nav",{"aria-label":"Chat outline","data-testid":"chat-outline-rail",onMouseLeave:()=>l(null),className:"absolute right-1 top-1/2 z-10 flex max-h-[70%] w-9 -translate-y-1/2 flex-col items-end overflow-y-auto py-2 [scrollbar-width:none]",children:s.map((u,d)=>{const h=a===null?0:Math.max(0,1-Math.abs(a-d)/3),m=u.key===t?18:10;return o.jsxs("div",{className:"relative flex h-2 w-full shrink-0 items-center justify-end",children:[o.jsx("button",{type:"button","aria-label":`Jump to prompt: ${u.text.slice(0,80)}`,"aria-current":u.key===t?"true":void 0,onMouseEnter:()=>l(d),onFocus:()=>l(d),onBlur:()=>l(null),onClick:()=>i(u.key),className:"flex h-2 w-full items-center justify-end pr-1 outline-none focus-visible:ring-2 focus-visible:ring-ring",children:o.jsx("span",{"aria-hidden":!0,className:I("block rounded-full transition-[width,height]",u.key===t?"bg-foreground":"bg-extra-muted"),style:{width:m+h*(26-m),height:h>.5?4:2}})}),a===d?o.jsx("div",{role:"tooltip",className:"pointer-events-none absolute right-10 top-1/2 w-[260px] -translate-y-1/2 rounded-lg border border-border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md shadow-(color:--shadow)",children:o.jsx("span",{className:"line-clamp-2",children:u.text})}):null]},u.key)})})}function nC({entries:s,prompts:t,agentOf:i,running:a,runningAgent:l,historyUnavailable:u,older:d,onLoadOlder:h,onRetry:m,onDiscard:p,emptyText:x,tail:y}){const w=b.useRef(null),k=b.useRef(null),j=async()=>{const z=w.current;if(!z||!h)return;const F=[...z.querySelectorAll("[data-entry-key]")].find(J=>J.getBoundingClientRect().bottom>z.getBoundingClientRect().top);k.current=F?{key:F.dataset.entryKey,top:F.getBoundingClientRect().top}:null,S.current=!1,await h()},S=b.useRef(!0),[A,R]=b.useState(!1),q=b.useRef(0),O=()=>{const z=w.current;z&&(S.current=!0,q.current=Date.now()+700,R(!1),z.scrollTo({top:z.scrollHeight,behavior:window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}))},L=s.at(-1),B=`${s.length}:${L?.key}:${L?.item?.text?.length??0}:${L?.item?.status??""}:${t.length}:${a}:${b.Children.count(y)}`;b.useLayoutEffect(()=>{const z=w.current;if(z&&k.current&&!d?.loading){const F=k.current,J=[...z.querySelectorAll("[data-entry-key]")].find(le=>le.dataset.entryKey===F.key);J&&(z.scrollTop+=J.getBoundingClientRect().top-F.top),k.current=null}z&&S.current&&(z.scrollTop=z.scrollHeight),z&&z.scrollHeight-z.scrollTop-z.clientHeight<80&&(S.current=!0,R(!1))},[B,d?.loading]),b.useEffect(()=>{const z=w.current;if(!z||typeof ResizeObserver>"u")return;const F=new ResizeObserver(()=>{S.current&&(z.scrollTop=z.scrollHeight)});return F.observe(z),()=>F.disconnect()},[]);const _=b.useRef(null);if(!a)_.current=null;else if(_.current==null){const z=[...s].reverse().find(J=>vs(J)==="user"),F=Date.parse(z?.ts??"");_.current=Number.isFinite(F)&&Date.now()-F<6*36e5?Math.min(F,Date.now()):Date.now()}const{chatDisplay:Q,chatOutline:C}=Ee().preferences,[Y,H]=b.useState(()=>new Set),fe=z=>H(F=>{const J=new Set(F);return J.has(z)?J.delete(z):J.add(z),J}),ee=b.useMemo(()=>eC(MA(s,{display:Q,running:a,expandedTurns:Y,isBoundary:gv}),a),[s,a,Q,Y]),xe=b.useMemo(()=>s.filter(z=>vs(z)==="user").map(z=>({key:z.key,text:String(z.item.text??"").trim()||"Message"})),[s]),[re,de]=b.useState(null),[U,Z]=b.useState(!1),oe=b.useRef(null);b.useEffect(()=>{const z=oe.current;if(!z||typeof ResizeObserver>"u")return;const F=new ResizeObserver(()=>Z(z.clientWidth>=918));return F.observe(z),()=>F.disconnect()},[]);const ge=()=>{const z=w.current;if(!z||!C)return;const F=z.getBoundingClientRect().top+8;let J=null;for(const le of xe){const ne=z.querySelector(`[data-entry-key="${CSS.escape(le.key)}"]`);ne&&ne.getBoundingClientRect().top<=F&&(J=le.key)}de(J??xe[0]?.key??null)};b.useEffect(ge,[xe,C]);const T=z=>{const F=w.current?.querySelector(`[data-entry-key="${CSS.escape(z)}"]`);F&&(S.current=!1,q.current=0,F.scrollIntoView({block:"start",behavior:window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}),de(z))};return o.jsxs("div",{ref:oe,className:"relative flex min-h-0 flex-1 flex-col",children:[o.jsx("div",{ref:w,onScroll:z=>{const F=z.currentTarget;ge();const J=F.scrollHeight-F.scrollTop-F.clientHeight<80;!J&&Date.now()<q.current||(S.current=J,R(!J))},onWheel:()=>{q.current=0},onTouchStart:()=>{q.current=0},onKeyDown:()=>{q.current=0},className:"min-h-0 flex-1 overflow-y-auto overscroll-contain [overflow-anchor:none] px-3 md:px-4",role:"log","aria-label":"Conversation","aria-live":"off",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-(--content-width) flex-col px-2 py-4",children:[d?.hasOlder?o.jsxs("div",{className:"mb-4 flex flex-col items-center gap-2",children:[o.jsx(we,{variant:"ghost",disabled:d.loading,onClick:()=>{j()},children:d.loading?"Loading…":"Load older messages"}),d.error?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d.error}):null]}):null,u?o.jsx("div",{className:"mb-4",children:o.jsx(Ul,{level:"warning",children:"Earlier history of this conversation is no longer available on the host."})}):null,!s.length&&!t.length?o.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:x}):null,ee.map(z=>z.type==="footer"?o.jsx(JA,{entries:z.entries,startTs:z.startTs,userKeys:z.userKeys},z.key):z.type==="group"?o.jsx("div",{className:"flex flex-col",style:z.gap?{marginTop:z.gap}:void 0,children:o.jsx(PA,{row:z.row})},z.row.key):z.type==="turn"?o.jsx("div",{className:"flex flex-col",style:z.gap?{marginTop:z.gap}:void 0,children:o.jsx(QA,{row:z.row,onToggle:()=>fe(z.row.key.slice(5))})},z.row.key):o.jsx("div",{"data-entry-key":z.entry.key,className:I("flex flex-col",z.nested&&"ml-[9px] border-l border-border pl-3"),"data-nested":z.nested||void 0,style:z.gap?{marginTop:z.gap}:void 0,children:o.jsx(WA,{entry:z.entry,compactBottom:z.compactBottom})},z.entry.key)),t.map((z,F)=>o.jsx(ZA,{prompt:z,gap:F>0?4:pv(ee.at(-1)?.type==="entry"?vs(ee.at(-1).entry):null,"user"),onRetry:()=>m(z.id),onDiscard:()=>p(z.id)},z.id)),a?o.jsx("div",{className:"mt-[13px] flex min-h-6 items-center self-start pb-8","data-testid":"working",role:"status","aria-label":`${l} is working`,children:o.jsxs("div",{className:"flex h-6 items-center gap-3 text-foreground",children:[o.jsx(Ch,{size:14,className:"-ml-0.5"}),o.jsx(bA,{since:_.current??Date.now(),className:"text-[length:calc(13px*var(--ui-scale))] text-muted-foreground"})]})}):null,y?o.jsx("div",{className:"flex flex-col gap-2 pb-4",children:y}):null]})}),C&&U?o.jsx(tC,{prompts:xe,active:re,onJump:T}):null,A?o.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-3 flex justify-center",children:o.jsx("button",{type:"button",onClick:O,"aria-label":"Scroll to bottom",title:"Scroll to bottom","data-testid":"scroll-to-bottom",className:"pointer-events-auto flex size-12 items-center justify-center rounded-full bg-secondary text-foreground shadow-md shadow-black/30 outline-none hover:bg-bubble focus-visible:ring-2 focus-visible:ring-ring",children:o.jsx(Qn,{"aria-hidden":!0,className:"size-6"})})}):null]})}function sC({onNewSession:s}){const{principal:t,workspace:i,sessions:a}=Ee(),l=Te(t??void 0,"session.write");return o.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-16",children:o.jsxs("div",{className:"max-w-sm text-center",children:[o.jsx("span",{className:"mx-auto mb-4 flex size-12 items-center justify-center rounded-xl bg-primary/10 text-highlight",children:o.jsx(uy,{"aria-hidden":!0,className:"size-6"})}),o.jsx("h2",{className:"text-base font-medium",children:i?"Pick a session or start a new one":"Choose a workspace"}),o.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:i?a.list.length?"Your sessions run on the host and keep their history between visits.":"This workspace has no sessions yet.":"Your access token decides which workspaces you can open."}),i&&l?o.jsxs(we,{className:"mt-5",onClick:s,children:[o.jsx(uy,{"aria-hidden":!0})," New session"]}):null]})})}const jc="inline-flex h-7 min-w-0 shrink items-center gap-1 rounded-2xl px-2 text-sm text-muted-foreground [&_svg]:size-3.5 [&_svg]:shrink-0";function Yr({icon:s,label:t,title:i}){return o.jsxs("span",{title:i,className:jc,children:[s,o.jsx("span",{className:"truncate",children:t})]})}const iC={"read-only":aN,"workspace-write":dc,"full-access":f0},hb=s=>s&&iC[s]||dc;function xv({mode:s,modes:t,disabled:i,locked:a,onSelect:l}){const u=hb(s),d=t.find(h=>h.id===s)?.label??Fl(s);return t.length<2&&t[0]?.id===s?o.jsx(Yr,{icon:o.jsx(u,{"aria-hidden":!0}),label:d,title:"Permissions"}):o.jsx(Kt,{label:"Permissions",title:a?`Permissions: ${d}. They change once the agent and its team are idle.`:`Permissions: ${d}`,align:"start",disabled:i,triggerClassName:I(jc,"outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-muted aria-expanded:text-foreground disabled:pointer-events-none disabled:opacity-60"),trigger:o.jsxs(o.Fragment,{children:[o.jsx(u,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"mode-control-label",children:d}),o.jsx(Qn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:t.map(h=>{const m=hb(h.id);return{id:h.id,label:h.label??Fl(h.id),icon:o.jsx(m,{"aria-hidden":!0}),checked:h.id===s,onSelect:()=>{h.id!==s&&l(h.id)}}})})}const cf=I(jc,"outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-muted aria-expanded:text-foreground disabled:pointer-events-none disabled:opacity-60");function aC({team:s,teamId:t,model:i,thinking:a,runtime:l}){const u=Oe(),{catalog:d,busy:h}=Ee(),m=u.liveConfigure(),{same:p,current:x,others:y}=Ij(d.models,{runtime:l,model:i}),w=x?.label??i,k=a?Xs(a):void 0,j=Hb(x),S=!!h.configure,A=(L,B)=>L.enabled?B:`${B}. ${L.reason??m.reason??""}`.trim(),R=(L,B,_)=>o.jsx("span",{className:"inline-flex min-w-0",title:L.enabled&&!S?void 0:S?`${B}. Applying the last change…`:A(L,B),children:_});if(!m.shown)return o.jsxs(o.Fragment,{children:[s?o.jsx(Yr,{icon:o.jsx(Yl,{"aria-hidden":!0}),label:s,title:`Team: ${s}. ${m.reason}`}):null,w?o.jsx(Yr,{icon:o.jsx(jf,{"aria-hidden":!0}),label:w,title:`Main agent's model: ${w}. ${m.reason}`}):null,k?o.jsx(Yr,{icon:o.jsx(Pr,{"aria-hidden":!0}),label:k,title:`Thinking: ${k}. ${m.reason}`}):null]});const q=d.teams.length?d.teams:t?[{id:t,label:s??t}]:[],O=!t||q.some(L=>L.id===t);return o.jsxs(o.Fragment,{children:[s||t?R(m.team,`Team: ${s??t}`,o.jsx(Kt,{label:"Team",title:A(m.team,`Team: ${s??t}`),align:"start",disabled:!m.team.enabled||S,testId:"session-team",triggerClassName:cf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(Yl,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"team-label",children:s??t}),o.jsx(Qn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[...O?[]:[{id:t,label:s??t,checked:!0,onSelect:()=>{}}],...q.map(L=>({id:L.id,label:L.label,checked:L.id===t,...L.id===t?{}:{title:"Restarts main on the same conversation with this team"},onSelect:()=>{L.id!==t&&u.configureLive({team:L.id})}}))]})):null,w?R(p.length?m.model:{enabled:!1},`Main agent's model: ${w}`,o.jsx(Kt,{label:"Model",title:A(m.model,`Main agent's model: ${w}`),align:"start",disabled:!m.model.enabled||S||!p.length,testId:"session-model",triggerClassName:cf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(jf,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"model-label",children:w}),o.jsx(Qn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[...p.map(L=>({id:L.id,label:L.label,checked:L.id===x?.id,onSelect:()=>{L.id!==x?.id&&u.configureLive({model:L.id})}})),...y?[{id:"other-runtimes",label:"Other runtimes: start a new session",disabled:!0,group:!0,title:"A session keeps its runtime. To use another runtime's model, start a new session with it.",onSelect:()=>{}}]:[]]})):null,k?j.length?R(m.thinking,`Thinking: ${k}`,o.jsx(Kt,{label:"Thinking",title:A(m.thinking,`Thinking: ${k}`),align:"start",disabled:!m.thinking.enabled||S,testId:"session-thinking",triggerClassName:cf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(Pr,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"session-thinking-label",children:k}),o.jsx(Qn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:j.map(L=>({id:L.id,label:L.label,checked:L.id===a,onSelect:()=>{L.id!==a&&u.configureLive({thinking:L.id})}}))})):o.jsx(Yr,{icon:o.jsx(Pr,{"aria-hidden":!0}),label:k,title:`Thinking: ${k}`}):null]})}function rC({sessionId:s}){const t=Oe(),{openAgent:i}=kt(),{tree:a,prompts:l,queued:u,busy:d,sessions:h,connection:m,preferences:p,catalog:x,principal:y}=Ee(),[w,k]=b.useState(null),[j,S]=b.useState(null),[A,R]=b.useState(void 0),q=a?.projection,O=!!a?.older?.hasOlder,L=b.useMemo(()=>q?sj(q,{hasOlder:O}):new Map,[q,O]);if(!a)return null;const B=a.projection,_=a.rootId,Q=s,C=h.list.find(ye=>ye.id===_),Y=B.sessions[_],H=ye=>B.sessions[ye]?.agent??(ye===_?"main":"agent"),fe=_ in B.running,ee=fe||t.rootBusy(_),xe=Q in B.running,re=!!B.closed[_]||!Y&&C?.status==="closed",de=Object.values(B.questions),U=t.driveBlock(),Z=l.filter(ye=>ye.rootId===_),oe=t.fileGate(_);if(a.status==="gone")return o.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:o.jsxs("div",{className:"max-w-sm text-center",role:"alert",children:[o.jsx(si,{"aria-hidden":!0,className:"mx-auto mb-3 size-8 text-destructive"}),o.jsx("h2",{className:"font-medium",children:"This session is no longer available"}),o.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:a.error?.message??"The host no longer has it, or your access token cannot see it."}),o.jsx(we,{className:"mt-4",variant:"secondary",onClick:()=>{t.selectSession(null),t.refreshSessions()},children:"Back to sessions"})]})});const ge=a.status==="attaching"||a.status==="detached",T=Ej(B,Q),z=Y?.teamLabel??C?.teamLabel,F=Y?.mode??C?.mode,J=Y?.model??C?.model,le=Te(y??void 0,"session.write"),ne=x.modes.length?x.modes:F?[{id:F}]:[],ce=ee||Object.keys(B.running).length>0,ve=!!F&&ne.length>1&&!d.mode&&!U&&le&&!ce&&m.phase==="open",Re=()=>{if(!ve)return;const ye=ne.findIndex(Ae=>Ae.id===F);t.configureMode(ne[(ye+1)%ne.length].id)},Qe=(Q===_?[...T].reverse().find(ye=>ye.item.kind==="todo"):void 0)?.item?.items??[],Ue=t.conversationGate(_),et=Q===_&&(Ue.fork.shown||Ue.rewind.shown)?{root:_,fork:Ue.fork,rewind:Ue.rewind,turns:L,askRewind:ye=>{const Ae=L.get(ye);Ae&&k(Ae)},askFork:ye=>S(ye)}:null,Fe=Y?.title??C?.title??"Session",be=de.length?de.map(ye=>o.jsx(uA,{question:ye,busy:!!d[`question:${ye.id}`],blocked:U,onAnswer:Ae=>{t.answerQuestion(ye.id,{text:Ae})},onDecline:()=>{t.answerQuestion(ye.id,{dismiss:!0})}},ye.id)):null;return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[a.status==="error"?o.jsxs("div",{role:"alert",className:"flex items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-4 py-2 text-xs text-destructive",children:[o.jsx("span",{className:"min-w-0 flex-1",children:a.error?.message??"Could not load this session."}),o.jsxs(we,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>t.retryAttach(),children:[o.jsx(uo,{"aria-hidden":!0})," Try again"]})]}):null,ge&&!T.length?o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx(Ft,{label:m.phase==="open"?"Loading conversation…":"Waiting for the connection…"})}):o.jsx(dv.Provider,{value:et,children:o.jsx(nC,{entries:T,prompts:Q===_?Z:[],agentOf:H,running:xe,runningAgent:H(Q),historyUnavailable:B.historyUnavailable,older:a.older,onLoadOlder:()=>t.loadOlder(),onRetry:ye=>{t.retryPrompt(ye)},onDiscard:ye=>t.discardPrompt(ye),emptyText:Q===_?re?"Nothing here yet.":"Send a message to start.":"This agent has not written anything yet.",tail:be})}),o.jsx(OA,{turn:w,onClose:()=>k(null),onDone:ye=>{k(null),ye&&R({id:Date.now(),text:ye})}}),o.jsx(DA,{turnId:j,title:Fe,onClose:()=>S(null)}),ge&&!T.length&&be?o.jsx("div",{className:"px-3 pb-3 md:px-4",children:o.jsx("div",{className:"mx-auto flex w-full max-w-(--content-width) flex-col gap-2 px-2",children:be})}):null,Q===_&&t.isArchived(_)?o.jsx(O5,{sessionId:_}):Q===_?o.jsxs(o.Fragment,{children:[re&&!fe?o.jsx("p",{className:"mx-auto w-full max-w-(--content-width) px-4 pb-2 text-center text-xs text-muted-foreground",children:"This session is closed on the host. Sending a message reopens it."}):null,o.jsx(ev,{meter:o.jsx(lb,{usage:Y?.usage}),images:Y?.promptImages===!0&&m.capabilities.includes("prompt.images")&&!!m.promptImageLimits?.maxBytes,imageLimits:m.promptImageLimits,imagesUnavailable:`${H(_)} runs on ${Y?.runtime??"a runtime"} here, which takes no images.`,files:!oe,fileLimits:m.attachmentLimits,filesUnavailable:oe??void 0,addText:A,commands:()=>t.listCommands(_),onSend:(ye,Ae,Ne)=>t.sendPrompt(ye,void 0,Ae,Ne),onQueue:ye=>t.queuePrompt(ye),onInterruptSend:ye=>t.interruptAndSend(ye),onStop:()=>{t.interrupt()},queued:u.filter(ye=>ye.rootId===_),onEditQueued:ye=>t.editQueued(ye),onSendQueued:ye=>{t.sendQueuedNow(ye)},running:ee,stopping:!!d.interrupt,blocked:U,disabledReason:m.phase!=="open"?"Reconnecting…":ge?"Loading…":void 0,placeholder:`Message ${H(_)}…`,sendBehavior:p.sendBehavior,sendShortcut:p.sendShortcut,onCycleMode:ve?Re:void 0,tracks:o.jsx(iA,{worked:Qe}),controls:o.jsxs(o.Fragment,{children:[o.jsx(aC,{team:z,teamId:Y?.workflow?.mode??C?.workflow?.mode,model:J,thinking:Y?.thinking??C?.thinking,runtime:Y?.runtime??C?.runtime}),F?o.jsx(xv,{mode:F,modes:ne,locked:ce,disabled:!!d.mode||!!d.configure||!!U||!le||m.phase!=="open"||ce,onSelect:ye=>{t.configureMode(ye)}}):null]})})]}):o.jsx("div",{className:"px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:px-4 md:pb-4",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-(--content-width) items-center gap-3 rounded-2xl border border-dotted border-input bg-card px-3 py-2 text-(length:--content-font-size) leading-[1.4] text-muted-foreground md:px-4 md:py-3",children:[o.jsxs("span",{className:"min-w-0 flex-1",children:[H(Q)," works on an assignment from main. Talk to main to steer it."]}),o.jsx(lb,{usage:B.sessions[Q]?.usage}),o.jsxs(we,{size:"sm",variant:"secondary",onClick:()=>i(_),children:[o.jsx(th,{"aria-hidden":!0})," Main"]})]})})]})}const oC=250,uf=I(jc,"outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-muted aria-expanded:text-foreground disabled:pointer-events-none disabled:opacity-60");function lC(s){const t=Oe(),{connection:i}=Ee(),[a,l]=b.useState({status:"idle"}),[u,d]=b.useState(0),h=s?JSON.stringify(s):"",m=i.phase==="open";b.useEffect(()=>{if(!s)return;const x=t.previewBlock();if(x){l(j=>({...j,status:"blocked",error:x}));return}if(!m)return;const y=new AbortController,w=Ib(s);l(j=>({status:"loading",preview:j.preview,base:j.base}));const k=setTimeout(()=>{t.previewSession(s,{signal:y.signal}).then(j=>{y.signal.aborted||l({status:"ready",preview:j,base:w})},j=>{y.signal.aborted||l(S=>({...S,status:"error",error:Be(j).message}))})},oC);return()=>{clearTimeout(k),y.abort()}},[h,m,t,u]);const p=b.useCallback(()=>d(x=>x+1),[]);return{...a,retry:p}}function cC(){const s=Oe(),{finishDraft:t}=kt(),{catalog:i,workspace:a,preferences:l,busy:u,connection:d,principal:h}=Ee(),m=s.fileGate(null),p=l.newSession,[x,y]=b.useState(()=>Yx(i,p)),[w,k]=b.useState("");b.useEffect(()=>{i.status==="ready"&&y(Yx(i,s.getState().preferences.newSession))},[i,s]);const[j,S]=b.useState(),A=Ib({workflow:x.team,model:x.model}),R=j?.base===A?j.preview:void 0,q=Ub(i.models,x.model,R),O=q?_j(q,x.thinking):void 0,L={...x,...O?{thinking:O}:{thinking:void 0}},B=a&&i.status!=="loading"?Vx(a,L):null,_=lC(B);b.useEffect(()=>{_.status==="ready"&&_.preview&&_.base&&S({preview:_.preview,base:_.base})},[_.status,_.preview,_.base]);const Q=_.status==="ready"&&_.base===A,C=_.status==="blocked"||_.status==="error",Y=!!u.create,fe=Te(h??void 0,"session.write")?void 0:"Your access token can view sessions but not start them.",ee=i.teams.length?i.teams:R?.teams??[],xe=Kx(ee,R),[re,de]=b.useState(),U=re?.workspace===a?re:void 0;b.useEffect(()=>{xe&&de(ze=>ze?.workspace===a&&ze.team?.id===xe.id&&ze.team.label===xe.label?ze:{team:xe,workspace:a})},[xe?.id,xe?.label,a]);const Z=!!a&&d.phase==="open"&&!!x.team&&!U&&i.status==="ready";b.useEffect(()=>{if(!Z||!a||s.previewBlock())return;const ze=new AbortController;return s.previewSession(Vx(a,{}),{signal:ze.signal}).then(ut=>{if(ze.signal.aborted)return;const At=Kx(i.teams.length?i.teams:ut.teams,ut);de(Rt=>Rt?.workspace===a?Rt:{workspace:a,...At?{team:At}:{}})},()=>{}),()=>ze.abort()},[Z,a,s]);const oe=Dj(ee,xe??U?.team),ge=qj({chosen:x.team,previewTeam:R?.team,previewSettled:C,previewError:_.error,previewBlocked:_.status==="blocked",previewNeedsRead:!Te(h??void 0,"session.read"),teams:ee,teamsKnown:i.teamsKnown,teamsUnavailable:i.teamsUnavailable}),T="stuck"in ge&&ge.stuck?ge.wait:void 0,z=()=>{_.retry(),s.retryTeams()},F=i.teamsUnavailable?.reason==="failed",J=ge.team,le=J?J===R?.team&&R.teamLabel||oe.find(ze=>ze.id===J)?.label||J:"Team",ne=ge.wait??(!C&&!Q?"Checking what would run…":void 0),ce=x.model?i.models.find(ze=>ze.id===x.model)?.label??x.model:q?q.label:R?.model||"Default model",ve=Hb(q),Re=O?Xs(O):R?.thinking?Xs(R.thinking):q?.effort?Xs(q.effort):"Default",Me=`composer-${b.useId()}`,Qe=()=>setTimeout(()=>document.getElementById(Me)?.focus(),0),Ue=ze=>{y(ut=>({...ut,...ze})),Qe()},et=ze=>{y(ut=>({...ut,model:ze||void 0,thinking:p.thinkingByModel?.[ze||"default"]})),Qe()},[Fe]=b.useState(()=>s.unsentDraft()),[be,ye]=b.useState();b.useEffect(()=>{Fe&&s.clearUnsentDraft(Fe);const ze=Rt=>ye(In=>({id:(In?.id??0)+1,text:Rt})),ut=s.takeUnsentDrafts(Rt=>Rt.workspace!==s.getState().workspace?!1:(ze(Rt.text),!0)),At=s.unsentDraft();return At&&(s.clearUnsentDraft(At),ze(At)),ut},[Fe,s]);const Ae=b.useRef(!1),Ne=b.useRef(!0);b.useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1}),[]);const Ht=async(ze,ut=[],At=[])=>{if(!(Ae.current||s.getState().busy.create||ne)){Ae.current=!0;try{const Rt=await Uj(s,{...J?{team:J}:{},...L.mode?{mode:L.mode}:{},...L.model?{model:L.model}:{},...L.thinking?{thinking:L.thinking}:{},...w.trim()?{title:w.trim()}:{},...ze.trim()?{prompt:ze}:{},...At.length?{files:At}:{}},ze,{mounted:()=>Ne.current,describe:Be,nameOf:Dt});t(Rt)}finally{Ae.current=!1}}},cn=o.jsxs(o.Fragment,{children:[o.jsx(Kt,{label:"Team",title:`Team: ${le}`,align:"start",disabled:Y,testId:"new-session-team",triggerClassName:uf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(Yl,{"aria-hidden":!0}),o.jsx("span",{className:"truncate",children:le}),o.jsx(Qn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[...oe.map(ze=>({id:ze.id,label:ze.label,checked:J===ze.id,onSelect:()=>Ue({team:ze.id})}))]}),i.models.length?o.jsx(Kt,{label:"Model",title:`Main agent's model: ${ce}`,align:"start",disabled:Y,testId:"new-session-model",triggerClassName:uf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(jf,{"aria-hidden":!0}),o.jsx("span",{className:"truncate",children:ce}),o.jsx(Qn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[{id:"",label:"Team default",checked:!x.model,onSelect:()=>et("")},...i.models.map((ze,ut)=>({id:ze.id,label:ze.label,checked:x.model===ze.id,group:ut===0,onSelect:()=>et(ze.id)}))]}):null,ve.length?o.jsx(Kt,{label:"Thinking",title:`Thinking: ${Re}`,align:"start",disabled:Y,testId:"new-session-thinking",triggerClassName:uf,trigger:o.jsxs(o.Fragment,{children:[o.jsx(Pr,{"aria-hidden":!0}),o.jsx("span",{className:"truncate","data-testid":"thinking-label",children:Re}),o.jsx(Qn,{"aria-hidden":!0,className:"!size-3 opacity-70"})]}),items:[{id:"",label:q?.effort?`Default (${Xs(q.effort)})`:"Default",checked:!O,onSelect:()=>Ue({thinking:void 0})},...ve.map((ze,ut)=>({id:ze.id,label:ze.label,checked:O===ze.id,group:ut===0,onSelect:()=>Ue({thinking:ze.id})}))]}):null,x.mode?o.jsx(xv,{mode:x.mode,modes:i.modes,locked:!1,disabled:Y,onSelect:ze=>Ue({mode:ze})}):null]});return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"new-session-screen",children:[o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto flex w-full max-w-[820px] flex-col gap-5 px-4 pb-6 pt-10 md:pt-16",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-medium text-foreground",children:"New session"}),a?o.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Runs on the host in ",o.jsx("span",{className:"font-mono text-foreground/90",children:Dt(a)}),". Your first message starts it."]}):null]}),i.status==="loading"?o.jsx(Ft,{label:"Loading teams and models…",className:"text-xs"}):null,i.status==="error"?o.jsx("p",{role:"alert",className:"text-xs text-destructive",children:i.error?.message}):null,o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{htmlFor:"new-title",className:"text-xs font-medium text-muted-foreground",children:"Title (optional)"}),o.jsx(Zn,{id:"new-title",value:w,onChange:ze=>k(ze.target.value),maxLength:200,disabled:Y,placeholder:"Named after your first message when empty",className:"bg-transparent"})]}),o.jsx(uC,{state:_,models:i.models,onRetry:z,retryWhenBlocked:F}),T?o.jsxs("p",{role:"alert","data-testid":"new-session-stuck",className:"flex items-start gap-2 text-xs text-destructive",children:[o.jsx(si,{"aria-hidden":!0,className:"mt-0.5 size-3.5 shrink-0"}),T]}):null]})}),o.jsx(ev,{onSend:Ht,sendShortcut:l.sendShortcut,onQueue:()=>{},onStop:()=>{},queued:[],onEditQueued:()=>null,onSendQueued:()=>{},running:!1,stopping:!1,blocked:fe,disabledReason:d.phase!=="open"?"Reconnecting…":Y?"Starting…":a?i.status==="loading"?"Loading…":void 0:"Choose a workspace first.",startHold:ne,placeholder:"What should main work on?",startLabel:"Start session",initialText:Fe,addText:be,autoFocus:!0,inputId:Me,controls:cn,files:!m,fileLimits:d.attachmentLimits,filesUnavailable:m??void 0})]})}function uC({state:s,models:t,onRetry:i,retryWhenBlocked:a}){const l=s.preview?Oj(s.preview,t):[];return o.jsxs("section",{"aria-label":"Session preview","data-testid":"session-preview","aria-busy":s.status==="loading",className:"overflow-hidden rounded-lg border border-border bg-card",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-2.5",children:[o.jsx("h3",{className:"text-xs font-normal text-muted-foreground",children:"This session will run"}),s.status==="loading"?o.jsx(Ft,{label:"Checking…",className:"text-xs"}):null]}),s.status==="blocked"?o.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3",children:[o.jsxs("p",{role:"note",className:"text-xs text-muted-foreground",children:["Preview not available: ",s.error]}),a?o.jsx("button",{type:"button",onClick:i,className:"shrink-0 rounded-md px-2 py-0.5 text-xs text-foreground outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",children:"Retry"}):null]}):null,s.status==="error"?o.jsxs("div",{className:"flex items-start justify-between gap-3 px-4 py-3",children:[o.jsxs("p",{role:"alert",className:"flex items-start gap-2 text-xs text-destructive",children:[o.jsx(si,{"aria-hidden":!0,className:"mt-0.5 size-3.5 shrink-0"}),s.error]}),o.jsx("button",{type:"button",onClick:i,className:"shrink-0 rounded-md px-2 py-0.5 text-xs text-foreground outline-none hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring",children:"Retry"})]}):null,l.length?o.jsx("dl",{className:I("grid grid-cols-[auto_1fr] gap-x-6 gap-y-2 px-4 py-3 text-sm",s.status!=="ready"&&"opacity-60"),children:l.map(u=>o.jsxs(b.Fragment,{children:[o.jsx("dt",{className:"text-muted-foreground",children:u.label}),o.jsx("dd",{className:"min-w-0 truncate text-foreground","data-testid":`preview-${u.key}`,children:u.value})]},u.key))}):s.status==="idle"||s.status==="loading"&&!s.preview?o.jsx("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"Asking the host…"}):null]})}const dC={open:"Open",in_progress:"In progress",review:"In review",closed:"Closed"},fC={open:"text-muted-foreground",in_progress:"text-dot-running",review:"text-dot-warning",closed:"text-highlight"};function xs({label:s,children:t}){return o.jsxs(o.Fragment,{children:[o.jsx("dt",{className:"text-muted-foreground",children:s}),o.jsx("dd",{className:"min-w-0 break-words",children:t})]})}function yv({id:s,onOpenTask:t}){const i=Oe(),{openTask:a}=kt(),l=t??a,{tasks:u,principal:d}=Ee(),h=u.rows.find(y=>y.id===s),m=Te(d??void 0,"project.write"),p=i.tasksBlock();if(b.useEffect(()=>(i.setTasksVisible(!0),()=>i.setTasksVisible(!1)),[i]),p)return o.jsxs("p",{className:"m-auto flex max-w-sm items-start gap-2 px-6 text-sm text-muted-foreground",children:[o.jsx(qa,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),p]});if(!h)return o.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:u.status==="loading"||u.status==="idle"?o.jsx(Ft,{label:"Loading the task…"}):o.jsxs("p",{className:"max-w-sm text-center text-sm text-muted-foreground",role:"status",children:["Task ",s," is no longer in this workspace's list."]})});const x=!!u.busy[h.id];return o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"task-detail",children:o.jsxs("article",{className:"mx-auto w-full max-w-(--content-width) px-4 py-6 sm:px-6",children:[o.jsxs("p",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[o.jsx("span",{className:"font-mono",children:h.id}),h.type?o.jsxs("span",{children:["· ",h.type]}):null,o.jsxs("span",{children:["· P",h.priority]}),o.jsxs("span",{className:I("inline-flex items-center gap-1",fC[h.status]),children:[o.jsx(n0,{"aria-hidden":!0,className:"size-3"}),dC[h.status]??h.status]}),h.status!=="closed"&&h.ready?o.jsx("span",{className:"text-info",children:"· ready"}):null]}),o.jsx("h2",{className:I("text-xl font-normal leading-snug",h.status==="closed"&&"text-muted-foreground"),children:h.title}),u.message?.level==="error"?o.jsx("p",{role:u.message.level==="error"?"alert":"status",className:I("mt-4 rounded-md px-3 py-2 text-xs",u.message.level==="error"?"bg-destructive/10 text-destructive":"bg-primary/10 text-highlight"),children:u.message.text}):null,h.approvals?.map(y=>o.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 rounded-xl border border-warning/40 bg-warning/[0.06] px-4 py-3 text-sm",children:[o.jsx(dc,{"aria-hidden":!0,className:"size-4 shrink-0 text-warning"}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"text-warning",children:"Needs your approval"}),y.note?o.jsxs("span",{className:"text-muted-foreground",children:[": ",y.note]}):null]}),y.rejected?o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Rejected ",Ri(y.rejected.at)]}):null,m?y.options?.length?y.options.map(w=>o.jsx(we,{size:"sm",disabled:x,onClick:()=>{i.changeTask(h,{gate:y.gate,choice:w})},children:w},w)):o.jsx(we,{size:"sm",disabled:x,onClick:()=>{i.changeTask(h,{gate:y.gate})},children:"Approve"}):null,m&&!y.rejected?o.jsx(we,{size:"sm",variant:"secondary",disabled:x,onClick:()=>{i.changeTask(h,{gate:y.gate,reject:!0})},children:"Reject"}):null]},y.gate)),o.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[m?h.status==="closed"?o.jsxs(we,{size:"sm",variant:"secondary",disabled:x,onClick:()=>{i.changeTask(h,{action:"reopen"})},children:[o.jsx(uo,{"aria-hidden":!0})," Reopen"]}):o.jsxs(we,{size:"sm",variant:"secondary",disabled:x,onClick:()=>{i.changeTask(h,{action:"close"})},children:[o.jsx(oc,{"aria-hidden":!0})," Close task"]}):o.jsx("p",{className:"text-xs text-muted-foreground",children:"Your access token can read tasks but not change them."}),x?o.jsx(Ft,{label:"Saving…",className:"text-xs"}):null]}),h.description?o.jsx("section",{"aria-label":"Description",className:"mt-6 text-(length:--content-font-size) leading-[1.5]",children:o.jsx(fo,{text:h.description})}):o.jsx("p",{className:"mt-6 text-sm text-muted-foreground",children:"No description."}),h.handoff?o.jsxs("section",{"aria-label":"Handoff",className:"mt-6 rounded-xl border border-border bg-card px-4 py-3",children:[o.jsxs("p",{className:"mb-1 text-xs text-muted-foreground",children:["Handoff · ",h.handoff.outcome,h.handoff.agent?` · ${h.handoff.agent}`:""]}),o.jsx("p",{className:"whitespace-pre-wrap text-sm",children:h.handoff.summary})]}):null,h.closed?o.jsxs("section",{"aria-label":"Closed",className:"mt-4 rounded-xl border border-border bg-card px-4 py-3",children:[o.jsxs("p",{className:"mb-1 text-xs text-muted-foreground",children:["Closed ",Ri(h.closed.at)," · ",h.closed.reason]}),h.closed.summary?o.jsx("p",{className:"whitespace-pre-wrap text-sm",children:h.closed.summary}):null]}):null,o.jsxs("dl",{className:"mt-6 grid grid-cols-[8rem_1fr] gap-x-4 gap-y-2 border-t border-border pt-4 text-sm",children:[h.assignee?o.jsx(xs,{label:"Assignee",children:h.assignee}):null,h.progress?o.jsxs(xs,{label:"Progress",children:[h.progress.done," of ",h.progress.total," done"]}):null,h.parent?o.jsx(xs,{label:"Parent",children:o.jsx("button",{type:"button",className:"font-mono text-highlight hover:underline",onClick:()=>l(h.parent),children:h.parent})}):null,h.blockedBy?.length?o.jsx(xs,{label:"Blocked by",children:h.blockedBy.map((y,w)=>o.jsxs(b.Fragment,{children:[w?", ":"",o.jsx("button",{type:"button",className:"font-mono text-highlight hover:underline",onClick:()=>l(y),children:y})]},y))}):null,h.waits?.length?o.jsx(xs,{label:"Waits on",children:h.waits.join("; ")}):null,h.labels?.length?o.jsx(xs,{label:"Labels",children:o.jsx("span",{className:"flex flex-wrap gap-1",children:h.labels.map(y=>o.jsx("span",{className:"rounded-full bg-secondary px-2 py-0.5 text-xs",children:y},y))})}):null,h.paths?.length?o.jsx(xs,{label:"Paths",children:o.jsx("span",{className:"space-y-0.5",children:h.paths.map(y=>o.jsx("span",{className:"block font-mono text-xs",children:y},y))})}):null,h.createdAt?o.jsx(xs,{label:"Created",children:Ri(h.createdAt)}):null,o.jsx(xs,{label:"Updated",children:Ri(h.updatedAt)})]})]})})}const hC=s=>Math.round(s*5/3),mC=200*1024,pC=s=>s instanceof Ei?s.failure:{message:s instanceof Error?s.message:"Something went wrong.",sent:"unknown",terminal:!1};function gC({path:s}){const t=Oe(),{fileTarget:i}=kt(),a=i(s),[l,u]=b.useState({status:"loading"}),[d,h]=b.useState(!1),[m,p]=b.useState(()=>a?.line?"source":"preview"),[x,y]=b.useState(!1),[w,k]=b.useState(0),j=b.useRef(null),S=hC(Ee().preferences.codeFontSize);b.useEffect(()=>{let Q=!0;return u(C=>C.status==="ready"?C:{status:"loading"}),t.readWorkspaceFile({path:s,includeIgnored:d}).then(C=>{Q&&u({status:"ready",content:C.content,size:C.size,...C.modifiedAt?{modifiedAt:C.modifiedAt}:{}})},C=>{Q&&u({status:"error",failure:pC(C)})}),()=>{Q=!1}},[t,s,d,w]),b.useEffect(()=>{a?.line&&p("source")},[a?.nonce,a?.line]);const A=S2(s)&&(l.status!=="ready"||l.size<=mC),R=!A||m==="source",q=l.status==="ready";b.useEffect(()=>{!q||!R||!a?.line||!j.current||(j.current.scrollTop=Math.max(0,(a.line-1)*S-3*S))},[q,R,a?.line,a?.nonce,S]);const O=()=>{navigator.clipboard?.writeText(s).then(()=>{y(!0),setTimeout(()=>y(!1),1500)},()=>t.notify("error",`Could not copy ${s}.`))},L=()=>k(Q=>Q+1),B=l.status==="ready"?j2(l.content):0,_=mc(l.status==="ready"&&R?l.content:"",s);return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"file-view","data-path":s,children:[o.jsxs("div",{className:"flex min-h-11 shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-4 py-1.5 text-xs text-muted-foreground",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-(length:--code-font-size) text-foreground",title:s,"data-testid":"file-view-path",children:s}),l.status==="ready"?o.jsxs("span",{"data-testid":"file-view-meta",children:[k2(l.size)," · ",B," ",B===1?"line":"lines"]}):null,A&&l.status==="ready"?o.jsxs("span",{className:"flex rounded-md border border-border p-0.5",role:"group","aria-label":"View",children:[o.jsxs("button",{type:"button","aria-pressed":m==="preview",onClick:()=>p("preview"),className:I("flex items-center gap-1 rounded px-2 py-0.5",m==="preview"?"bg-secondary text-foreground":"hover:text-foreground"),children:[o.jsx(lo,{"aria-hidden":!0,className:"size-3.5"}),"Preview"]}),o.jsxs("button",{type:"button","aria-pressed":m==="source",onClick:()=>p("source"),className:I("flex items-center gap-1 rounded px-2 py-0.5",m==="source"?"bg-secondary text-foreground":"hover:text-foreground"),children:[o.jsx(OS,{"aria-hidden":!0,className:"size-3.5"}),"Source"]})]}):null,o.jsx(we,{size:"icon-sm",variant:"ghost",onClick:O,"aria-label":"Copy path",title:x?"Copied":"Copy path","data-testid":"file-view-copy-path",children:o.jsx(ws,{"aria-hidden":!0})}),o.jsx(we,{size:"icon-sm",variant:"ghost",onClick:L,"aria-label":"Refresh",title:"Refresh","data-testid":"file-view-refresh",children:o.jsx(co,{"aria-hidden":!0})})]}),l.status==="loading"?o.jsx("div",{className:"flex flex-1 items-center justify-center","data-testid":"file-view-loading",children:o.jsx(Ft,{label:"Reading the file…"})}):l.status==="error"?o.jsx(xC,{failure:l.failure,onRetry:L,onShowIgnored:()=>h(!0)}):R?o.jsx("div",{ref:j,className:"relative min-h-0 flex-1 overflow-auto","data-testid":"file-view-source",children:o.jsxs("div",{className:"relative flex min-w-max font-mono text-(length:--code-font-size)",style:{lineHeight:`${S}px`},children:[a?.line&&a.line<=B?o.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 bg-highlight/10",style:{top:8+(a.line-1)*S,height:S},"data-testid":"file-view-target-line"}):null,o.jsx("pre",{"aria-hidden":!0,className:"sticky left-0 z-[1] select-none border-r border-border bg-background py-2 pl-3 pr-3 text-right text-extra-muted","data-testid":"file-view-gutter",children:Array.from({length:Math.max(B,1)},(Q,C)=>C+1).join(`
57
+ `)}),o.jsx("pre",{className:"relative py-2 pl-4 pr-6 text-foreground","data-testid":"file-view-content",children:_?_.map((Q,C)=>o.jsxs(b.Fragment,{children:[C?`
58
+ `:null,o.jsx(pc,{tokens:Q})]},C)):l.content})]})}):o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"file-view-preview",children:o.jsx("article",{className:"mx-auto w-full max-w-(--content-width) px-4 py-6 sm:px-6",children:o.jsx(fo,{text:l.content})})})]})}function xC({failure:s,onRetry:t,onShowIgnored:i}){const a=s.reason==="binary"||s.reason==="too_large"||s.reason==="blocked_path"||s.reason==="grant"||s.reason==="capability";return o.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center","data-testid":"file-view-error","data-reason":s.reason??"",children:[o.jsx("p",{className:"max-w-sm text-sm text-muted-foreground",role:a?"note":"alert",children:s.message}),s.reason==="too_large"?o.jsx("p",{className:"text-xs text-extra-muted",children:"Files over 1 MB are not read remotely."}):null,s.reason==="ignored"?o.jsx(we,{size:"sm",variant:"secondary",onClick:i,"data-testid":"file-view-show-ignored",children:"Show anyway"}):a?null:o.jsx(we,{size:"sm",variant:"outline",onClick:t,"data-testid":"file-view-retry",children:"Retry"})]})}const Mh="outline-none focus-visible:ring-2 focus-visible:ring-ring",df=I("flex size-8 shrink-0 items-center justify-center rounded-lg text-extra-muted hover:bg-secondary hover:text-foreground [&_svg]:size-[18px]",Mh);function yC({navOpen:s,onToggleNav:t,explorerOpen:i,onToggleExplorer:a,onRename:l,onArchive:u}){const{tree:d,sessions:h,workspace:m,connection:p,principal:x}=Ee(),y=d?.rootId,w=y?d.projection.sessions[y]:void 0,k=y?h.list.find(O=>O.id===y):void 0,j=y?Wn({id:y,title:w?.title??k?.title}):m?Dt(m):"ALP",S=!!y&&y in d.projection.running,A=!!y&&!!d.projection.closed[y],R=Te(x??void 0,"session.write"),q=k??(y?{id:y,title:w?.title}:void 0);return o.jsxs("header",{className:"flex h-14 shrink-0 items-center justify-between gap-2 border-b border-border bg-background px-2 md:h-9 md:px-3",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 md:gap-2",children:[o.jsx("button",{type:"button","aria-label":s?"Close sessions":"Open sessions","aria-expanded":s,title:"Toggle sidebar",onClick:t,className:I(df,"md:-ml-1.5"),children:o.jsx($a,{"aria-hidden":!0,strokeWidth:1.5})}),o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col md:flex-none md:flex-row md:items-center md:gap-2",children:[o.jsx("h1",{className:"min-w-0 truncate text-sm font-normal text-foreground md:font-light",title:j,"data-testid":"workspace-header-title",children:j}),y&&m?o.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground md:text-sm",title:m,children:Dt(m)}):null]}),y&&q?o.jsx(Kt,{label:"Session actions",align:"start",trigger:o.jsx(sh,{"aria-hidden":!0,className:"size-[18px]"}),triggerClassName:df,items:[{label:"Rename",icon:o.jsx(Ui,{"aria-hidden":!0}),onSelect:()=>l(q),disabled:!R},{label:"Copy session ID",icon:o.jsx(ws,{"aria-hidden":!0}),onSelect:()=>{navigator.clipboard?.writeText(y)}},{label:"Archive",icon:o.jsx(ac,{"aria-hidden":!0}),onSelect:()=>u(q),disabled:!R,destructive:!0}]}):null,o.jsx("span",{className:"sr-only","aria-live":"polite",children:p.phase!=="open"?"Reconnecting":y?S?"Agent is working":A?"Session closed":"Agent is idle":""})]}),o.jsx("div",{className:"flex shrink-0 items-center gap-1 md:gap-2",children:o.jsx("button",{type:"button","aria-label":"Agents and tasks","aria-expanded":i,title:"Toggle explorer",onClick:a,className:I(df,"md:-mr-1.5"),"data-testid":"workspace-explorer-toggle",children:o.jsx(lh,{"aria-hidden":!0,strokeWidth:1.5})})})]})}function bC(s){const{tree:t,tasks:i,sessions:a}=Ee();if(s.kind==="agent"){const u=t?.projection,d=u?.sessions[s.id],h=s.id===t?.rootId,m=!!u&&Object.values(u.questions).some(k=>k.sessionId===s.id),p=!!u&&s.id in u.running,x=h?a.list.find(k=>k.id===s.id):void 0,y=d?.agent??(h?"main":"agent"),w=h?Wn({id:s.id,title:d?.title??x?.title}):d?.title??y;return{label:w,icon:m?o.jsxs("span",{className:"relative flex size-3.5","data-status":"needs_input",children:[o.jsx(Oa,{"aria-hidden":!0,className:"size-3.5"}),o.jsx(si,{"aria-hidden":!0,className:"absolute -bottom-0.5 -right-0.5 size-2 fill-dot-warning text-background"})]}):p?o.jsx(p1,{}):o.jsx(Oa,{"aria-hidden":!0,className:"size-3.5"}),title:h?`${w} · ${y}`:`${y} · assignment from main`}}if(s.kind==="draft")return{label:"New session",icon:o.jsx(fc,{"aria-hidden":!0,className:"size-3.5"}),title:"New session"};if(s.kind==="launcher")return{label:"New tab",icon:o.jsx(ks,{"aria-hidden":!0,className:"size-3.5"}),title:"New tab"};if(s.kind==="file")return{label:Dt(s.id),icon:o.jsx(ih,{"aria-hidden":!0,className:"size-3.5"}),title:s.id};if(s.kind==="panel"){const u=ni[s.id];return{label:u.label,icon:o.jsx(u.icon,{"aria-hidden":!0,className:"size-3.5"}),title:u.label}}const l=i.rows.find(u=>u.id===s.id);return{label:l?.title??s.id,icon:l?.approvals?.length?o.jsx(f0,{"aria-hidden":!0,className:"size-3.5 text-dot-warning"}):l?.status==="closed"?o.jsx(n0,{"aria-hidden":!0,className:"size-3.5 text-highlight"}):o.jsx(Bi,{"aria-hidden":!0,className:"size-3.5"}),title:`Task ${s.id}`}}function vC({tab:s,active:t,onSelect:i,onClose:a,onMenu:l,dragging:u,wrapper:d}){const h=bC(s);return o.jsx(W1,{label:h.label,icon:h.icon,title:h.title,active:t,onSelect:i,onClose:a,onMenu:l,dragging:u,wrapper:d,testId:"workspace-tab","data-tab":qe(s)})}function wC(s,t,i=!1){const{tabs:a,byPane:l,close:u,closeOthers:d}=kt(),{selected:h,sessions:m,tree:p,principal:x}=Ee(),y=Oe(),w=Te(x??void 0,"session.write"),k=i?a:l[s]??[],j=i?a:void 0;return S=>{const A=`workspace-tab-context-${qe(S)}`,R=_=>jh(k,S,_,h).length===0,q=[],O=_=>{navigator.clipboard?.writeText(_).catch(()=>{})},L=S.kind==="agent"?y.agentControls(S.id):void 0;if(S.kind==="agent"&&L?.resume.shown&&q.push({id:"copy-resume-command",label:"Copy resume command",icon:o.jsx(ws,{"aria-hidden":!0}),disabled:!L.resume.enabled,title:L.resume.reason,testId:`${A}-copy-resume-command`,onSelect:()=>{y.copyResumeCommand(S.id,_=>navigator.clipboard?navigator.clipboard.writeText(_):Promise.reject(new Error("The browser gives no clipboard here.")))}}),S.kind==="agent"){if(q.push({id:"copy-agent-id",label:"Copy agent id",icon:o.jsx(ws,{"aria-hidden":!0}),hint:S.id.slice(0,7),testId:`${A}-copy-agent-id`,onSelect:()=>O(S.id)}),S.id===h){const Q=m.list.find(C=>C.id===S.id)??{id:S.id,title:p?.projection.sessions[S.id]?.title};q.push({id:"rename",label:"Rename",icon:o.jsx(Ui,{"aria-hidden":!0}),disabled:!w,testId:`${A}-rename`,onSelect:()=>t(Q)})}}else S.kind==="file"?q.push({id:"copy-path",label:"Copy path",icon:o.jsx(ws,{"aria-hidden":!0}),testId:`${A}-copy-path`,onSelect:()=>O(S.id)}):S.kind==="task"&&q.push({id:"copy-task-id",label:"Copy task id",icon:o.jsx(ws,{"aria-hidden":!0}),hint:S.id,testId:`${A}-copy-task-id`,onSelect:()=>O(S.id)});const B=[{id:"close-left",label:"Close to the left",icon:o.jsx(Jb,{"aria-hidden":!0}),disabled:R("left"),testId:`${A}-close-left`,onSelect:()=>d(S,"left",j)},{id:"close-right",label:"Close to the right",icon:o.jsx(e0,{"aria-hidden":!0}),disabled:R("right"),testId:`${A}-close-right`,onSelect:()=>d(S,"right",j)},{id:"close-others",label:"Close other tabs",icon:o.jsx(a0,{"aria-hidden":!0}),disabled:R("others"),testId:`${A}-close-others`,onSelect:()=>d(S,"others",j)},...L?.reload.shown?[{id:"reload-agent",label:"Reload agent",icon:o.jsx(nN,{"aria-hidden":!0}),disabled:!L.reload.enabled,title:L.reload.reason??W2,testId:`${A}-reload-agent`,onSelect:()=>{y.reloadAgent({sessionId:S.id,requestId:Qf()}).catch(()=>{})}}]:[],...L?.compact.shown?[{id:"compact-agent",label:"Compact context",icon:o.jsx(rN,{"aria-hidden":!0}),disabled:!L.compact.enabled,title:L.compact.reason??J2,testId:`${A}-compact-agent`,onSelect:()=>{y.compactAgent({sessionId:S.id}).catch(()=>{})}}]:[],{id:"close",label:"Close",icon:o.jsx(en,{"aria-hidden":!0}),testId:`${A}-close`,onSelect:()=>u(S)}];return q.some(_=>_.id==="rename")&&(B[0]={...B[0],group:!0}),[...q,...B]}}const kC=5,Sc=b.createContext({target:null,setTarget:()=>{},splits:!1}),mb=(s,t,i)=>Array.from(s?.querySelectorAll("[data-drag-tab]")??[]).filter(a=>a.dataset.dragTab!==t).filter(a=>{const l=a.getBoundingClientRect();return l.left+l.width/2<i}).length;function jC(s,t=!1){const{tabs:i,byPane:a,move:l,moveTabToPane:u,splitWith:d}=kt(),h=b.useContext(Sc),m=t?i:a[s]??[],p=b.useRef(null),[x,y]=b.useState(null),w=b.useRef(!1),k=A=>R=>{if(R.button!==0||R.target.closest('[aria-label^="Close "]'))return;const q=qe(A),O=R.clientX,L=R.clientY,B=m.map(qe);let _=!1,Q=B.indexOf(q),C=null;w.current=!1;const Y=(re,de)=>re===de||!!re&&!!de&&re.pane===de.pane&&re.kind===de.kind&&(re.kind==="row"?re.index===de.index:re.position===de.position),H=re=>{if(!_&&Math.hypot(re.clientX-O,re.clientY-L)<kC)return;_=!0;const de=C;C=null;const U=h.splits?document.elementFromPoint(re.clientX,re.clientY):null,Z=U?.closest("[data-pane-row]"),oe=U?.closest("[data-pane-body]");if(Z&&Z.dataset.paneRow!==s)C={pane:Z.dataset.paneRow,kind:"row",index:mb(Z,q,re.clientX)};else if(oe&&!Z){const ge=oe.getBoundingClientRect(),T=MT({width:ge.width,height:ge.height,x:re.clientX-ge.left,y:re.clientY-ge.top}),z=oe.dataset.paneBody;(z!==s||T!=="center"&&B.length>1)&&(C={pane:z,kind:"zone",position:T})}if(Y(de,C)||h.setTarget(C),C){y(null);return}if(oe&&!Z){Q=-1,y(ge=>ge&&null);return}Q=mb(p.current,q,re.clientX),y({key:q,order:qf(B,q,Q)})},fe=re=>()=>{if(window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",ee),window.removeEventListener("pointercancel",xe),_){w.current=!0,setTimeout(()=>{w.current=!1},0);const de=C;re&&de?.kind==="row"?u(A,de.pane,de.index):re&&de?.kind==="zone"?de.position==="center"?u(A,de.pane):d(A,de.pane,de.position):re&&Q>=0&&l(A,Q,t)}h.setTarget(null),y(null)},ee=fe(!0),xe=fe(!1);window.addEventListener("pointermove",H),window.addEventListener("pointerup",ee),window.addEventListener("pointercancel",xe)},j=A=>{w.current&&(w.current=!1,A.stopPropagation(),A.preventDefault())},S=x?q1(m,qe,x.order):m;return{row:p,shown:S,dragging:x?.key??null,wrapper:A=>({onPointerDown:k(A),onClickCapture:j,"data-drag-tab":qe(A)})}}const bv=["terminal","diff"],vv=["tasks","agents"],pb=I("flex size-7 shrink-0 items-center justify-center rounded-md text-extra-muted hover:bg-card hover:text-foreground [&_svg]:size-3.5",Mh);function SC({paneId:s=oo,whole:t=!1,onNewSession:i,onRename:a,menuRequest:l,onMenuRequestHandled:u}){const{activeOf:d,activate:h,close:m,openPanel:p,focusedPane:x,panes:y,splitEmpty:w,canSplitEmpty:k,maximized:j,toggleMaximized:S}=kt(),A=jC(s,t),R=b.useContext(Sc),q=wC(s,a,t),[O,L]=b.useState(null),B=b.useCallback(()=>L(null),[]),_=b.useCallback(()=>A.row.current?.querySelector('[role="tab"][aria-selected="true"]'),[A.row]),{workspace:Q,principal:C,connection:Y}=Ee(),H=Te(C??void 0,"session.write");if(!Q)return null;const fe=d(s),ee=s===x,xe=Vt(y.root).length>1,re=ho(),de=(Z,oe=!1)=>{const ge=ni[Z];return{label:ge.label,icon:o.jsx(ge.icon,{"aria-hidden":!0}),onSelect:()=>p(Z),group:oe}},U=R.target?.kind==="row"&&R.target.pane===s;return o.jsxs("div",{className:I("flex h-9 shrink-0 items-center border-b border-border bg-background",U&&"bg-secondary/60"),"data-pane-row":s,children:[o.jsxs("div",{ref:A.row,role:"tablist","aria-label":"Open tabs",className:"flex min-w-0 flex-1 items-center overflow-x-auto px-1 [scrollbar-width:none]",children:[A.shown.map(Z=>o.jsx(vC,{tab:Z,active:!!fe&&qe(fe)===qe(Z),onSelect:()=>h(Z),onClose:()=>m(Z),onMenu:oe=>L({tab:Z,at:oe}),dragging:A.dragging===qe(Z),wrapper:A.wrapper(Z)},qe(Z))),o.jsx(Kt,{label:"New tab",align:"start",openRequest:ee?l:void 0,onOpenRequestHandled:u,testId:"workspace-new-tab",trigger:o.jsx(ks,{"aria-hidden":!0,className:"size-4"}),triggerClassName:I("mx-1 flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-card hover:text-foreground",Mh),items:[{label:"Agent",icon:o.jsx(fc,{"aria-hidden":!0}),onSelect:i,disabled:!H||Y.phase!=="open"},...bv.map(Z=>de(Z)),...vv.map((Z,oe)=>de(Z,oe===0))]})]}),R.splits?o.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 pr-1",children:[xe?o.jsx("button",{type:"button",className:pb,"aria-pressed":j===s,onClick:()=>S(s),"aria-label":j===s?"Restore pane":"Maximize pane",title:j===s?"Restore pane":"Maximize pane","data-testid":j===s?"workspace-restore-pane":"workspace-maximize-pane",children:j===s?o.jsx(PS,{"aria-hidden":!0}):o.jsx(KS,{"aria-hidden":!0})}):null,o.jsx(Kt,{label:"More actions",testId:"workspace-split-pane-menu",trigger:o.jsx(sh,{"aria-hidden":!0,className:"size-3.5"}),triggerClassName:pb,items:[{id:"split-right",label:"Split pane right",icon:o.jsx(i0,{"aria-hidden":!0}),hint:Pl("pane.split.right",re)||void 0,disabled:!k,testId:"workspace-split-pane-right",onSelect:()=>w("right")},{id:"split-down",label:"Split pane down",icon:o.jsx(d0,{"aria-hidden":!0}),hint:Pl("pane.split.down",re)||void 0,disabled:!k,testId:"workspace-split-pane-down",onSelect:()=>w("bottom")}]})]}):null,o.jsx(d1,{label:"Tab actions",at:O?.at??null,items:O?q(O.tab):[],onClose:B,fallbackFocus:_,testId:O?`workspace-tab-context-${qe(O.tab)}`:void 0})]})}function NC({paneId:s=oo,onNewSession:t}){const{activeOf:i}=kt(),{tree:a,workspace:l}=Ee(),u=i(s);return u?.kind==="draft"?o.jsx(cC,{}):u?.kind==="launcher"?o.jsx(TC,{launcher:u.id},u.id):u?.kind==="task"?o.jsx(yv,{id:u.id}):u?.kind==="file"?o.jsx(gC,{path:u.id},`${l??""}
59
+ ${u.id}`):u?.kind==="panel"?o.jsx("div",{className:I("min-h-0 flex-1",u.id==="terminal"?"overflow-hidden":"overflow-y-auto"),children:o.jsx(Q1,{kind:u.id})}):u?.kind==="agent"&&a?o.jsx(rC,{sessionId:u.id},u.id):o.jsx(sC,{onNewSession:t})}function TC({launcher:s}){const{launch:t,openPanel:i,openDraft:a}=kt(),{principal:l,connection:u}=Ee(),d=Te(l??void 0,"session.write"),h=b.useRef(null),m=b.useContext(Ah).focused;b.useEffect(()=>{m&&h.current?.focus({preventScroll:!0})},[]);const p=k=>{const j=k.key==="ArrowDown"?1:k.key==="ArrowUp"?-1:0;if(!j)return;k.preventDefault();const S=Array.from(k.currentTarget.querySelectorAll("button:not(:disabled)")),A=S.indexOf(document.activeElement);S[(A+j+S.length)%S.length]?.focus()},x="flex min-h-11 items-center gap-2 rounded-lg border border-transparent bg-card px-3 text-left text-sm text-foreground outline-none hover:bg-secondary focus-visible:border-ring disabled:pointer-events-none disabled:opacity-50",y=[[{id:"agent",label:"Agent",icon:o.jsx(fc,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),disabled:!d||u.phase!=="open",run:a},...bv.map(k=>{const j=ni[k];return{id:k,label:j.label,icon:o.jsx(j.icon,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),run:()=>i(k)}})],vv.map(k=>{const j=ni[k];return{id:k,label:j.label,icon:o.jsx(j.icon,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),run:()=>i(k)}})];let w=-1;return o.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-y-auto p-6","data-testid":"workspace-pane-new-tab-panel",children:o.jsx("div",{className:"flex w-full max-w-[380px] flex-col gap-12",onKeyDown:p,children:y.map((k,j)=>o.jsx("div",{className:"flex flex-col gap-1",children:k.map(S=>(w+=1,o.jsxs("button",{ref:w===0?h:void 0,type:"button",disabled:S.disabled,className:x,"data-testid":`workspace-pane-new-tab-${S.id}`,onClick:()=>t(s,S.run),children:[S.icon,o.jsx("span",{className:"min-w-0 flex-1 truncate",children:S.label})]},S.id)))},j))})})}function AC({position:s}){const t={center:"inset-2",left:"inset-y-0 left-0 w-1/2",right:"inset-y-0 right-0 w-1/2",top:"inset-x-0 top-0 h-1/2",bottom:"inset-x-0 bottom-0 h-1/2"}[s];return o.jsx("div",{"aria-hidden":!0,"data-testid":"workspace-drop-zone","data-position":s,className:I("pointer-events-none absolute z-40 rounded-md border-2 border-highlight bg-highlight/20",t)})}const CC=[{position:"left",label:"Split pane left",icon:o.jsx($a,{"aria-hidden":!0})},{position:"top",label:"Split pane up",icon:o.jsx(ZS,{"aria-hidden":!0})},{position:"right",label:"Split pane right",icon:o.jsx(lh,{"aria-hidden":!0})},{position:"bottom",label:"Split pane down",icon:o.jsx(WS,{"aria-hidden":!0})}];function EC(s){const t=s.target;return s.shiftKey||window.getSelection()?.toString()?!0:!!t.closest?.('input, textarea, select, [contenteditable=""], [contenteditable="true"], a[href], .xterm')}function wv({id:s,props:t,whole:i=!1}){const{focusedPane:a,focusPane:l,panes:u,splitEmpty:d,canSplitEmpty:h}=kt(),[m,p]=b.useState(null),x=b.useContext(Sc),y=s===a,w=Vt(u.root).length>1,k=b.useMemo(()=>({id:s,focused:y}),[s,y]),j=x.target?.kind==="zone"&&x.target.pane===s?x.target.position:null,S=A=>{!y&&!A.target.closest?.('[role="menu"]')&&l(s)};return o.jsx(Ah.Provider,{value:k,children:o.jsxs("section",{"aria-label":w?`Pane${y?" (focused)":""}`:void 0,"data-testid":`workspace-pane-${s}`,"data-focused":y?"true":"false",onPointerDownCapture:S,onFocusCapture:S,className:I("relative flex min-h-0 min-w-0 flex-1 flex-col bg-background",w&&!y&&"[&_[role=tab][aria-selected=true]]:text-muted-foreground"),children:[o.jsx(SC,{paneId:s,whole:i,...t}),o.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col","data-pane-body":s,onContextMenu:x.splits&&h?A=>{EC(A)||(A.preventDefault(),p({x:A.clientX,y:A.clientY}))}:void 0,children:[o.jsx(NC,{paneId:s,onNewSession:t.onNewSession}),j?o.jsx(AC,{position:j}):null]}),o.jsx(d1,{label:"Pane actions",at:m,onClose:()=>p(null),testId:m?`workspace-pane-context-${s}`:void 0,items:m?CC.map(({position:A,label:R,icon:q})=>({id:`split-${A}`,label:R,icon:q,testId:`workspace-pane-split-${A}`,disabled:!Rf(u,{target:s,position:A}),onSelect:()=>d(A,s)})):[]})]})})}function MC({group:s,index:t,container:i,onPreview:a}){const{resize:l}=kt(),[u,d]=b.useState(!1),h=s.direction==="horizontal",m=(s.sizes[t]??0)+(s.sizes[t+1]??0),p=s.sizes.slice(0,t).reduce((j,S)=>j+S,0),x=j=>{const S=Gr,A=Math.min(m-S,Math.max(S,j)),R=s.sizes.slice();return R[t]=A,R[t+1]=m-A,R},y=j=>l(s.id,x(j)),w=j=>{if(j.button!==0||!i.current)return;j.preventDefault();const S=j.currentTarget,A=i.current.getBoundingClientRect();S.setPointerCapture(j.pointerId),d(!0);let R=null;const q=L=>{const B=h?(L.clientX-A.left)/A.width:(L.clientY-A.top)/A.height;R=x(B-p),a(R)},O=()=>{S.removeEventListener("pointermove",q),S.removeEventListener("pointerup",O),S.removeEventListener("pointercancel",O),S.removeEventListener("lostpointercapture",O),d(!1),R&&l(s.id,R),a(null)};S.addEventListener("pointermove",q),S.addEventListener("pointerup",O),S.addEventListener("pointercancel",O),S.addEventListener("lostpointercapture",O)},k=j=>{const S=j.shiftKey?.1:.02,A=h?"ArrowLeft":"ArrowUp",R=h?"ArrowRight":"ArrowDown",q=s.sizes[t]??0;if(j.key===A)y(q-S);else if(j.key===R)y(q+S);else if(j.key==="Home")y(0);else if(j.key==="End")y(m);else return;j.preventDefault()};return o.jsx("div",{role:"separator","aria-orientation":h?"vertical":"horizontal","aria-label":"Resize panes",tabIndex:0,"aria-valuenow":Math.round((s.sizes[t]??0)*100),"aria-valuemin":0,"aria-valuemax":100,"data-testid":"workspace-split-resize-handle",onPointerDown:w,onKeyDown:k,className:I("group relative z-10 shrink-0 touch-none bg-border outline-none",h?"w-px cursor-col-resize":"h-px cursor-row-resize"),children:o.jsx("span",{"aria-hidden":!0,className:I("absolute bg-ring opacity-0 transition-opacity delay-100 group-hover:opacity-100 group-focus-visible:opacity-100",h?"inset-y-0 -left-[4px] w-[9px]":"inset-x-0 -top-[4px] h-[9px]",u&&"opacity-100")})})}function kv({node:s,props:t}){const i=b.useRef(null),[a,l]=b.useState(null);if(s.kind==="pane")return o.jsx(wv,{id:s.id,props:t});const u={...s,sizes:a&&a.length===s.sizes.length?a:s.sizes};return o.jsx("div",{ref:i,className:I("flex min-h-0 min-w-0 flex-1",s.direction==="horizontal"?"flex-row":"flex-col"),"data-testid":"workspace-split-group","data-direction":s.direction,children:s.children.map((d,h)=>o.jsxs(b.Fragment,{children:[o.jsx("div",{className:"flex min-h-0 min-w-0",style:{flexGrow:u.sizes[h]??0,flexShrink:1,flexBasis:0},"data-testid":"split-group-child",children:o.jsx(kv,{node:d,props:t})}),h<s.children.length-1?o.jsx(MC,{group:u,index:h,container:i,onPreview:l}):null]},d.id))})}function zC(s){const{panes:t,focusedPane:i,maximized:a}=kt(),[l,u]=b.useState(null),d=b.useMemo(()=>({target:l,setTarget:u,splits:s.splits}),[l,s.splits]),h=Vt(t.root),m=!s.splits||h.length<2?i:a&&h.includes(a)?a:null;return o.jsx(Sc.Provider,{value:d,children:o.jsx("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"workspace-panes","data-panes":h.length,children:m?o.jsx(wv,{id:m,props:s,whole:!s.splits&&h.length>1}):o.jsx(kv,{node:t.root,props:s})})})}const RC="outline-none focus-visible:ring-2 focus-visible:ring-ring",ff=I("flex size-8 shrink-0 items-center justify-center rounded-lg text-extra-muted hover:bg-secondary hover:text-foreground [&_svg]:size-[18px]",RC);function _C({navOpen:s,onToggleNav:t,onClose:i}){const{workspace:a}=Ee(),[l,u]=b.useState(null),d=b.useRef(null),h=b.useRef(null);b.useEffect(()=>(d.current?.focus(),()=>{setTimeout(()=>document.querySelector('[data-focused="true"] [role="tab"][aria-selected="true"]')?.focus(),0)}),[]);const m=b.useRef({task:l,onClose:i});return m.current={task:l,onClose:i},b.useEffect(()=>{const p=x=>{if(x.key!=="Escape"||x.defaultPrevented||x.isComposing)return;const y=x.target;h1(y)&&y.value||document.querySelector('dialog[open], [role="menu"], [data-modal-overlay]')||(x.preventDefault(),m.current.task&&!LC(h.current)?u(null):m.current.onClose())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[]),o.jsxs("section",{"aria-label":"ALP tasks","data-testid":"alp-tasks-screen",ref:h,className:"flex min-h-0 flex-1 flex-col bg-background text-foreground",children:[o.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b border-border px-2 md:h-9 md:px-3",children:[o.jsx("button",{type:"button","aria-label":s?"Close sessions":"Open sessions","aria-expanded":s,title:"Toggle sidebar",onClick:t,className:I(ff,"md:-ml-1.5"),children:o.jsx($a,{"aria-hidden":!0,strokeWidth:1.5})}),o.jsx(Bi,{"aria-hidden":!0,className:"size-4 shrink-0 text-muted-foreground"}),o.jsx("h1",{className:"min-w-0 truncate text-sm",children:"ALP tasks"}),a?o.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground md:text-sm",title:a,children:Dt(a)}):null,o.jsx("span",{className:"flex-1"}),o.jsx("button",{ref:d,type:"button",className:ff,"aria-label":"Close tasks",title:"Close",onClick:i,"data-testid":"alp-tasks-screen-close",children:o.jsx(en,{"aria-hidden":!0,strokeWidth:1.5})})]}),o.jsxs("div",{className:"@container flex min-h-0 flex-1",children:[o.jsx("div",{className:I("min-h-0 min-w-0 overflow-y-auto",l?"hidden @[820px]:block @[820px]:w-2/5 @[820px]:shrink-0 @[820px]:border-r @[820px]:border-border":"flex-1"),children:o.jsx(U1,{onOpen:u,current:l})}),l?o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[o.jsx("div",{className:"flex h-10 shrink-0 items-center border-b border-border px-2 @[820px]:hidden",children:o.jsxs("button",{type:"button",className:I(ff,"w-auto gap-1.5 px-2 text-sm text-muted-foreground"),onClick:()=>u(null),"aria-label":"Back to tasks",children:[o.jsx(th,{"aria-hidden":!0})," Tasks"]})}),o.jsx(yv,{id:l,onOpenTask:u},l)]}):null]})]})}const LC=s=>(s?.getBoundingClientRect().width??0)>=820,Yf={sidebar:M1,dock:z1},OC=400,jv=(s,t=0)=>{const{min:i,max:a}=Yf[s];return{min:i,max:Math.max(i,Math.min(a,(typeof window>"u"?1/0:window.innerWidth)-t-OC))}};function gb(s,t=0){const i=s==="sidebar"?"sidebarWidth":"dockWidth",[a,l]=b.useState(()=>kh(ec())[i]??Yf[s].initial),u=b.useCallback(h=>{D1(ec(),m=>({...m,[i]:h}))},[i]),[,d]=b.useReducer(h=>h+1,0);return b.useEffect(()=>(window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)),[]),{width:Jl(a,jv(s,t))??Yf[s].initial,setWidth:l,save:u,reserved:t}}function xb({which:s,side:t,width:i,reserved:a=0,onWidth:l,onCommit:u,testId:d}){const[h,m]=b.useState(!1),{min:p,max:x}=jv(s,a),y=b.useRef(null);b.useEffect(()=>()=>y.current?.(),[]);const w=S=>Jl(S,{min:p,max:x})??i,k=S=>{if(S.button!==0)return;S.preventDefault();const A=S.clientX,R=i;let q=i;const O=S.currentTarget;O.setPointerCapture(S.pointerId),m(!0);const L=document.body.style.cursor;document.body.style.cursor="col-resize";const B=Q=>{const C=Q.clientX-A;q=w(R+(t==="right"?C:-C)),l(q)},_=()=>{y.current=null,O.removeEventListener("pointermove",B),O.removeEventListener("pointerup",_),O.removeEventListener("pointercancel",_),O.removeEventListener("lostpointercapture",_),document.body.style.cursor=L,m(!1),u(q)};y.current=_,O.addEventListener("pointermove",B),O.addEventListener("pointerup",_),O.addEventListener("pointercancel",_),O.addEventListener("lostpointercapture",_)},j=S=>{const A=S.shiftKey?48:16,R=t==="right"?1:-1;let q=null;if(S.key==="ArrowRight"?q=i+A*R:S.key==="ArrowLeft"?q=i-A*R:S.key==="Home"?q=p:S.key==="End"&&(q=x),q===null)return;S.preventDefault();const O=w(q);l(O),u(O)};return o.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":s==="sidebar"?"Resize sidebar":"Resize explorer",tabIndex:0,"aria-valuenow":i,"aria-valuemin":p,"aria-valuemax":x,"data-testid":d,onPointerDown:k,onKeyDown:j,className:I("group absolute inset-y-0 z-10 w-2.5 cursor-col-resize touch-none outline-none",t==="right"?"-right-[5px]":"-left-[5px]"),children:o.jsx("span",{"aria-hidden":!0,className:I("absolute inset-y-0 left-1/2 w-[3px] -translate-x-1/2 bg-ring opacity-0 transition-opacity delay-100 group-hover:opacity-100 group-focus-visible:opacity-100",h&&"opacity-100")})})}function yb(s){const t=b.useCallback(i=>{const a=window.matchMedia(s);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[s]);return b.useSyncExternalStore(t,()=>window.matchMedia(s).matches,()=>!1)}function DC(){const s=Oe(),{openDraft:t}=kt(),{notice:i}=Ee();return b.useEffect(()=>{if(!i)return;const a=setTimeout(()=>s.dismissNotice(),8e3);return()=>clearTimeout(a)},[i,s]),i?o.jsxs("div",{role:i.level==="error"?"alert":"status",className:I("mx-auto my-2 flex w-[min(92%,28rem)] shrink-0 items-start gap-2 rounded-lg border px-3 py-2.5 text-sm shadow-xl shadow-[var(--shadow)]",i.level==="error"?"border-destructive/40 bg-[var(--notice-error)] text-destructive":"border-border bg-popover text-foreground"),children:[i.level==="error"?o.jsx(si,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}):o.jsx(rh,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0 text-info"}),o.jsx("span",{className:"min-w-0 flex-1",children:i.text}),i.action==="new-session"?o.jsx(we,{size:"sm",variant:"secondary",className:"h-7 shrink-0 text-xs",onClick:()=>{s.dismissNotice(),t()},children:"New session"}):null,o.jsx(we,{size:"icon-sm",variant:"ghost","aria-label":"Dismiss",onClick:()=>s.dismissNotice(),children:o.jsx(en,{"aria-hidden":!0})})]}):null}function hf(){const s=Oe(),{connection:t}=Ee();return t.phase!=="reconnecting"?null:o.jsxs("div",{role:"status",className:"flex items-center gap-2 border-b border-warning/30 bg-warning/10 px-4 py-2 text-xs text-warning",children:[o.jsx(pN,{"aria-hidden":!0,className:"size-4 shrink-0"}),o.jsxs("span",{className:"min-w-0 flex-1",children:["Connection to the host lost. Reconnecting",t.attempt>1?` (attempt ${t.attempt})`:"","… Work on the host keeps running."]}),o.jsx(we,{size:"sm",variant:"ghost",className:"h-7 text-xs text-warning",onClick:()=>s.disconnect(),children:"Disconnect"})]})}function qC({settings:s,history:t,splits:i,onAction:a}){const l=Oe(),{tabs:u,row:d,active:h,activate:m,close:p,openPanel:x,panes:y,focusedPane:w,splitEmpty:k,canSplitEmpty:j,closePane:S,focusAdjacent:A,moveTabAdjacent:R}=kt(),q=i?d:u,{workspace:O}=Ee(),L=Vt(y.root).length>1,{sessions:B,selected:_}=Ee();return D5((Q,C)=>{if(s&&Q.action!=="settings.toggle")return!1;const Y=(H,fe,ee)=>H.length?fe<0?ee>0?0:H.length-1:(fe+ee+H.length)%H.length:-1;switch(Q.action){case"session.index":{const H=B.list[(C??1)-1];return H?(l.selectSession(H.id),a("session.opened",Q)):!1}case"session.relative":{const H=Y(B.list,B.list.findIndex(fe=>fe.id===_),Q.delta??1);return H<0?!1:(l.selectSession(B.list[H].id),a("session.opened",Q))}case"tab.index":{const H=q[(C??1)-1];return H?(m(H),a("tab.shown",Q)):!1}case"tab.relative":{const H=Y(q,h?q.findIndex(fe=>qe(fe)===qe(h)):-1,Q.delta??1);return H<0?!1:(m(q[H]),a("tab.shown",Q))}case"tab.close":return!h||t?!1:(p(h),!0);case"tab.changes":case"tab.files":case"tab.terminal":{const H=Q.action.slice(4);return x(H),a("tab.shown",Q)}case"pane.split.right":case"pane.split.down":if(!i||t||!O||!j)return!1;k(Q.action==="pane.split.right"?"right":"bottom");return;case"pane.focus.left":case"pane.focus.right":case"pane.focus.up":case"pane.focus.down":if(!i||t||!L)return!1;A(Q.action.slice(11));return;case"pane.move.left":case"pane.move.right":case"pane.move.up":case"pane.move.down":if(!i||t||!L)return!1;R(Q.action.slice(10));return;case"pane.close":if(!i||t||!L)return!1;S(w);return;default:return a(Q.action,Q,C)}},{allowInModal:["settings.toggle"]}),null}function Jt(s,t,i){const a=xc.find(l=>l.action===s&&l.label&&(!l.mac||t)&&(i===void 0||l.delta===i));return a?xh(gh(a,t),t):void 0}function BC({open:s,scope:t,onClose:i,history:a,splits:l,onAction:u,onOpenSession:d}){const h=Ee(),m=Oe(),{workspace:p,principal:x,connection:y,sessions:w,tree:k,selected:j}=h,{tabs:S,row:A,active:R,activate:q,close:O,closeOthers:L,openPanel:B,openFile:_,panes:Q,focusedPane:C,splitEmpty:Y,canSplitEmpty:H,closePane:fe,focusAdjacent:ee,moveTabAdjacent:xe}=kt(),re=l?A:S,de=(be,ye)=>L(be,ye,l?void 0:S),U=Vt(Q.root).length>1,Z=be=>!R||jh(re,R,be,j).length===0,oe=b.useMemo(()=>ho(),[]),ge=Te(x??void 0,"session.write"),T=y.phase==="open",z=k?.rootId,F=!a&&!!p,J=R?re.findIndex(be=>qe(be)===qe(R)):-1,le=be=>{if(!re.length)return;const ye=J<0?be>0?0:re.length-1:(J+be+re.length)%re.length;q(re[ye]),u("tab.shown")},ne=(be,ye,Ae,Ne)=>({id:be,label:Ae,group:"workspace",icon:ni[ye].icon,shortcut:Ne,disabled:!p,keywords:["tab","panel"],run:()=>{B(ye),u("tab.shown")}}),ce=[{id:"new-session",label:"New session",group:"workspace",always:!0,icon:fc,shortcut:Jt("session.new",oe),keywords:["new agent","start"],disabled:!p||!ge||!T,run:()=>u("session.new")},ne("new-terminal","terminal","New terminal",Jt("tab.terminal",oe)),ne("open-changes","changes","Open Changes",Jt("tab.changes",oe)),ne("open-files","files","Open Files",Jt("tab.files",oe)),ne("open-diff","diff","Open Diff"),ne("open-agents","agents","Open Agents"),{id:"tab-previous",label:"Previous tab",group:"workspace",icon:nh,shortcut:Jt("tab.relative",oe,-1),disabled:!F||re.length<2,run:()=>le(-1)},{id:"tab-next",label:"Next tab",group:"workspace",icon:Jn,shortcut:Jt("tab.relative",oe,1),disabled:!F||re.length<2,run:()=>le(1)},{id:"tab-close",label:"Close current tab",group:"workspace",icon:en,shortcut:Jt("tab.close",oe),disabled:!F||!R,run:()=>{R&&O(R)}},{id:"tab-close-left",label:"Close to the left",group:"workspace",icon:Jb,keywords:["tabs"],disabled:!F||Z("left"),run:()=>{R&&de(R,"left")}},{id:"tab-close-right",label:"Close to the right",group:"workspace",icon:e0,keywords:["tabs"],disabled:!F||Z("right"),run:()=>{R&&de(R,"right")}},{id:"tab-close-others",label:"Close other tabs",group:"workspace",icon:a0,disabled:!F||Z("others"),run:()=>{R&&de(R,"others")}},{id:"session-rename",label:"Rename session",group:"workspace",icon:Ui,disabled:!z||!ge,run:()=>u("session.rename")},{id:"session-copy-id",label:"Copy session ID",group:"workspace",icon:ws,keywords:["agent id"],disabled:!z,run:()=>{z&&navigator.clipboard?.writeText(z).catch(()=>{})}},{id:"session-archive",label:"Archive session",group:"workspace",icon:ac,shortcut:Jt("session.archive",oe),disabled:!z||!ge,run:()=>u("session.archive")},...l?ve():[],{id:"toggle-explorer",label:"Toggle explorer",group:"workspace",icon:lh,shortcut:Jt("sidebar.right",oe),disabled:a,run:()=>u("sidebar.right")},{id:"history",label:"History",group:"actions",always:!0,icon:cc,keywords:["archived","sessions"],disabled:!p,run:()=>u("history")},{id:"settings",label:"Settings",group:"actions",always:!0,icon:ch,shortcut:Jt("settings.toggle",oe),keywords:["preferences","theme"],run:()=>u("settings.toggle")},{id:"shortcuts",label:"Keyboard shortcuts",group:"actions",always:!0,icon:IS,shortcut:Jt("shortcuts.toggle",oe),keywords:["keys","help"],run:()=>u("shortcuts.toggle")},{id:"toggle-sidebar",label:"Toggle left sidebar",group:"actions",icon:$a,shortcut:Jt("sidebar.left",oe),run:()=>u("sidebar.left")},{id:"search-sessions",label:"Search sessions in the sidebar",group:"actions",icon:ti,keywords:["filter","find"],disabled:!p,run:()=>u("search")},{id:"alp-open-tasks",label:"Open ALP tasks",group:"alp",always:!0,icon:Bi,keywords:["tasks","todo","alp","panel"],disabled:!p,run:()=>{B("tasks"),u("tab.shown")}},{id:"alp-open-tasks-screen",label:"Open ALP tasks full screen",group:"alp",always:!0,icon:Bi,keywords:["tasks","todo","alp","phone"],disabled:!p,run:()=>u("tasks.screen")}];function ve(){const be=F,ye=(Ne,Ht)=>({id:`pane-focus-${Ne}`,label:Ht,group:"workspace",icon:RS,keywords:["pane","focus",Ne],disabled:!be||!U,run:()=>{ee(Ne)}}),Ae=(Ne,Ht)=>({id:`pane-move-tab-${Ne}`,label:Ht,group:"workspace",icon:wS,keywords:["pane","tab","move",Ne],disabled:!be||!U||!R,run:()=>{xe(Ne)}});return[{id:"pane-split-right",label:"Split pane right",group:"workspace",icon:i0,shortcut:Jt("pane.split.right",oe),keywords:["split","pane","vertical"],disabled:!be||!H,run:()=>Y("right")},{id:"pane-split-down",label:"Split pane down",group:"workspace",icon:d0,shortcut:Jt("pane.split.down",oe),keywords:["split","pane","horizontal"],disabled:!be||!H,run:()=>Y("bottom")},ye("left","Focus pane left"),ye("right","Focus pane right"),ye("up","Focus pane up"),ye("down","Focus pane down"),Ae("left","Move tab left"),Ae("right","Move tab right"),Ae("up","Move tab up"),Ae("down","Move tab down"),{id:"pane-close",label:"Close pane",group:"workspace",icon:en,shortcut:Jt("pane.close",oe),keywords:["pane","close"],disabled:!be||!U,run:()=>fe(C)}]}const Re=w.list.map(be=>({id:be.id,title:Wn(be),subtitle:[p?Dt(p):"",be.status==="closed"?"Closed":Ri(be.updatedAt??be.createdAt)].filter(Boolean).join(" · "),bucket:bh(be,ic(h,be.id),ao(h,be.id)),attention:!!ao(h,be.id),updatedAt:be.updatedAt??be.createdAt})),Me=be=>{be===h.selected?(q({kind:"agent",id:be}),u("session.opened")):d(be)},Qe=b.useMemo(()=>Y5(x?.workspaces??[],p),[x,p]),Ue=b.useMemo(()=>({available:y.capabilities.includes("workspace.files"),source:p,search:be=>m.searchWorkspaceFiles({query:be,limit:Wb})}),[y.capabilities,p,m]),et=be=>{if(m.filesReadable&&m.canReadFiles){_(be),u("tab.shown");return}const ye=m.filesReadable?"this access token cannot read files":"this host does not offer file reading",Ae=navigator.clipboard?.writeText(be);if(!Ae){m.notify("error",`Could not copy ${be}.`);return}Ae.then(()=>m.notify("info",`Copied ${be} (${ye})`),()=>m.notify("error",`Could not copy ${be}.`))},Fe=be=>{m.selectWorkspace(be),u("tab.shown")};return o.jsx(W5,{open:s,scope:t,onClose:i,actions:ce,sessions:Re,workspaces:Qe,files:Ue,onOpenSession:Me,onSelectWorkspace:Fe,onPickFile:et,mac:oe})}function $C({onOpenSession:s}){return H4({onOpenSession:s}),null}function UC({request:s}){const{openDraft:t}=kt();return b.useEffect(()=>{s&&t()},[s,t]),null}function HC(){const s=yb("(min-width: 1024px)"),t=yb("(min-width: 768px)"),[i,a]=b.useState(!1),[l,u]=b.useState(!1),d=T5(),h=gb("sidebar"),[m,p]=b.useState(0),[x,y]=b.useState(!1),[w,k]=b.useState(null),[j,S]=b.useState(null),[A,R]=b.useState(!1),[q,O]=b.useState(!1),[L,B]=b.useState(0),[_,Q]=b.useState(!1),[C,Y]=b.useState(0),[H,fe]=b.useState(!1),ee=()=>{R(!1),fe(!1)},xe=()=>{fe(!1),R(!0)},re=A||H,de=Oe(),{selected:U,workspace:Z,principal:oe,connection:ge,sessions:T,tree:z}=Ee(),F=Te(oe??void 0,"session.write");b.useEffect(()=>{U&&(R(!1),fe(!1))},[U]);const[J,le]=b.useState(!1),[ne,ce]=b.useState(!1),ve=t?!J:i,Re=gb("dock",t&&ve?h.width:0),Me=s?!ne:l;b.useEffect(()=>{if(!i&&!l)return;const Ae=Ne=>{Ne.key==="Escape"&&(a(!1),u(!1))};return window.addEventListener("keydown",Ae),()=>window.removeEventListener("keydown",Ae)},[i,l]);const Qe=()=>p(Ae=>Ae+1),Ue=()=>t?le(Ae=>!Ae):a(Ae=>!Ae),et=()=>s?ce(Ae=>!Ae):u(Ae=>!Ae),Fe=()=>{t?le(!1):a(!0)},be=()=>{const Ae=z?.rootId;return Ae?T.list.find(Ne=>Ne.id===Ae)??{id:Ae,title:z.projection.sessions[Ae]?.title}:null},ye=Ae=>{switch(Ae){case"session.new":case"tab.agent":if(!Z||!F||ge.phase!=="open")return!1;ee(),Qe();return;case"session.archive":{const Ne=be();if(!Ne||!F||de.isArchived(Ne.id))return!1;S(Ne);return}case"session.opened":case"tab.shown":ee();return;case"search":Fe(),B(Ne=>Ne+1);return;case"command-center.toggle":Q(Ne=>Ne?!1:{scope:null});return;case"command-center.files":Q({scope:"files"});return;case"history":if(!Z)return!1;xe();return;case"session.rename":{const Ne=be();if(!Ne||!F)return!1;k(Ne);return}case"shortcuts.toggle":O(Ne=>!Ne);return;case"tasks.screen":if(!Z)return!1;R(!1),fe(!0);return;case"settings.toggle":Q(!1),y(Ne=>!Ne);return;case"tab.menu":if(!Z||re)return!1;Y(Ne=>Ne+1);return;case"sidebar.left":Ue();return;case"sidebar.right":et();return;case"sidebar.both":{const Ne=!ve&&!Me;t?le(!Ne):a(Ne),s?ce(!Ne):u(Ne);return}default:return!1}};return o.jsxs(HT,{children:[o.jsxs("div",{className:"flex h-dvh overflow-hidden",...x?{inert:!0,"aria-hidden":!0}:{},children:[!t&&i?o.jsx("div",{className:"fixed inset-0 z-30 bg-black/60","aria-hidden":!0,onClick:()=>a(!1)}):null,t&&J?null:o.jsxs("div",{className:I("z-40 shrink-0 border-r border-border bg-sidebar",t?"relative":"fixed inset-y-0 left-0 w-[min(100vw,22rem)] transition-transform duration-200",!t&&!i&&"-translate-x-full"),style:t?{width:h.width}:void 0,"data-testid":"sidebar-column",...!t&&!i?{inert:!0}:{},children:[t?o.jsx(xb,{which:"sidebar",side:"right",width:h.width,onWidth:h.setWidth,onCommit:h.save,testId:"left-sidebar-resize-handle"}):null,o.jsx(B4,{onNewSession:()=>{ee(),Qe()},onRename:k,onArchive:S,onSettings:Ae=>y(Ae??!0),onShortcuts:()=>O(!0),onNavigate:()=>a(!1),onClose:t?void 0:()=>a(!1),onHistory:()=>xe(),historyOpen:A,onTasks:()=>{Z&&(R(!1),fe(!0))},tasksOpen:H,onOpenSession:()=>ee(),searchRequest:L,onSearchRequestHandled:()=>B(0)})]}),o.jsxs("main",{className:"flex min-w-0 flex-1 flex-col bg-background",children:[H?o.jsxs(o.Fragment,{children:[o.jsx(hf,{}),o.jsx(_C,{navOpen:ve,onToggleNav:Ue,onClose:ee})]}):A?o.jsxs(o.Fragment,{children:[o.jsx(hf,{}),o.jsx(L5,{navOpen:ve,onToggleNav:Ue,onOpen:()=>ee(),onBack:()=>ee()})]}):o.jsxs(o.Fragment,{children:[o.jsx(yC,{navOpen:ve,onToggleNav:Ue,explorerOpen:Me,onToggleExplorer:et,onRename:k,onArchive:S}),o.jsx(hf,{}),o.jsx(zC,{splits:t,onNewSession:Qe,onRename:k,menuRequest:C,onMenuRequestHandled:()=>Y(0)})]}),o.jsx(DC,{})]}),Me&&!re?o.jsxs(o.Fragment,{children:[s?null:o.jsx("div",{className:"fixed inset-0 z-30 bg-black/60","aria-hidden":!0,onClick:()=>u(!1)}),o.jsxs("div",{className:I("shrink-0 border-l border-border bg-sidebar",s?"relative":"fixed inset-y-0 right-0 z-40 w-[min(100vw,24rem)] shadow-2xl"),style:s?{width:Re.width}:void 0,"data-testid":"explorer-column",children:[s?o.jsx(xb,{which:"dock",side:"left",width:Re.width,reserved:Re.reserved,onWidth:Re.setWidth,onCommit:Re.save,testId:"workspace-explorer-sidebar-resize-handle"}):null,o.jsx(A5,{dock:d,onClose:s?void 0:()=>u(!1)})]})]}):null,o.jsx(UC,{request:m}),o.jsx($C,{onOpenSession:Ae=>{de.selectSession(Ae),ee(),y(!1)}}),o.jsx(N3,{session:w,onClose:()=>k(null)}),o.jsx(T3,{session:j,onClose:()=>S(null)}),o.jsx(q5,{open:q,onClose:()=>O(!1)}),o.jsx(BC,{open:!!_,scope:_?_.scope:null,onClose:()=>Q(!1),history:re,splits:t,onAction:ye,onOpenSession:Ae=>{de.selectSession(Ae),ee(),a(!1)}}),o.jsx(qC,{settings:!!x,history:re,splits:t,onAction:ye})]}),x?o.jsx("div",{className:"fixed inset-0 z-50","data-modal-overlay":!0,children:o.jsx(mT,{mobile:!t,initialPage:typeof x=="string"?x:void 0,onClose:()=>y(!1)})}):null]})}function IC(){const{principal:s,connection:t,preferences:i}=Ee();b.useLayoutEffect(()=>e4(i.theme,i.syntaxTheme),[i.theme,i.syntaxTheme]);const{uiFontFamily:a,monoFontFamily:l,uiFontSize:u,contentFontSize:d,codeFontSize:h,contentMaxWidth:m}=i;return b.useLayoutEffect(()=>t4({uiFontFamily:a,monoFontFamily:l,uiFontSize:u,contentFontSize:d,codeFontSize:h,contentMaxWidth:m}),[a,l,u,d,h,m]),!!s&&(t.phase==="open"||t.phase==="reconnecting")?o.jsx(HC,{}):o.jsx(k3,{})}function GC(){try{return window.localStorage}catch{return}}function YC(){try{return window.sessionStorage}catch{return}}const zh=YC(),Aa=Ab({location:window.location,history:window.history,storage:zh}),Ba=new pS({storage:GC(),linkStorage:zh});Aa&&"token"in Aa?Ba.connect({url:Aa.url,token:Aa.token,link:!0}):Aa&&Ba.showError(Aa.error);window.addEventListener("pagehide",()=>Ba.disconnect({keepTerminals:!0,keepLink:!0}));window.addEventListener("pageshow",s=>{if(!s.persisted)return;const t=Ab({location:window.location,history:window.history,storage:zh});t&&"token"in t&&Ba.connect({url:t.url,token:t.token,link:!0})});window.addEventListener("storage",s=>{(s.key===eh||s.key===null)&&Ba.reloadPreferences()});Fk.createRoot(document.getElementById("root")).render(o.jsx(b.StrictMode,{children:o.jsx(x3,{controller:Ba,children:o.jsx(IC,{})})}));export{we as B,J0 as D,uo as R,hc as S,FC as T,Ee as a,f0 as b,VC as c,XC as e,o as j,KC as p,b as r,PC as t,Oe as u};