@gbasin/agentboard-darwin-x64 0.2.32 → 0.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/agentboard
CHANGED
|
Binary file
|
|
@@ -313,4 +313,4 @@ void main() {
|
|
|
313
313
|
*
|
|
314
314
|
* This source code is licensed under the MIT license found in the
|
|
315
315
|
* LICENSE file in the root directory of this source tree.
|
|
316
|
-
*/var Ec=E,LA=mS;function TA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var RA=typeof Object.is=="function"?Object.is:TA,DA=LA.useSyncExternalStore,MA=Ec.useRef,AA=Ec.useEffect,PA=Ec.useMemo,IA=Ec.useDebugValue;vS.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var a=MA(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=PA(function(){function o(_){if(!c){if(c=!0,f=_,_=n(_),i!==void 0&&l.hasValue){var y=l.value;if(i(y,_))return u=y}return u=_}if(y=u,RA(f,_))return y;var v=n(_);return i!==void 0&&i(y,v)?(f=_,y):(f=_,u=v)}var c=!1,f,u,p=r===void 0?null:r;return[function(){return o(t())},p===null?void 0:function(){return o(p())}]},[t,r,n,i]);var s=DA(e,a[0],a[1]);return AA(function(){l.hasValue=!0,l.value=s},[s]),IA(s),s};gS.exports=vS;var OA=gS.exports;const BA=lp(19),NA=BA?FA:HA;function _S(e,t,r,n,i){return NA(e,t,r,n,i)}function jA(e,t,r,n,i){const a=E.useCallback(()=>t(e.getSnapshot(),r,n,i),[e,t,r,n,i]);return mS.useSyncExternalStore(e.subscribe,a,a)}function FA(e,t,r,n,i){return jA(e,t,r,n,i)}function HA(e,t,r,n,i){return OA.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,a=>t(a,r,n,i))}class $A{constructor(t){rt(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));rt(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const r=this.updateTick;for(const n of this.listeners){if(r!==this.updateTick)return;n(t)}}update(t){for(const r in t)if(!Object.is(this.state[r],t[r])){this.setState({...this.state,...t});return}}set(t,r){Object.is(this.state[t],r)||this.setState({...this.state,[t]:r})}notifyAll(){const t={...this.state};this.setState(t)}use(t,r,n,i){return _S(this,t,r,n,i)}}class zA extends $A{constructor(t,r={},n){super(t),this.context=r,this.selectors=n}useSyncedValue(t,r){E.useDebugValue(t),qt(()=>{this.state[t]!==r&&this.set(t,r)},[t,r])}useSyncedValueWithCleanup(t,r){const n=this;qt(()=>(n.state[t]!==r&&n.set(t,r),()=>{n.set(t,void 0)}),[n,t,r])}useSyncedValues(t){const r=this,n=Object.values(t);qt(()=>{r.update(t)},[r,...n])}useControlledProp(t,r){E.useDebugValue(t);const n=r!==void 0;qt(()=>{n&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})},[t,r,n])}select(t,r,n,i){const a=this.selectors[t];return a(this.state,r,n,i)}useState(t,r,n,i){return E.useDebugValue(t),_S(this,this.selectors[t],r,n,i)}useContextCallback(t,r){E.useDebugValue(t);const n=Yr(r??ur);this.context[t]=n}useStateSetter(t){const r=E.useRef(void 0);return r.current===void 0&&(r.current=n=>{this.set(t,n)}),r.current}observe(t,r){let n;typeof t=="function"?n=t:n=this.selectors[t];let i=n(this.state);return r(i,i,this),this.subscribe(a=>{const l=n(a);if(!Object.is(i,l)){const s=i;i=l,r(l,s,this)}})}}const $a=null;class UA{constructor(){rt(this,"callbacks",[]);rt(this,"callbacksCount",0);rt(this,"nextId",1);rt(this,"startId",1);rt(this,"isScheduled",!1);rt(this,"tick",t=>{var i;this.isScheduled=!1;const r=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let a=0;a<r.length;a+=1)(i=r[a])==null||i.call(r,t)})}request(t){const r=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(t){const r=t-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const za=new UA;class yp{constructor(){rt(this,"currentId",$a);rt(this,"cancel",()=>{this.currentId!==$a&&(za.cancel(this.currentId),this.currentId=$a)});rt(this,"disposeEffect",()=>this.cancel)}static create(){return new yp}static request(t){return za.request(t)}static cancel(t){return za.cancel(t)}request(t){this.cancel(),this.currentId=za.request(()=>{this.currentId=$a,t()})}}function WA(){const e=ks(yp.create).current;return gp(e.disposeEffect),e}const Ui=0;class Go{constructor(){rt(this,"currentId",Ui);rt(this,"clear",()=>{this.currentId!==Ui&&(clearTimeout(this.currentId),this.currentId=Ui)});rt(this,"disposeEffect",()=>this.clear)}static create(){return new Go}start(t,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ui,r()},t)}isStarted(){return this.currentId!==Ui}}function VA(){const e=ks(Go.create).current;return gp(e.disposeEffect),e}let Nv=0;function yS(e){return Nv+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Nv}`}function Js(e){return(e==null?void 0:e.ownerDocument)||document}function Mu(e,t){if(typeof e=="string")return{description:e};if(typeof e=="function"){const r=e(t);return typeof r=="string"?{description:r}:r}return e}const la=typeof navigator<"u",Au=YA(),KA=QA(),GA=JA();typeof CSS>"u"||!CSS.supports||CSS.supports("-webkit-backdrop-filter:none");Au.platform==="MacIntel"&&Au.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(Au.platform);const qA=la&&/apple/i.test(navigator.vendor);la&&KA.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const XA=GA.includes("jsdom/");function YA(){if(!la)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e!=null&&e.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function JA(){if(!la)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:r})=>`${t}/${r}`).join(" "):navigator.userAgent}function QA(){if(!la)return"";const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform??""}function Zl(e){var r;let t=e.activeElement;for(;((r=t==null?void 0:t.shadowRoot)==null?void 0:r.activeElement)!=null;)t=t.shadowRoot.activeElement;return t}function yi(e,t){var n;if(!e||!t)return!1;const r=(n=t.getRootNode)==null?void 0:n.call(t);if(e.contains(t))return!0;if(r&&zM(r)){let i=t;for(;i;){if(e===i)return!0;i=i.parentNode||i.host}}return!1}function wp(e){return"composedPath"in e?e.composedPath()[0]:e.target}function gd(e){if(!e||XA)return!0;try{return e.matches(":focus-visible")}catch{return!0}}const Ua=vA(e=>e.toasts,e=>{const t=new Map;let r=0,n=0;return e.forEach((i,a)=>{const l=i.transitionStatus==="ending";t.set(i.id,{value:i,domIndex:a,visibleIndex:l?-1:r,offsetY:n}),n+=i.height||0,l||(r+=1)}),t}),sn={toasts:Tr(e=>e.toasts),isEmpty:Tr(e=>e.toasts.length===0),toast:Tr(Ua,(e,t)=>{var r;return(r=e.get(t))==null?void 0:r.value}),toastIndex:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.domIndex)??-1}),toastOffsetY:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.offsetY)??0}),toastVisibleIndex:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.visibleIndex)??-1}),hovering:Tr(e=>e.hovering),focused:Tr(e=>e.focused),expanded:Tr(e=>e.hovering||e.focused),expandedOrOutOfFocus:Tr(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Tr(e=>e.prevFocusElement)};class ZA extends zA{constructor(r){super(r,{},sn);rt(this,"timers",new Map);rt(this,"areTimersPaused",!1);rt(this,"setViewport",r=>{this.set("viewport",r)});rt(this,"disposeEffect",()=>()=>{this.timers.forEach(r=>{var n;(n=r.timeout)==null||n.clear()}),this.timers.clear()});rt(this,"addToast",r=>{const{toasts:n,timeout:i,limit:a}=this.state,l=r.id||yS("toast"),s={...r,id:l,transitionStatus:"starting"},o=[s,...n],c=o.filter(u=>u.transitionStatus!=="ending");if(c.length>a){const u=c.length-a,p=c.slice(-u),_=new Set(p.map(y=>y.id));this.setToasts(o.map(y=>{const v=_.has(y.id);return y.limited!==v?{...y,limited:v}:y}))}else this.setToasts(o.map(u=>u.limited?{...u,limited:!1}:u));const f=s.timeout??i;return s.type!=="loading"&&f>0&&this.scheduleTimer(l,f,()=>this.closeToast(l)),sn.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),l});rt(this,"updateToast",(r,n)=>{this.updateToastInternal(r,n)});rt(this,"updateToastInternal",(r,n)=>{var v,h;const{timeout:i,toasts:a}=this.state,l=sn.toast(this.state,r)??null;if(!l||l.transitionStatus==="ending")return;const s={...l,...n};this.setToasts(a.map(m=>m.id===r?{...m,...n}:m));const o=s.timeout??i,c=(l==null?void 0:l.timeout)??i,f=Object.hasOwn(n,"timeout"),u=s.transitionStatus!=="ending"&&s.type!=="loading"&&o>0,p=this.timers.has(r),_=c!==o,y=(l==null?void 0:l.type)==="loading";if(!u&&p){const m=this.timers.get(r);(v=m==null?void 0:m.timeout)==null||v.clear(),this.timers.delete(r);return}if(u&&(!p||_||f||y)){const m=this.timers.get(r);m&&((h=m.timeout)==null||h.clear(),this.timers.delete(r)),this.scheduleTimer(r,o,()=>this.closeToast(r)),sn.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}});rt(this,"closeToast",r=>{var c;const n=sn.toast(this.state,r);(c=n==null?void 0:n.onClose)==null||c.call(n);const{limit:i,toasts:a}=this.state;let l=0;const s=a.map(f=>{if(f.id===r)return{...f,transitionStatus:"ending",height:0};if(f.transitionStatus==="ending")return f;const u=l>=i;return l+=1,f.limited!==u?{...f,limited:u}:f}),o=this.timers.get(r);o&&o.timeout&&(o.timeout.clear(),this.timers.delete(r)),this.handleFocusManagement(r),this.setToasts(s)});rt(this,"promiseToast",(r,n)=>{const i=Mu(n.loading),a=this.addToast({...i,type:"loading"}),l=r.then(s=>{const o=Mu(n.success,s);return this.updateToast(a,{...o,type:"success",timeout:o.timeout}),s}).catch(s=>{const o=Mu(n.error,s);return this.updateToast(a,{...o,type:"error",timeout:o.timeout}),Promise.reject(s)});return{}.hasOwnProperty.call(n,"setPromise")&&n.setPromise(l),l});rt(this,"handleDocumentPointerDown",r=>{if(r.pointerType!=="touch")return;const n=wp(r);yi(this.state.viewport,n)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))})}setFocused(r){this.set("focused",r)}setHovering(r){this.set("hovering",r)}setIsWindowFocused(r){this.set("isWindowFocused",r)}setPrevFocusElement(r){this.set("prevFocusElement",r)}removeToast(r){var l;const n=sn.toastIndex(this.state,r);if(n===-1)return;const i=this.state.toasts[n];(l=i==null?void 0:i.onRemove)==null||l.call(i);const a=[...this.state.toasts];a.splice(n,1),this.setToasts(a)}pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(r=>{if(r.timeout){r.timeout.clear();const n=Date.now()-r.start,i=r.delay-n;r.remaining=i>0?i:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((r,n)=>{r.remaining=r.remaining>0?r.remaining:r.delay,r.timeout??(r.timeout=Go.create()),r.timeout.start(r.remaining,()=>{this.timers.delete(n),r.callback()}),r.start=Date.now()}))}restoreFocusToPrevElement(){var r;(r=this.state.prevFocusElement)==null||r.focus({preventScroll:!0})}scheduleTimer(r,n,i){const a=Date.now(),l=!sn.expandedOrOutOfFocus(this.state),s=l?Go.create():void 0;s==null||s.start(n,()=>{this.timers.delete(r),i()}),this.timers.set(r,{timeout:s,start:l?a:0,delay:n,remaining:n,callback:i})}setToasts(r){const n={toasts:r};r.length===0&&(n.hovering=!1,n.focused=!1),this.update(n)}handleFocusManagement(r){var o,c;const n=Zl(Js(this.state.viewport));if(!this.state.viewport||!yi(this.state.viewport,n)||!gd(n))return;const i=sn.toasts(this.state),a=sn.toastIndex(this.state,r);let l=null,s=a+1;for(;s<i.length;){if(i[s].transitionStatus!=="ending"){l=i[s];break}s+=1}if(!l)for(s=a-1;s>=0;){if(i[s].transitionStatus!=="ending"){l=i[s];break}s-=1}l?(c=(o=l.ref)==null?void 0:o.current)==null||c.focus():this.restoreFocusToPrevElement()}}const eP=function(t){const{children:r,timeout:n=5e3,limit:i=3,toastManager:a}=t,l=ks(()=>new ZA({timeout:n,limit:i,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return gp(l.disposeEffect),E.useEffect(function(){return a?a[" subscribe"](({action:c,options:f})=>{const u=f.id;c==="promise"&&f.promise?l.promiseToast(f.promise,f):c==="update"&&u?l.updateToast(u,f):c==="close"&&u?l.closeToast(u):l.addToast(f)}):void 0},[l,n,a]),l.useSyncedValues({timeout:n,limit:i}),T.jsx(vp.Provider,{value:l,children:r})},Pu=E.forwardRef(function(t,r){const[n,i]=E.useState();qt(()=>{qA&&i("button")},[]);const a={tabIndex:0,role:n};return T.jsx("span",{...t,ref:r,style:ap,"aria-hidden":n?void 0:!0,...a,"data-base-ui-focus-guard":""})});let tP=function(e){return e.frontmostHeight="--toast-frontmost-height",e}({});const rP=E.forwardRef(function(t,r){var M;const{render:n,className:i,children:a,...l}=t,s=_p(),o=VA(),c=E.useRef(!1),f=E.useRef(!1),u=s.useState("isEmpty"),p=s.useState("toasts"),_=s.useState("focused"),y=s.useState("expanded"),v=s.useState("prevFocusElement"),h=((M=p[0])==null?void 0:M.height)??0,m=E.useMemo(()=>p.some(D=>D.transitionStatus==="ending"),[p]);E.useEffect(()=>{const D=s.state.viewport;if(!D)return;function O(F){u||F.key==="F6"&&F.target!==D&&(F.preventDefault(),s.setPrevFocusElement(Zl(Js(D))),D==null||D.focus({preventScroll:!0}),s.pauseTimers(),s.setFocused(!0))}const z=Ko(D);return z.addEventListener("keydown",O),()=>{z.removeEventListener("keydown",O)}},[s,u]),E.useEffect(()=>{const D=s.state.viewport;if(!D||u)return;const O=Ko(D);function z(H){H.target===O&&(s.setIsWindowFocused(!1),s.pauseTimers())}function F(H){if(H.relatedTarget||H.target===O)return;const I=wp(H),R=Zl(Js(D));(!yi(D,I)||!gd(R))&&s.resumeTimers(),o.start(0,()=>s.setIsWindowFocused(!0))}return O.addEventListener("blur",z,!0),O.addEventListener("focus",F,!0),()=>{O.removeEventListener("blur",z,!0),O.removeEventListener("focus",F,!0)}},[s,o,u]),E.useEffect(()=>{const D=s.state.viewport;if(!D||u)return;const O=Js(D);return O.addEventListener("pointerdown",s.handleDocumentPointerDown,!0),()=>{O.removeEventListener("pointerdown",s.handleDocumentPointerDown,!0)}},[u,s]);function d(D){var z,F,H;const O=s.state.viewport;O&&(c.current=!0,D.relatedTarget===O?(H=(F=(z=p[0])==null?void 0:z.ref)==null?void 0:F.current)==null||H.focus():s.restoreFocusToPrevElement())}function g(D){D.key==="Tab"&&D.shiftKey&&D.target===s.state.viewport&&(D.preventDefault(),s.restoreFocusToPrevElement(),s.resumeTimers())}E.useEffect(()=>{!s.state.isWindowFocused||m||!f.current||(s.resumeTimers(),s.setHovering(!1),f.current=!1)},[m,s]);function w(){s.pauseTimers(),s.setHovering(!0),f.current=!1}function b(){m?f.current=!0:(s.resumeTimers(),s.setHovering(!1))}function x(){if(c.current){c.current=!1;return}_||gd(Js(s.state.viewport).activeElement)&&(s.setFocused(!0),s.pauseTimers())}function C(D){!_||yi(s.state.viewport,D.relatedTarget)||(s.setFocused(!1),s.resumeTimers())}const S={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:w,onMouseMove:w,onMouseLeave:b,onFocus:x,onBlur:C,onKeyDown:g,onClick:x},k={expanded:y},L=Ls("div",t,{ref:[r,s.setViewport],state:k,props:[S,{style:{[tP.frontmostHeight]:h?`${h}px`:void 0}},l,{children:T.jsxs(E.Fragment,{children:[!u&&v&&T.jsx(Pu,{onFocus:d}),a,!u&&v&&T.jsx(Pu,{onFocus:d})]})}]}),A=E.useMemo(()=>p.filter(D=>D.priority==="high"),[p]);return T.jsxs(E.Fragment,{children:[!u&&v&&T.jsx(Pu,{onFocus:d}),L,!_&&A.length>0&&T.jsx("div",{style:ap,children:A.map(D=>T.jsxs("div",{role:"alert","aria-atomic":!0,children:[T.jsx("div",{children:D.title}),T.jsx("div",{children:D.description})]},D.id))})]})});function nP(e){return lp(19)?e:e?"true":void 0}const wS=E.createContext(void 0);function Sp(){const e=E.useContext(wS);if(!e)throw new Error(Jr(66));return e}let xp=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const sP={[xp.startingStyle]:""},iP={[xp.endingStyle]:""},oP={transitionStatus(e){return e==="starting"?sP:e==="ending"?iP:null}};function aP(e){return e==null?e:"current"in e?e.current:e}function lP(e,t=!1,r=!0){const n=WA();return Yr((i,a=null)=>{n.cancel();function l(){hn.flushSync(i)}const s=aP(e);if(s==null)return;const o=s;if(typeof o.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{let u=function(){const _=xp.startingStyle;if(!o.hasAttribute(_)){n.request(p);return}const y=new MutationObserver(()=>{o.hasAttribute(_)||(y.disconnect(),p())});y.observe(o,{attributes:!0,attributeFilter:[_]}),a==null||a.addEventListener("abort",()=>y.disconnect(),{once:!0})},p=function(){Promise.all(o.getAnimations().map(_=>_.finished)).then(()=>{a!=null&&a.aborted||l()}).catch(()=>{const _=o.getAnimations();if(r){if(a!=null&&a.aborted)return;l()}else _.length>0&&_.some(y=>y.pending||y.playState!=="finished")&&p()})};var c=u,f=p;if(t){u();return}n.request(p)}})}function cP(e){const{enabled:t=!0,open:r,ref:n,onComplete:i}=e,a=Yr(i),l=lP(n,r,!1);E.useEffect(()=>{if(!t)return;const s=new AbortController;return l(a,s.signal),()=>{s.abort()}},[t,r,a,l])}let ss=function(e){return e.index="--toast-index",e.offsetY="--toast-offset-y",e.height="--toast-height",e.swipeMovementX="--toast-swipe-movement-x",e.swipeMovementY="--toast-swipe-movement-y",e}({});const uP={...oP,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},Wi=40,hP=10,En=.5,dP=1;function jv(e,t,r){switch(e){case"up":return-r;case"down":return r;case"left":return-t;case"right":return t;default:return 0}}function fP(e){const r=window.getComputedStyle(e).transform;let n=0,i=0,a=1;if(r&&r!=="none"){const l=r.match(/matrix(?:3d)?\(([^)]+)\)/);if(l){const s=l[1].split(", ").map(parseFloat);s.length===6?(n=s[4],i=s[5],a=Math.sqrt(s[0]*s[0]+s[1]*s[1])):s.length===16&&(n=s[12],i=s[13],a=s[0])}}return{x:n,y:i,scale:a}}const pP=E.forwardRef(function(t,r){var ve;const{toast:n,render:i,className:a,swipeDirection:l=["down","right"],...s}=t,o=((ve=n.positionerProps)==null?void 0:ve.anchor)!==void 0;let c=[];o||(c=Array.isArray(l)?l:[l]);const f=c.length>0,u=_p(),[p,_]=E.useState(void 0),[y,v]=E.useState(!1),[h,m]=E.useState(!1),[d,g]=E.useState(!1),[w,b]=E.useState({x:0,y:0}),[x,C]=E.useState({x:0,y:0,scale:1}),[S,k]=E.useState(),[L,A]=E.useState(),[M,D]=E.useState(null),O=E.useRef(null),z=E.useRef({x:0,y:0}),F=E.useRef({x:0,y:0,scale:1}),H=E.useRef(void 0),I=E.useRef(0),R=E.useRef(!1),P=E.useRef({x:0,y:0}),N=E.useRef(!1),j=u.useState("toastIndex",n.id),W=u.useState("toastVisibleIndex",n.id),V=u.useState("toastOffsetY",n.id),Z=u.useState("focused"),Q=u.useState("expanded");cP({open:n.transitionStatus!=="ending",ref:O,onComplete(){n.transitionStatus==="ending"&&u.removeToast(n.id)}});const $=Yr((se=!1)=>{const ae=O.current;if(!ae)return;const fe=ae.style.height;ae.style.height="auto";const ie=ae.offsetHeight;ae.style.height=fe;function ge(){u.updateToastInternal(n.id,{ref:O,height:ie,...n.transitionStatus==="starting"?{transitionStatus:void 0}:{}})}se?hn.flushSync(ge):ge()});qt($,[$]);function B(se,ae){let fe=se,ie=ae;return!c.includes("left")&&!c.includes("right")?fe=se>0?se**En:-(Math.abs(se)**En):(!c.includes("right")&&se>0&&(fe=se**En),!c.includes("left")&&se<0&&(fe=-(Math.abs(se)**En))),!c.includes("up")&&!c.includes("down")?ie=ae>0?ae**En:-(Math.abs(ae)**En):(!c.includes("down")&&ae>0&&(ie=ae**En),!c.includes("up")&&ae<0&&(ie=-(Math.abs(ae)**En))),{x:fe,y:ie}}function K(se){var ie;if(se.button!==0)return;se.pointerType==="touch"&&u.pauseTimers();const ae=wp(se.nativeEvent);if(!(ae&&ae.closest('button,a,input,textarea,[role="button"],[data-swipe-ignore]'))){if(R.current=!1,H.current=void 0,I.current=0,z.current={x:se.clientX,y:se.clientY},P.current=z.current,O.current){const ge=fP(O.current);F.current=ge,C(ge),b({x:ge.x,y:ge.y})}u.setHovering(!0),v(!0),m(!1),D(null),N.current=!0,(ie=O.current)==null||ie.setPointerCapture(se.pointerId)}}function U(se){if(!y)return;se.preventDefault(),N.current&&(z.current={x:se.clientX,y:se.clientY},N.current=!1);const{clientY:ae,clientX:fe,movementX:ie,movementY:ge}=se;(ge<0&&ae>P.current.y||ge>0&&ae<P.current.y)&&(P.current={x:P.current.x,y:ae}),(ie<0&&fe>P.current.x||ie>0&&fe<P.current.x)&&(P.current={x:fe,y:P.current.y});const be=fe-z.current.x,Te=ae-z.current.y,je=ae-P.current.y,He=fe-P.current.x;if(!h&&Math.sqrt(be*be+Te*Te)>=dP&&(m(!0),M===null)){const J=c.includes("left")||c.includes("right"),ee=c.includes("up")||c.includes("down");if(J&&ee){const Be=Math.abs(be),q=Math.abs(Te);D(Be>q?"horizontal":"vertical")}}let Pe;if(!H.current)M==="vertical"?Te>0?Pe="down":Te<0&&(Pe="up"):M==="horizontal"?be>0?Pe="right":be<0&&(Pe="left"):Math.abs(be)>=Math.abs(Te)?Pe=be>0?"right":"left":Pe=Te>0?"down":"up",Pe&&c.includes(Pe)&&(H.current=Pe,I.current=jv(Pe,be,Te),_(Pe));else{const Qe=H.current,J=jv(Qe,He,je);J>Wi?(R.current=!1,_(Qe)):!(c.includes("left")&&c.includes("right"))&&!(c.includes("up")&&c.includes("down"))&&I.current-J>=hP&&(R.current=!0)}const Oe=B(be,Te);let ke=F.current.x,Le=F.current.y;M==="horizontal"?(c.includes("left")||c.includes("right"))&&(ke+=Oe.x):(M==="vertical"||(c.includes("left")||c.includes("right"))&&(ke+=Oe.x),(c.includes("up")||c.includes("down"))&&(Le+=Oe.y)),b({x:ke,y:Le})}function te(se){var be;if(!y)return;if(v(!1),m(!1),D(null),(be=O.current)==null||be.releasePointerCapture(se.pointerId),R.current){b({x:x.x,y:x.y}),_(void 0);return}let ae=!1;const fe=w.x-x.x,ie=w.y-x.y;let ge;for(const Te of c){switch(Te){case"right":fe>Wi&&(ae=!0,ge="right");break;case"left":fe<-Wi&&(ae=!0,ge="left");break;case"down":ie>Wi&&(ae=!0,ge="down");break;case"up":ie<-Wi&&(ae=!0,ge="up");break}if(ae)break}ae?(_(ge),g(!0),u.closeToast(n.id)):(b({x:x.x,y:x.y}),_(void 0))}function Y(se){if(se.key==="Escape"){if(!O.current||!yi(O.current,Zl(Js(O.current))))return;u.closeToast(n.id)}}E.useEffect(()=>{if(!f)return;const se=O.current;if(!se)return;function ae(fe){yi(se,fe.target)&&fe.preventDefault()}return se.addEventListener("touchmove",ae,{passive:!1}),()=>{se.removeEventListener("touchmove",ae)}},[f]);function ye(){if(!y&&w.x===x.x&&w.y===x.y&&!d)return{[ss.swipeMovementX]:"0px",[ss.swipeMovementY]:"0px"};const se=w.x-x.x,ae=w.y-x.y;return{transition:y?"none":void 0,transform:y?`translateX(${w.x}px) translateY(${w.y}px) scale(${x.scale})`:void 0,[ss.swipeMovementX]:`${se}px`,[ss.swipeMovementY]:`${ae}px`}}const pe=n.priority==="high",ne={role:pe?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":S,"aria-describedby":L,"aria-hidden":pe&&!Z?!0:void 0,onPointerDown:f?K:void 0,onPointerMove:f?U:void 0,onPointerUp:f?te:void 0,onKeyDown:Y,inert:nP(n.limited),style:{...ye(),[ss.index]:n.transitionStatus==="ending"?j:W,[ss.offsetY]:`${V}px`,[ss.height]:n.height?`${n.height}px`:void 0}},oe=E.useMemo(()=>({rootRef:O,toast:n,titleId:S,setTitleId:k,descriptionId:L,setDescriptionId:A,swiping:y,swipeDirection:p,recalculateHeight:$,index:j,visibleIndex:W,expanded:Q}),[n,S,L,y,p,$,j,W,Q]),ce={transitionStatus:n.transitionStatus,expanded:Q,limited:n.limited||!1,type:n.type,swiping:oe.swiping,swipeDirection:oe.swipeDirection},ue=Ls("div",t,{ref:[r,oe.rootRef],state:ce,stateAttributesMapping:uP,props:[ne,s]});return T.jsx(wS.Provider,{value:oe,children:ue})}),mP=E.forwardRef(function(t,r){const{render:n,className:i,id:a,children:l,...s}=t,{toast:o,setDescriptionId:c}=Sp(),f=l??o.description,u=!!f,p=up(a);qt(()=>{if(u)return c(p),()=>{c(void 0)}},[u,p,c]);const _={type:o.type},y=Ls("p",t,{ref:r,state:_,props:{...s,id:p,children:f}});return u?y:null}),gP=E.forwardRef(function(t,r){const{render:n,className:i,id:a,children:l,...s}=t,{toast:o,setTitleId:c}=Sp(),f=l??o.title,u=!!f,p=up(a);qt(()=>{if(u)return c(p),()=>{c(void 0)}},[u,p,c]);const _={type:o.type},y=Ls("h2",t,{ref:r,state:_,props:{...s,id:p,children:f}});return u?y:null}),vP=E.forwardRef(function(t,r){const{render:n,className:i,disabled:a,nativeButton:l=!0,...s}=t,o=_p(),{toast:c}=Sp(),f=o.useState("expanded"),[u,p]=E.useState(!1),{getButtonProps:_,buttonRef:y}=Vw({disabled:a,native:l}),v={type:c.type};return Ls("button",t,{ref:[r,y],state:v,props:[{"aria-hidden":!f&&!u,onClick(){o.closeToast(c.id)},onFocus(){p(!0)},onBlur(){p(!1)}},s,_]})});function _P(){const e=E.useContext(vp);if(!e)throw new Error(Jr(73));const t=e.useState("toasts");return E.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function yP(){const e=new Set;function t(r){e.forEach(n=>n(r))}return{" subscribe":function(n){return e.add(n),()=>{e.delete(n)}},add(r){const n=r.id||yS("toast"),i={...r,id:n,transitionStatus:"starting"};return t({action:"add",options:i}),n},close(r){t({action:"close",options:{id:r}})},update(r,n){t({action:"update",options:{...n,id:r}})},promise(r,n){let i=r;return t({action:"promise",options:{...n,promise:r,setPromise(a){i=a}}}),i}}}const wP=5e3,SS=yP();function SP({toast:e}){return T.jsxs(pP,{toast:e,className:Yl("relative flex w-80 items-start gap-3 border bg-elevated p-4 shadow-lg","data-[swipe=move]:translate-x-[var(--toast-swipe-move-x)]","data-[ending-style]:translate-x-[var(--toast-swipe-end-x)]","data-[ending-style]:opacity-0","data-[starting-style]:translate-y-2 data-[starting-style]:opacity-0","transition-all duration-200",e.type==="error"&&"border-error/50",e.type==="success"&&"border-approval/50",(!e.type||e.type==="info")&&"border-border"),children:[T.jsxs("div",{className:"flex-1 min-w-0",children:[T.jsx(gP,{className:Yl("text-sm font-medium",e.type==="error"&&"text-error",e.type==="success"&&"text-approval",(!e.type||e.type==="info")&&"text-primary"),children:e.title}),e.description&&T.jsx(mP,{className:"mt-1 text-xs text-muted line-clamp-2",children:e.description})]}),T.jsx(vP,{className:"shrink-0 text-muted hover:text-primary transition-colors","aria-label":"Close",children:T.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[T.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),T.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function xP(){const{toasts:e}=_P();return T.jsx(T.Fragment,{children:e.map(t=>T.jsx(SP,{toast:t},t.id))})}function bP(){return T.jsxs(eP,{timeout:wP,toastManager:SS,children:[T.jsx(xP,{}),T.jsx(rP,{className:"fixed bottom-4 right-4 z-[100] flex flex-col gap-2"})]})}const Fv=["CONNECTING","OPEN","CLOSING","CLOSED"],CP=3e3,EP=8e3,kP=15e3,LP=5e3,Iu=2e4,TP=1e4,RP=1500,DP=5e3,MP=750,AP=4,PP=5e3;class IP{constructor(){this.ws=null,this.listeners=new Set,this.statusListeners=new Set,this.status="connecting",this.error=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.connectTimer=null,this.manualClose=!1,this.lastTick=Date.now(),this.wakeCheckInterval=null,this.lifecycleStarted=!1,this.heartbeatTimer=null,this.pongTimer=null,this.lastForceReconnectTs=0,this.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{var t;if(Ge("ws_visibility",{state:document.visibilityState,...this.wsSnap()},"info"),document.visibilityState==="visible"){const r=Date.now(),n=r-this.lastTick;this.lastTick=r,Ge("ws_resume",{gapMs:n,...this.wsSnap()},"info"),((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?this.verifyConnection():this.forceReconnect("visibilitychange",!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)},this.onPageShow=t=>{Ge("ws_pageshow",{persisted:t.persisted,...this.wsSnap()},"info"),t.persisted&&(this.lastTick=Date.now(),this.forceReconnect("pageshow",!0))}}wsSnap(){return{status:this.status,ws:this.ws?Fv[this.ws.readyState]:null,attempt:this.reconnectAttempts,failures:this.consecutiveFailures,leaked:this.leakedSockets.size,online:typeof navigator<"u"?navigator.onLine:void 0,verifying:this.verifyTimer!==null,buffered:this.ws?this.ws.bufferedAmount:void 0}}connect(){if(this.ws){const a=this.ws.readyState===WebSocket.OPEN;if(a&&this.status==="connected"){Ge("ws_connect_skip",{reason:"already_open",...this.wsSnap()});return}Ge("ws_connect_destroy_zombie",{reason:a?"open_desynced":"not_open",...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus("connecting");const r=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`;Ge("ws_connect",{url:r,resume:this.isResumeAttempt,...this.wsSnap()},"info");const n=new WebSocket(r);this.ws=n,this.leakedSockets.add(n);const i=this.isResumeAttempt?EP:CP;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{if(this.ws!==n)return;this.connectTimer=null,n.readyState===WebSocket.OPEN&&this.status==="connected"||(Ge("ws_connect_timeout",{wsState:Fv[n.readyState],managerStatus:this.status,timeoutMs:i,...this.wsSnap()},"info"),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect())},i),n.onopen=()=>{if(this.ws!==n){Ge("ws_onopen_stale",this.wsSnap(),"info");return}Ge("ws_onopen",this.wsSnap(),"info"),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.connectionEpoch+=1,this.leakedSockets.delete(n),this.setStatus("connected"),this.startHeartbeat()},n.onmessage=a=>{try{const l=a.data,s=performance.now(),o=JSON.parse(l),c=performance.now()-s,f=o;if(f._parseMs=Math.round(c),f._rawLength=l.length,o.type==="pong"){o.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),Ge("ws_verify_ok",this.wsSnap(),"info"),this.startHeartbeat(DP)));return}this.listeners.forEach(u=>u(o))}catch{}},n.onerror=()=>{this.ws===n&&(Ge("ws_onerror",this.wsSnap(),"info"),this.clearConnectTimer())},n.onclose=a=>{if(this.ws!==n){Ge("ws_onclose_stale",{code:a.code,...this.wsSnap()},"info");return}Ge("ws_onclose",{code:a.code,reason:a.reason,clean:a.wasClean,...this.wsSnap()},"info"),this.clearConnectTimer(),this.cancelVerify(),this.consecutiveFailures+=1,this.ws=null,this.manualClose?this.setStatus("disconnected"):this.scheduleReconnect()}}disconnect(){this.manualClose=!0,this.clearConnectTimer(),this.cancelVerify(),this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.destroySocket(),this.setStatus("disconnected")}startLifecycleListeners(){this.lifecycleStarted||typeof document>"u"||typeof window>"u"||(this.lifecycleStarted=!0,document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pageshow",this.onPageShow),this.lastTick=Date.now(),this.wakeCheckInterval=window.setInterval(()=>{const t=Date.now(),r=t-this.lastTick;this.isHidden()||(r>kP&&(Ge("ws_time_jump",{gapMs:r,...this.wsSnap()},"info"),this.forceReconnect("time_jump",!0)),this.lastTick=t)},LP))}stopLifecycleListeners(){this.lifecycleStarted&&(this.lifecycleStarted=!1,document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("pageshow",this.onPageShow),this.wakeCheckInterval!==null&&(window.clearInterval(this.wakeCheckInterval),this.wakeCheckInterval=null))}send(t){var r;if(((r=this.ws)==null?void 0:r.readyState)!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(t)),!0}catch(n){return Ge("ws_send_error",{messageType:t.type,error:n instanceof Error?n.message:String(n),...this.wsSnap()},"info"),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeStatus(t){return this.statusListeners.add(t),t(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(t)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;const t=this.pingSeq,r=this.ws;if(Ge("ws_verify",{seq:t,...this.wsSnap()},"info"),!this.send({type:"ping",seq:t})){Ge("ws_verify_send_fail",this.wsSnap(),"info"),this.forceReconnect("verify_send_fail",!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===r&&(Ge("ws_verify_timeout",this.wsSnap(),"info"),this.forceReconnect("verify_timeout",!0))},RP)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(t="unknown",r=!1){var a;if(this.manualClose){Ge("ws_force_skip",{trigger:t,reason:"manual_close"});return}const n=Date.now(),i=r?200:500;if(n-this.lastForceReconnectTs<i){Ge("ws_force_skip",{trigger:t,reason:"debounce",force:r});return}if(!r&&((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN&&this.status==="connected"){Ge("ws_force_skip",{trigger:t,reason:"already_connected"});return}this.lastForceReconnectTs=n,Ge("ws_force_reconnect",{trigger:t,force:r,...this.wsSnap()},"info"),this.reconnectAttempts=0,this.consecutiveFailures=0,this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.destroySocket(),r?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus("reconnecting"),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},MP)):this.connect()}startHeartbeat(t){this.stopHeartbeat();const r=()=>{var n;((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:"ping",seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,Ge("ws_pong_timeout",this.wsSnap(),"info"),this.destroySocket(),this.scheduleReconnect()},TP)))};t!==void 0&&t<Iu?this.heartbeatTimer=window.setTimeout(()=>{r(),this.heartbeatTimer=window.setInterval(r,Iu)},t):this.heartbeatTimer=window.setInterval(r,Iu)}stopHeartbeat(){this.heartbeatTimer!==null&&(window.clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongTimer()}clearPongTimer(){this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}setStatus(t,r=null){this.status=t,this.error=r,this.statusListeners.forEach(n=>n(t,r,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){Ge("ws_schedule_skip",{reason:"hidden",...this.wsSnap()}),this.setStatus("reconnecting");return}if(this.consecutiveFailures>=AP){Ge("ws_stall_detected",this.wsSnap(),"info"),this.purgeLeakedSockets(),this.consecutiveFailures=0,this.reconnectAttempts=0,this.isResumeAttempt=!0,this.setStatus("reconnecting"),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},PP);return}this.reconnectAttempts+=1;const t=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);Ge("ws_schedule_reconnect",{delay:t,...this.wsSnap()}),this.setStatus("reconnecting"),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}isHidden(){return typeof document<"u"&&document.visibilityState==="hidden"}clearConnectTimer(){this.connectTimer&&(window.clearTimeout(this.connectTimer),this.connectTimer=null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;const t=this.ws;this.ws=null,this.leakedSockets.add(t),t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){Ge("ws_purge_leaked",{count:this.leakedSockets.size},"info");for(const t of this.leakedSockets)try{t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,t.close()}catch{}this.leakedSockets.clear()}}}const Hr=new IP;function OP(){const e=Ve(c=>c.setConnectionStatus),t=Ve(c=>c.setConnectionError),[r,n]=E.useState(Hr.getStatus()),[i,a]=E.useState(Hr.getConnectionEpoch());E.useEffect(()=>{Hr.connect(),Hr.startLifecycleListeners();const c=Hr.subscribeStatus((f,u,p)=>{n(f),a(p),e(f),t(u)});return()=>{c(),Hr.stopLifecycleListeners()}},[t,e]);const l=E.useMemo(()=>c=>{Hr.send(c)},[]),s=E.useMemo(()=>Hr.subscribe.bind(Hr),[]),o=E.useMemo(()=>()=>Hr.getConnectionEpoch(),[]);return{status:r,connectionEpoch:i,sendMessage:l,subscribe:s,getConnectionEpoch:o}}const BP=100;function NP({viewport:e,win:t,doc:r}){if(!e)return!1;const n=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+n),l=Math.max(0,a),s=Math.max(0,e.height||0),o=Math.max(0,e.width||0);return r.documentElement.style.setProperty("--keyboard-inset",`${l}px`),r.documentElement.style.setProperty("--viewport-offset-top",`${n}px`),r.documentElement.style.setProperty("--viewport-offset-left",`${i}px`),r.documentElement.style.setProperty("--visual-viewport-height",`${s}px`),r.documentElement.style.setProperty("--visual-viewport-width",`${o}px`),l>BP?r.documentElement.classList.add("keyboard-visible"):r.documentElement.classList.remove("keyboard-visible"),!0}function jP(e){e.documentElement.style.removeProperty("--keyboard-inset"),e.documentElement.style.removeProperty("--viewport-offset-top"),e.documentElement.style.removeProperty("--viewport-offset-left"),e.documentElement.style.removeProperty("--visual-viewport-height"),e.documentElement.style.removeProperty("--visual-viewport-width"),e.documentElement.classList.remove("keyboard-visible")}function FP(){E.useEffect(()=>{const e=window.visualViewport;if(!e)return;let t=null,r=null;const n=()=>{var v;const _=document.activeElement;if(!_)return!1;const y=(v=_.tagName)==null?void 0:v.toLowerCase();return y==="input"||y==="textarea"?!0:!!_.isContentEditable},i=()=>{NP({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!="function"){i();return}t!==null&&window.cancelAnimationFrame(t);const _=performance.now(),y=()=>{i(),performance.now()-_<1500?t=window.requestAnimationFrame(y):t=null};t=window.requestAnimationFrame(y)},l=()=>{if(!n()){o();return}i()},s=()=>{r!==null||typeof window.setInterval!="function"||(r=window.setInterval(l,250),l())},o=()=>{r===null||typeof window.clearInterval!="function"||(window.clearInterval(r),r=null)},c=()=>{n()?(a(),s(),i()):o()},f=()=>{c()},u=()=>{c()},p=()=>{a()};return i(),c(),e.addEventListener("resize",i),e.addEventListener("scroll",i),typeof window.addEventListener=="function"&&(window.addEventListener("resize",i),window.addEventListener("orientationchange",p)),typeof document.addEventListener=="function"&&(document.addEventListener("focusin",f),document.addEventListener("focusout",u),document.addEventListener("focus",f,!0),document.addEventListener("blur",u,!0)),()=>{e.removeEventListener("resize",i),e.removeEventListener("scroll",i),typeof window.removeEventListener=="function"&&(window.removeEventListener("resize",i),window.removeEventListener("orientationchange",p)),typeof document.removeEventListener=="function"&&(document.removeEventListener("focusin",f),document.removeEventListener("focusout",u),document.removeEventListener("focus",f,!0),document.removeEventListener("blur",u,!0)),t!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(t),o(),jP(document)}},[])}function HP(){const[e,t]=E.useState(!1),[r,n]=E.useState(void 0),[i,a]=E.useState(void 0),[l,s]=E.useState(void 0),[o,c]=E.useState(!1),[f,u]=E.useState(null),[p,_]=E.useState(null),y=Ve(J=>J.sessions),v=Ve(J=>J.agentSessions),h=Ve(J=>J.selectedSessionId),m=Ve(J=>J.setSessions),d=Ve(J=>J.setAgentSessions),g=Ve(J=>J.setHostStatuses),w=Ve(J=>J.updateSession),b=Ve(J=>J.setSelectedSessionId),x=Ve(J=>J.hasLoaded),C=Ve(J=>J.connectionStatus),S=Ve(J=>J.connectionError),k=Ve(J=>J.clearExitingSession),L=Ve(J=>J.markSessionExiting),A=Ve(J=>J.setRemoteAllowControl),M=Ve(J=>J.setRemoteAllowAttach),D=Ve(J=>J.setHostLabel),O=Ve(J=>J.hostStatuses),z=Ve(J=>J.remoteAllowControl),F=Ve(J=>J.hostLabel),H=ql(J=>J.theme),I=hC(),R=me(J=>J.defaultProjectDir),P=me(J=>J.commandPresets),N=me(J=>J.defaultPresetId),j=me(J=>J.lastProjectPath),W=me(J=>J.setLastProjectPath),V=me(J=>J.addRecentPath),Z=me(J=>J.shortcutModifier),Q=me(J=>J.sidebarWidth),$=me(J=>J.setSidebarWidth),B=me(J=>J.projectFilters),K=me(J=>J.hostFilters),U=me(J=>J.soundOnPermission),te=me(J=>J.soundOnIdle),{sendMessage:Y,subscribe:ye,connectionEpoch:pe,getConnectionEpoch:ne}=OP();FP(),E.useEffect(()=>{if(typeof document>"u"||!U&&!te)return;let J=!1;const ee=()=>{J&&!J3()||(J=!0,fd())};return document.addEventListener("click",ee,{passive:!0}),document.addEventListener("keydown",ee,{passive:!0}),document.addEventListener("touchstart",ee,{passive:!0}),()=>{document.removeEventListener("click",ee),document.removeEventListener("keydown",ee),document.removeEventListener("touchstart",ee)}},[U,te]);const oe=E.useRef(!1),ce=E.useCallback(J=>{J.preventDefault(),oe.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);E.useEffect(()=>{if(typeof document>"u"||typeof document.addEventListener!="function")return;const J=Be=>{if(!oe.current)return;const q=Be.clientX;$(Math.max(ty,Math.min(ry,q)))},ee=()=>{oe.current&&(oe.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",ee),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",ee)}},[$]),E.useEffect(()=>{const J=ye(ee=>{var Be,q;if(ee.type==="sessions"){const de=Ve.getState().sessions,{soundOnPermission:X,soundOnIdle:_e}=me.getState();if(X||_e)for(const re of ee.sessions){const le=de.find(we=>we.id===re.id);le&&le.status!==re.status&&(le.status!=="permission"&&re.status==="permission"&&X&&pd(),le.status==="working"&&re.status==="waiting"&&_e&&md())}if(ge.current.size>0){const re=ne();for(const[le,we]of ge.current)we.epoch!==re&&ge.current.delete(le)}ge.current.size>0?m(ee.sessions.filter(re=>!ge.current.has(re.id))):m(ee.sessions)}if(ee.type==="host-status"&&g(ee.hosts),ee.type==="server-config"&&(A(ee.remoteAllowControl),M(ee.remoteAllowAttach),D(ee.hostLabel),ee.clientLogLevel&&YR(ee.clientLogLevel)),ee.type==="session-update"){const X=Ve.getState().sessions.find(le=>le.id===ee.session.id),_e=X==null?void 0:X.status,re=ee.session.status;if(w(ee.session),_e){const{soundOnPermission:le,soundOnIdle:we}=me.getState();_e!=="permission"&&re==="permission"&&le&&pd(),_e==="working"&&re==="waiting"&&we&&md()}}if(ee.type==="session-created"){const de=Ve.getState().sessions;de.some(re=>re.id===ee.session.id)||m([ee.session,...de]),b(ee.session.id),V(ee.session.projectPath);const{projectFilters:X,setProjectFilters:_e}=me.getState();X.length>0&&!X.includes(ee.session.projectPath)&&_e([...X,ee.session.projectPath])}if(ee.type==="session-removed"){ge.current.delete(ee.sessionId);const de=Ve.getState().sessions,X=de.filter(_e=>_e.id!==ee.sessionId);X.length!==de.length&&m(X)}if(ee.type==="agent-sessions"&&d(ee.active,ee.inactive),ee.type==="agent-sessions-active"){const de=Ve.getState().agentSessions;d(ee.active,de.inactive)}if(ee.type==="session-orphaned"&&!ee.supersededBy){const de=Ve.getState().sessions,X=de.filter(_e=>{var re;return((re=_e.agentSessionId)==null?void 0:re.trim())!==ee.session.sessionId});X.length!==de.length&&m(X)}if(ee.type==="session-activated"){const de=Ve.getState().sessions.find(X=>X.tmuxWindow===ee.window);de&&w({...de,agentSessionId:ee.session.sessionId,agentSessionName:ee.session.displayName,logFilePath:ee.session.logFilePath,isPinned:ee.session.isPinned,lastUserMessage:ee.session.lastUserMessage??de.lastUserMessage})}if(ee.type==="session-resume-result")if(ee.ok&&ee.session){const de=Ve.getState().sessions;de.some(X=>X.id===ee.session.id)||m([ee.session,...de]),b(ee.session.id)}else ee.ok||(u(`${(Be=ee.error)==null?void 0:Be.code}: ${(q=ee.error)==null?void 0:q.message}`),window.setTimeout(()=>u(null),6e3));if(ee.type==="terminal-error"&&(!ee.sessionId||ee.sessionId===h)&&(u(`${ee.code}: ${ee.message}`),window.setTimeout(()=>u(null),6e3)),ee.type==="terminal-ready"&&ee.sessionId===h&&u(null),ee.type==="error"&&(u(ee.message),window.setTimeout(()=>u(null),6e3)),ee.type==="kill-failed"){const de=ge.current.get(ee.sessionId);if(de){const X=Ve.getState().sessions;X.some(_e=>_e.id===ee.sessionId)||m([de.session,...X]),de.wasSelected&&b(ee.sessionId),ge.current.delete(ee.sessionId)}k(ee.sessionId),u(ee.message),window.setTimeout(()=>u(null),6e3)}ee.type==="session-pin-result"&&!ee.ok&&ee.error&&(u(ee.error),window.setTimeout(()=>u(null),6e3)),ee.type==="session-resurrection-failed"&&SS.add({title:"Session resurrection failed",description:`"${ee.displayName}" could not be resumed: ${ee.error}`,type:"error",timeout:8e3})});return()=>{J()}},[h,V,k,Y,b,m,d,g,A,M,D,ye,w]);const ue=E.useMemo(()=>y.find(J=>J.id===h)||null,[h,y]);E.useEffect(()=>{ue!=null&&ue.projectPath&&!ue.remote&&W(ue.projectPath)},[ue==null?void 0:ue.projectPath,ue==null?void 0:ue.remote,W]);const ve=me(J=>J.sessionSortMode),se=me(J=>J.sessionSortDirection),ae=me(J=>J.manualSessionOrder),fe=E.useMemo(()=>np(y,{mode:ve,direction:se,manualOrder:ae}),[y,ve,se,ae]),ie=E.useMemo(()=>{let J=fe;return B.length>0&&(J=J.filter(ee=>B.includes(ee.projectPath))),K.length>0&&(J=J.filter(ee=>K.includes(ee.host??""))),J},[fe,B,K]);E.useEffect(()=>{h&&ie.length>0&&!ie.some(J=>J.id===h)&&b(ie[0].id)},[h,ie,b]),E.useEffect(()=>{window.matchMedia("(max-width: 767px)").matches&&x&&h===null&&fe.length>0&&b(fe[0].id)},[x,h,fe,b]);const ge=E.useRef(new Map),be=E.useCallback(J=>{const{sessions:ee,selectedSessionId:Be}=Ve.getState(),q=ee.find(de=>de.id===J);q&&ge.current.set(J,{session:q,wasSelected:Be===J,epoch:ne()}),L(J),m(ee.filter(de=>de.id!==J)),Y({type:"session-kill",sessionId:J})},[L,m,Y]);E.useEffect(()=>{const J=ea(Z),ee=Be=>{if(Be.defaultPrevented)return;const q=Be.code,de=WC(Be,J);if(de&&(q==="BracketLeft"||q==="BracketRight")){Be.preventDefault();const X=ie;if(X.length===0)return;const _e=X.findIndex(we=>we.id===h);if(_e===-1){b(X[0].id);return}const le=(_e+(q==="BracketLeft"?-1:1)+X.length)%X.length;b(X[le].id);return}if(de&&q==="KeyN"){Be.preventDefault(),!e&&I&&t(!0);return}if(de&&q==="KeyX"){Be.preventDefault(),h&&!e&&be(h);return}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[e,h,b,ie,be,Z,I]);const Te=()=>I?(n(void 0),a(void 0),s(void 0),t(!0),!0):!1,je=()=>c(!0),He=(J,ee,Be,q)=>{Y({type:"session-create",projectPath:J,name:ee,command:Be,host:q}),q||W(J)},Pe=J=>{Y({type:"session-resume",sessionId:J})},Oe=(J,ee)=>{Y({type:"session-rename",sessionId:J,newName:ee})},ke=E.useCallback(J=>{const ee=y.find(Be=>Be.id===J);ee&&Y({type:"session-create",projectPath:ee.projectPath,command:ee.command||void 0,host:ee.remote&&ee.host?ee.host:void 0})},[y,Y]),Le=E.useCallback((J,ee)=>{Y({type:"session-pin",sessionId:J,isPinned:ee})},[Y]);E.useEffect(()=>{document.documentElement.setAttribute("data-theme",H)},[H]),E.useEffect(()=>{fetch("/api/server-info").then(J=>J.json()).then(J=>_(J)).catch(()=>{})},[]);const Qe=E.useMemo(()=>F?O.filter(J=>J.host!==F):O,[O,F]);return T.jsxs("div",{className:"flex h-full overflow-hidden",children:[T.jsxs("div",{className:"hidden h-full flex-col md:flex md:shrink-0",style:{width:Q},children:[T.jsx(KC,{connectionStatus:C,onNewSession:Te,onOpenSettings:je,tailscaleIp:(p==null?void 0:p.tailscaleIp)??null}),T.jsx(fw,{sessions:y,inactiveSessions:v.inactive,selectedSessionId:h,onSelect:b,onRename:Oe,onResume:Pe,onKill:be,onDuplicate:ke,onSetPinned:Le,loading:!x,error:S||f})]}),T.jsx("div",{className:"hidden md:block w-1 shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-white/10 active:bg-white/20",onMouseDown:ce}),T.jsx(fM,{session:ue,sessions:ie,connectionStatus:C,connectionEpoch:pe,sendMessage:Y,subscribe:ye,onClose:()=>b(null),onSelectSession:b,onNewSession:Te,onKillSession:be,onRenameSession:Oe,onOpenSettings:je,onResumeSession:Pe,onSetPinned:Le,inactiveSessions:v.inactive,loading:!x,error:S||f}),T.jsx(mM,{isOpen:e,onClose:()=>t(!1),onCreate:He,defaultProjectDir:R,commandPresets:P,defaultPresetId:N,lastProjectPath:j,activeProjectPath:ue&&!ue.remote?ue.projectPath:void 0,remoteHosts:Qe,remoteAllowControl:z,initialHost:r,initialPath:i,initialCommand:l}),T.jsx(Z3,{isOpen:o,onClose:()=>c(!1)}),T.jsx(bP,{})]})}const $P="modulepreload",zP=function(e){return"/"+e},Hv={},UP=function(t,r,n){let i=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),s=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=Promise.allSettled(r.map(o=>{if(o=zP(o),o in Hv)return;Hv[o]=!0;const c=o.endsWith(".css"),f=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${f}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":$P,c||(u.as="script"),u.crossOrigin="",u.href=o,s&&u.setAttribute("nonce",s),document.head.appendChild(u),c)return new Promise((p,_)=>{u.addEventListener("load",p),u.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${o}`)))})}))}function a(l){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=l,window.dispatchEvent(s),!s.defaultPrevented)throw l}return i.then(l=>{for(const s of l||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};function WP(e={}){const{immediate:t=!1,onNeedRefresh:r,onOfflineReady:n,onRegistered:i,onRegisteredSW:a,onRegisterError:l}=e;let s,o;const c=async(u=!0)=>{await o};async function f(){if("serviceWorker"in navigator){if(s=await UP(async()=>{const{Workbox:u}=await import("./workbox-window.prod.es5-vqzQaGvo.js");return{Workbox:u}},[]).then(({Workbox:u})=>new u("/sw.js",{scope:"/",type:"classic"})).catch(u=>{l==null||l(u)}),!s)return;s.addEventListener("activated",u=>{(u.isUpdate||u.isExternal)&&window.location.reload()}),s.addEventListener("installed",u=>{u.isUpdate||n==null||n()}),s.register({immediate:t}).then(u=>{a?a("/sw.js",u):i==null||i(u)}).catch(u=>{l==null||l(u)})}}return o=f(),c}Zo()&&document.documentElement.classList.add("ios");$C()&&document.documentElement.classList.add("ios-pwa");WP({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},5*60*1e3),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t.update()}))}});const xS=document.getElementById("root");if(!xS)throw new Error("Root element not found");ey(xS).render(T.jsx(gt.StrictMode,{children:T.jsx(HP,{})}));
|
|
316
|
+
*/var Ec=E,LA=mS;function TA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var RA=typeof Object.is=="function"?Object.is:TA,DA=LA.useSyncExternalStore,MA=Ec.useRef,AA=Ec.useEffect,PA=Ec.useMemo,IA=Ec.useDebugValue;vS.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var a=MA(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=PA(function(){function o(_){if(!c){if(c=!0,f=_,_=n(_),i!==void 0&&l.hasValue){var y=l.value;if(i(y,_))return u=y}return u=_}if(y=u,RA(f,_))return y;var v=n(_);return i!==void 0&&i(y,v)?(f=_,y):(f=_,u=v)}var c=!1,f,u,p=r===void 0?null:r;return[function(){return o(t())},p===null?void 0:function(){return o(p())}]},[t,r,n,i]);var s=DA(e,a[0],a[1]);return AA(function(){l.hasValue=!0,l.value=s},[s]),IA(s),s};gS.exports=vS;var OA=gS.exports;const BA=lp(19),NA=BA?FA:HA;function _S(e,t,r,n,i){return NA(e,t,r,n,i)}function jA(e,t,r,n,i){const a=E.useCallback(()=>t(e.getSnapshot(),r,n,i),[e,t,r,n,i]);return mS.useSyncExternalStore(e.subscribe,a,a)}function FA(e,t,r,n,i){return jA(e,t,r,n,i)}function HA(e,t,r,n,i){return OA.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,a=>t(a,r,n,i))}class $A{constructor(t){rt(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));rt(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const r=this.updateTick;for(const n of this.listeners){if(r!==this.updateTick)return;n(t)}}update(t){for(const r in t)if(!Object.is(this.state[r],t[r])){this.setState({...this.state,...t});return}}set(t,r){Object.is(this.state[t],r)||this.setState({...this.state,[t]:r})}notifyAll(){const t={...this.state};this.setState(t)}use(t,r,n,i){return _S(this,t,r,n,i)}}class zA extends $A{constructor(t,r={},n){super(t),this.context=r,this.selectors=n}useSyncedValue(t,r){E.useDebugValue(t),qt(()=>{this.state[t]!==r&&this.set(t,r)},[t,r])}useSyncedValueWithCleanup(t,r){const n=this;qt(()=>(n.state[t]!==r&&n.set(t,r),()=>{n.set(t,void 0)}),[n,t,r])}useSyncedValues(t){const r=this,n=Object.values(t);qt(()=>{r.update(t)},[r,...n])}useControlledProp(t,r){E.useDebugValue(t);const n=r!==void 0;qt(()=>{n&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})},[t,r,n])}select(t,r,n,i){const a=this.selectors[t];return a(this.state,r,n,i)}useState(t,r,n,i){return E.useDebugValue(t),_S(this,this.selectors[t],r,n,i)}useContextCallback(t,r){E.useDebugValue(t);const n=Yr(r??ur);this.context[t]=n}useStateSetter(t){const r=E.useRef(void 0);return r.current===void 0&&(r.current=n=>{this.set(t,n)}),r.current}observe(t,r){let n;typeof t=="function"?n=t:n=this.selectors[t];let i=n(this.state);return r(i,i,this),this.subscribe(a=>{const l=n(a);if(!Object.is(i,l)){const s=i;i=l,r(l,s,this)}})}}const $a=null;class UA{constructor(){rt(this,"callbacks",[]);rt(this,"callbacksCount",0);rt(this,"nextId",1);rt(this,"startId",1);rt(this,"isScheduled",!1);rt(this,"tick",t=>{var i;this.isScheduled=!1;const r=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let a=0;a<r.length;a+=1)(i=r[a])==null||i.call(r,t)})}request(t){const r=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(t){const r=t-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const za=new UA;class yp{constructor(){rt(this,"currentId",$a);rt(this,"cancel",()=>{this.currentId!==$a&&(za.cancel(this.currentId),this.currentId=$a)});rt(this,"disposeEffect",()=>this.cancel)}static create(){return new yp}static request(t){return za.request(t)}static cancel(t){return za.cancel(t)}request(t){this.cancel(),this.currentId=za.request(()=>{this.currentId=$a,t()})}}function WA(){const e=ks(yp.create).current;return gp(e.disposeEffect),e}const Ui=0;class Go{constructor(){rt(this,"currentId",Ui);rt(this,"clear",()=>{this.currentId!==Ui&&(clearTimeout(this.currentId),this.currentId=Ui)});rt(this,"disposeEffect",()=>this.clear)}static create(){return new Go}start(t,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ui,r()},t)}isStarted(){return this.currentId!==Ui}}function VA(){const e=ks(Go.create).current;return gp(e.disposeEffect),e}let Nv=0;function yS(e){return Nv+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Nv}`}function Js(e){return(e==null?void 0:e.ownerDocument)||document}function Mu(e,t){if(typeof e=="string")return{description:e};if(typeof e=="function"){const r=e(t);return typeof r=="string"?{description:r}:r}return e}const la=typeof navigator<"u",Au=YA(),KA=QA(),GA=JA();typeof CSS>"u"||!CSS.supports||CSS.supports("-webkit-backdrop-filter:none");Au.platform==="MacIntel"&&Au.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(Au.platform);const qA=la&&/apple/i.test(navigator.vendor);la&&KA.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const XA=GA.includes("jsdom/");function YA(){if(!la)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e!=null&&e.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function JA(){if(!la)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:r})=>`${t}/${r}`).join(" "):navigator.userAgent}function QA(){if(!la)return"";const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform??""}function Zl(e){var r;let t=e.activeElement;for(;((r=t==null?void 0:t.shadowRoot)==null?void 0:r.activeElement)!=null;)t=t.shadowRoot.activeElement;return t}function yi(e,t){var n;if(!e||!t)return!1;const r=(n=t.getRootNode)==null?void 0:n.call(t);if(e.contains(t))return!0;if(r&&zM(r)){let i=t;for(;i;){if(e===i)return!0;i=i.parentNode||i.host}}return!1}function wp(e){return"composedPath"in e?e.composedPath()[0]:e.target}function gd(e){if(!e||XA)return!0;try{return e.matches(":focus-visible")}catch{return!0}}const Ua=vA(e=>e.toasts,e=>{const t=new Map;let r=0,n=0;return e.forEach((i,a)=>{const l=i.transitionStatus==="ending";t.set(i.id,{value:i,domIndex:a,visibleIndex:l?-1:r,offsetY:n}),n+=i.height||0,l||(r+=1)}),t}),sn={toasts:Tr(e=>e.toasts),isEmpty:Tr(e=>e.toasts.length===0),toast:Tr(Ua,(e,t)=>{var r;return(r=e.get(t))==null?void 0:r.value}),toastIndex:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.domIndex)??-1}),toastOffsetY:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.offsetY)??0}),toastVisibleIndex:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.visibleIndex)??-1}),hovering:Tr(e=>e.hovering),focused:Tr(e=>e.focused),expanded:Tr(e=>e.hovering||e.focused),expandedOrOutOfFocus:Tr(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Tr(e=>e.prevFocusElement)};class ZA extends zA{constructor(r){super(r,{},sn);rt(this,"timers",new Map);rt(this,"areTimersPaused",!1);rt(this,"setViewport",r=>{this.set("viewport",r)});rt(this,"disposeEffect",()=>()=>{this.timers.forEach(r=>{var n;(n=r.timeout)==null||n.clear()}),this.timers.clear()});rt(this,"addToast",r=>{const{toasts:n,timeout:i,limit:a}=this.state,l=r.id||yS("toast"),s={...r,id:l,transitionStatus:"starting"},o=[s,...n],c=o.filter(u=>u.transitionStatus!=="ending");if(c.length>a){const u=c.length-a,p=c.slice(-u),_=new Set(p.map(y=>y.id));this.setToasts(o.map(y=>{const v=_.has(y.id);return y.limited!==v?{...y,limited:v}:y}))}else this.setToasts(o.map(u=>u.limited?{...u,limited:!1}:u));const f=s.timeout??i;return s.type!=="loading"&&f>0&&this.scheduleTimer(l,f,()=>this.closeToast(l)),sn.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),l});rt(this,"updateToast",(r,n)=>{this.updateToastInternal(r,n)});rt(this,"updateToastInternal",(r,n)=>{var v,h;const{timeout:i,toasts:a}=this.state,l=sn.toast(this.state,r)??null;if(!l||l.transitionStatus==="ending")return;const s={...l,...n};this.setToasts(a.map(m=>m.id===r?{...m,...n}:m));const o=s.timeout??i,c=(l==null?void 0:l.timeout)??i,f=Object.hasOwn(n,"timeout"),u=s.transitionStatus!=="ending"&&s.type!=="loading"&&o>0,p=this.timers.has(r),_=c!==o,y=(l==null?void 0:l.type)==="loading";if(!u&&p){const m=this.timers.get(r);(v=m==null?void 0:m.timeout)==null||v.clear(),this.timers.delete(r);return}if(u&&(!p||_||f||y)){const m=this.timers.get(r);m&&((h=m.timeout)==null||h.clear(),this.timers.delete(r)),this.scheduleTimer(r,o,()=>this.closeToast(r)),sn.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}});rt(this,"closeToast",r=>{var c;const n=sn.toast(this.state,r);(c=n==null?void 0:n.onClose)==null||c.call(n);const{limit:i,toasts:a}=this.state;let l=0;const s=a.map(f=>{if(f.id===r)return{...f,transitionStatus:"ending",height:0};if(f.transitionStatus==="ending")return f;const u=l>=i;return l+=1,f.limited!==u?{...f,limited:u}:f}),o=this.timers.get(r);o&&o.timeout&&(o.timeout.clear(),this.timers.delete(r)),this.handleFocusManagement(r),this.setToasts(s)});rt(this,"promiseToast",(r,n)=>{const i=Mu(n.loading),a=this.addToast({...i,type:"loading"}),l=r.then(s=>{const o=Mu(n.success,s);return this.updateToast(a,{...o,type:"success",timeout:o.timeout}),s}).catch(s=>{const o=Mu(n.error,s);return this.updateToast(a,{...o,type:"error",timeout:o.timeout}),Promise.reject(s)});return{}.hasOwnProperty.call(n,"setPromise")&&n.setPromise(l),l});rt(this,"handleDocumentPointerDown",r=>{if(r.pointerType!=="touch")return;const n=wp(r);yi(this.state.viewport,n)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))})}setFocused(r){this.set("focused",r)}setHovering(r){this.set("hovering",r)}setIsWindowFocused(r){this.set("isWindowFocused",r)}setPrevFocusElement(r){this.set("prevFocusElement",r)}removeToast(r){var l;const n=sn.toastIndex(this.state,r);if(n===-1)return;const i=this.state.toasts[n];(l=i==null?void 0:i.onRemove)==null||l.call(i);const a=[...this.state.toasts];a.splice(n,1),this.setToasts(a)}pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(r=>{if(r.timeout){r.timeout.clear();const n=Date.now()-r.start,i=r.delay-n;r.remaining=i>0?i:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((r,n)=>{r.remaining=r.remaining>0?r.remaining:r.delay,r.timeout??(r.timeout=Go.create()),r.timeout.start(r.remaining,()=>{this.timers.delete(n),r.callback()}),r.start=Date.now()}))}restoreFocusToPrevElement(){var r;(r=this.state.prevFocusElement)==null||r.focus({preventScroll:!0})}scheduleTimer(r,n,i){const a=Date.now(),l=!sn.expandedOrOutOfFocus(this.state),s=l?Go.create():void 0;s==null||s.start(n,()=>{this.timers.delete(r),i()}),this.timers.set(r,{timeout:s,start:l?a:0,delay:n,remaining:n,callback:i})}setToasts(r){const n={toasts:r};r.length===0&&(n.hovering=!1,n.focused=!1),this.update(n)}handleFocusManagement(r){var o,c;const n=Zl(Js(this.state.viewport));if(!this.state.viewport||!yi(this.state.viewport,n)||!gd(n))return;const i=sn.toasts(this.state),a=sn.toastIndex(this.state,r);let l=null,s=a+1;for(;s<i.length;){if(i[s].transitionStatus!=="ending"){l=i[s];break}s+=1}if(!l)for(s=a-1;s>=0;){if(i[s].transitionStatus!=="ending"){l=i[s];break}s-=1}l?(c=(o=l.ref)==null?void 0:o.current)==null||c.focus():this.restoreFocusToPrevElement()}}const eP=function(t){const{children:r,timeout:n=5e3,limit:i=3,toastManager:a}=t,l=ks(()=>new ZA({timeout:n,limit:i,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return gp(l.disposeEffect),E.useEffect(function(){return a?a[" subscribe"](({action:c,options:f})=>{const u=f.id;c==="promise"&&f.promise?l.promiseToast(f.promise,f):c==="update"&&u?l.updateToast(u,f):c==="close"&&u?l.closeToast(u):l.addToast(f)}):void 0},[l,n,a]),l.useSyncedValues({timeout:n,limit:i}),T.jsx(vp.Provider,{value:l,children:r})},Pu=E.forwardRef(function(t,r){const[n,i]=E.useState();qt(()=>{qA&&i("button")},[]);const a={tabIndex:0,role:n};return T.jsx("span",{...t,ref:r,style:ap,"aria-hidden":n?void 0:!0,...a,"data-base-ui-focus-guard":""})});let tP=function(e){return e.frontmostHeight="--toast-frontmost-height",e}({});const rP=E.forwardRef(function(t,r){var M;const{render:n,className:i,children:a,...l}=t,s=_p(),o=VA(),c=E.useRef(!1),f=E.useRef(!1),u=s.useState("isEmpty"),p=s.useState("toasts"),_=s.useState("focused"),y=s.useState("expanded"),v=s.useState("prevFocusElement"),h=((M=p[0])==null?void 0:M.height)??0,m=E.useMemo(()=>p.some(D=>D.transitionStatus==="ending"),[p]);E.useEffect(()=>{const D=s.state.viewport;if(!D)return;function O(F){u||F.key==="F6"&&F.target!==D&&(F.preventDefault(),s.setPrevFocusElement(Zl(Js(D))),D==null||D.focus({preventScroll:!0}),s.pauseTimers(),s.setFocused(!0))}const z=Ko(D);return z.addEventListener("keydown",O),()=>{z.removeEventListener("keydown",O)}},[s,u]),E.useEffect(()=>{const D=s.state.viewport;if(!D||u)return;const O=Ko(D);function z(H){H.target===O&&(s.setIsWindowFocused(!1),s.pauseTimers())}function F(H){if(H.relatedTarget||H.target===O)return;const I=wp(H),R=Zl(Js(D));(!yi(D,I)||!gd(R))&&s.resumeTimers(),o.start(0,()=>s.setIsWindowFocused(!0))}return O.addEventListener("blur",z,!0),O.addEventListener("focus",F,!0),()=>{O.removeEventListener("blur",z,!0),O.removeEventListener("focus",F,!0)}},[s,o,u]),E.useEffect(()=>{const D=s.state.viewport;if(!D||u)return;const O=Js(D);return O.addEventListener("pointerdown",s.handleDocumentPointerDown,!0),()=>{O.removeEventListener("pointerdown",s.handleDocumentPointerDown,!0)}},[u,s]);function d(D){var z,F,H;const O=s.state.viewport;O&&(c.current=!0,D.relatedTarget===O?(H=(F=(z=p[0])==null?void 0:z.ref)==null?void 0:F.current)==null||H.focus():s.restoreFocusToPrevElement())}function g(D){D.key==="Tab"&&D.shiftKey&&D.target===s.state.viewport&&(D.preventDefault(),s.restoreFocusToPrevElement(),s.resumeTimers())}E.useEffect(()=>{!s.state.isWindowFocused||m||!f.current||(s.resumeTimers(),s.setHovering(!1),f.current=!1)},[m,s]);function w(){s.pauseTimers(),s.setHovering(!0),f.current=!1}function b(){m?f.current=!0:(s.resumeTimers(),s.setHovering(!1))}function x(){if(c.current){c.current=!1;return}_||gd(Js(s.state.viewport).activeElement)&&(s.setFocused(!0),s.pauseTimers())}function C(D){!_||yi(s.state.viewport,D.relatedTarget)||(s.setFocused(!1),s.resumeTimers())}const S={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:w,onMouseMove:w,onMouseLeave:b,onFocus:x,onBlur:C,onKeyDown:g,onClick:x},k={expanded:y},L=Ls("div",t,{ref:[r,s.setViewport],state:k,props:[S,{style:{[tP.frontmostHeight]:h?`${h}px`:void 0}},l,{children:T.jsxs(E.Fragment,{children:[!u&&v&&T.jsx(Pu,{onFocus:d}),a,!u&&v&&T.jsx(Pu,{onFocus:d})]})}]}),A=E.useMemo(()=>p.filter(D=>D.priority==="high"),[p]);return T.jsxs(E.Fragment,{children:[!u&&v&&T.jsx(Pu,{onFocus:d}),L,!_&&A.length>0&&T.jsx("div",{style:ap,children:A.map(D=>T.jsxs("div",{role:"alert","aria-atomic":!0,children:[T.jsx("div",{children:D.title}),T.jsx("div",{children:D.description})]},D.id))})]})});function nP(e){return lp(19)?e:e?"true":void 0}const wS=E.createContext(void 0);function Sp(){const e=E.useContext(wS);if(!e)throw new Error(Jr(66));return e}let xp=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const sP={[xp.startingStyle]:""},iP={[xp.endingStyle]:""},oP={transitionStatus(e){return e==="starting"?sP:e==="ending"?iP:null}};function aP(e){return e==null?e:"current"in e?e.current:e}function lP(e,t=!1,r=!0){const n=WA();return Yr((i,a=null)=>{n.cancel();function l(){hn.flushSync(i)}const s=aP(e);if(s==null)return;const o=s;if(typeof o.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{let u=function(){const _=xp.startingStyle;if(!o.hasAttribute(_)){n.request(p);return}const y=new MutationObserver(()=>{o.hasAttribute(_)||(y.disconnect(),p())});y.observe(o,{attributes:!0,attributeFilter:[_]}),a==null||a.addEventListener("abort",()=>y.disconnect(),{once:!0})},p=function(){Promise.all(o.getAnimations().map(_=>_.finished)).then(()=>{a!=null&&a.aborted||l()}).catch(()=>{const _=o.getAnimations();if(r){if(a!=null&&a.aborted)return;l()}else _.length>0&&_.some(y=>y.pending||y.playState!=="finished")&&p()})};var c=u,f=p;if(t){u();return}n.request(p)}})}function cP(e){const{enabled:t=!0,open:r,ref:n,onComplete:i}=e,a=Yr(i),l=lP(n,r,!1);E.useEffect(()=>{if(!t)return;const s=new AbortController;return l(a,s.signal),()=>{s.abort()}},[t,r,a,l])}let ss=function(e){return e.index="--toast-index",e.offsetY="--toast-offset-y",e.height="--toast-height",e.swipeMovementX="--toast-swipe-movement-x",e.swipeMovementY="--toast-swipe-movement-y",e}({});const uP={...oP,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},Wi=40,hP=10,En=.5,dP=1;function jv(e,t,r){switch(e){case"up":return-r;case"down":return r;case"left":return-t;case"right":return t;default:return 0}}function fP(e){const r=window.getComputedStyle(e).transform;let n=0,i=0,a=1;if(r&&r!=="none"){const l=r.match(/matrix(?:3d)?\(([^)]+)\)/);if(l){const s=l[1].split(", ").map(parseFloat);s.length===6?(n=s[4],i=s[5],a=Math.sqrt(s[0]*s[0]+s[1]*s[1])):s.length===16&&(n=s[12],i=s[13],a=s[0])}}return{x:n,y:i,scale:a}}const pP=E.forwardRef(function(t,r){var ve;const{toast:n,render:i,className:a,swipeDirection:l=["down","right"],...s}=t,o=((ve=n.positionerProps)==null?void 0:ve.anchor)!==void 0;let c=[];o||(c=Array.isArray(l)?l:[l]);const f=c.length>0,u=_p(),[p,_]=E.useState(void 0),[y,v]=E.useState(!1),[h,m]=E.useState(!1),[d,g]=E.useState(!1),[w,b]=E.useState({x:0,y:0}),[x,C]=E.useState({x:0,y:0,scale:1}),[S,k]=E.useState(),[L,A]=E.useState(),[M,D]=E.useState(null),O=E.useRef(null),z=E.useRef({x:0,y:0}),F=E.useRef({x:0,y:0,scale:1}),H=E.useRef(void 0),I=E.useRef(0),R=E.useRef(!1),P=E.useRef({x:0,y:0}),N=E.useRef(!1),j=u.useState("toastIndex",n.id),W=u.useState("toastVisibleIndex",n.id),V=u.useState("toastOffsetY",n.id),Z=u.useState("focused"),Q=u.useState("expanded");cP({open:n.transitionStatus!=="ending",ref:O,onComplete(){n.transitionStatus==="ending"&&u.removeToast(n.id)}});const $=Yr((se=!1)=>{const ae=O.current;if(!ae)return;const fe=ae.style.height;ae.style.height="auto";const ie=ae.offsetHeight;ae.style.height=fe;function ge(){u.updateToastInternal(n.id,{ref:O,height:ie,...n.transitionStatus==="starting"?{transitionStatus:void 0}:{}})}se?hn.flushSync(ge):ge()});qt($,[$]);function B(se,ae){let fe=se,ie=ae;return!c.includes("left")&&!c.includes("right")?fe=se>0?se**En:-(Math.abs(se)**En):(!c.includes("right")&&se>0&&(fe=se**En),!c.includes("left")&&se<0&&(fe=-(Math.abs(se)**En))),!c.includes("up")&&!c.includes("down")?ie=ae>0?ae**En:-(Math.abs(ae)**En):(!c.includes("down")&&ae>0&&(ie=ae**En),!c.includes("up")&&ae<0&&(ie=-(Math.abs(ae)**En))),{x:fe,y:ie}}function K(se){var ie;if(se.button!==0)return;se.pointerType==="touch"&&u.pauseTimers();const ae=wp(se.nativeEvent);if(!(ae&&ae.closest('button,a,input,textarea,[role="button"],[data-swipe-ignore]'))){if(R.current=!1,H.current=void 0,I.current=0,z.current={x:se.clientX,y:se.clientY},P.current=z.current,O.current){const ge=fP(O.current);F.current=ge,C(ge),b({x:ge.x,y:ge.y})}u.setHovering(!0),v(!0),m(!1),D(null),N.current=!0,(ie=O.current)==null||ie.setPointerCapture(se.pointerId)}}function U(se){if(!y)return;se.preventDefault(),N.current&&(z.current={x:se.clientX,y:se.clientY},N.current=!1);const{clientY:ae,clientX:fe,movementX:ie,movementY:ge}=se;(ge<0&&ae>P.current.y||ge>0&&ae<P.current.y)&&(P.current={x:P.current.x,y:ae}),(ie<0&&fe>P.current.x||ie>0&&fe<P.current.x)&&(P.current={x:fe,y:P.current.y});const be=fe-z.current.x,Te=ae-z.current.y,je=ae-P.current.y,He=fe-P.current.x;if(!h&&Math.sqrt(be*be+Te*Te)>=dP&&(m(!0),M===null)){const J=c.includes("left")||c.includes("right"),ee=c.includes("up")||c.includes("down");if(J&&ee){const Be=Math.abs(be),q=Math.abs(Te);D(Be>q?"horizontal":"vertical")}}let Pe;if(!H.current)M==="vertical"?Te>0?Pe="down":Te<0&&(Pe="up"):M==="horizontal"?be>0?Pe="right":be<0&&(Pe="left"):Math.abs(be)>=Math.abs(Te)?Pe=be>0?"right":"left":Pe=Te>0?"down":"up",Pe&&c.includes(Pe)&&(H.current=Pe,I.current=jv(Pe,be,Te),_(Pe));else{const Qe=H.current,J=jv(Qe,He,je);J>Wi?(R.current=!1,_(Qe)):!(c.includes("left")&&c.includes("right"))&&!(c.includes("up")&&c.includes("down"))&&I.current-J>=hP&&(R.current=!0)}const Oe=B(be,Te);let ke=F.current.x,Le=F.current.y;M==="horizontal"?(c.includes("left")||c.includes("right"))&&(ke+=Oe.x):(M==="vertical"||(c.includes("left")||c.includes("right"))&&(ke+=Oe.x),(c.includes("up")||c.includes("down"))&&(Le+=Oe.y)),b({x:ke,y:Le})}function te(se){var be;if(!y)return;if(v(!1),m(!1),D(null),(be=O.current)==null||be.releasePointerCapture(se.pointerId),R.current){b({x:x.x,y:x.y}),_(void 0);return}let ae=!1;const fe=w.x-x.x,ie=w.y-x.y;let ge;for(const Te of c){switch(Te){case"right":fe>Wi&&(ae=!0,ge="right");break;case"left":fe<-Wi&&(ae=!0,ge="left");break;case"down":ie>Wi&&(ae=!0,ge="down");break;case"up":ie<-Wi&&(ae=!0,ge="up");break}if(ae)break}ae?(_(ge),g(!0),u.closeToast(n.id)):(b({x:x.x,y:x.y}),_(void 0))}function Y(se){if(se.key==="Escape"){if(!O.current||!yi(O.current,Zl(Js(O.current))))return;u.closeToast(n.id)}}E.useEffect(()=>{if(!f)return;const se=O.current;if(!se)return;function ae(fe){yi(se,fe.target)&&fe.preventDefault()}return se.addEventListener("touchmove",ae,{passive:!1}),()=>{se.removeEventListener("touchmove",ae)}},[f]);function ye(){if(!y&&w.x===x.x&&w.y===x.y&&!d)return{[ss.swipeMovementX]:"0px",[ss.swipeMovementY]:"0px"};const se=w.x-x.x,ae=w.y-x.y;return{transition:y?"none":void 0,transform:y?`translateX(${w.x}px) translateY(${w.y}px) scale(${x.scale})`:void 0,[ss.swipeMovementX]:`${se}px`,[ss.swipeMovementY]:`${ae}px`}}const pe=n.priority==="high",ne={role:pe?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":S,"aria-describedby":L,"aria-hidden":pe&&!Z?!0:void 0,onPointerDown:f?K:void 0,onPointerMove:f?U:void 0,onPointerUp:f?te:void 0,onKeyDown:Y,inert:nP(n.limited),style:{...ye(),[ss.index]:n.transitionStatus==="ending"?j:W,[ss.offsetY]:`${V}px`,[ss.height]:n.height?`${n.height}px`:void 0}},oe=E.useMemo(()=>({rootRef:O,toast:n,titleId:S,setTitleId:k,descriptionId:L,setDescriptionId:A,swiping:y,swipeDirection:p,recalculateHeight:$,index:j,visibleIndex:W,expanded:Q}),[n,S,L,y,p,$,j,W,Q]),ce={transitionStatus:n.transitionStatus,expanded:Q,limited:n.limited||!1,type:n.type,swiping:oe.swiping,swipeDirection:oe.swipeDirection},ue=Ls("div",t,{ref:[r,oe.rootRef],state:ce,stateAttributesMapping:uP,props:[ne,s]});return T.jsx(wS.Provider,{value:oe,children:ue})}),mP=E.forwardRef(function(t,r){const{render:n,className:i,id:a,children:l,...s}=t,{toast:o,setDescriptionId:c}=Sp(),f=l??o.description,u=!!f,p=up(a);qt(()=>{if(u)return c(p),()=>{c(void 0)}},[u,p,c]);const _={type:o.type},y=Ls("p",t,{ref:r,state:_,props:{...s,id:p,children:f}});return u?y:null}),gP=E.forwardRef(function(t,r){const{render:n,className:i,id:a,children:l,...s}=t,{toast:o,setTitleId:c}=Sp(),f=l??o.title,u=!!f,p=up(a);qt(()=>{if(u)return c(p),()=>{c(void 0)}},[u,p,c]);const _={type:o.type},y=Ls("h2",t,{ref:r,state:_,props:{...s,id:p,children:f}});return u?y:null}),vP=E.forwardRef(function(t,r){const{render:n,className:i,disabled:a,nativeButton:l=!0,...s}=t,o=_p(),{toast:c}=Sp(),f=o.useState("expanded"),[u,p]=E.useState(!1),{getButtonProps:_,buttonRef:y}=Vw({disabled:a,native:l}),v={type:c.type};return Ls("button",t,{ref:[r,y],state:v,props:[{"aria-hidden":!f&&!u,onClick(){o.closeToast(c.id)},onFocus(){p(!0)},onBlur(){p(!1)}},s,_]})});function _P(){const e=E.useContext(vp);if(!e)throw new Error(Jr(73));const t=e.useState("toasts");return E.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function yP(){const e=new Set;function t(r){e.forEach(n=>n(r))}return{" subscribe":function(n){return e.add(n),()=>{e.delete(n)}},add(r){const n=r.id||yS("toast"),i={...r,id:n,transitionStatus:"starting"};return t({action:"add",options:i}),n},close(r){t({action:"close",options:{id:r}})},update(r,n){t({action:"update",options:{...n,id:r}})},promise(r,n){let i=r;return t({action:"promise",options:{...n,promise:r,setPromise(a){i=a}}}),i}}}const wP=5e3,SS=yP();function SP({toast:e}){return T.jsxs(pP,{toast:e,className:Yl("relative flex w-80 items-start gap-3 border bg-elevated p-4 shadow-lg","data-[swipe=move]:translate-x-[var(--toast-swipe-move-x)]","data-[ending-style]:translate-x-[var(--toast-swipe-end-x)]","data-[ending-style]:opacity-0","data-[starting-style]:translate-y-2 data-[starting-style]:opacity-0","transition-all duration-200",e.type==="error"&&"border-error/50",e.type==="success"&&"border-approval/50",(!e.type||e.type==="info")&&"border-border"),children:[T.jsxs("div",{className:"flex-1 min-w-0",children:[T.jsx(gP,{className:Yl("text-sm font-medium",e.type==="error"&&"text-error",e.type==="success"&&"text-approval",(!e.type||e.type==="info")&&"text-primary"),children:e.title}),e.description&&T.jsx(mP,{className:"mt-1 text-xs text-muted line-clamp-2",children:e.description})]}),T.jsx(vP,{className:"shrink-0 text-muted hover:text-primary transition-colors","aria-label":"Close",children:T.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[T.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),T.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function xP(){const{toasts:e}=_P();return T.jsx(T.Fragment,{children:e.map(t=>T.jsx(SP,{toast:t},t.id))})}function bP(){return T.jsxs(eP,{timeout:wP,toastManager:SS,children:[T.jsx(xP,{}),T.jsx(rP,{className:"fixed bottom-4 right-4 z-[100] flex flex-col gap-2"})]})}const Fv=["CONNECTING","OPEN","CLOSING","CLOSED"],CP=3e3,EP=8e3,kP=15e3,LP=5e3,Iu=2e4,TP=1e4,RP=1500,DP=5e3,MP=750,AP=4,PP=5e3;class IP{constructor(){this.ws=null,this.listeners=new Set,this.statusListeners=new Set,this.status="connecting",this.error=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.connectTimer=null,this.manualClose=!1,this.lastTick=Date.now(),this.wakeCheckInterval=null,this.lifecycleStarted=!1,this.heartbeatTimer=null,this.pongTimer=null,this.lastForceReconnectTs=0,this.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{var t;if(Ge("ws_visibility",{state:document.visibilityState,...this.wsSnap()},"info"),document.visibilityState==="visible"){const r=Date.now(),n=r-this.lastTick;this.lastTick=r,Ge("ws_resume",{gapMs:n,...this.wsSnap()},"info"),((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?this.verifyConnection():this.forceReconnect("visibilitychange",!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)},this.onPageShow=t=>{Ge("ws_pageshow",{persisted:t.persisted,...this.wsSnap()},"info"),t.persisted&&(this.lastTick=Date.now(),this.forceReconnect("pageshow",!0))}}wsSnap(){return{status:this.status,ws:this.ws?Fv[this.ws.readyState]:null,attempt:this.reconnectAttempts,failures:this.consecutiveFailures,leaked:this.leakedSockets.size,online:typeof navigator<"u"?navigator.onLine:void 0,verifying:this.verifyTimer!==null,buffered:this.ws?this.ws.bufferedAmount:void 0}}connect(){if(this.ws){const a=this.ws.readyState===WebSocket.OPEN;if(a&&this.status==="connected"){Ge("ws_connect_skip",{reason:"already_open",...this.wsSnap()});return}Ge("ws_connect_destroy_zombie",{reason:a?"open_desynced":"not_open",...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus("connecting");const r=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`;Ge("ws_connect",{url:r,resume:this.isResumeAttempt,...this.wsSnap()},"info");const n=new WebSocket(r);this.ws=n,this.leakedSockets.add(n);const i=this.isResumeAttempt?EP:CP;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{if(this.ws!==n)return;this.connectTimer=null,n.readyState===WebSocket.OPEN&&this.status==="connected"||(Ge("ws_connect_timeout",{wsState:Fv[n.readyState],managerStatus:this.status,timeoutMs:i,...this.wsSnap()},"info"),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect())},i),n.onopen=()=>{if(this.ws!==n){Ge("ws_onopen_stale",this.wsSnap(),"info");return}Ge("ws_onopen",this.wsSnap(),"info"),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.connectionEpoch+=1,this.leakedSockets.delete(n),this.setStatus("connected"),this.startHeartbeat()},n.onmessage=a=>{try{const l=a.data,s=performance.now(),o=JSON.parse(l),c=performance.now()-s,f=o;if(f._parseMs=Math.round(c),f._rawLength=l.length,o.type==="pong"){o.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),Ge("ws_verify_ok",this.wsSnap(),"info"),this.startHeartbeat(DP)));return}this.listeners.forEach(u=>u(o))}catch{}},n.onerror=()=>{this.ws===n&&(Ge("ws_onerror",this.wsSnap(),"info"),this.clearConnectTimer())},n.onclose=a=>{if(this.ws!==n){Ge("ws_onclose_stale",{code:a.code,...this.wsSnap()},"info");return}Ge("ws_onclose",{code:a.code,reason:a.reason,clean:a.wasClean,...this.wsSnap()},"info"),this.clearConnectTimer(),this.cancelVerify(),this.consecutiveFailures+=1,this.ws=null,this.manualClose?this.setStatus("disconnected"):this.scheduleReconnect()}}disconnect(){this.manualClose=!0,this.clearConnectTimer(),this.cancelVerify(),this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.destroySocket(),this.setStatus("disconnected")}startLifecycleListeners(){this.lifecycleStarted||typeof document>"u"||typeof window>"u"||(this.lifecycleStarted=!0,document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pageshow",this.onPageShow),this.lastTick=Date.now(),this.wakeCheckInterval=window.setInterval(()=>{const t=Date.now(),r=t-this.lastTick;this.isHidden()||(r>kP&&(Ge("ws_time_jump",{gapMs:r,...this.wsSnap()},"info"),this.forceReconnect("time_jump",!0)),this.lastTick=t)},LP))}stopLifecycleListeners(){this.lifecycleStarted&&(this.lifecycleStarted=!1,document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("pageshow",this.onPageShow),this.wakeCheckInterval!==null&&(window.clearInterval(this.wakeCheckInterval),this.wakeCheckInterval=null))}send(t){var r;if(((r=this.ws)==null?void 0:r.readyState)!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(t)),!0}catch(n){return Ge("ws_send_error",{messageType:t.type,error:n instanceof Error?n.message:String(n),...this.wsSnap()},"info"),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeStatus(t){return this.statusListeners.add(t),t(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(t)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;const t=this.pingSeq,r=this.ws;if(Ge("ws_verify",{seq:t,...this.wsSnap()},"info"),!this.send({type:"ping",seq:t})){Ge("ws_verify_send_fail",this.wsSnap(),"info"),this.forceReconnect("verify_send_fail",!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===r&&(Ge("ws_verify_timeout",this.wsSnap(),"info"),this.forceReconnect("verify_timeout",!0))},RP)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(t="unknown",r=!1){var a;if(this.manualClose){Ge("ws_force_skip",{trigger:t,reason:"manual_close"});return}const n=Date.now(),i=r?200:500;if(n-this.lastForceReconnectTs<i){Ge("ws_force_skip",{trigger:t,reason:"debounce",force:r});return}if(!r&&((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN&&this.status==="connected"){Ge("ws_force_skip",{trigger:t,reason:"already_connected"});return}this.lastForceReconnectTs=n,Ge("ws_force_reconnect",{trigger:t,force:r,...this.wsSnap()},"info"),this.reconnectAttempts=0,this.consecutiveFailures=0,this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.destroySocket(),r?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus("reconnecting"),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},MP)):this.connect()}startHeartbeat(t){this.stopHeartbeat();const r=()=>{var n;((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:"ping",seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,Ge("ws_pong_timeout",this.wsSnap(),"info"),this.destroySocket(),this.scheduleReconnect()},TP)))};t!==void 0&&t<Iu?this.heartbeatTimer=window.setTimeout(()=>{r(),this.heartbeatTimer=window.setInterval(r,Iu)},t):this.heartbeatTimer=window.setInterval(r,Iu)}stopHeartbeat(){this.heartbeatTimer!==null&&(window.clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongTimer()}clearPongTimer(){this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}setStatus(t,r=null){this.status=t,this.error=r,this.statusListeners.forEach(n=>n(t,r,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){Ge("ws_schedule_skip",{reason:"hidden",...this.wsSnap()}),this.setStatus("reconnecting");return}if(this.consecutiveFailures>=AP){Ge("ws_stall_detected",this.wsSnap(),"info"),this.purgeLeakedSockets(),this.consecutiveFailures=0,this.reconnectAttempts=0,this.isResumeAttempt=!0,this.setStatus("reconnecting"),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},PP);return}this.reconnectAttempts+=1;const t=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);Ge("ws_schedule_reconnect",{delay:t,...this.wsSnap()}),this.setStatus("reconnecting"),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}isHidden(){return typeof document<"u"&&document.visibilityState==="hidden"}clearConnectTimer(){this.connectTimer&&(window.clearTimeout(this.connectTimer),this.connectTimer=null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;const t=this.ws;this.ws=null,this.leakedSockets.add(t),t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){Ge("ws_purge_leaked",{count:this.leakedSockets.size},"info");for(const t of this.leakedSockets)try{t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,t.close()}catch{}this.leakedSockets.clear()}}}const Hr=new IP;function OP(){const e=Ve(c=>c.setConnectionStatus),t=Ve(c=>c.setConnectionError),[r,n]=E.useState(Hr.getStatus()),[i,a]=E.useState(Hr.getConnectionEpoch());E.useEffect(()=>{Hr.connect(),Hr.startLifecycleListeners();const c=Hr.subscribeStatus((f,u,p)=>{n(f),a(p),e(f),t(u)});return()=>{c(),Hr.stopLifecycleListeners()}},[t,e]);const l=E.useMemo(()=>c=>{Hr.send(c)},[]),s=E.useMemo(()=>Hr.subscribe.bind(Hr),[]),o=E.useMemo(()=>()=>Hr.getConnectionEpoch(),[]);return{status:r,connectionEpoch:i,sendMessage:l,subscribe:s,getConnectionEpoch:o}}const BP=100;function NP({viewport:e,win:t,doc:r}){if(!e)return!1;const n=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+n),l=Math.max(0,a),s=Math.max(0,e.height||0),o=Math.max(0,e.width||0);return r.documentElement.style.setProperty("--keyboard-inset",`${l}px`),r.documentElement.style.setProperty("--viewport-offset-top",`${n}px`),r.documentElement.style.setProperty("--viewport-offset-left",`${i}px`),r.documentElement.style.setProperty("--visual-viewport-height",`${s}px`),r.documentElement.style.setProperty("--visual-viewport-width",`${o}px`),l>BP?r.documentElement.classList.add("keyboard-visible"):r.documentElement.classList.remove("keyboard-visible"),!0}function jP(e){e.documentElement.style.removeProperty("--keyboard-inset"),e.documentElement.style.removeProperty("--viewport-offset-top"),e.documentElement.style.removeProperty("--viewport-offset-left"),e.documentElement.style.removeProperty("--visual-viewport-height"),e.documentElement.style.removeProperty("--visual-viewport-width"),e.documentElement.classList.remove("keyboard-visible")}function FP(){E.useEffect(()=>{const e=window.visualViewport;if(!e)return;let t=null,r=null;const n=()=>{var v;const _=document.activeElement;if(!_)return!1;const y=(v=_.tagName)==null?void 0:v.toLowerCase();return y==="input"||y==="textarea"?!0:!!_.isContentEditable},i=()=>{NP({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!="function"){i();return}t!==null&&window.cancelAnimationFrame(t);const _=performance.now(),y=()=>{i(),performance.now()-_<1500?t=window.requestAnimationFrame(y):t=null};t=window.requestAnimationFrame(y)},l=()=>{if(!n()){o();return}i()},s=()=>{r!==null||typeof window.setInterval!="function"||(r=window.setInterval(l,250),l())},o=()=>{r===null||typeof window.clearInterval!="function"||(window.clearInterval(r),r=null)},c=()=>{n()?(a(),s(),i()):o()},f=()=>{c()},u=()=>{c()},p=()=>{a()};return i(),c(),e.addEventListener("resize",i),e.addEventListener("scroll",i),typeof window.addEventListener=="function"&&(window.addEventListener("resize",i),window.addEventListener("orientationchange",p)),typeof document.addEventListener=="function"&&(document.addEventListener("focusin",f),document.addEventListener("focusout",u),document.addEventListener("focus",f,!0),document.addEventListener("blur",u,!0)),()=>{e.removeEventListener("resize",i),e.removeEventListener("scroll",i),typeof window.removeEventListener=="function"&&(window.removeEventListener("resize",i),window.removeEventListener("orientationchange",p)),typeof document.removeEventListener=="function"&&(document.removeEventListener("focusin",f),document.removeEventListener("focusout",u),document.removeEventListener("focus",f,!0),document.removeEventListener("blur",u,!0)),t!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(t),o(),jP(document)}},[])}function HP(){const[e,t]=E.useState(!1),[r,n]=E.useState(void 0),[i,a]=E.useState(void 0),[l,s]=E.useState(void 0),[o,c]=E.useState(!1),[f,u]=E.useState(null),[p,_]=E.useState(null),y=Ve(J=>J.sessions),v=Ve(J=>J.agentSessions),h=Ve(J=>J.selectedSessionId),m=Ve(J=>J.setSessions),d=Ve(J=>J.setAgentSessions),g=Ve(J=>J.setHostStatuses),w=Ve(J=>J.updateSession),b=Ve(J=>J.setSelectedSessionId),x=Ve(J=>J.hasLoaded),C=Ve(J=>J.connectionStatus),S=Ve(J=>J.connectionError),k=Ve(J=>J.clearExitingSession),L=Ve(J=>J.markSessionExiting),A=Ve(J=>J.setRemoteAllowControl),M=Ve(J=>J.setRemoteAllowAttach),D=Ve(J=>J.setHostLabel),O=Ve(J=>J.hostStatuses),z=Ve(J=>J.remoteAllowControl),F=Ve(J=>J.hostLabel),H=ql(J=>J.theme),I=hC(),R=me(J=>J.defaultProjectDir),P=me(J=>J.commandPresets),N=me(J=>J.defaultPresetId),j=me(J=>J.lastProjectPath),W=me(J=>J.setLastProjectPath),V=me(J=>J.addRecentPath),Z=me(J=>J.shortcutModifier),Q=me(J=>J.sidebarWidth),$=me(J=>J.setSidebarWidth),B=me(J=>J.projectFilters),K=me(J=>J.hostFilters),U=me(J=>J.soundOnPermission),te=me(J=>J.soundOnIdle),{sendMessage:Y,subscribe:ye,connectionEpoch:pe,getConnectionEpoch:ne}=OP();FP(),E.useEffect(()=>{if(typeof document>"u"||!U&&!te)return;let J=!1;const ee=()=>{J&&!J3()||(J=!0,fd())};return document.addEventListener("click",ee,{passive:!0}),document.addEventListener("keydown",ee,{passive:!0}),document.addEventListener("touchstart",ee,{passive:!0}),()=>{document.removeEventListener("click",ee),document.removeEventListener("keydown",ee),document.removeEventListener("touchstart",ee)}},[U,te]);const oe=E.useRef(!1),ce=E.useCallback(J=>{J.preventDefault(),oe.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);E.useEffect(()=>{if(typeof document>"u"||typeof document.addEventListener!="function")return;const J=Be=>{if(!oe.current)return;const q=Be.clientX;$(Math.max(ty,Math.min(ry,q)))},ee=()=>{oe.current&&(oe.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",ee),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",ee)}},[$]),E.useEffect(()=>{const J=ye(ee=>{var Be,q;if(ee.type==="sessions"){const de=Ve.getState().sessions,{soundOnPermission:X,soundOnIdle:_e}=me.getState();if(X||_e)for(const re of ee.sessions){const le=de.find(we=>we.id===re.id);le&&le.status!==re.status&&(le.status!=="permission"&&re.status==="permission"&&X&&pd(),le.status==="working"&&re.status==="waiting"&&_e&&md())}if(ge.current.size>0){const re=ne();for(const[le,we]of ge.current)we.epoch!==re&&ge.current.delete(le)}ge.current.size>0?m(ee.sessions.filter(re=>!ge.current.has(re.id))):m(ee.sessions)}if(ee.type==="host-status"&&g(ee.hosts),ee.type==="server-config"&&(A(ee.remoteAllowControl),M(ee.remoteAllowAttach),D(ee.hostLabel),ee.clientLogLevel&&YR(ee.clientLogLevel)),ee.type==="session-update"){const X=Ve.getState().sessions.find(le=>le.id===ee.session.id),_e=X==null?void 0:X.status,re=ee.session.status;if(w(ee.session),_e){const{soundOnPermission:le,soundOnIdle:we}=me.getState();_e!=="permission"&&re==="permission"&&le&&pd(),_e==="working"&&re==="waiting"&&we&&md()}}if(ee.type==="session-created"){const de=Ve.getState().sessions;de.some(re=>re.id===ee.session.id)||m([ee.session,...de]),b(ee.session.id),V(ee.session.projectPath);const{projectFilters:X,setProjectFilters:_e}=me.getState();X.length>0&&!X.includes(ee.session.projectPath)&&_e([...X,ee.session.projectPath])}if(ee.type==="session-removed"){const de=Ve.getState().sessions,X=de.filter(_e=>_e.id!==ee.sessionId);X.length!==de.length&&m(X)}if(ee.type==="agent-sessions"&&d(ee.active,ee.inactive),ee.type==="agent-sessions-active"){const de=Ve.getState().agentSessions;d(ee.active,de.inactive)}if(ee.type==="session-orphaned"&&!ee.supersededBy){const de=Ve.getState().sessions,X=de.filter(_e=>{var re;return((re=_e.agentSessionId)==null?void 0:re.trim())!==ee.session.sessionId});X.length!==de.length&&m(X)}if(ee.type==="session-activated"){const de=Ve.getState().sessions.find(X=>X.tmuxWindow===ee.window);de&&w({...de,agentSessionId:ee.session.sessionId,agentSessionName:ee.session.displayName,logFilePath:ee.session.logFilePath,isPinned:ee.session.isPinned,lastUserMessage:ee.session.lastUserMessage??de.lastUserMessage})}if(ee.type==="session-resume-result")if(ee.ok&&ee.session){const de=Ve.getState().sessions;de.some(X=>X.id===ee.session.id)||m([ee.session,...de]),b(ee.session.id)}else ee.ok||(u(`${(Be=ee.error)==null?void 0:Be.code}: ${(q=ee.error)==null?void 0:q.message}`),window.setTimeout(()=>u(null),6e3));if(ee.type==="terminal-error"&&(!ee.sessionId||ee.sessionId===h)&&(u(`${ee.code}: ${ee.message}`),window.setTimeout(()=>u(null),6e3)),ee.type==="terminal-ready"&&ee.sessionId===h&&u(null),ee.type==="error"&&(u(ee.message),window.setTimeout(()=>u(null),6e3)),ee.type==="kill-failed"){const de=ge.current.get(ee.sessionId);if(de){const X=Ve.getState().sessions;X.some(_e=>_e.id===ee.sessionId)||m([de.session,...X]),de.wasSelected&&b(ee.sessionId),ge.current.delete(ee.sessionId)}k(ee.sessionId),u(ee.message),window.setTimeout(()=>u(null),6e3)}ee.type==="session-pin-result"&&!ee.ok&&ee.error&&(u(ee.error),window.setTimeout(()=>u(null),6e3)),ee.type==="session-resurrection-failed"&&SS.add({title:"Session resurrection failed",description:`"${ee.displayName}" could not be resumed: ${ee.error}`,type:"error",timeout:8e3})});return()=>{J()}},[h,V,k,Y,b,m,d,g,A,M,D,ye,w]);const ue=E.useMemo(()=>y.find(J=>J.id===h)||null,[h,y]);E.useEffect(()=>{ue!=null&&ue.projectPath&&!ue.remote&&W(ue.projectPath)},[ue==null?void 0:ue.projectPath,ue==null?void 0:ue.remote,W]);const ve=me(J=>J.sessionSortMode),se=me(J=>J.sessionSortDirection),ae=me(J=>J.manualSessionOrder),fe=E.useMemo(()=>np(y,{mode:ve,direction:se,manualOrder:ae}),[y,ve,se,ae]),ie=E.useMemo(()=>{let J=fe;return B.length>0&&(J=J.filter(ee=>B.includes(ee.projectPath))),K.length>0&&(J=J.filter(ee=>K.includes(ee.host??""))),J},[fe,B,K]);E.useEffect(()=>{h&&ie.length>0&&!ie.some(J=>J.id===h)&&b(ie[0].id)},[h,ie,b]),E.useEffect(()=>{window.matchMedia("(max-width: 767px)").matches&&x&&h===null&&fe.length>0&&b(fe[0].id)},[x,h,fe,b]);const ge=E.useRef(new Map),be=E.useCallback(J=>{const{sessions:ee,selectedSessionId:Be}=Ve.getState(),q=ee.find(de=>de.id===J);q&&ge.current.set(J,{session:q,wasSelected:Be===J,epoch:ne()}),L(J),m(ee.filter(de=>de.id!==J)),Y({type:"session-kill",sessionId:J})},[L,m,Y]);E.useEffect(()=>{const J=ea(Z),ee=Be=>{if(Be.defaultPrevented)return;const q=Be.code,de=WC(Be,J);if(de&&(q==="BracketLeft"||q==="BracketRight")){Be.preventDefault();const X=ie;if(X.length===0)return;const _e=X.findIndex(we=>we.id===h);if(_e===-1){b(X[0].id);return}const le=(_e+(q==="BracketLeft"?-1:1)+X.length)%X.length;b(X[le].id);return}if(de&&q==="KeyN"){Be.preventDefault(),!e&&I&&t(!0);return}if(de&&q==="KeyX"){Be.preventDefault(),h&&!e&&be(h);return}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[e,h,b,ie,be,Z,I]);const Te=()=>I?(n(void 0),a(void 0),s(void 0),t(!0),!0):!1,je=()=>c(!0),He=(J,ee,Be,q)=>{Y({type:"session-create",projectPath:J,name:ee,command:Be,host:q}),q||W(J)},Pe=J=>{Y({type:"session-resume",sessionId:J})},Oe=(J,ee)=>{Y({type:"session-rename",sessionId:J,newName:ee})},ke=E.useCallback(J=>{const ee=y.find(Be=>Be.id===J);ee&&Y({type:"session-create",projectPath:ee.projectPath,command:ee.command||void 0,host:ee.remote&&ee.host?ee.host:void 0})},[y,Y]),Le=E.useCallback((J,ee)=>{Y({type:"session-pin",sessionId:J,isPinned:ee})},[Y]);E.useEffect(()=>{document.documentElement.setAttribute("data-theme",H)},[H]),E.useEffect(()=>{fetch("/api/server-info").then(J=>J.json()).then(J=>_(J)).catch(()=>{})},[]);const Qe=E.useMemo(()=>F?O.filter(J=>J.host!==F):O,[O,F]);return T.jsxs("div",{className:"flex h-full overflow-hidden",children:[T.jsxs("div",{className:"hidden h-full flex-col md:flex md:shrink-0",style:{width:Q},children:[T.jsx(KC,{connectionStatus:C,onNewSession:Te,onOpenSettings:je,tailscaleIp:(p==null?void 0:p.tailscaleIp)??null}),T.jsx(fw,{sessions:y,inactiveSessions:v.inactive,selectedSessionId:h,onSelect:b,onRename:Oe,onResume:Pe,onKill:be,onDuplicate:ke,onSetPinned:Le,loading:!x,error:S||f})]}),T.jsx("div",{className:"hidden md:block w-1 shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-white/10 active:bg-white/20",onMouseDown:ce}),T.jsx(fM,{session:ue,sessions:ie,connectionStatus:C,connectionEpoch:pe,sendMessage:Y,subscribe:ye,onClose:()=>b(null),onSelectSession:b,onNewSession:Te,onKillSession:be,onRenameSession:Oe,onOpenSettings:je,onResumeSession:Pe,onSetPinned:Le,inactiveSessions:v.inactive,loading:!x,error:S||f}),T.jsx(mM,{isOpen:e,onClose:()=>t(!1),onCreate:He,defaultProjectDir:R,commandPresets:P,defaultPresetId:N,lastProjectPath:j,activeProjectPath:ue&&!ue.remote?ue.projectPath:void 0,remoteHosts:Qe,remoteAllowControl:z,initialHost:r,initialPath:i,initialCommand:l}),T.jsx(Z3,{isOpen:o,onClose:()=>c(!1)}),T.jsx(bP,{})]})}const $P="modulepreload",zP=function(e){return"/"+e},Hv={},UP=function(t,r,n){let i=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),s=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=Promise.allSettled(r.map(o=>{if(o=zP(o),o in Hv)return;Hv[o]=!0;const c=o.endsWith(".css"),f=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${f}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":$P,c||(u.as="script"),u.crossOrigin="",u.href=o,s&&u.setAttribute("nonce",s),document.head.appendChild(u),c)return new Promise((p,_)=>{u.addEventListener("load",p),u.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${o}`)))})}))}function a(l){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=l,window.dispatchEvent(s),!s.defaultPrevented)throw l}return i.then(l=>{for(const s of l||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};function WP(e={}){const{immediate:t=!1,onNeedRefresh:r,onOfflineReady:n,onRegistered:i,onRegisteredSW:a,onRegisterError:l}=e;let s,o;const c=async(u=!0)=>{await o};async function f(){if("serviceWorker"in navigator){if(s=await UP(async()=>{const{Workbox:u}=await import("./workbox-window.prod.es5-vqzQaGvo.js");return{Workbox:u}},[]).then(({Workbox:u})=>new u("/sw.js",{scope:"/",type:"classic"})).catch(u=>{l==null||l(u)}),!s)return;s.addEventListener("activated",u=>{(u.isUpdate||u.isExternal)&&window.location.reload()}),s.addEventListener("installed",u=>{u.isUpdate||n==null||n()}),s.register({immediate:t}).then(u=>{a?a("/sw.js",u):i==null||i(u)}).catch(u=>{l==null||l(u)})}}return o=f(),c}Zo()&&document.documentElement.classList.add("ios");$C()&&document.documentElement.classList.add("ios-pwa");WP({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},5*60*1e3),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t.update()}))}});const xS=document.getElementById("root");if(!xS)throw new Error("Root element not found");ey(xS).render(T.jsx(gt.StrictMode,{children:T.jsx(HP,{})}));
|
package/dist/client/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<title>Agentboard</title>
|
|
9
9
|
<link rel="apple-touch-icon" href="/icons/pwa-192x192.png" />
|
|
10
10
|
<meta name="theme-color" content="#0f172a" />
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-DG65I1ro.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-CX44X0Mv.css">
|
|
13
13
|
<link rel="manifest" href="/manifest.webmanifest"></head>
|
|
14
14
|
<body>
|
package/dist/client/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(!self.define){let e,n={};const o=(o,i)=>(o=new URL(o+".js",i).href,n[o]||new Promise(n=>{if("document"in self){const e=document.createElement("script");e.src=o,e.onload=n,document.head.appendChild(e)}else e=o,importScripts(o),n()}).then(()=>{let e=n[o];if(!e)throw new Error(`Module ${o} didn’t register its module`);return e}));self.define=(i,s)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(n[r])return;let f={};const t=e=>o(e,r),d={module:{uri:r},exports:f,require:t};n[r]=Promise.all(i.map(e=>d[e]||t(e))).then(e=>(s(...e),f))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"index.html",revision:"
|
|
1
|
+
if(!self.define){let e,n={};const o=(o,i)=>(o=new URL(o+".js",i).href,n[o]||new Promise(n=>{if("document"in self){const e=document.createElement("script");e.src=o,e.onload=n,document.head.appendChild(e)}else e=o,importScripts(o),n()}).then(()=>{let e=n[o];if(!e)throw new Error(`Module ${o} didn’t register its module`);return e}));self.define=(i,s)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(n[r])return;let f={};const t=e=>o(e,r),d={module:{uri:r},exports:f,require:t};n[r]=Promise.all(i.map(e=>d[e]||t(e))).then(e=>(s(...e),f))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"index.html",revision:"cbfe5106f9e28af4ed9262764e07e2b2"},{url:"favicon.svg",revision:"12048a608dedfc53518ddc59c07e41b6"},{url:"icons/pwa-512x512.png",revision:"eb82042b3e4ed505f3efe1b79622d998"},{url:"icons/pwa-192x192.png",revision:"affb57c15619ee7223d1adea372ad514"},{url:"fonts/jetbrains-mono-vietnamese-wght-normal.woff2",revision:"ddf99e6e35c6ee9f00a41d2567b0e77f"},{url:"fonts/jetbrains-mono-latin-wght-normal.woff2",revision:"b058178d7f309414f8f856b99fd80d9b"},{url:"fonts/jetbrains-mono-latin-ext-wght-normal.woff2",revision:"e36841ed93d5bfe6b1d487d18ad7e90b"},{url:"fonts/jetbrains-mono-greek-wght-normal.woff2",revision:"51671ed9eb64e29390d4791ab0023c8e"},{url:"fonts/jetbrains-mono-cyrillic-wght-normal.woff2",revision:"615bf869ebeb5998734d81fc8958116c"},{url:"fonts/jetbrains-mono-cyrillic-ext-wght-normal.woff2",revision:"742dd0628e0118d32dccf0437900670b"},{url:"assets/workbox-window.prod.es5-vqzQaGvo.js",revision:null},{url:"assets/index-DG65I1ro.js",revision:null},{url:"assets/index-CX44X0Mv.css",revision:null},{url:"icons/pwa-192x192.png",revision:"affb57c15619ee7223d1adea372ad514"},{url:"icons/pwa-512x512.png",revision:"eb82042b3e4ed505f3efe1b79622d998"},{url:"manifest.webmanifest",revision:"b6d4b3666a548fa0f0c6919d31ec2eee"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api(?:\/|$)/,/^\/ws(?:\/|$)/]}))});
|