@gbasin/agentboard-darwin-x64 0.5.0 → 0.5.2
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.
|
@@ -18,37 +18,37 @@ Error generating stack: `+e.message+`
|
|
|
18
18
|
While dragging, use the arrow keys to move the item.
|
|
19
19
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
20
20
|
`},Xd={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Zd(e){let{announcements:t=Xd,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Yd}=e,{announce:a,announcement:o}=Gd(),s=jd(`DndLiveRegion`),[c,l]=(0,x.useState)(!1);if((0,x.useEffect)(()=>{l(!0)},[]),qd((0,x.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=x.createElement(x.Fragment,null,x.createElement(Ud,{id:r,value:i.draggable}),x.createElement(Wd,{id:s,announcement:o}));return n?(0,U.createPortal)(u,n):u}var Qd;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(Qd||={});function $d(){}function ef(e,t){return(0,x.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function tf(){var e=[...arguments];return(0,x.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var nf=Object.freeze({x:0,y:0});function rf(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function af(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function of(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function sf(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function cf(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var lf=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=cf(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=rf(cf(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(af)};function uf(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var df=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=uf(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(of)};function ff(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function pf(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:nf}function mf(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var hf=mf(1);function gf(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function _f(e,t,n){let r=gf(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var vf={ignoreTransform:!1};function yf(e,t){t===void 0&&(t=vf);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=vd(e).getComputedStyle(e);t&&(n=_f(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function bf(e){return yf(e,{ignoreTransform:!0})}function xf(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Sf(e,t){return t===void 0&&(t=vd(e).getComputedStyle(e)),t.position===`fixed`}function Cf(e,t){t===void 0&&(t=vd(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function wf(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(yd(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!bd(i)||xd(i)||n.includes(i))return n;let a=vd(e).getComputedStyle(i);return i!==e&&Cf(i,a)&&n.push(i),Sf(i,a)?n:r(i.parentNode)}return e?r(e):n}function Tf(e){let[t]=wf(e,1);return t??null}function Ef(e){return!hd||!e?null:gd(e)?e:_d(e)?yd(e)||e===Sd(e).scrollingElement?window:bd(e)?e:null:null}function Df(e){return gd(e)?e.scrollX:e.scrollLeft}function Of(e){return gd(e)?e.scrollY:e.scrollTop}function kf(e){return{x:Df(e),y:Of(e)}}var Af;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Af||={});function jf(e){return!hd||!e?!1:e===document.scrollingElement}function Mf(e){let t={x:0,y:0},n=jf(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Nf={x:.2,y:.2};function Pf(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Nf);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Mf(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Af.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Af.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Af.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Af.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Ff(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function If(e){return e.reduce((e,t)=>Nd(e,kf(t)),nf)}function Lf(e){return e.reduce((e,t)=>e+Df(t),0)}function Rf(e){return e.reduce((e,t)=>e+Of(t),0)}function zf(e,t){if(t===void 0&&(t=yf),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Tf(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Bf=[[`x`,[`left`,`right`],Lf],[`y`,[`top`,`bottom`],Rf]],Vf=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=wf(t),r=If(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Bf)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},Hf=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Uf(e){let{EventTarget:t}=vd(e);return e instanceof t?e:Sd(e)}function Wf(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Gf;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Gf||={});function Kf(e){e.preventDefault()}function qf(e){e.stopPropagation()}var Jf;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(Jf||={});var Yf={start:[Jf.Space,Jf.Enter],cancel:[Jf.Esc],end:[Jf.Space,Jf.Enter,Jf.Tab]},Xf=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Jf.Right:return{...n,x:n.x+25};case Jf.Left:return{...n,x:n.x-25};case Jf.Down:return{...n,y:n.y+25};case Jf.Up:return{...n,y:n.y-25}}},Zf=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Hf(Sd(t)),this.windowListeners=new Hf(vd(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Gf.Resize,this.handleCancel),this.windowListeners.add(Gf.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Gf.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&zf(n),t(nf)}handleKeyDown(e){if(Id(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Yf,coordinateGetter:a=Xf,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:nf;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Pd(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Mf(n),p=Ff(n),m={x:Math.min(i===Jf.Right?p.right-p.width/2:p.right,Math.max(i===Jf.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Jf.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Jf.Down?p.top:p.top+p.height/2,u.y))},h=i===Jf.Right&&!s||i===Jf.Left&&!c,g=i===Jf.Down&&!l||i===Jf.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Jf.Right&&e<=d.x||i===Jf.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Jf.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Jf.Down&&e<=d.y||i===Jf.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Jf.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Nd(Pd(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Zf.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Yf,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Qf(e){return!!(e&&`distance`in e)}function $f(e){return!!(e&&`delay`in e)}var ep=class{constructor(e,t,n){n===void 0&&(n=Uf(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Sd(i),this.documentListeners=new Hf(this.document),this.listeners=new Hf(n),this.windowListeners=new Hf(vd(i)),this.initialCoordinates=Rd(r)??nf,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Gf.Resize,this.handleCancel),this.windowListeners.add(Gf.DragStart,Kf),this.windowListeners.add(Gf.VisibilityChange,this.handleCancel),this.windowListeners.add(Gf.ContextMenu,Kf),this.documentListeners.add(Gf.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if($f(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Qf(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Gf.Click,qf,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Gf.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Rd(e)??nf,s=Pd(n,o);if(!t&&a){if(Qf(a)){if(a.tolerance!=null&&Wf(s,a.tolerance))return this.handleCancel();if(Wf(s,a.distance))return this.handleStart()}if($f(a)&&Wf(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Jf.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},tp={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},np=class extends ep{constructor(e){let{event:t}=e,n=Sd(t.target);super(e,tp,n)}};np.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var rp={move:{name:`mousemove`},end:{name:`mouseup`}},ip;(function(e){e[e.RightClick=2]=`RightClick`})(ip||={});var ap=class extends ep{constructor(e){super(e,rp,Sd(e.event.target))}};ap.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===ip.RightClick?!1:(r?.({event:n}),!0)}}];var op={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},sp=class extends ep{constructor(e){super(e,op)}static setup(){return window.addEventListener(op.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(op.move.name,e)};function e(){}}};sp.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var cp;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(cp||={});var lp;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(lp||={});function up(e){let{acceleration:t,activator:n=cp.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=lp.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=fp({delta:d,disabled:!a}),[m,h]=Td(),g=(0,x.useRef)({x:0,y:0}),_=(0,x.useRef)({x:0,y:0}),v=(0,x.useMemo)(()=>{switch(n){case cp.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case cp.DraggableRect:return i}},[n,i,c]),y=(0,x.useRef)(null),b=(0,x.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),S=(0,x.useMemo)(()=>s===lp.TreeOrder?[...l].reverse():l,[s,l]);(0,x.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of S){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Pf(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,S,u,JSON.stringify(f)])}var dp={x:{[Af.Backward]:!1,[Af.Forward]:!1},y:{[Af.Backward]:!1,[Af.Forward]:!1}};function fp(e){let{delta:t,disabled:n}=e,r=kd(t);return Dd(e=>{if(n||!r||!e)return dp;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Af.Backward]:e.x[Af.Backward]||i.x===-1,[Af.Forward]:e.x[Af.Forward]||i.x===1},y:{[Af.Backward]:e.y[Af.Backward]||i.y===-1,[Af.Forward]:e.y[Af.Forward]||i.y===1}}},[n,t,r])}function pp(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Dd(e=>t==null?null:r??e??null,[r,t])}function mp(e,t){return(0,x.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var hp;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(hp||={});var gp;(function(e){e.Optimized=`optimized`})(gp||={});var _p=new Map;function vp(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,x.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,x.useRef)(e),d=g(),f=Ed(d),p=(0,x.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,x.useRef)(null),h=Dd(t=>{if(d&&!n)return _p;if(!t||t===_p||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Vf(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,x.useEffect)(()=>{u.current=e},[e]),(0,x.useEffect)(()=>{d||p()},[n,d]),(0,x.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,x.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case hp.Always:return!1;case hp.BeforeDragging:return n;default:return!n}}}function yp(e,t){return Dd(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function bp(e,t){return yp(e,t)}function xp(e){let{callback:t,disabled:n}=e,r=wd(t),i=(0,x.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,x.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Sp(e){let{callback:t,disabled:n}=e,r=wd(t),i=(0,x.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,x.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Cp(e){return new Vf(yf(e),e)}function wp(e,t,n){t===void 0&&(t=Cp);let[r,i]=(0,x.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=xp({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=Sp({callback:a});return Cd(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Tp(e){return pf(e,yp(e))}var Ep=[];function Dp(e){let t=(0,x.useRef)(e),n=Dd(n=>e?n&&n!==Ep&&e&&t.current&&e.parentNode===t.current.parentNode?n:wf(e):Ep,[e]);return(0,x.useEffect)(()=>{t.current=e},[e]),n}function Op(e){let[t,n]=(0,x.useState)(null),r=(0,x.useRef)(e),i=(0,x.useCallback)(e=>{let t=Ef(e.target);t&&n(e=>e?(e.set(t,kf(t)),new Map(e)):null)},[]);return(0,x.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Ef(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,kf(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Ef(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,x.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Nd(e,t),nf):If(e):nf,[e,t])}function kp(e,t){t===void 0&&(t=[]);let n=(0,x.useRef)(null);return(0,x.useEffect)(()=>{n.current=null},t),(0,x.useEffect)(()=>{let t=e!==nf;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Pd(e,n.current):nf}function Ap(e){(0,x.useEffect)(()=>{if(!hd)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function jp(e,t){return(0,x.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Mp(e){return(0,x.useMemo)(()=>e?xf(e):null,[e])}var Np=[];function Pp(e,t){t===void 0&&(t=yf);let[n]=e,r=Mp(n?vd(n):null),[i,a]=(0,x.useState)(Np);function o(){a(()=>e.length?e.map(e=>jf(e)?r:new Vf(t(e),e)):Np)}let s=Sp({callback:o});return Cd(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Fp(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return bd(t)?t:e}function Ip(e){let{measure:t}=e,[n,r]=(0,x.useState)(null),i=Sp({callback:(0,x.useCallback)(e=>{for(let{target:n}of e)if(bd(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Od((0,x.useCallback)(e=>{let n=Fp(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,x.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Lp=[{sensor:np,options:{}},{sensor:Zf,options:{}}],Rp={current:{}},zp={draggable:{measure:bf},droppable:{measure:bf,strategy:hp.WhileDragging,frequency:gp.Optimized},dragOverlay:{measure:yf}},Bp=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Vp={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Bp,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:$d},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:zp,measureDroppableContainers:$d,windowRect:null,measuringScheduled:!1},Hp={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:$d,draggableNodes:new Map,over:null,measureDroppableContainers:$d},Up=(0,x.createContext)(Hp),Wp=(0,x.createContext)(Vp);function Gp(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Bp}}}function Kp(e,t){switch(t.type){case Qd.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Qd.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Qd.DragEnd:case Qd.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Qd.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Bp(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Qd.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Bp(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Qd.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Bp(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function qp(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,x.useContext)(Up),a=kd(r),o=kd(n?.id);return(0,x.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Id(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Vd(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Jp(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Yp(e){return(0,x.useMemo)(()=>({draggable:{...zp.draggable,...e?.draggable},droppable:{...zp.droppable,...e?.droppable},dragOverlay:{...zp.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Xp(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,x.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Cd(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=pf(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=Tf(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Zp=(0,x.createContext)({...nf,scaleX:1,scaleY:1}),Qp;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Qp||={});var $p=(0,x.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Lp,collisionDetection:o=df,measuring:s,modifiers:c,...l}=e,[u,d]=(0,x.useReducer)(Kp,void 0,Gp),[f,p]=Jd(),[m,h]=(0,x.useState)(Qp.Uninitialized),g=m===Qp.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,S=_==null?null:v.get(_),C=(0,x.useRef)({initial:null,translated:null}),w=(0,x.useMemo)(()=>_==null?null:{id:_,data:S?.data??Rp,rect:C},[_,S]),T=(0,x.useRef)(null),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(null),A=Ed(l,Object.values(l)),j=jd(`DndDescribedBy`,t),M=(0,x.useMemo)(()=>b.getEnabled(),[b]),N=Yp(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=vp(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=pp(v,_),ee=(0,x.useMemo)(()=>O?Rd(O):null,[O]),R=De(),z=bp(L,N.draggable.measure);Xp({activeNode:_==null?null:v.get(_),config:R.layoutShiftCompensation,initialRect:z,measure:N.draggable.measure});let B=wp(L,N.draggable.measure,z),te=wp(L?L.parentElement:null),V=(0,x.useRef)({activatorEvent:null,active:null,activeNode:L,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=b.getNodeFor(V.current.over?.id),H=Ip({measure:N.dragOverlay.measure}),re=H.nodeRef.current??L,ie=g?H.rect??B:null,ae=!!(H.nodeRef.current&&H.rect),oe=Tp(ae?null:B),se=Mp(re?vd(re):null),ce=Dp(g?ne??L:null),le=Pp(ce),ue=Jp(c,{transform:{x:y.x-oe.x,y:y.y-oe.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:B,containerNodeRect:te,draggingNodeRect:ie,over:V.current.over,overlayNodeRect:H.rect,scrollableAncestors:ce,scrollableAncestorRects:le,windowRect:se}),de=ee?Nd(ee,y):null,fe=Op(ce),pe=kp(fe),me=kp(fe,[B]),he=Nd(ue,pe),ge=ie?hf(ie,ue):null,_e=w&&ge?o({active:w,collisionRect:ge,droppableRects:P,droppableContainers:M,pointerCoordinates:de}):null,ve=sf(_e,`id`),[ye,be]=(0,x.useState)(null),xe=ff(ae?ue:Nd(ue,me),ye?.rect??null,B),Se=(0,x.useRef)(null),Ce=(0,x.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=v.get(T.current);if(!i)return;let a=e.nativeEvent;Se.current=new n({active:T.current,activeNode:i,event:a,options:r,context:V,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=T.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:C}};(0,U.unstable_batchedUpdates)(()=>{r?.(i),h(Qp.Initializing),d({type:Qd.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(Se.current),k(a)})},onMove(e){d({type:Qd.DragMove,coordinates:e})},onEnd:o(Qd.DragEnd),onCancel:o(Qd.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=V.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Qd.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Qd.DragCancel)}T.current=null,(0,U.unstable_batchedUpdates)(()=>{d({type:e}),h(Qp.Uninitialized),be(null),D(null),k(null),Se.current=null;let t=e===Qd.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),we=mp(a,(0,x.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,Ce(n,t))},[v,Ce]));Ap(a),Cd(()=>{B&&m===Qp.Initializing&&h(Qp.Initialized)},[B,m]),(0,x.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=V.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:he.x,y:he.y},over:i};(0,U.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[he.x,he.y]),(0,x.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=V.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(ve),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,U.unstable_batchedUpdates)(()=>{be(s),a?.(c),f({type:`onDragOver`,event:c})})},[ve]),Cd(()=>{V.current={activatorEvent:O,active:w,activeNode:L,collisionRect:ge,collisions:_e,droppableRects:P,draggableNodes:v,draggingNode:re,draggingNodeRect:ie,droppableContainers:b,over:ye,scrollableAncestors:ce,scrollAdjustedTranslate:he},C.current={initial:ie,translated:ge}},[w,L,_e,ge,v,re,ie,P,b,ye,ce,he]),up({...R,delta:y,draggingRect:ge,pointerCoordinates:de,scrollableAncestors:ce,scrollableAncestorRects:le});let Te=(0,x.useMemo)(()=>({active:w,activeNode:L,activeNodeRect:B,activatorEvent:O,collisions:_e,containerNodeRect:te,dragOverlay:H,draggableNodes:v,droppableContainers:b,droppableRects:P,over:ye,measureDroppableContainers:F,scrollableAncestors:ce,scrollableAncestorRects:le,measuringConfiguration:N,measuringScheduled:I,windowRect:se}),[w,L,B,O,_e,te,H,v,b,P,ye,F,ce,le,N,I,se]),Ee=(0,x.useMemo)(()=>({activatorEvent:O,activators:we,active:w,activeNodeRect:B,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:ye,measureDroppableContainers:F}),[O,we,w,B,d,j,v,ye,F]);return x.createElement(Kd.Provider,{value:p},x.createElement(Up.Provider,{value:Ee},x.createElement(Wp.Provider,{value:Te},x.createElement(Zp.Provider,{value:xe},i)),x.createElement(qp,{disabled:n?.restoreFocus===!1})),x.createElement(Zd,{...n,hiddenTextDescribedById:j}));function De(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),em=(0,x.createContext)(null),tm=`button`,nm=`Draggable`;function rm(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=jd(nm),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,x.useContext)(Up),{role:p=tm,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,x.useContext)(g?Zp:em),[v,y]=Od(),[b,S]=Od(),C=jp(o,t),w=Ed(n);return Cd(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,x.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===tm?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:C,node:v,over:f,setNodeRef:y,setActivatorNodeRef:S,transform:_}}function im(){return(0,x.useContext)(Wp)}var am=`Droppable`,om={timeout:25};function sm(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=jd(am),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,x.useContext)(Up),u=(0,x.useRef)({disabled:n}),d=(0,x.useRef)(!1),f=(0,x.useRef)(null),p=(0,x.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...om,...i},_=Ed(h??r),v=Sp({callback:(0,x.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Od((0,x.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),S=Ed(t);return(0,x.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,x.useEffect)(()=>(s({type:Qd.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:S}}),()=>s({type:Qd.UnregisterDroppable,key:a,id:r})),[r]),(0,x.useEffect)(()=>{n!==u.current.disabled&&(s({type:Qd.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function cm(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function lm(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function um(e){return e!==null&&e>=0}function dm(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function fm(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var pm=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=cm(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},mm={scaleX:1,scaleY:1},hm=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...mm}:null}let s=gm(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...mm}:r<t&&r>=a?{x:0,y:o.height+s,...mm}:{x:0,y:0,...mm}};function gm(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var _m=`Sortable`,vm=x.createContext({activeIndex:-1,containerId:_m,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:pm,disabled:{draggable:!1,droppable:!1}});function ym(e){let{children:t,id:n,items:r,strategy:i=pm,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=im(),d=jd(_m,n),f=s.rect!==null,p=(0,x.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,x.useRef)(p),v=!dm(p,_.current),y=g!==-1&&h===-1||v,b=fm(a);Cd(()=>{v&&m&&u(p)},[v,p,m,u]),(0,x.useEffect)(()=>{_.current=p},[p]);let S=(0,x.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:lm(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return x.createElement(vm.Provider,{value:S},t)}var bm=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return cm(n,r,i).indexOf(t)},xm=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},Sm={duration:200,easing:`ease`},Cm=`transform`,wm=zd.Transition.toString({property:Cm,duration:0,easing:`linear`}),Tm={roleDescription:`sortable`};function Em(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,x.useState)(null),s=(0,x.useRef)(n);return Cd(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=yf(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,x.useEffect)(()=>{a&&o(null)},[a]),a}function Dm(e){let{animateLayoutChanges:t=xm,attributes:n,disabled:r,data:i,getNewIndex:a=bm,id:o,strategy:s,resizeObserverConfig:c,transition:l=Sm}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,x.useContext)(vm),y=Om(r,p),b=u.indexOf(o),S=(0,x.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),C=(0,x.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:w,node:T,isOver:E,setNodeRef:D}=sm({id:o,data:S,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:L}=rm({id:o,data:S,attributes:{...Tm,...n},disabled:y.draggable}),ee=md(D,M),R=!!O,z=R&&!m&&um(f)&&um(g),B=!_&&P,te=z?(B&&z?L:null)??(s??v)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:b}):null,V=um(f)&&um(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ne=O?.id,H=(0,x.useRef)({activeId:ne,items:u,newIndex:V,containerId:d}),re=u!==H.current.items,U=t({active:O,containerId:d,isDragging:P,isSorting:R,id:o,index:b,items:u,newIndex:H.current.newIndex,previousItems:H.current.items,previousContainerId:H.current.containerId,transition:l,wasDragging:H.current.activeId!=null}),ie=Em({disabled:!U,index:b,node:T,rect:w});return(0,x.useEffect)(()=>{R&&H.current.newIndex!==V&&(H.current.newIndex=V),d!==H.current.containerId&&(H.current.containerId=d),u!==H.current.items&&(H.current.items=u)},[R,V,d,u]),(0,x.useEffect)(()=>{if(ne===H.current.activeId)return;if(ne!=null&&H.current.activeId==null){H.current.activeId=ne;return}let e=setTimeout(()=>{H.current.activeId=ne},50);return()=>clearTimeout(e)},[ne]),{active:O,activeIndex:f,attributes:j,data:S,rect:w,index:b,newIndex:V,items:u,isOver:E,isSorting:R,isDragging:P,listeners:N,node:T,overIndex:g,over:F,setNodeRef:ee,setActivatorNodeRef:I,setDroppableNodeRef:D,setDraggableNodeRef:M,transform:ie??te,transition:ae()};function ae(){if(ie||re&&H.current.newIndex===b)return wm;if(!(B&&!Id(k)||!l)&&(R||U))return zd.Transition.toString({...l,property:Cm})}}function Om(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}Jf.Down,Jf.Right,Jf.Up,Jf.Left;var km={permission:0,waiting:1,working:2,unknown:3};function Am(e){let t=e.agentSessionId?.trim();return t&&t.length>0?t:e.id}var jm={mode:`created`,direction:`desc`};function Mm(e,t=jm){let{mode:n,direction:r,manualOrder:i}=t;if(n===`manual`&&i&&i.length>0){let t=new Map(i.map((e,t)=>[e,t]));return e.toSorted((e,n)=>{let r=Am(e),i=Am(n),a=t.get(r)??t.get(e.id)??1/0,o=t.get(i)??t.get(n.id)??1/0;return a===1/0&&o===1/0?Date.parse(n.createdAt)-Date.parse(e.createdAt):a-o})}return e.toSorted((e,t)=>{if(n===`status`){let n=km[e.status]??km.unknown,r=km[t.status]??km.unknown;return n===r?Date.parse(t.lastActivity)-Date.parse(e.lastActivity):n-r}let i=Date.parse(e.createdAt),a=Date.parse(t.createdAt);return r===`desc`?a-i:i-a})}function Nm(e,t){let n=new Map;for(let t of e){let e=t.projectPath?.trim();if(e){let r=Date.parse(t.lastActivity)||0;r>(n.get(e)||0)&&n.set(e,r)}}for(let e of t){let t=e.projectPath?.trim();if(t){let r=Date.parse(e.lastActivityAt)||0;r>(n.get(t)||0)&&n.set(t,r)}}return Array.from(n.keys()).toSorted((e,t)=>{let r=n.get(e)||0;return(n.get(t)||0)-r})}function Pm(e,t){let n=new Map;for(let t of e){let e=t.host?.trim();if(e){let r=Date.parse(t.lastActivity)||0;r>(n.get(e)||0)&&n.set(e,r)}}for(let e of t){let t=e.host?.trim();if(t){let r=Date.parse(e.lastActivityAt)||0;r>(n.get(t)||0)&&n.set(t,r)}}return Array.from(n.keys()).toSorted((e,t)=>{let r=n.get(e)||0;return(n.get(t)||0)-r})}function Fm(e){let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Im(e){let t=e.trim();if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return null;let r=n.split(/[\\/]/);return r[r.length-1]||null}function Lm(e){let t=e.map(e=>{let t=e.trim(),n=t.replace(/[\\/]+$/,``);return{path:e,parts:n.split(/[\\/]/).filter(Boolean),fallback:n||t||e}}),n=new Map;for(let e of t)n.set(e.path,1);let r=!0;for(;r;){r=!1;let e=new Map;for(let r of t){if(r.parts.length===0)continue;let t=n.get(r.path)??1,i=r.parts.slice(-t).join(`/`);e.set(i,(e.get(i)??0)+1)}for(let i of t){if(i.parts.length===0)continue;let t=n.get(i.path)??1,a=i.parts.slice(-t).join(`/`);(e.get(a)??0)>1&&t<i.parts.length&&(n.set(i.path,t+1),r=!0)}}let i=new Map,a=new Map;for(let e of t){let t=e.fallback;if(e.parts.length>0){let r=n.get(e.path)??1;t=e.parts.slice(-r).join(`/`)}i.set(e.path,t),a.set(t,(a.get(t)??0)+1)}let o=new Map;for(let e of t){let t=i.get(e.path)??e.fallback;(a.get(t)??0)>1&&(t=e.fallback),o.set(e.path,t)}return o}function Rm(e){let t=e.trim();return!t||t.length<=6?t:`${t.slice(0,3)}…${t.slice(-3)}`}function zm(e){let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,document.body.appendChild(t),t.focus(),t.select();try{if(!document.execCommand(`copy`))throw 0}catch{navigator.clipboard?.writeText(e).catch(()=>{})}document.body.removeChild(t)}function Bm({useSafariLayoutFallback:e,isDragging:t,dndTransform:n,generatedTransform:r}){return e&&!t&&!n||!n?r:!r||r===`none`?n:`${n} ${r}`}var Vm=`agentboard-session`,Hm=N(Vm);function Um(e,t){return e.id===t.id&&e.name===t.name&&e.tmuxWindow===t.tmuxWindow&&e.projectPath===t.projectPath&&e.status===t.status&&e.lastActivity===t.lastActivity&&e.createdAt===t.createdAt&&e.source===t.source&&e.host===t.host&&e.remote===t.remote&&e.command===t.command&&e.agentType===t.agentType&&e.agentSessionId===t.agentSessionId&&e.agentSessionName===t.agentSessionName&&e.logFilePath===t.logFilePath&&e.isPinned===t.isPinned&&e.lastUserMessage===t.lastUserMessage}function Wm(e,t){if(e.length!==t.length)return!1;let n=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=n.get(e.id);if(!t||!Um(t,e))return!1}return!0}function Gm(e){return typeof e==`string`&&e.length>0?e:null}function Km(e){return Array.isArray(e)?e:[]}var qm=T()(k((e,t)=>({sessions:[],agentSessions:{active:[],hibernating:[],history:[]},agentSessionsEpoch:-1,hostStatuses:[],exitingSessions:new Map,selectedSessionId:null,selectedHibernatingSessionId:null,hasLoaded:!1,connectionStatus:`connecting`,connectionError:null,connectionEpoch:0,remoteAllowControl:!1,remoteAllowAttach:!1,hostLabel:null,preferWindowName:!1,setSessions:n=>{let r=t(),i=r.selectedSessionId,a=r.selectedHibernatingSessionId,o=r.sessions,s=r.exitingSessions;if(r.hasLoaded&&Wm(o,n))return;let c=new Set(n.map(e=>e.id)),l=o.filter(e=>!c.has(e.id)&&!s.has(e.id)),u=i;if(i!==null&&!n.some(e=>e.id===i))if(a===null){let{sessionSortMode:e,sessionSortDirection:t}=H.getState();u=Mm(n,{mode:e,direction:t})[0]?.id??null}else u=null;if(l.length>0){let t=new Map(s);for(let e of l)t.set(e.id,e);e({sessions:n,hasLoaded:!0,selectedSessionId:u,exitingSessions:t})}else e({sessions:n,hasLoaded:!0,selectedSessionId:u})},setAgentSessions:(t,n,r)=>e(e=>{let i={active:Km(t),hibernating:Km(n),history:Km(r)};return{agentSessions:i,agentSessionsEpoch:e.connectionEpoch,selectedHibernatingSessionId:e.selectedHibernatingSessionId&&!i.hibernating.some(t=>t.sessionId===e.selectedHibernatingSessionId)?null:e.selectedHibernatingSessionId}}),setActiveAgentSessions:t=>e(e=>({agentSessions:{active:Km(t),hibernating:e.agentSessions.hibernating,history:e.agentSessions.history}})),setHostStatuses:t=>e({hostStatuses:t}),updateSession:t=>e(e=>({sessions:e.sessions.map(e=>e.id===t.id?t:e)})),setSelectedSessionId:t=>e({selectedSessionId:t,...t===null?{}:{selectedHibernatingSessionId:null}}),setSelectedHibernatingSessionId:t=>e({selectedHibernatingSessionId:t,...t===null?{}:{selectedSessionId:null}}),setConnectionStatus:t=>e({connectionStatus:t}),setConnectionError:t=>e({connectionError:t}),setConnectionState:(t,n,r)=>e({connectionStatus:t,connectionError:n,connectionEpoch:r}),setRemoteAllowControl:t=>e({remoteAllowControl:t}),setRemoteAllowAttach:t=>e({remoteAllowAttach:t}),setHostLabel:t=>e({hostLabel:t}),setPreferWindowName:t=>e({preferWindowName:t}),markSessionExiting:n=>{let r=t().sessions.find(e=>e.id===n);if(r){let i=new Map(t().exitingSessions);i.set(n,r),e({exitingSessions:i})}},clearExitingSession:n=>{let r=new Map(t().exitingSessions);r.delete(n),e({exitingSessions:r})}}),{name:Vm,storage:D(()=>Hm),partialize:e=>({selectedSessionId:e.selectedSessionId,selectedHibernatingSessionId:e.selectedHibernatingSessionId}),merge:(e,t)=>{let n=e,r=n?.selectedHibernatingSessionId??n?.selectedSleepingSessionId;return{...t,selectedSessionId:Gm(n?.selectedSessionId),selectedHibernatingSessionId:Gm(r)}}}));function Jm(e,t,n=!1){let[r,i]=(0,x.useState)(!1),a=(0,x.useRef)(e),o=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{let r=a.current;if(n?e>r:e!==r){o.current=!0;let n=setTimeout(()=>{o.current&&=(i(!0),!1)},t);return a.current=e,()=>clearTimeout(n)}a.current=e},[e,t,n]),[r,()=>i(!1)]}function Ym(e,t,n,r){let i=(0,x.useRef)(new Map);(0,x.useEffect)(()=>{let a=new Set(e.map(e=>e.id));for(let e of t.keys())if(a.has(e)){let t=i.current.get(e);t&&(clearTimeout(t),i.current.delete(e)),n(e)}else if(!i.current.has(e)){let t=setTimeout(()=>{i.current.delete(e),n(e)},r+100);i.current.set(e,t)}},[e,t,n,r]),(0,x.useEffect)(()=>()=>{for(let e of i.current.values())clearTimeout(e);i.current.clear()},[])}function Xm({className:e}){return(0,W.jsx)(`svg`,{viewBox:`0 0 92.2 92.2`,fill:`currentColor`,className:e,"aria-label":`Anthropic`,children:(0,W.jsx)(`path`,{d:`M66.5,0H52.4l25.7,65h14.1L66.5,0z M25.7,0L0,65h14.4l5.3-13.6h26.9L51.8,65h14.4L40.5,0C40.5,0,25.7,0,25.7,0z M24.3,39.3l8.8-22.8l8.8,22.8H24.3z`,transform:`translate(0, 13.6)`})})}function Zm({className:e}){return(0,W.jsx)(`svg`,{viewBox:`-1 -1 26 26`,fill:`currentColor`,className:e,"aria-label":`OpenAI`,children:(0,W.jsx)(`path`,{d:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`})})}function Qm({className:e}){return(0,W.jsx)(`svg`,{viewBox:`0 0 588.42 568.88`,fill:`currentColor`,className:e,"aria-label":`Pi`,children:(0,W.jsx)(`path`,{d:`M 10.499686,177.03840 L 31.174931,178.56990 C 52.615925,154.32116 61.039171,82.595924 187.38789,96.634671 C 182.79339,403.95560 48.021426,436.37234 56.444675,499.41907 C 59.507674,535.15406 87.840417,557.10556 118.47041,558.38181 C 215.21014,555.06356 210.87089,424.63084 240.99038,95.868921 L 365.80760,95.868921 C 359.17110,211.75239 341.04836,327.63586 339.00636,441.22208 C 340.53786,516.77606 386.48285,557.10556 446.97708,557.61606 C 546.52456,560.93431 577.92030,444.79558 577.92030,395.27709 L 556.47931,395.27710 C 554.43731,436.11709 534.78306,465.47083 492.92207,467.25758 C 378.82535,468.78908 441.61683,266.63113 442.38258,97.400421 L 577.92030,98.166171 L 577.15455,11.636437 C 13.807491,8.9075799 85.312284,-2.1366151 10.499686,177.03840 z`})})}var $m=[[`claude`,Xm],[`codex`,Zm],[`pi`,Qm]];function eh({agentType:e,command:t,className:n=``}){let r=(e||t?.split(` `)[0]||``).toLowerCase();for(let[e,t]of $m)if(r.startsWith(e))return(0,W.jsx)(t,{className:n});return(0,W.jsx)(Ve,{className:n})}var th=360;function nh(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function rh(e){return{"--badge-hue":`${nh(e)%th}`}}function ih({name:e,fullPath:t,className:n=``}){let r=rh(e);return(0,W.jsx)(`span`,{className:`project-badge inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none ${n}`,style:r,title:t,children:e})}var ah=(0,x.memo)(function({session:e,showSessionIdPrefix:t,showProjectName:n,showLastUserMessage:r,onResume:i,onPreview:a}){let o=Fm(e.lastActivityAt),s=Im(e.projectPath),c=e.displayName||s||e.sessionId.slice(0,8),l=n&&!!s,u=r&&!!e.lastUserMessage,d=t?Rm(e.sessionId):``,f=(0,x.useRef)(null),[p,m]=(0,x.useState)(null);return(0,x.useEffect)(()=>{if(!p)return;let e=e=>{f.current&&!f.current.contains(e.target)&&m(null)},t=e=>{e.key===`Escape`&&m(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[p]),(0,W.jsxs)(`div`,{className:`group relative cursor-pointer px-3 py-2 hover:bg-hover`,role:`button`,tabIndex:0,title:`Click to preview`,onClick:()=>a(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e))},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),m({x:e.clientX,y:e.clientY})},children:[(0,W.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-muted opacity-0 hover:text-primary group-hover:opacity-100`,title:`Wake directly`,onClick:t=>{t.stopPropagation(),i(e.sessionId)},children:`▶`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2.5 group-hover:pr-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(eh,{agentType:e.agentType,className:`h-3.5 w-3.5 shrink-0 text-muted`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:c}),e.lastResumeError&&(0,W.jsx)(ae,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":`Wake failed`,title:`Last wake failed: ${e.lastResumeError}`}),d&&(0,W.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:e.sessionId,children:d}),(0,W.jsx)(`span`,{className:`ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted`,children:o})]}),(l||u)&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[l&&(0,W.jsx)(ih,{name:s,fullPath:e.projectPath}),u&&(0,W.jsxs)(`span`,{className:`truncate text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`…`:e.lastUserMessage,`"`]})]})]}),p&&(0,W.jsx)(`div`,{ref:f,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:p.x,top:p.y},role:`menu`,children:e.logFilePath&&(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),m(null),e.logFilePath&&zm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,W.jsx)(ye,{width:14,height:14}),`Copy Log Path`]})})]})});function oh({name:e,className:t=``}){let n=rh(`host:${e}`);return(0,W.jsx)(`span`,{className:`inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium uppercase leading-none tracking-wide ${t}`,style:n,title:e,children:e})}function sh({hosts:e,selectedHosts:t,onSelect:n,statuses:r=[]}){let[i,a]=(0,x.useState)(!1),o=(0,x.useId)(),s=(0,x.useRef)(null),c=(0,x.useMemo)(()=>new Set(t),[t]),l=(0,x.useMemo)(()=>new Map(r.map(e=>[e.host,e])),[r]),u=(0,x.useMemo)(()=>t.length===0?`All Hosts`:t.join(`, `),[t]),d=(0,x.useMemo)(()=>t.length===0?`All Hosts`:t.length===1?t[0]:`${t.length} hosts`,[t]);(0,x.useEffect)(()=>{if(!i||typeof document>`u`||!document.addEventListener||!document.removeEventListener)return;let e=e=>{let t=e.target;t&&s.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e,{passive:!0}),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[i]);let f=t=>{let r=new Set(c);r.has(t)?r.delete(t):r.add(t),n(e.filter(e=>r.has(e)))};return(0,W.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-controls":o,"aria-label":`Filter by host`,onClick:()=>a(e=>!e),className:`flex h-6 max-w-[9rem] items-center gap-1.5 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none`,title:u,children:[(0,W.jsx)(Fe,{className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate leading-none`,children:d}),(0,W.jsx)(se,{className:`h-3 w-3 shrink-0 text-muted`})]}),i&&(0,W.jsxs)(`div`,{id:o,role:`menu`,className:`absolute left-0 z-20 mt-1 w-48 max-w-[calc(100vw-1.5rem)] rounded border border-border bg-surface p-2 text-xs shadow-lg`,children:[(0,W.jsxs)(`label`,{role:`menuitemcheckbox`,"aria-checked":t.length===0,className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:t.length===0,onChange:()=>n([]),className:`h-3.5 w-3.5 accent-approval`}),(0,W.jsx)(`span`,{children:`All Hosts`})]}),(0,W.jsx)(`div`,{className:`my-2 h-px bg-border`}),e.length===0?(0,W.jsx)(`div`,{className:`px-2 py-1 text-muted`,children:`No hosts`}):(0,W.jsx)(`div`,{className:`max-h-48 overflow-y-auto pr-1`,children:e.map(e=>{let t=l.get(e),n=t?!t.ok:!1;return(0,W.jsxs)(`label`,{role:`menuitemcheckbox`,"aria-checked":c.has(e),className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,title:t?.error?`${e}: ${t.error}`:e,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:c.has(e),onChange:()=>f(e),className:`h-3.5 w-3.5 accent-approval`}),(0,W.jsx)(`span`,{className:`truncate`,children:e}),n&&(0,W.jsx)(`span`,{className:`ml-auto text-[10px] uppercase text-danger`,children:`offline`})]},e)})})]})]})}function ch({projects:e,selectedProjects:t,onSelect:n,hasHiddenPermissions:r}){let[i,a]=(0,x.useState)(!1),o=(0,x.useId)(),s=(0,x.useRef)(null),c=(0,x.useMemo)(()=>Lm(e),[e]),l=(0,x.useMemo)(()=>new Set(t),[t]),u=r&&t.length>0,d=(0,x.useMemo)(()=>t.length===0?`All Projects`:t.map(e=>c.get(e)??Im(e)??e).join(`, `),[c,t]),f=(0,x.useMemo)(()=>{if(t.length===0)return`All Projects`;if(t.length===1){let e=t[0];return c.get(e)??Im(e)??e}return`${t.length} projects`},[c,t]);(0,x.useEffect)(()=>{if(!i||typeof document>`u`||!document.addEventListener||!document.removeEventListener)return;let e=e=>{let t=e.target;t&&s.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e,{passive:!0}),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=t=>{let r=new Set(l);r.has(t)?r.delete(t):r.add(t),n(e.filter(e=>r.has(e)))};return(0,W.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-controls":o,"aria-label":`Filter by project`,onClick:()=>a(e=>!e),className:`flex h-6 max-w-[11rem] items-center gap-1.5 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none`,title:d,children:[(0,W.jsx)(xe,{className:`h-3.5 w-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate leading-none`,children:f}),(0,W.jsx)(se,{className:`h-3 w-3 shrink-0 text-muted`})]}),i&&(0,W.jsxs)(`div`,{id:o,role:`menu`,className:`absolute left-0 z-20 mt-1 w-60 max-w-[calc(100vw-1.5rem)] rounded border border-border bg-surface p-2 text-xs shadow-lg`,children:[(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:t.length===0,onChange:()=>n([]),className:`h-3.5 w-3.5 accent-approval`}),(0,W.jsx)(`span`,{children:`All Projects`})]}),(0,W.jsx)(`div`,{className:`my-2 h-px bg-border`}),e.length===0?(0,W.jsx)(`div`,{className:`px-2 py-1 text-muted`,children:`No projects`}):(0,W.jsx)(`div`,{className:`max-h-48 overflow-y-auto pr-1`,children:e.map(e=>{let t=c.get(e)??Im(e)??e;return(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,title:e,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:l.has(e),onChange:()=>p(e),className:`h-3.5 w-3.5 accent-approval`}),(0,W.jsx)(`span`,{className:`truncate`,children:t})]},e)})})]}),u&&(0,W.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 h-2 w-2 rounded-full bg-approval pulse-approval ring-2 ring-elevated`,title:`Hidden sessions need attention`,"aria-label":`Clear project filters`,onClick:e=>{e.stopPropagation(),n([])},children:(0,W.jsx)(`span`,{className:`sr-only`,children:`Clear project filters`})})]})}function lh(e){return!e||typeof e!=`object`||Array.isArray(e)?null:e}function uh(e){return typeof e==`string`?e:null}var dh=new Set([`tool_result`,`custom_tool_call_output`]),fh=new Set([`text`,`input_text`,`output_text`]);function ph(e){return e===`user`?`user`:e===`assistant`?`assistant`:e===`system`||e===`developer`?`system`:e===`tool`?`tool`:`other`}function mh(e){let t=uh(e.type)??``,n=lh(e.payload),r=uh(n?.type)??``,i=uh(e.source)??uh(n?.source)??``,a=uh(e.agent)??``;return i.toLowerCase()===`pi`||a.toLowerCase()===`pi`?`pi`:t===`response_item`||t===`event_msg`?`codex`:t===`tool_use`||t===`result`||t===`user`||t===`assistant`||t===`system`?`claude`:r===`user_message`||r===`assistant_message`?`codex`:`unknown`}function hh(e){let t=uh(lh(e.payload)?.type);return{family:mh(e),rawType:uh(e.type)??`unknown`,...t?{payloadType:t}:{}}}function gh(e){if(!e)return[];if(typeof e==`string`)return e.trim()?[e]:[];if(Array.isArray(e)){let t=[];for(let n of e){if(typeof n==`string`){n.trim()&&t.push(n);continue}let e=lh(n);if(!e)continue;let r=uh(e.type);if(r&&dh.has(r)||r&&!fh.has(r))continue;let i=uh(e.text);i&&i.trim()&&t.push(i)}return t}let t=lh(e);if(t){let e=uh(t.type);if(e&&dh.has(e))return[];let n=uh(t.text);return n&&n.trim()?[n]:[...gh(t.content),...gh(t.message)]}return[]}function _h(e,t){if(e.type!==`response_item`)return[];let n=lh(e.payload);if(!n||n.type!==`message`)return[];let r=ph(n.role);return gh(n.content).map(e=>({kind:`message`,role:r,text:e,source:t}))}function vh(e,t){if(e.type!==`event_msg`)return[];let n=lh(e.payload);if(!n)return[];let r=uh(n.type),i=null;if(r===`user_message`?i=`user`:r===`assistant_message`||r===`agent_message`?i=`assistant`:r===`system_message`?i=`system`:r===`message`&&(i=ph(n.role)),!i||![`user`,`assistant`,`system`].includes(i))return[];let a=Array.from(new Set([...gh(n.message),...gh(n.content),...gh(n.text)]));return a.length===0?[]:a.map(e=>({kind:`message`,role:i,text:e,source:t}))}function yh(e,t){let n=ph(e.type),r=lh(e.message);if(r){let n=ph(r.role??e.type);return[...gh(r.content),...gh(r.text),...gh(r.message)].map(e=>({kind:`message`,role:n,text:e,source:t}))}return[`user`,`assistant`,`system`].includes(n)?[...gh(e.content),...gh(e.text)].map(e=>({kind:`message`,role:n,text:e,source:t})):[]}function bh(e,t){let n=ph(e.role);return[`user`,`assistant`,`system`].includes(n)?[...gh(e.content),...gh(e.message),...gh(e.text)].map(e=>({kind:`message`,role:n,text:e,source:t})):[]}function xh(e,t){let n=uh(e.type),r=uh(e.event);return n!==`tool_use`&&r!==`tool_use`?[]:[{kind:`tool_call`,role:`assistant`,text:`[Tool: ${uh(e.name)??`tool`}]`,source:t}]}function Sh(e,t){if(e.type!==`result`)return[];let n=uh(e.result);return!n||!n.trim()?[]:[{kind:`result`,role:`system`,text:n,source:t}]}function Ch(e,t){let n=lh(e.payload),r=[...gh(e.message),...gh(e.content),...gh(e.text),...gh(n?.message),...gh(n?.content)];return r.length===0?[]:r.map(e=>({kind:`unknown`,role:`other`,text:e,source:t}))}function wh(e,t){let n=uh(e.type),r=uh(lh(e.payload)?.type);return n&&dh.has(n)||r&&dh.has(r)?[{kind:`tool_result`,role:`tool`,text:``,source:t}]:[]}function Th(e){let t=lh(e);if(!t||t.isMeta===!0)return[];let n=hh(t),r=[..._h(t,n),...vh(t,n),...yh(t,n),...xh(t,n),...Sh(t,n),...wh(t,n)];if(r.length>0)return r;let i=bh(t,n);return i.length>0?i:Ch(t,n)}function Eh(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);return{parsed:!0,events:Th(e),raw:e}}catch{return{parsed:!1,events:[{kind:`unknown`,role:`other`,text:t,source:{family:`unknown`,rawType:`raw_text`}}],raw:e}}}function Dh(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Oh=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kh=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ah={};function jh(e,t){return((t||Ah).jsx?kh:Oh).test(e)}var Mh=/[ \t\n\f\r]/g;function Nh(e){return typeof e==`object`?e.type===`text`?Ph(e.value):!1:Ph(e)}function Ph(e){return e.replace(Mh,``)===``}var Fh=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};Fh.prototype.normal={},Fh.prototype.property={},Fh.prototype.space=void 0;function Ih(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new Fh(n,r,t)}function Lh(e){return e.toLowerCase()}var Rh=class{constructor(e,t){this.attribute=t,this.property=e}};Rh.prototype.attribute=``,Rh.prototype.booleanish=!1,Rh.prototype.boolean=!1,Rh.prototype.commaOrSpaceSeparated=!1,Rh.prototype.commaSeparated=!1,Rh.prototype.defined=!1,Rh.prototype.mustUseProperty=!1,Rh.prototype.number=!1,Rh.prototype.overloadedBoolean=!1,Rh.prototype.property=``,Rh.prototype.spaceSeparated=!1,Rh.prototype.space=void 0;var zh=c({boolean:()=>Vh,booleanish:()=>Hh,commaOrSpaceSeparated:()=>Kh,commaSeparated:()=>Gh,number:()=>q,overloadedBoolean:()=>Uh,spaceSeparated:()=>Wh}),Bh=0,Vh=qh(),Hh=qh(),Uh=qh(),q=qh(),Wh=qh(),Gh=qh(),Kh=qh();function qh(){return 2**++Bh}var Jh=Object.keys(zh),Yh=class extends Rh{constructor(e,t,n,r){let i=-1;if(super(e,t),Xh(this,`space`,r),typeof n==`number`)for(;++i<Jh.length;){let e=Jh[i];Xh(this,Jh[i],(n&zh[e])===zh[e])}}};Yh.prototype.defined=!0;function Xh(e,t,n){n&&(e[t]=n)}function Zh(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Yh(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Lh(r)]=r,n[Lh(a.attribute)]=r}return new Fh(t,n,e.space)}var Qh=Zh({properties:{ariaActiveDescendant:null,ariaAtomic:Hh,ariaAutoComplete:null,ariaBusy:Hh,ariaChecked:Hh,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:Wh,ariaCurrent:null,ariaDescribedBy:Wh,ariaDetails:null,ariaDisabled:Hh,ariaDropEffect:Wh,ariaErrorMessage:null,ariaExpanded:Hh,ariaFlowTo:Wh,ariaGrabbed:Hh,ariaHasPopup:null,ariaHidden:Hh,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Wh,ariaLevel:q,ariaLive:null,ariaModal:Hh,ariaMultiLine:Hh,ariaMultiSelectable:Hh,ariaOrientation:null,ariaOwns:Wh,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:Hh,ariaReadOnly:Hh,ariaRelevant:null,ariaRequired:Hh,ariaRoleDescription:Wh,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:Hh,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function $h(e,t){return t in e?e[t]:t}function eg(e,t){return $h(e,t.toLowerCase())}var tg=Zh({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Gh,acceptCharset:Wh,accessKey:Wh,action:null,allow:null,allowFullScreen:Vh,allowPaymentRequest:Vh,allowUserMedia:Vh,alpha:Vh,alt:null,as:null,async:Vh,autoCapitalize:null,autoComplete:Wh,autoFocus:Vh,autoPlay:Vh,blocking:Wh,capture:null,charSet:null,checked:Vh,cite:null,className:Wh,closedBy:null,colorSpace:null,cols:q,colSpan:q,command:null,commandFor:null,content:null,contentEditable:Hh,controls:Vh,controlsList:Wh,coords:q|Gh,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Vh,defer:Vh,dir:null,dirName:null,disabled:Vh,download:Uh,draggable:Hh,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Vh,formTarget:null,headers:Wh,height:q,hidden:Uh,high:q,href:null,hrefLang:null,htmlFor:Wh,httpEquiv:Wh,id:null,imageSizes:null,imageSrcSet:null,inert:Vh,inputMode:null,integrity:null,is:null,isMap:Vh,itemId:null,itemProp:Wh,itemRef:Wh,itemScope:Vh,itemType:Wh,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Vh,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:Vh,muted:Vh,name:null,nonce:null,noModule:Vh,noValidate:Vh,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Vh,optimum:q,pattern:null,ping:Wh,placeholder:null,playsInline:Vh,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Vh,referrerPolicy:null,rel:Wh,required:Vh,reversed:Vh,rows:q,rowSpan:q,sandbox:Wh,scope:null,scoped:Vh,seamless:Vh,selected:Vh,shadowRootClonable:Vh,shadowRootCustomElementRegistry:Vh,shadowRootDelegatesFocus:Vh,shadowRootMode:null,shadowRootSerializable:Vh,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:Hh,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:Vh,useMap:null,value:Hh,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Wh,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Vh,declare:Vh,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:Vh,noHref:Vh,noShade:Vh,noWrap:Vh,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:Hh,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Vh,disablePictureInPicture:Vh,disableRemotePlayback:Vh,exportParts:Gh,part:Wh,prefix:null,property:null,results:q,security:null,unselectable:null},space:`html`,transform:eg}),ng=Zh({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Kh,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:Wh,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:Vh,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Gh,g2:Gh,glyphName:Gh,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:Kh,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Wh,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Kh,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Kh,rev:Kh,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Kh,requiredFeatures:Kh,requiredFonts:Kh,requiredFormats:Kh,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:Kh,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Kh,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Kh,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:$h}),rg=Zh({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),ig=Zh({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:eg}),ag=Zh({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),og={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},sg=/[A-Z]/g,cg=/-[a-z]/g,lg=/^data[-\w.:]+$/i;function ug(e,t){let n=Lh(t),r=t,i=Rh;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&lg.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(cg,fg);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!cg.test(e)){let n=e.replace(sg,dg);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Yh}return new i(r,t)}function dg(e){return`-`+e.toLowerCase()}function fg(e){return e.charAt(1).toUpperCase()}var pg=Ih([Qh,tg,rg,ig,ag],`html`),mg=Ih([Qh,ng,rg,ig,ag],`svg`);function hg(e){return e.join(` `).trim()}var gg=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
21
|
-
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),_g=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(gg());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),vg=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),yg=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(_g()),r=vg();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),bg=Sg(`end`),xg=Sg(`start`);function Sg(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Cg(e){let t=xg(e),n=bg(e);if(t&&n)return{start:t,end:n}}function wg(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Eg(e.position):`start`in e||`end`in e?Eg(e):`line`in e||`column`in e?Tg(e):``}function Tg(e){return Dg(e&&e.line)+`:`+Dg(e&&e.column)}function Eg(e){return Tg(e&&e.start)+`-`+Tg(e&&e.end)}function Dg(e){return e&&typeof e==`number`?e:1}var Og=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=wg(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Og.prototype.file=``,Og.prototype.name=``,Og.prototype.reason=``,Og.prototype.message=``,Og.prototype.stack=``,Og.prototype.column=void 0,Og.prototype.line=void 0,Og.prototype.ancestors=void 0,Og.prototype.cause=void 0,Og.prototype.fatal=void 0,Og.prototype.place=void 0,Og.prototype.ruleId=void 0,Og.prototype.source=void 0;var kg=u(yg(),1),Ag={}.hasOwnProperty,jg=new Map,Mg=/[A-Z]/g,Ng=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Pg=new Set([`td`,`th`]),Fg=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Ig(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=qg(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Kg(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?mg:pg,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Lg(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Lg(e,t,n){if(t.type===`element`)return Rg(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return zg(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Vg(e,t,n);if(t.type===`mdxjsEsm`)return Bg(e,t);if(t.type===`root`)return Hg(e,t,n);if(t.type===`text`)return Ug(e,t)}function Rg(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=mg,e.schema=i),e.ancestors.push(t);let a=$g(e,t.tagName,!1),o=Jg(e,t),s=Xg(e,t);return Ng.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Nh(e):!0})),Wg(e,o,a,t),Gg(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function zg(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}e_(e,t.position)}function Bg(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);e_(e,t.position)}function Vg(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=mg,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:$g(e,t.name,!0),o=Yg(e,t),s=Xg(e,t);return Wg(e,o,a,t),Gg(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Hg(e,t,n){let r={};return Gg(r,Xg(e,t)),e.create(t,e.Fragment,r,n)}function Ug(e,t){return t.value}function Wg(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Gg(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Kg(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function qg(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=xg(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Jg(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Ag.call(t.properties,i)){let a=Zg(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Pg.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Yg(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else e_(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else e_(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Xg(e,t){let n=[],r=-1,i=e.passKeys?new Map:jg;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Lg(e,a,o);s!==void 0&&n.push(s)}return n}function Zg(e,t,n){let r=ug(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Dh(n):hg(n)),r.property===`style`){let t=typeof n==`object`?n:Qg(e,String(n));return e.stylePropertyNameCase===`css`&&(t=t_(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?og[r.property]||r.property:r.attribute,n]}}function Qg(e,t){try{return(0,kg.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Og("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=Fg+`#cannot-parse-style-attribute`,r}}function $g(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=jh(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=jh(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Ag.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);e_(e)}function e_(e,t){let n=new Og("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=Fg+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function t_(e){let t={},n;for(n in e)Ag.call(e,n)&&(t[n_(n)]=e[n]);return t}function n_(e){let t=e.replace(Mg,r_);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function r_(e){return`-`+e.toLowerCase()}var i_={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},a_={};function o_(e,t){let n=t||a_;return s_(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function s_(e,t,n){if(l_(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return c_(e.children,t,n)}return Array.isArray(e)?c_(e,t,n):``}function c_(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=s_(e[i],t,n);return r.join(``)}function l_(e){return!!(e&&typeof e==`object`)}var u_=document.createElement(`i`);function d_(e){let t=`&`+e+`;`;u_.innerHTML=t;let n=u_.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function f_(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function p_(e,t){return e.length>0?(f_(e,e.length,0,t),e):t}var m_={}.hasOwnProperty;function h_(e){let t={},n=-1;for(;++n<e.length;)g_(t,e[n]);return t}function g_(e,t){let n;for(n in t){let r=(m_.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){m_.call(r,a)||(r[a]=[]);let e=i[a];__(r[a],Array.isArray(e)?e:e?[e]:[])}}}function __(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);f_(e,0,0,r)}function v_(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function y_(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var b_=j_(/[A-Za-z]/),x_=j_(/[\dA-Za-z]/),S_=j_(/[#-'*+\--9=?A-Z^-~]/);function C_(e){return e!==null&&(e<32||e===127)}var w_=j_(/\d/),T_=j_(/[\dA-Fa-f]/),E_=j_(/[!-/:-@[-`{-~]/);function J(e){return e!==null&&e<-2}function D_(e){return e!==null&&(e<0||e===32)}function O_(e){return e===-2||e===-1||e===32}var k_=j_(/\p{P}|\p{S}/u),A_=j_(/\s/);function j_(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function M_(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&x_(e.charCodeAt(n+1))&&x_(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function N_(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return O_(r)?(e.enter(n),s(r)):t(r)}function s(r){return O_(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var P_={tokenize:F_};function F_(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),N_(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return J(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var I_={tokenize:R_},L_={tokenize:z_};function R_(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return f_(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(L_,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(L_,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return J(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;f_(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function z_(e,t,n){return N_(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function B_(e){if(e===null||D_(e)||A_(e))return 1;if(k_(e))return 2}function V_(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var H_={name:`attention`,resolveAll:U_,tokenize:W_};function U_(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};G_(d,-c),G_(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=p_(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=p_(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=p_(l,V_(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=p_(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=p_(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,f_(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function W_(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=B_(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=B_(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function G_(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var K_={name:`autolink`,tokenize:q_};function q_(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return b_(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||x_(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||x_(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||C_(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):S_(t)?(e.consume(t),l):n(t)}function u(e){return x_(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||x_(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var J_={partial:!0,tokenize:Y_};function Y_(e,t,n){return r;function r(t){return O_(t)?N_(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||J(e)?t(e):n(e)}}var X_={continuation:{tokenize:Q_},exit:$_,name:`blockQuote`,tokenize:Z_};function Z_(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return O_(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Q_(e,t,n){let r=this;return i;function i(t){return O_(t)?N_(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(X_,t,n)(r)}}function $_(e){e.exit(`blockQuote`)}var ev={name:`characterEscape`,tokenize:tv};function tv(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return E_(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var nv={name:`characterReference`,tokenize:rv};function rv(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=x_,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=T_,u):(e.enter(`characterReferenceValue`),a=7,o=w_,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===x_&&!d_(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var iv={partial:!0,tokenize:sv},av={concrete:!0,name:`codeFenced`,tokenize:ov};function ov(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),O_(t)?N_(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||J(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(iv,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):O_(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),N_(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||J(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||J(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&O_(t)?N_(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||J(t)?e.check(iv,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||J(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),O_(t)?N_(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),O_(t)?N_(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||J(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function sv(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var cv={name:`codeIndented`,tokenize:uv},lv={partial:!0,tokenize:dv};function uv(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),N_(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):J(t)?e.attempt(lv,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||J(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function dv(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):N_(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):J(e)?i(e):n(e)}}var fv={name:`codeText`,previous:mv,resolve:pv,tokenize:hv};function pv(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function mv(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function hv(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||J(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var gv=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&_v(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),_v(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),_v(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);_v(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);_v(this.left,t.reverse())}}};function _v(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function vv(e){let t={},n=-1,r,i,a,o,s,c,l,u=new gv(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,yv(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return f_(e,0,1/0,u.slice(0)),!l}function yv(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var bv={resolve:Sv,tokenize:Cv},xv={partial:!0,tokenize:wv};function Sv(e){return vv(e),e}function Cv(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):J(t)?e.check(xv,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function wv(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),N_(e,a,`linePrefix`)}function a(i){if(i===null||J(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Tv(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||C_(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||J(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||D_(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||C_(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Ev(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):J(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||J(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!O_(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Dv(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),N_(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||J(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Ov(e,t){let n;return r;function r(i){return J(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):O_(i)?N_(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var kv={name:`definition`,tokenize:jv},Av={partial:!0,tokenize:Mv};function jv(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Ev.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=y_(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return D_(t)?Ov(e,l)(t):l(t)}function l(t){return Tv(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Av,d,d)(t)}function d(t){return O_(t)?N_(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||J(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Mv(e,t,n){return r;function r(t){return D_(t)?Ov(e,i)(t):n(t)}function i(t){return Dv(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return O_(t)?N_(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||J(e)?t(e):n(e)}}var Nv={name:`hardBreakEscape`,tokenize:Pv};function Pv(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return J(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Fv={name:`headingAtx`,resolve:Iv,tokenize:Lv};function Iv(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},f_(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Lv(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||D_(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||J(n)?(e.exit(`atxHeading`),t(n)):O_(n)?N_(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||D_(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Rv=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),zv=[`pre`,`script`,`style`,`textarea`],Bv={concrete:!0,name:`htmlFlow`,resolveTo:Uv,tokenize:Wv},Vv={partial:!0,tokenize:Kv},Hv={partial:!0,tokenize:Gv};function Uv(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Wv(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):b_(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):b_(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return b_(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||D_(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&zv.includes(l)?(i=1,r.interrupt?t(s):O(s)):Rv.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||x_(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return O_(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||b_(t)?(e.consume(t),b):O_(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||x_(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):O_(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):O_(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||J(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||D_(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||O_(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||J(t)?O(t):O_(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):J(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Vv,ee,k)(t)):t===null||J(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Hv,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||J(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return zv.includes(n)?(e.consume(t),L):O(t)}return b_(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||J(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function Gv(e,t,n){let r=this;return i;function i(t){return J(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Kv(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(J_,t,n)}}var qv={name:`htmlText`,tokenize:Jv};function Jv(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):b_(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):b_(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):J(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):J(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):J(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):J(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return b_(t)?(e.consume(t),S):n(t)}function S(t){return t===45||x_(t)?(e.consume(t),S):C(t)}function C(t){return J(t)?(o=C,N(t)):O_(t)?(e.consume(t),C):M(t)}function w(t){return t===45||x_(t)?(e.consume(t),w):t===47||t===62||D_(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||b_(t)?(e.consume(t),E):J(t)?(o=T,N(t)):O_(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||x_(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):J(t)?(o=D,N(t)):O_(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):J(t)?(o=O,N(t)):O_(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):J(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||D_(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||D_(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return O_(t)?N_(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var Yv={name:`labelEnd`,resolveAll:$v,resolveTo:ey,tokenize:ty},Xv={tokenize:ny},Zv={tokenize:ry},Qv={tokenize:iy};function $v(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&f_(e,0,e.length,n),e}function ey(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=p_(s,e.slice(a+1,a+r+3)),s=p_(s,[[`enter`,u,t]]),s=p_(s,V_(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=p_(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=p_(s,e.slice(o+1)),s=p_(s,[[`exit`,c,t]]),f_(e,a,e.length,s),e}function ty(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(y_(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Xv,u,o?u:d)(t):t===91?e.attempt(Zv,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Qv,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function ny(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return D_(t)?Ov(e,a)(t):a(t)}function a(t){return t===41?u(t):Tv(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return D_(t)?Ov(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Dv(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return D_(t)?Ov(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function ry(e,t,n){let r=this;return i;function i(t){return Ev.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(y_(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function iy(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var ay={name:`labelStartImage`,resolveAll:Yv.resolveAll,tokenize:oy};function oy(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var sy={name:`labelStartLink`,resolveAll:Yv.resolveAll,tokenize:cy};function cy(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var ly={name:`lineEnding`,tokenize:uy};function uy(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),N_(e,t,`linePrefix`)}}var dy={name:`thematicBreak`,tokenize:fy};function fy(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||J(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),O_(t)?N_(e,s,`whitespace`)(t):s(t))}}var py={continuation:{tokenize:_y},exit:yy,name:`list`,tokenize:gy},my={partial:!0,tokenize:by},hy={partial:!0,tokenize:vy};function gy(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:w_(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(dy,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return w_(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(J_,r.interrupt?n:u,e.attempt(my,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return O_(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function _y(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(J_,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,N_(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!O_(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(hy,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,N_(e,e.attempt(py,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function vy(e,t,n){let r=this;return N_(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function yy(e){e.exit(this.containerState.type)}function by(e,t,n){let r=this;return N_(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!O_(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var xy={name:`setextUnderline`,resolveTo:Sy,tokenize:Cy};function Sy(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Cy(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),O_(t)?N_(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||J(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var wy={tokenize:Ty};function Ty(e){let t=this,n=e.attempt(J_,r,e.attempt(this.parser.constructs.flowInitial,i,N_(e,e.attempt(this.parser.constructs.flow,i,e.attempt(bv,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Ey={resolveAll:Ay()},Dy=ky(`string`),Oy=ky(`text`);function ky(e){return{resolveAll:Ay(e===`text`?jy:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function Ay(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function jy(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var My=c({attentionMarkers:()=>By,contentInitial:()=>Py,disable:()=>Vy,document:()=>Ny,flow:()=>Iy,flowInitial:()=>Fy,insideSpan:()=>zy,string:()=>Ly,text:()=>Ry}),Ny={42:py,43:py,45:py,48:py,49:py,50:py,51:py,52:py,53:py,54:py,55:py,56:py,57:py,62:X_},Py={91:kv},Fy={[-2]:cv,[-1]:cv,32:cv},Iy={35:Fv,42:dy,45:[xy,dy],60:Bv,61:xy,95:dy,96:av,126:av},Ly={38:nv,92:ev},Ry={[-5]:ly,[-4]:ly,[-3]:ly,33:ay,38:nv,42:H_,60:[K_,qv],91:sy,92:[Nv,ev],93:Yv,95:H_,96:fv},zy={null:[H_,Ey]},By={null:[42,95]},Vy={null:[]};function Hy(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=p_(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=V_(a,l.events,l),l.events):[]}function f(e,t){return Wy(p(e),t)}function p(e){return Uy(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){J(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&f_(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Uy(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Wy(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
21
|
+
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),_g=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(gg());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),vg=s((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),yg=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(_g()),r=vg();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),bg=Sg(`end`),xg=Sg(`start`);function Sg(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Cg(e){let t=xg(e),n=bg(e);if(t&&n)return{start:t,end:n}}function wg(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Eg(e.position):`start`in e||`end`in e?Eg(e):`line`in e||`column`in e?Tg(e):``}function Tg(e){return Dg(e&&e.line)+`:`+Dg(e&&e.column)}function Eg(e){return Tg(e&&e.start)+`-`+Tg(e&&e.end)}function Dg(e){return e&&typeof e==`number`?e:1}var Og=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=wg(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Og.prototype.file=``,Og.prototype.name=``,Og.prototype.reason=``,Og.prototype.message=``,Og.prototype.stack=``,Og.prototype.column=void 0,Og.prototype.line=void 0,Og.prototype.ancestors=void 0,Og.prototype.cause=void 0,Og.prototype.fatal=void 0,Og.prototype.place=void 0,Og.prototype.ruleId=void 0,Og.prototype.source=void 0;var kg=u(yg(),1),Ag={}.hasOwnProperty,jg=new Map,Mg=/[A-Z]/g,Ng=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Pg=new Set([`td`,`th`]),Fg=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Ig(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=qg(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Kg(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?mg:pg,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Lg(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Lg(e,t,n){if(t.type===`element`)return Rg(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return zg(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Vg(e,t,n);if(t.type===`mdxjsEsm`)return Bg(e,t);if(t.type===`root`)return Hg(e,t,n);if(t.type===`text`)return Ug(e,t)}function Rg(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=mg,e.schema=i),e.ancestors.push(t);let a=$g(e,t.tagName,!1),o=Jg(e,t),s=Xg(e,t);return Ng.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!Nh(e):!0})),Wg(e,o,a,t),Gg(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function zg(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}e_(e,t.position)}function Bg(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);e_(e,t.position)}function Vg(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=mg,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:$g(e,t.name,!0),o=Yg(e,t),s=Xg(e,t);return Wg(e,o,a,t),Gg(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Hg(e,t,n){let r={};return Gg(r,Xg(e,t)),e.create(t,e.Fragment,r,n)}function Ug(e,t){return t.value}function Wg(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Gg(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Kg(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function qg(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=xg(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Jg(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Ag.call(t.properties,i)){let a=Zg(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Pg.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Yg(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else e_(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else e_(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Xg(e,t){let n=[],r=-1,i=e.passKeys?new Map:jg;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Lg(e,a,o);s!==void 0&&n.push(s)}return n}function Zg(e,t,n){let r=ug(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Dh(n):hg(n)),r.property===`style`){let t=typeof n==`object`?n:Qg(e,String(n));return e.stylePropertyNameCase===`css`&&(t=t_(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?og[r.property]||r.property:r.attribute,n]}}function Qg(e,t){try{return(0,kg.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Og("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=Fg+`#cannot-parse-style-attribute`,r}}function $g(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=jh(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=jh(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Ag.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);e_(e)}function e_(e,t){let n=new Og("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=Fg+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function t_(e){let t={},n;for(n in e)Ag.call(e,n)&&(t[n_(n)]=e[n]);return t}function n_(e){let t=e.replace(Mg,r_);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function r_(e){return`-`+e.toLowerCase()}var i_={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},a_={};function o_(e,t){let n=t||a_;return s_(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function s_(e,t,n){if(l_(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return c_(e.children,t,n)}return Array.isArray(e)?c_(e,t,n):``}function c_(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=s_(e[i],t,n);return r.join(``)}function l_(e){return!!(e&&typeof e==`object`)}var u_=document.createElement(`i`);function d_(e){let t=`&`+e+`;`;u_.innerHTML=t;let n=u_.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function f_(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function p_(e,t){return e.length>0?(f_(e,e.length,0,t),e):t}var m_={}.hasOwnProperty;function h_(e){let t={},n=-1;for(;++n<e.length;)g_(t,e[n]);return t}function g_(e,t){let n;for(n in t){let r=(m_.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){m_.call(r,a)||(r[a]=[]);let e=i[a];__(r[a],Array.isArray(e)?e:e?[e]:[])}}}function __(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);f_(e,0,0,r)}function v_(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function y_(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var b_=M_(/[A-Za-z]/),x_=M_(/[\dA-Za-z]/),S_=M_(/[#-'*+\--9=?A-Z^-~]/);function C_(e){return e!==null&&(e<32||e===127)}var w_=M_(/\d/),T_=M_(/[\dA-Fa-f]/),E_=M_(/[!-/:-@[-`{-~]/);function D_(e){return e!==null&&e<-2}function O_(e){return e!==null&&(e<0||e===32)}function k_(e){return e===-2||e===-1||e===32}var A_=M_(/\p{P}|\p{S}/u),j_=M_(/\s/);function M_(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function N_(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&x_(e.charCodeAt(n+1))&&x_(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function P_(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return k_(r)?(e.enter(n),s(r)):t(r)}function s(r){return k_(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var F_={tokenize:I_};function I_(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),P_(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return D_(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var L_={tokenize:z_},R_={tokenize:B_};function z_(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return f_(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(R_,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(R_,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return D_(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;f_(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function B_(e,t,n){return P_(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function V_(e){if(e===null||O_(e)||j_(e))return 1;if(A_(e))return 2}function H_(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var U_={name:`attention`,resolveAll:W_,tokenize:G_};function W_(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};K_(d,-c),K_(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=p_(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=p_(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=p_(l,H_(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=p_(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=p_(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,f_(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function G_(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=V_(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=V_(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function K_(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var q_={name:`autolink`,tokenize:J_};function J_(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return b_(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||x_(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||x_(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||C_(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):S_(t)?(e.consume(t),l):n(t)}function u(e){return x_(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||x_(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Y_={partial:!0,tokenize:X_};function X_(e,t,n){return r;function r(t){return k_(t)?P_(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||D_(e)?t(e):n(e)}}var Z_={continuation:{tokenize:$_},exit:ev,name:`blockQuote`,tokenize:Q_};function Q_(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return k_(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function $_(e,t,n){let r=this;return i;function i(t){return k_(t)?P_(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Z_,t,n)(r)}}function ev(e){e.exit(`blockQuote`)}var tv={name:`characterEscape`,tokenize:nv};function nv(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return E_(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var rv={name:`characterReference`,tokenize:iv};function iv(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=x_,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=T_,u):(e.enter(`characterReferenceValue`),a=7,o=w_,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===x_&&!d_(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var av={partial:!0,tokenize:cv},ov={concrete:!0,name:`codeFenced`,tokenize:sv};function sv(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),k_(t)?P_(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||D_(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(av,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||D_(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):k_(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),P_(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||D_(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||D_(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&k_(t)?P_(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||D_(t)?e.check(av,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||D_(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),k_(t)?P_(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),k_(t)?P_(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||D_(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function cv(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var lv={name:`codeIndented`,tokenize:dv},uv={partial:!0,tokenize:fv};function dv(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),P_(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):D_(t)?e.attempt(uv,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||D_(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function fv(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):D_(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):P_(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):D_(e)?i(e):n(e)}}var pv={name:`codeText`,previous:hv,resolve:mv,tokenize:gv};function mv(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function hv(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function gv(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):D_(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||D_(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var _v=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&vv(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),vv(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),vv(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);vv(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);vv(this.left,t.reverse())}}};function vv(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function yv(e){let t={},n=-1,r,i,a,o,s,c,l,u=new _v(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,bv(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return f_(e,0,1/0,u.slice(0)),!l}function bv(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var xv={resolve:Cv,tokenize:wv},Sv={partial:!0,tokenize:Tv};function Cv(e){return yv(e),e}function wv(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):D_(t)?e.check(Sv,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Tv(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P_(e,a,`linePrefix`)}function a(i){if(i===null||D_(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Ev(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||C_(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||D_(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||O_(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||C_(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Dv(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):D_(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||D_(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!k_(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Ov(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):D_(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P_(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||D_(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function kv(e,t){let n;return r;function r(i){return D_(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):k_(i)?P_(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Av={name:`definition`,tokenize:Mv},jv={partial:!0,tokenize:Nv};function Mv(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Dv.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=y_(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return O_(t)?kv(e,l)(t):l(t)}function l(t){return Ev(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(jv,d,d)(t)}function d(t){return k_(t)?P_(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||D_(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Nv(e,t,n){return r;function r(t){return O_(t)?kv(e,i)(t):n(t)}function i(t){return Ov(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return k_(t)?P_(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||D_(e)?t(e):n(e)}}var Pv={name:`hardBreakEscape`,tokenize:Fv};function Fv(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return D_(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Iv={name:`headingAtx`,resolve:Lv,tokenize:Rv};function Lv(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},f_(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Rv(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||O_(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||D_(n)?(e.exit(`atxHeading`),t(n)):k_(n)?P_(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||O_(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var zv=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Bv=[`pre`,`script`,`style`,`textarea`],Vv={concrete:!0,name:`htmlFlow`,resolveTo:Wv,tokenize:Gv},Hv={partial:!0,tokenize:qv},Uv={partial:!0,tokenize:Kv};function Wv(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Gv(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):b_(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):b_(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return b_(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||O_(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Bv.includes(l)?(i=1,r.interrupt?t(s):O(s)):zv.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||x_(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return k_(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||b_(t)?(e.consume(t),b):k_(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||x_(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):k_(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):k_(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||D_(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||O_(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||k_(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||D_(t)?O(t):k_(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):D_(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Hv,ee,k)(t)):t===null||D_(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Uv,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||D_(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Bv.includes(n)?(e.consume(t),L):O(t)}return b_(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||D_(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function Kv(e,t,n){let r=this;return i;function i(t){return D_(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function qv(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Y_,t,n)}}var Jv={name:`htmlText`,tokenize:Yv};function Yv(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):b_(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):b_(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):D_(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):D_(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):D_(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):D_(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return b_(t)?(e.consume(t),S):n(t)}function S(t){return t===45||x_(t)?(e.consume(t),S):C(t)}function C(t){return D_(t)?(o=C,N(t)):k_(t)?(e.consume(t),C):M(t)}function w(t){return t===45||x_(t)?(e.consume(t),w):t===47||t===62||O_(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||b_(t)?(e.consume(t),E):D_(t)?(o=T,N(t)):k_(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||x_(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):D_(t)?(o=D,N(t)):k_(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):D_(t)?(o=O,N(t)):k_(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):D_(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||O_(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||O_(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return k_(t)?P_(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var Xv={name:`labelEnd`,resolveAll:ey,resolveTo:ty,tokenize:ny},Zv={tokenize:ry},Qv={tokenize:iy},$v={tokenize:ay};function ey(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&f_(e,0,e.length,n),e}function ty(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=p_(s,e.slice(a+1,a+r+3)),s=p_(s,[[`enter`,u,t]]),s=p_(s,H_(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=p_(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=p_(s,e.slice(o+1)),s=p_(s,[[`exit`,c,t]]),f_(e,a,e.length,s),e}function ny(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(y_(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Zv,u,o?u:d)(t):t===91?e.attempt(Qv,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt($v,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function ry(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return O_(t)?kv(e,a)(t):a(t)}function a(t){return t===41?u(t):Ev(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return O_(t)?kv(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Ov(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return O_(t)?kv(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function iy(e,t,n){let r=this;return i;function i(t){return Dv.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(y_(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function ay(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var oy={name:`labelStartImage`,resolveAll:Xv.resolveAll,tokenize:sy};function sy(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var cy={name:`labelStartLink`,resolveAll:Xv.resolveAll,tokenize:ly};function ly(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var uy={name:`lineEnding`,tokenize:dy};function dy(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),P_(e,t,`linePrefix`)}}var fy={name:`thematicBreak`,tokenize:py};function py(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||D_(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),k_(t)?P_(e,s,`whitespace`)(t):s(t))}}var my={continuation:{tokenize:vy},exit:by,name:`list`,tokenize:_y},hy={partial:!0,tokenize:xy},gy={partial:!0,tokenize:yy};function _y(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:w_(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(fy,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return w_(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Y_,r.interrupt?n:u,e.attempt(hy,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return k_(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function vy(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Y_,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,P_(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!k_(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(gy,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,P_(e,e.attempt(my,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function yy(e,t,n){let r=this;return P_(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function by(e){e.exit(this.containerState.type)}function xy(e,t,n){let r=this;return P_(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!k_(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Sy={name:`setextUnderline`,resolveTo:Cy,tokenize:wy};function Cy(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function wy(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),k_(t)?P_(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||D_(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Ty={tokenize:Ey};function Ey(e){let t=this,n=e.attempt(Y_,r,e.attempt(this.parser.constructs.flowInitial,i,P_(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xv,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Dy={resolveAll:jy()},Oy=Ay(`string`),ky=Ay(`text`);function Ay(e){return{resolveAll:jy(e===`text`?My:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function jy(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function My(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Ny=c({attentionMarkers:()=>Vy,contentInitial:()=>Fy,disable:()=>Hy,document:()=>Py,flow:()=>Ly,flowInitial:()=>Iy,insideSpan:()=>By,string:()=>Ry,text:()=>zy}),Py={42:my,43:my,45:my,48:my,49:my,50:my,51:my,52:my,53:my,54:my,55:my,56:my,57:my,62:Z_},Fy={91:Av},Iy={[-2]:lv,[-1]:lv,32:lv},Ly={35:Iv,42:fy,45:[Sy,fy],60:Vv,61:Sy,95:fy,96:ov,126:ov},Ry={38:rv,92:tv},zy={[-5]:uy,[-4]:uy,[-3]:uy,33:oy,38:rv,42:U_,60:[q_,Jv],91:cy,92:[Pv,tv],93:Xv,95:U_,96:pv},By={null:[U_,Dy]},Vy={null:[42,95]},Hy={null:[]};function Uy(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=p_(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=H_(a,l.events,l),l.events):[]}function f(e,t){return Gy(p(e),t)}function p(e){return Wy(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){D_(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&f_(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Wy(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Gy(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
22
22
|
`;break;case-3:o=`\r
|
|
23
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Gy(e){let t={constructs:h_([My,...(e||{}).extensions||[]]),content:n(P_),defined:[],document:n(I_),flow:n(wy),lazy:{},string:n(Dy),text:n(Oy)};return t;function n(e){return n;function n(n){return Hy(t,e,n)}}}function Ky(e){for(;!vv(e););return e}var qy=/[\0\t\n\r]/g;function Jy(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(qy.lastIndex=u,c=qy.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Yy=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Xy(e){return e.replace(Yy,Zy)}function Zy(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return v_(n.slice(t?2:1),t?16:10)}return d_(n)||e}var Qy={}.hasOwnProperty;function $y(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),eb(n)(Ky(Gy(n).document().write(Jy()(e,t,!0))))}function eb(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(de),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(se),blockQuote:a(re),characterEscape:T,characterReference:T,codeFenced:a(U),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(U,o),codeText:a(ie,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ae),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(oe),hardBreakEscape:a(ce),hardBreakTrailing:a(ce),htmlFlow:a(le,o),htmlFlowData:T,htmlText:a(le,o),htmlTextData:T,image:a(ue),label:o,link:a(de),listItem:a(pe),listItemValue:f,listOrdered:a(fe,d),listUnordered:a(fe),paragraph:a(me),reference:R,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(se),strong:a(he),thematicBreak:a(_e)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:H,autolinkProtocol:ne,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:B,characterReferenceMarkerNumeric:B,characterReferenceValue:te,characterReference:V,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:z,resourceDestinationString:I,resourceTitleString:L,resource:ee,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};nb(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Qy.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||ib).call(a,void 0,e[0])}for(r.position={start:tb(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:tb(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:tb(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||ib).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+wg({start:e.start,end:e.end})+`): it’s not open`);n.position.end=tb(e.end)}function u(){return o_(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=y_(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ge(),n.position={start:tb(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=tb(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=tb(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Xy(t),n.identifier=y_(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function R(){this.data.referenceType=`collapsed`}function z(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=y_(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function B(e){this.data.characterReferenceType=e.type}function te(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=v_(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=d_(t);let i=this.stack[this.stack.length-1];i.value+=r}function V(e){let t=this.stack.pop();t.position.end=tb(e.end)}function ne(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function H(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function re(){return{type:`blockquote`,children:[]}}function U(){return{type:`code`,lang:null,meta:null,value:``}}function ie(){return{type:`inlineCode`,value:``}}function ae(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function oe(){return{type:`emphasis`,children:[]}}function se(){return{type:`heading`,depth:0,children:[]}}function ce(){return{type:`break`}}function le(){return{type:`html`,value:``}}function ue(){return{type:`image`,title:null,url:``,alt:null}}function de(){return{type:`link`,title:null,url:``,children:[]}}function fe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function pe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function me(){return{type:`paragraph`,children:[]}}function he(){return{type:`strong`,children:[]}}function ge(){return{type:`text`,value:``}}function _e(){return{type:`thematicBreak`}}}function tb(e){return{line:e.line,column:e.column,offset:e.offset}}function nb(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?nb(e,r):rb(e,r)}}function rb(e,t){let n;for(n in t)if(Qy.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function ib(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+wg({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+wg({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+wg({start:t.start,end:t.end})+`) is still open`)}function ab(e){let t=this;t.parser=n;function n(n){return $y(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function ob(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function sb(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
24
|
-
`}]}function
|
|
25
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function
|
|
23
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Ky(e){let t={constructs:h_([Ny,...(e||{}).extensions||[]]),content:n(F_),defined:[],document:n(L_),flow:n(Ty),lazy:{},string:n(Oy),text:n(ky)};return t;function n(e){return n;function n(n){return Uy(t,e,n)}}}function qy(e){for(;!yv(e););return e}var Jy=/[\0\t\n\r]/g;function Yy(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(Jy.lastIndex=u,c=Jy.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Xy=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Zy(e){return e.replace(Xy,Qy)}function Qy(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return v_(n.slice(t?2:1),t?16:10)}return d_(n)||e}var $y={}.hasOwnProperty;function eb(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),tb(n)(qy(Ky(n).document().write(Yy()(e,t,!0))))}function tb(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(de),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(se),blockQuote:a(re),characterEscape:T,characterReference:T,codeFenced:a(U),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(U,o),codeText:a(ie,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ae),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(oe),hardBreakEscape:a(ce),hardBreakTrailing:a(ce),htmlFlow:a(le,o),htmlFlowData:T,htmlText:a(le,o),htmlTextData:T,image:a(ue),label:o,link:a(de),listItem:a(pe),listItemValue:f,listOrdered:a(fe,d),listUnordered:a(fe),paragraph:a(me),reference:R,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(se),strong:a(he),thematicBreak:a(_e)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:H,autolinkProtocol:ne,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:B,characterReferenceMarkerNumeric:B,characterReferenceValue:te,characterReference:V,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:z,resourceDestinationString:I,resourceTitleString:L,resource:ee,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};rb(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];$y.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||ab).call(a,void 0,e[0])}for(r.position={start:nb(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:nb(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:nb(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||ab).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+wg({start:e.start,end:e.end})+`): it’s not open`);n.position.end=nb(e.end)}function u(){return o_(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=y_(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ge(),n.position={start:nb(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=nb(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=nb(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Zy(t),n.identifier=y_(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function R(){this.data.referenceType=`collapsed`}function z(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=y_(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function B(e){this.data.characterReferenceType=e.type}function te(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=v_(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=d_(t);let i=this.stack[this.stack.length-1];i.value+=r}function V(e){let t=this.stack.pop();t.position.end=nb(e.end)}function ne(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function H(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function re(){return{type:`blockquote`,children:[]}}function U(){return{type:`code`,lang:null,meta:null,value:``}}function ie(){return{type:`inlineCode`,value:``}}function ae(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function oe(){return{type:`emphasis`,children:[]}}function se(){return{type:`heading`,depth:0,children:[]}}function ce(){return{type:`break`}}function le(){return{type:`html`,value:``}}function ue(){return{type:`image`,title:null,url:``,alt:null}}function de(){return{type:`link`,title:null,url:``,children:[]}}function fe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function pe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function me(){return{type:`paragraph`,children:[]}}function he(){return{type:`strong`,children:[]}}function ge(){return{type:`text`,value:``}}function _e(){return{type:`thematicBreak`}}}function nb(e){return{line:e.line,column:e.column,offset:e.offset}}function rb(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?rb(e,r):ib(e,r)}}function ib(e,t){let n;for(n in t)if($y.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function ab(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+wg({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+wg({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+wg({start:t.start,end:t.end})+`) is still open`)}function ob(e){let t=this;t.parser=n;function n(n){return eb(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function sb(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function cb(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
24
|
+
`}]}function lb(e,t){let n=t.value?t.value+`
|
|
25
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function ub(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function db(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fb(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=N_(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function pb(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mb(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function hb(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function gb(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return hb(e,t);let i={src:N_(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function _b(e,t){let n={src:N_(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function vb(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function yb(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return hb(e,t);let i={href:N_(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function bb(e,t){let n={href:N_(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function xb(e,t,n){let r=e.all(t),i=n?Sb(n):Cb(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
26
26
|
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
27
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function
|
|
27
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Sb(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Cb(n[r])}return t}function Cb(e){return e.spread??e.children.length>1}function wb(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function Tb(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Eb(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Db(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ob(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=xg(t.children[1]),o=bg(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function kb(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Ab(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var jb=9,Mb=32;function Nb(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(Pb(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Pb(t.slice(i),i>0,!1)),a.join(``)}function Pb(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===jb||t===Mb;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===jb||t===Mb;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function Fb(e,t){let n={type:`text`,value:Nb(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Ib(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Lb={blockquote:sb,break:cb,code:lb,delete:ub,emphasis:db,footnoteReference:fb,heading:pb,html:mb,imageReference:gb,image:_b,inlineCode:vb,linkReference:yb,link:bb,listItem:xb,list:wb,paragraph:Tb,root:Eb,strong:Db,table:Ob,tableCell:Ab,tableRow:kb,text:Fb,thematicBreak:Ib,toml:Rb,yaml:Rb,definition:Rb,footnoteDefinition:Rb};function Rb(){}var zb=typeof self==`object`?self:globalThis,Bb=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new zb[e](t)},Vb=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(Bb(e,t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(Bb(a,o),i)};return r},Hb=e=>Vb(new Map,e)(0),Ub=``,{toString:Wb}={},{keys:Gb}=Object,Kb=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=Wb.call(e).slice(8,-1);switch(n){case`Array`:return[1,Ub];case`Object`:return[2,Ub];case`Date`:return[3,Ub];case`RegExp`:return[4,Ub];case`Map`:return[5,Ub];case`Set`:return[6,Ub];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},qb=([e,t])=>e===0&&(t===`function`||t===`symbol`),Jb=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=Kb(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of Gb(r))(e||!qb(Kb(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(qb(Kb(n))||qb(Kb(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!qb(Kb(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},Yb=(e,{json:t,lossy:n}={})=>{let r=[];return Jb(!(t||n),!!t,new Map,r)(e),r},Xb=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?Hb(Yb(e,t)):structuredClone(e):(e,t)=>Hb(Yb(e,t));function Zb(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function Qb(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function $b(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||Zb,r=e.options.footnoteBackLabel||Qb,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=N_(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...Xb(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
28
28
|
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
29
|
-
`}]}}var
|
|
29
|
+
`}]}}var ex=(function(e){if(e==null)return ax;if(typeof e==`function`)return ix(e);if(typeof e==`object`)return Array.isArray(e)?tx(e):nx(e);if(typeof e==`string`)return rx(e);throw Error(`Expected function, string, or object as test`)});function tx(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ex(e[n]);return ix(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function nx(e){let t=e;return ix(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function rx(e){return ix(t);function t(t){return t&&t.type===e}}function ix(e){return t;function t(t,n,r){return!!(ox(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function ax(){return!0}function ox(e){return typeof e==`object`&&!!e&&`type`in e}function sx(e){return e}var cx=[];function lx(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=ex(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+sx(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=cx,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=ux(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function ux(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?cx:[e]}function dx(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),lx(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var fx={}.hasOwnProperty,px={};function mx(e,t){let n=t||px,r=new Map,i=new Map,a={all:s,applyData:gx,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Lb,...n.handlers},one:o,options:n,patch:hx,wrap:vx};return dx(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(fx.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=Xb(n);return r.children=a.all(e),r}return Xb(e)}return(a.options.unknownHandler||_x)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=yx(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=yx(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function hx(e,t){e.position&&(t.position=Cg(e))}function gx(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,Xb(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function _x(e,t){let n=t.data||{},r=`value`in t&&!(fx.call(n,`hProperties`)||fx.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function vx(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
30
30
|
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
31
31
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
32
|
-
`}),n}function
|
|
33
|
-
`},i)),a}function bx(e,t){return e&&`run`in e?async function(n,r){let i=yx(n,{file:r,...t});await e.run(i,r)}:function(n,r){return yx(n,{file:r,...e||t})}}function xx(e){if(e)throw e}var Sx=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function Cx(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function wx(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Tx(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Tx(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var Ex={basename:Dx,dirname:Ox,extname:kx,join:Ax,sep:`/`};function Dx(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Nx(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Ox(e){if(Nx(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function kx(e){Nx(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function Ax(...e){let t=-1,n;for(;++t<e.length;)Nx(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:jx(n)}function jx(e){Nx(e);let t=e.codePointAt(0)===47,n=Mx(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Mx(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function Nx(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Px={cwd:Fx};function Fx(){return`/`}function Ix(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Lx(e){if(typeof e==`string`)e=new URL(e);else if(!Ix(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return Rx(e)}function Rx(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var zx=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Bx=class{constructor(e){let t;t=e?Ix(e)?{path:e}:typeof e==`string`||Wx(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Px.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<zx.length;){let e=zx[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)zx.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Ex.basename(this.path):void 0}set basename(e){Hx(e,`basename`),Vx(e,`basename`),this.path=Ex.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Ex.dirname(this.path):void 0}set dirname(e){Ux(this.basename,`dirname`),this.path=Ex.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Ex.extname(this.path):void 0}set extname(e){if(Vx(e,`extname`),Ux(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Ex.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Ix(e)&&(e=Lx(e)),Hx(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Ex.basename(this.path,this.extname):void 0}set stem(e){Hx(e,`stem`),Vx(e,`stem`),this.path=Ex.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Og(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Vx(e,t){if(e&&e.includes(Ex.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Ex.sep+"`")}function Hx(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function Ux(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Wx(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Gx=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Kx=u(Sx(),1),qx={}.hasOwnProperty,Jx=new class e extends Gx{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=wx()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Kx.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(Zx(`data`,this.frozen),this.namespace[e]=t,this):qx.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Zx(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=eS(e),n=this.parser||this.Parser;return Yx(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Yx(`process`,this.parser||this.Parser),Xx(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=eS(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);nS(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Yx(`processSync`,this.parser||this.Parser),Xx(`processSync`,this.compiler||this.Compiler),this.process(e,r),$x(`processSync`,`process`,t),n;function r(e,r){t=!0,xx(e),n=r}}run(e,t,n){Qx(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=eS(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),$x(`runSync`,`run`,n),r;function i(e,t){xx(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=eS(t),r=this.compiler||this.Compiler;return Xx(`stringify`,r),Qx(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(Zx(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,Kx.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Cx(o)&&Cx(r)&&(r=(0,Kx.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Yx(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Xx(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function Zx(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Qx(e){if(!Cx(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function $x(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function eS(e){return tS(e)?e:new Bx(e)}function tS(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function nS(e){return typeof e==`string`||rS(e)}function rS(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var iS=[],aS={allowDangerousHtml:!0},oS=/^(https?|ircs?|mailto|xmpp)$/i,sS=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function cS(e){let t=lS(e),n=uS(e);return dS(t.runSync(t.parse(n),n),e)}function lS(e){let t=e.rehypePlugins||iS,n=e.remarkPlugins||iS,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...aS}:aS;return Jx().use(ab).use(n).use(bx,r).use(t)}function uS(e){let t=e.children||``,n=new Bx;return typeof t==`string`?n.value=t:``+t,n}function dS(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||fS;for(let e of sS)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return ux(e,l),Ig(e,{Fragment:W.Fragment,components:i,ignoreInvalidStyle:!0,jsx:W.jsx,jsxs:W.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in i_)if(Object.hasOwn(i_,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=i_[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function fS(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||oS.test(e.slice(0,t))?e:``}function pS(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function mS(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function hS(e,t,n){let r=$b((n||{}).ignore||[]),i=gS(t),a=-1;for(;++a<i.length;)cx(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function gS(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([_S(e[0]),vS(e[1])])}return t}function _S(e){return typeof e==`string`?new RegExp(mS(e),`g`):e}function vS(e){return typeof e==`function`?e:function(){return e}}var yS=`phrasing`,bS=[`autolink`,`link`,`image`,`label`];function xS(){return{transforms:[kS],enter:{literalAutolink:CS,literalAutolinkEmail:wS,literalAutolinkHttp:wS,literalAutolinkWww:wS},exit:{literalAutolink:OS,literalAutolinkEmail:DS,literalAutolinkHttp:TS,literalAutolinkWww:ES}}}function SS(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:yS,notInConstruct:bS},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:yS,notInConstruct:bS},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:yS,notInConstruct:bS}]}}function CS(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function wS(e){this.config.enter.autolinkProtocol.call(this,e)}function TS(e){this.config.exit.autolinkProtocol.call(this,e)}function ES(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function DS(e){this.config.exit.autolinkEmail.call(this,e)}function OS(e){this.exit(e)}function kS(e){hS(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,AS],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,jS]],{ignore:[`link`,`linkReference`]})}function AS(e,t,n,r,i){let a=``;if(!PS(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!MS(n)))return!1;let o=NS(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function jS(e,t,n,r){return!PS(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function MS(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function NS(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=pS(e,`(`),a=pS(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function PS(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||A_(n)||k_(n))&&(!t||n!==47)}WS.peek=US;function FS(){this.buffer()}function IS(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function LS(){this.buffer()}function RS(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function zS(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=y_(this.sliceSerialize(e)).toLowerCase(),n.label=t}function BS(e){this.exit(e)}function VS(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=y_(this.sliceSerialize(e)).toLowerCase(),n.label=t}function HS(e){this.exit(e)}function US(){return`[`}function WS(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function GS(){return{enter:{gfmFootnoteCallString:FS,gfmFootnoteCall:IS,gfmFootnoteDefinitionLabelString:LS,gfmFootnoteDefinition:RS},exit:{gfmFootnoteCallString:zS,gfmFootnoteCall:BS,gfmFootnoteDefinitionLabelString:VS,gfmFootnoteDefinition:HS}}}function KS(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:WS},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
34
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?JS
|
|
35
|
-
`)}function
|
|
36
|
-
`&&
|
|
37
|
-
`}function
|
|
32
|
+
`}),n}function yx(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function bx(e,t){let n=mx(e,t),r=n.one(e,void 0),i=$b(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
33
|
+
`},i)),a}function xx(e,t){return e&&`run`in e?async function(n,r){let i=bx(n,{file:r,...t});await e.run(i,r)}:function(n,r){return bx(n,{file:r,...e||t})}}function Sx(e){if(e)throw e}var Cx=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function wx(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Tx(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Ex(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Ex(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var Dx={basename:Ox,dirname:kx,extname:Ax,join:jx,sep:`/`};function Ox(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Px(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function kx(e){if(Px(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function Ax(e){Px(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function jx(...e){let t=-1,n;for(;++t<e.length;)Px(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Mx(n)}function Mx(e){Px(e);let t=e.codePointAt(0)===47,n=Nx(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Nx(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function Px(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Fx={cwd:Ix};function Ix(){return`/`}function Lx(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Rx(e){if(typeof e==`string`)e=new URL(e);else if(!Lx(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return zx(e)}function zx(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var Bx=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Vx=class{constructor(e){let t;t=e?Lx(e)?{path:e}:typeof e==`string`||Gx(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Fx.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Bx.length;){let e=Bx[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)Bx.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Dx.basename(this.path):void 0}set basename(e){Ux(e,`basename`),Hx(e,`basename`),this.path=Dx.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Dx.dirname(this.path):void 0}set dirname(e){Wx(this.basename,`dirname`),this.path=Dx.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Dx.extname(this.path):void 0}set extname(e){if(Hx(e,`extname`),Wx(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=Dx.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Lx(e)&&(e=Rx(e)),Ux(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Dx.basename(this.path,this.extname):void 0}set stem(e){Ux(e,`stem`),Hx(e,`stem`),this.path=Dx.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Og(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function Hx(e,t){if(e&&e.includes(Dx.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Dx.sep+"`")}function Ux(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function Wx(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Gx(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Kx=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),qx=u(Cx(),1),Jx={}.hasOwnProperty,Yx=new class e extends Kx{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Tx()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,qx.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(Qx(`data`,this.frozen),this.namespace[e]=t,this):Jx.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Qx(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=tS(e),n=this.parser||this.Parser;return Xx(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Xx(`process`,this.parser||this.Parser),Zx(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=tS(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);rS(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Xx(`processSync`,this.parser||this.Parser),Zx(`processSync`,this.compiler||this.Compiler),this.process(e,r),eS(`processSync`,`process`,t),n;function r(e,r){t=!0,Sx(e),n=r}}run(e,t,n){$x(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=tS(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),eS(`runSync`,`run`,n),r;function i(e,t){Sx(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=tS(t),r=this.compiler||this.Compiler;return Zx(`stringify`,r),$x(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(Qx(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,qx.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];wx(o)&&wx(r)&&(r=(0,qx.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Xx(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Zx(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function Qx(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function $x(e){if(!wx(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function eS(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function tS(e){return nS(e)?e:new Vx(e)}function nS(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function rS(e){return typeof e==`string`||iS(e)}function iS(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var aS=[],oS={allowDangerousHtml:!0},sS=/^(https?|ircs?|mailto|xmpp)$/i,cS=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function lS(e){let t=uS(e),n=dS(e);return fS(t.runSync(t.parse(n),n),e)}function uS(e){let t=e.rehypePlugins||aS,n=e.remarkPlugins||aS,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...oS}:oS;return Yx().use(ob).use(n).use(xx,r).use(t)}function dS(e){let t=e.children||``,n=new Vx;return typeof t==`string`?n.value=t:``+t,n}function fS(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||pS;for(let e of cS)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return dx(e,l),Ig(e,{Fragment:W.Fragment,components:i,ignoreInvalidStyle:!0,jsx:W.jsx,jsxs:W.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in i_)if(Object.hasOwn(i_,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=i_[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function pS(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||sS.test(e.slice(0,t))?e:``}function mS(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function hS(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function gS(e,t,n){let r=ex((n||{}).ignore||[]),i=_S(t),a=-1;for(;++a<i.length;)lx(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function _S(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([vS(e[0]),yS(e[1])])}return t}function vS(e){return typeof e==`string`?new RegExp(hS(e),`g`):e}function yS(e){return typeof e==`function`?e:function(){return e}}var bS=`phrasing`,xS=[`autolink`,`link`,`image`,`label`];function SS(){return{transforms:[AS],enter:{literalAutolink:wS,literalAutolinkEmail:TS,literalAutolinkHttp:TS,literalAutolinkWww:TS},exit:{literalAutolink:kS,literalAutolinkEmail:OS,literalAutolinkHttp:ES,literalAutolinkWww:DS}}}function CS(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:bS,notInConstruct:xS},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:bS,notInConstruct:xS},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:bS,notInConstruct:xS}]}}function wS(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function TS(e){this.config.enter.autolinkProtocol.call(this,e)}function ES(e){this.config.exit.autolinkProtocol.call(this,e)}function DS(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function OS(e){this.config.exit.autolinkEmail.call(this,e)}function kS(e){this.exit(e)}function AS(e){gS(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,jS],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,MS]],{ignore:[`link`,`linkReference`]})}function jS(e,t,n,r,i){let a=``;if(!FS(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!NS(n)))return!1;let o=PS(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function MS(e,t,n,r){return!FS(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function NS(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function PS(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=mS(e,`(`),a=mS(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function FS(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||j_(n)||A_(n))&&(!t||n!==47)}GS.peek=WS;function IS(){this.buffer()}function LS(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function RS(){this.buffer()}function zS(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function BS(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=y_(this.sliceSerialize(e)).toLowerCase(),n.label=t}function VS(e){this.exit(e)}function HS(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=y_(this.sliceSerialize(e)).toLowerCase(),n.label=t}function US(e){this.exit(e)}function WS(){return`[`}function GS(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function KS(){return{enter:{gfmFootnoteCallString:IS,gfmFootnoteCall:LS,gfmFootnoteDefinitionLabelString:RS,gfmFootnoteDefinition:zS},exit:{gfmFootnoteCallString:BS,gfmFootnoteCall:VS,gfmFootnoteDefinitionLabelString:HS,gfmFootnoteDefinition:US}}}function qS(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:GS},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
34
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?YS:JS))),s(),o}}function JS(e,t,n){return t===0?e:YS(e,t,n)}function YS(e,t,n){return(n?``:` `)+e}var XS=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];tC.peek=nC;function ZS(){return{canContainEols:[`delete`],enter:{strikethrough:$S},exit:{strikethrough:eC}}}function QS(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:XS}],handlers:{delete:tC}}}function $S(e){this.enter({type:`delete`,children:[]},e)}function eC(e){this.exit(e)}function tC(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function nC(){return`~`}function rC(e){return e.length}function iC(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||rC,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=aC(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=oC(r[d]);else{let e=oC(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
35
|
+
`)}function aC(e){return e==null?``:String(e)}function oC(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function sC(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),cC);return i(),o}function cC(e,t,n){return`>`+(n?``:` `)+e}function lC(e,t){return uC(e,t.inConstruct,!0)&&!uC(e,t.notInConstruct,!1)}function uC(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function dC(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
36
|
+
`&&lC(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
37
|
+
`}function fC(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function pC(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function mC(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function hC(e,t,n,r){let i=mC(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(pC(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,gC);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(fC(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
38
38
|
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
39
39
|
`),a&&(u+=s.move(a+`
|
|
40
|
-
`)),u+=s.move(c),l(),u}function
|
|
41
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function
|
|
40
|
+
`)),u+=s.move(c),l(),u}function gC(e,t,n){return(n?``:` `)+e}function _C(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function vC(e,t,n,r){let i=_C(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
41
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function yC(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function bC(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function xC(e,t,n){let r=V_(e),i=V_(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}SC.peek=CC;function SC(e,t,n,r){let i=yC(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=xC(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=bC(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=xC(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+bC(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function CC(e,t,n){return n.options.emphasis||`*`}function wC(e,t){let n=!1;return dx(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&o_(e)&&(t.options.setext||n))}function TC(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(wC(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
42
42
|
`,after:`
|
|
43
43
|
`});return r(),t(),o+`
|
|
44
44
|
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
45
45
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
46
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=
|
|
46
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=bC(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}EC.peek=DC;function EC(e){return e.value||``}function DC(){return`<`}OC.peek=kC;function OC(e,t,n,r){let i=_C(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function kC(){return`!`}AC.peek=jC;function AC(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function jC(){return`!`}MC.peek=NC;function MC(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function NC(){return"`"}function PC(e,t){let n=o_(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}FC.peek=IC;function FC(e,t,n,r){let i=_C(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(PC(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function IC(e,t,n){return PC(e,n)?`<`:`[`}LC.peek=RC;function LC(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function RC(){return`[`}function zC(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function BC(e){let t=zC(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function VC(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function HC(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function UC(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?VC(n):zC(n),s=e.ordered?o===`.`?`)`:`.`:BC(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),HC(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function WC(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function GC(e,t,n,r){let i=WC(n),a=n.bulletCurrent||zC(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function KC(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var qC=ex([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function JC(e,t,n,r){return(e.children.some(function(e){return qC(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function YC(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}XC.peek=ZC;function XC(e,t,n,r){let i=YC(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=xC(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=bC(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=xC(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+bC(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function ZC(e,t,n){return n.options.strong||`*`}function QC(e,t,n,r){return n.safe(e.value,r)}function $C(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function ew(e,t,n){let r=(HC(n)+(n.options.ruleSpaces?` `:``)).repeat($C(n));return n.options.ruleSpaces?r.slice(0,-1):r}var tw={blockquote:sC,break:dC,code:hC,definition:vC,emphasis:SC,hardBreak:dC,heading:TC,html:EC,image:OC,imageReference:AC,inlineCode:MC,link:FC,linkReference:LC,list:UC,listItem:GC,paragraph:KC,root:JC,strong:XC,text:QC,thematicBreak:ew};function nw(){return{enter:{table:rw,tableData:sw,tableHeader:sw,tableRow:aw},exit:{codeText:cw,table:iw,tableData:ow,tableHeader:ow,tableRow:ow}}}function rw(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function iw(e){this.exit(e),this.data.inTable=void 0}function aw(e){this.enter({type:`tableRow`,children:[]},e)}function ow(e){this.exit(e)}function sw(e){this.enter({type:`tableCell`,children:[]},e)}function cw(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,lw));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function lw(e,t){return t===`|`?t:e}function uw(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
47
47
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
48
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return rC(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=ew.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function uw(){return{exit:{taskListCheckValueChecked:fw,taskListCheckValueUnchecked:fw,paragraph:pw}}}function dw(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:mw}}}function fw(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function pw(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function mw(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=ew.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function hw(){return[xS(),GS(),XS(),tw(),uw()]}function gw(e){return{extensions:[SS(),KS(e),ZS(),lw(e),dw()]}}var _w={tokenize:jw,partial:!0},vw={tokenize:Mw,partial:!0},yw={tokenize:Nw,partial:!0},bw={tokenize:Pw,partial:!0},xw={tokenize:Fw,partial:!0},Sw={name:`wwwAutolink`,tokenize:kw,previous:Iw},Cw={name:`protocolAutolink`,tokenize:Aw,previous:Lw},ww={name:`emailAutolink`,tokenize:Ow,previous:Rw},Tw={};function Ew(){return{text:Tw}}for(var Dw=48;Dw<123;)Tw[Dw]=ww,Dw++,Dw===58?Dw=65:Dw===91&&(Dw=97);Tw[43]=ww,Tw[45]=ww,Tw[46]=ww,Tw[95]=ww,Tw[72]=[ww,Cw],Tw[104]=[ww,Cw],Tw[87]=[ww,Sw],Tw[119]=[ww,Sw];function Ow(e,t,n){let r=this,i,a;return o;function o(t){return!zw(t)||!Rw.call(r,r.previous)||Bw(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return zw(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(xw,u,l)(t):t===45||t===95||x_(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&b_(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function kw(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Iw.call(r,r.previous)||Bw(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(_w,e.attempt(vw,e.attempt(yw,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Aw(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Lw.call(r,r.previous)&&!Bw(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(b_(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||C_(t)||D_(t)||A_(t)||k_(t)?n(t):e.attempt(vw,e.attempt(yw,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function jw(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Mw(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(bw,c,s)(t):t===null||D_(t)||A_(t)||t!==45&&k_(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Nw(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(bw,t,a)(o):o===null||D_(o)||A_(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Pw(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||D_(o)||A_(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||D_(e)||A_(e)?t(e):r(e)}function a(e){return b_(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):b_(t)?(e.consume(t),o):n(t)}}function Fw(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return x_(e)?n(e):t(e)}}function Iw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||D_(e)}function Lw(e){return!b_(e)}function Rw(e){return!(e===47||zw(e))}function zw(e){return e===43||e===45||e===46||e===95||x_(e)}function Bw(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Vw={tokenize:Yw,partial:!0};function Hw(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Kw,continuation:{tokenize:qw},exit:Jw}},text:{91:{name:`gfmFootnoteCall`,tokenize:Gw},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Uw,resolveTo:Ww}}}}function Uw(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=y_(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Ww(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Gw(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||D_(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(y_(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return D_(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Kw(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||D_(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=y_(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return D_(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),N_(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function qw(e,t,n){return e.check(J_,t,e.attempt(Vw,t,n))}function Jw(e){e.exit(`gfmFootnoteDefinition`)}function Yw(e,t,n){let r=this;return N_(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Xw(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&f_(o,o.length,0,V_(s,e.slice(r+1,n),t)),f_(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),f_(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=B_(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=B_(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Zw=class{constructor(){this.map=[]}add(e,t,n){Qw(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Qw(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function $w(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function eT(){return{flow:{null:{name:`table`,tokenize:tT,resolveAll:nT}}}}function tT(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):J(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):O_(t)?N_(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||D_(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,O_(t)?N_(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return O_(t)?N_(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||J(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return O_(t)?N_(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||J(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||J(n)?(e.exit(`tableRow`),t(n)):O_(n)?N_(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||D_(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function nT(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Zw;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(iT(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=rT(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=rT(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=rT(f,t,o,i,n,d)):(o[0]=o[1],d=rT(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&iT(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=$w(t.events,n))}return e}function rT(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},aT(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=aT(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=aT(t.events,n[2]),a=aT(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},aT(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function iT(e,t,n,r,i){let a=[],o=aT(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function aT(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var oT={name:`tasklistCheck`,tokenize:cT};function sT(){return{text:{91:oT}}}function cT(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return D_(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return J(r)?t(r):O_(r)?e.check({tokenize:lT},t,n)(r):n(r)}}function lT(e,t,n){return N_(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function uT(e){return h_([Ew(),Hw(),Xw(e),eT(),sT()])}var dT={};function fT(e){let t=this,n=e||dT,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(uT(n)),a.push(hw()),o.push(gw(n))}function pT(e){hS(e,[/\r?\n|\r/g,mT])}function mT(){return{type:`break`}}function hT(){return function(e){pT(e)}}var gT=1e4,_T=200;function vT(e){let t=lh(e.payload),n=lh(e.message),r=uh(e.timestamp)??uh(t?.timestamp)??uh(n?.timestamp)??uh(e.created_at)??uh(t?.created_at)??uh(e.createdAt)??uh(t?.createdAt);return r&&!Number.isNaN(Date.parse(r))?r:null}function yT(e){if(!e)return null;let t=new Date(e);if(Number.isNaN(t.getTime()))return null;let n=new Date,r=t.toDateString()===n.toDateString(),i=t.getFullYear()===n.getFullYear(),a=r?{hour:`numeric`,minute:`2-digit`}:i?{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}:{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`};return new Intl.DateTimeFormat(void 0,a).format(t)}function bT(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function xT(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(e=>{if(typeof e==`string`)return e;let t=lh(e);if(!t)return``;let n=uh(t.type);return n===`thinking`?``:n===`tool_use`?`[Tool: ${uh(t.name)??`tool`}]`:(uh(t.text)??uh(t.content)??uh(t.output))||``}).filter(Boolean).join(`
|
|
48
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return iC(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=tw.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function dw(){return{exit:{taskListCheckValueChecked:pw,taskListCheckValueUnchecked:pw,paragraph:mw}}}function fw(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:hw}}}function pw(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function mw(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function hw(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=tw.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function gw(){return[SS(),KS(),ZS(),nw(),dw()]}function _w(e){return{extensions:[CS(),qS(e),QS(),uw(e),fw()]}}var vw={tokenize:Mw,partial:!0},yw={tokenize:Nw,partial:!0},bw={tokenize:Pw,partial:!0},xw={tokenize:Fw,partial:!0},Sw={tokenize:Iw,partial:!0},Cw={name:`wwwAutolink`,tokenize:Aw,previous:Lw},ww={name:`protocolAutolink`,tokenize:jw,previous:Rw},Tw={name:`emailAutolink`,tokenize:kw,previous:zw},Ew={};function Dw(){return{text:Ew}}for(var Ow=48;Ow<123;)Ew[Ow]=Tw,Ow++,Ow===58?Ow=65:Ow===91&&(Ow=97);Ew[43]=Tw,Ew[45]=Tw,Ew[46]=Tw,Ew[95]=Tw,Ew[72]=[Tw,ww],Ew[104]=[Tw,ww],Ew[87]=[Tw,Cw],Ew[119]=[Tw,Cw];function kw(e,t,n){let r=this,i,a;return o;function o(t){return!Bw(t)||!zw.call(r,r.previous)||Vw(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Bw(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Sw,u,l)(t):t===45||t===95||x_(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&b_(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Aw(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Lw.call(r,r.previous)||Vw(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(vw,e.attempt(yw,e.attempt(bw,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function jw(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Rw.call(r,r.previous)&&!Vw(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(b_(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||C_(t)||O_(t)||j_(t)||A_(t)?n(t):e.attempt(yw,e.attempt(bw,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Mw(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Nw(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(xw,c,s)(t):t===null||O_(t)||j_(t)||t!==45&&A_(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Pw(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(xw,t,a)(o):o===null||O_(o)||j_(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Fw(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||O_(o)||j_(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||O_(e)||j_(e)?t(e):r(e)}function a(e){return b_(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):b_(t)?(e.consume(t),o):n(t)}}function Iw(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return x_(e)?n(e):t(e)}}function Lw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||O_(e)}function Rw(e){return!b_(e)}function zw(e){return!(e===47||Bw(e))}function Bw(e){return e===43||e===45||e===46||e===95||x_(e)}function Vw(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Hw={tokenize:Xw,partial:!0};function Uw(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:qw,continuation:{tokenize:Jw},exit:Yw}},text:{91:{name:`gfmFootnoteCall`,tokenize:Kw},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Ww,resolveTo:Gw}}}}function Ww(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=y_(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Gw(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Kw(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||O_(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(y_(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return O_(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function qw(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||O_(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=y_(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return O_(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),P_(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Jw(e,t,n){return e.check(Y_,t,e.attempt(Hw,t,n))}function Yw(e){e.exit(`gfmFootnoteDefinition`)}function Xw(e,t,n){let r=this;return P_(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Zw(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&f_(o,o.length,0,H_(s,e.slice(r+1,n),t)),f_(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),f_(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=V_(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=V_(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Qw=class{constructor(){this.map=[]}add(e,t,n){$w(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function $w(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function eT(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function tT(){return{flow:{null:{name:`table`,tokenize:nT,resolveAll:rT}}}}function nT(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):D_(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):k_(t)?P_(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||O_(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,k_(t)?P_(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return k_(t)?P_(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||D_(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return k_(t)?P_(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||D_(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||D_(n)?(e.exit(`tableRow`),t(n)):k_(n)?P_(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||O_(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function rT(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Qw;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(aT(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=iT(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=iT(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=iT(f,t,o,i,n,d)):(o[0]=o[1],d=iT(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&aT(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=eT(t.events,n))}return e}function iT(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},oT(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=oT(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=oT(t.events,n[2]),a=oT(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},oT(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function aT(e,t,n,r,i){let a=[],o=oT(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function oT(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var sT={name:`tasklistCheck`,tokenize:lT};function cT(){return{text:{91:sT}}}function lT(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return O_(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return D_(r)?t(r):k_(r)?e.check({tokenize:uT},t,n)(r):n(r)}}function uT(e,t,n){return P_(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function dT(e){return h_([Dw(),Uw(),Zw(e),tT(),cT()])}var fT={};function pT(e){let t=this,n=e||fT,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(dT(n)),a.push(gw()),o.push(_w(n))}function mT(e){gS(e,[/\r?\n|\r/g,hT])}function hT(){return{type:`break`}}function gT(){return function(e){mT(e)}}var _T=1e4,vT=200;function yT(e){let t=lh(e.payload),n=lh(e.message),r=uh(e.timestamp)??uh(t?.timestamp)??uh(n?.timestamp)??uh(e.created_at)??uh(t?.created_at)??uh(e.createdAt)??uh(t?.createdAt);return r&&!Number.isNaN(Date.parse(r))?r:null}function bT(e){if(!e)return null;let t=new Date(e);if(Number.isNaN(t.getTime()))return null;let n=new Date,r=t.toDateString()===n.toDateString(),i=t.getFullYear()===n.getFullYear(),a=r?{hour:`numeric`,minute:`2-digit`}:i?{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}:{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`};return new Intl.DateTimeFormat(void 0,a).format(t)}function xT(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ST(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(e=>{if(typeof e==`string`)return e;let t=lh(e);if(!t)return``;let n=uh(t.type);return n===`thinking`?``:n===`tool_use`?`[Tool: ${uh(t.name)??`tool`}]`:(uh(t.text)??uh(t.content)??uh(t.output))||``}).filter(Boolean).join(`
|
|
49
49
|
|
|
50
|
-
`);let t=lh(e);if(!t)return
|
|
51
|
-
`)?(0,W.jsx)(`code`,{className:e,children:t}):(0,W.jsx)(`code`,{className:`rounded bg-surface px-1 py-0.5 text-[0.9em] text-primary`,children:t})},table:({children:e})=>(0,W.jsx)(`div`,{className:`my-2 overflow-x-auto`,children:(0,W.jsx)(`table`,{className:`w-full border-collapse text-xs`,children:e})}),th:({children:e})=>(0,W.jsx)(`th`,{className:`border border-border px-2 py-1 text-left font-semibold`,children:e}),td:({children:e})=>(0,W.jsx)(`td`,{className:`border border-border px-2 py-1 align-top`,children:e})};function LT({content:e}){return(0,W.jsx)(`div`,{className:`min-w-0 break-words text-sm leading-6 text-primary [overflow-wrap:anywhere]`,children:(0,W.jsx)(cS,{remarkPlugins:[fT,hT],components:IT,children:e})})}function RT({entry:e,showRole:t=!0}){if(OT(e))return(0,W.jsx)(FT,{entry:e});let n=MT(e.lineNumber,e.timestamp,e.exactLineNumber);return(0,W.jsxs)(`article`,{className:`grid grid-cols-[5.75rem_minmax(0,1fr)] gap-3 pb-2 sm:grid-cols-[6.75rem_minmax(0,1fr)] ${t?`mt-4 border-t border-border/60 pt-4 first:mt-0 first:border-t-0 first:pt-0`:`pt-1`}`,children:[(0,W.jsxs)(`div`,{className:`select-none pt-0.5 text-right`,children:[t&&(0,W.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide ${PT(e)}`,children:NT(e)}),(0,W.jsx)(`div`,{className:`text-[10px] tabular-nums text-muted ${t?`mt-1`:``}`,title:jT(e.lineNumber,e.timestamp,e.exactLineNumber),children:n})]}),(0,W.jsx)(LT,{content:e.content})]})}function zT({entry:e}){let[t,n]=(0,x.useState)(!1),r=e.prominence===`system`||e.prominence===`plain`,i=e.prominence===`tool`&&!!(e.body&&e.body.length>160),a=yT(e.timestamp),o=r?`border-border/70 bg-surface/20 opacity-80`:e.prominence===`tool`?`border-border bg-surface/35`:`border-border bg-surface/50`,s=e.prominence===`message`?`bg-accent/15 text-accent`:`bg-surface text-muted`;return(0,W.jsx)(`article`,{className:`rounded-md border ${o}`,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-[5.75rem_minmax(0,1fr)] gap-3 px-3 py-2 sm:grid-cols-[6.75rem_minmax(0,1fr)]`,children:[(0,W.jsx)(`div`,{className:`select-none text-right text-[11px] tabular-nums text-muted`,title:jT(e.lineNumber,e.timestamp,e.exactLineNumber),children:a??(e.exactLineNumber?`Line ${e.lineNumber+1}`:`Entry`)}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${s}`,children:e.source}),(0,W.jsx)(`span`,{className:`min-w-0 break-words text-xs font-semibold text-primary`,children:e.title})]}),e.body&&!i&&(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded bg-base px-3 py-2 text-xs leading-relaxed text-secondary`,children:e.body}),e.body&&i&&(0,W.jsxs)(`div`,{className:`rounded bg-base px-3 py-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`select-none text-[11px] text-muted hover:text-primary`,"aria-expanded":t,onClick:()=>n(e=>!e),children:`Output`}),t&&(0,W.jsx)(`pre`,{className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words text-xs leading-relaxed text-secondary`,children:e.body})]}),e.details.length>0&&(0,W.jsxs)(`details`,{className:`group`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer select-none text-[11px] text-muted hover:text-primary`,children:`Details`}),(0,W.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.details.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted`,children:e.label}),(0,W.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-base px-3 py-2 text-[11px] leading-relaxed text-muted`,children:e.value})]},e.label))})]})]})]})})}async function BT(e,t){let n=await fetch(e,{signal:t});if(!n.ok){let e=`Failed to load preview (HTTP ${n.status})`;try{let t=await n.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return await n.json()}function VT({session:e,className:t=``,onStateChange:n}){let[r,i]=(0,x.useState)(!0),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(`messages`),p=(0,x.useRef)(null),m=(0,x.useRef)(!1),h=(0,x.useRef)(!1);(0,x.useEffect)(()=>{let t=!1,n=new AbortController,r=setTimeout(()=>n.abort(),gT);return(async()=>{i(!0),c(null),u(null);try{let r=await BT(`/api/session-preview/${e.sessionId}?limit=${_T}`,n.signal);t||u(r)}catch(e){if(t)return;n.signal.aborted?c(`Preview timed out`):c(e instanceof Error?e.message:`Failed to load preview`)}finally{t||i(!1)}})(),()=>{t=!0,clearTimeout(r),n.abort()}},[e.sessionId]);let g=async()=>{if(!l||h.current||!l.hasMoreBefore)return;h.current=!0,m.current=!0;let t=new AbortController,n=setTimeout(()=>t.abort(),gT);o(!0),c(null);try{let n=new URLSearchParams({limit:String(_T)});typeof l.startByte==`number`?n.set(`beforeByte`,String(l.startByte)):n.set(`beforeLine`,String(l.startLine));let r=await BT(`/api/session-preview/${e.sessionId}?${n.toString()}`,t.signal);u(e=>e?{...e,totalLines:r.totalLines??e.totalLines,startLine:r.startLine,endLine:e.endLine,hasMoreBefore:r.hasMoreBefore,startByte:r.startByte,endByte:e.endByte,lines:[...r.lines,...e.lines],lineKeys:[...r.lineKeys??r.lines.map((e,t)=>String(r.startLine+t)),...e.lineKeys??e.lines.map((t,n)=>String(e.startLine+n))]}:r)}catch(e){m.current=!1,t.signal.aborted?c(`Preview timed out`):c(e instanceof Error?e.message:`Failed to load preview`)}finally{clearTimeout(n),h.current=!1,o(!1)}};(0,x.useEffect)(()=>{n?.({loading:r,error:s})},[s,r,n]),(0,x.useLayoutEffect)(()=>{if(!(!p.current||!l)){if(m.current){m.current=!1;return}p.current.scrollTop=0}},[l,d]);let _=(0,x.useMemo)(()=>l?.lines.flatMap((e,t)=>{let n=l.totalLines!==null,r=n?l.startLine+t:(l.startByte??0)+t;return ET(e,l.lineKeys?.[t]??String(r),r,n)})??[],[l]),v=(0,x.useMemo)(()=>l?.lines.map((e,t)=>{let n=l.totalLines!==null,r=n?l.startLine+t:(l.startByte??0)+t;return CT(e,l.lineKeys?.[t]??String(r),r,n)})??[],[l]),y=(0,x.useMemo)(()=>DT(_),[_]),b=(0,x.useMemo)(()=>kT(y),[y]),S=(0,x.useMemo)(()=>v.slice().reverse(),[v]),C=l?l.totalLines===0?`No transcript entries`:l.totalLines===null?`Showing ${l.lines.length} recent log entries`:`Showing ${l.lines.length} of ${l.totalLines} log entries`:`Derived from the saved session log.`;return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-elevated ${t}`.trim(),children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-border px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-primary`,children:`Transcript`}),(0,W.jsx)(`p`,{className:`text-xs text-muted`,children:C})]}),(0,W.jsxs)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-base p-0.5`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>f(`messages`),className:`rounded px-2.5 py-1 text-xs transition-colors ${d===`messages`?`bg-accent text-white`:`text-muted hover:text-primary`}`,"aria-pressed":d===`messages`,children:`Messages`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>f(`events`),className:`rounded px-2.5 py-1 text-xs transition-colors ${d===`events`?`bg-accent text-white`:`text-muted hover:text-primary`}`,"aria-pressed":d===`events`,children:`Events`})]})]}),(0,W.jsxs)(`div`,{ref:p,className:`flex-1 overflow-y-auto p-4 font-mono text-xs`,children:[r&&(0,W.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted`,children:`Loading preview...`}),s&&(0,W.jsx)(`div`,{className:`flex items-center justify-center py-8 text-danger`,children:s}),l&&d===`messages`&&(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col`,children:[b.length===0?(0,W.jsx)(`div`,{className:`py-8 text-center text-muted`,children:`No readable messages found. Try Events.`}):b.map(({entry:e,showRole:t})=>(0,W.jsx)(RT,{entry:e,showRole:t},AT(e))),l.hasMoreBefore&&(0,W.jsx)(`button`,{type:`button`,className:`btn mx-auto mt-3`,onClick:g,disabled:a,children:a?`Loading...`:`Load earlier`})]}),l&&d===`events`&&(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-2`,children:[(0,W.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,W.jsx)(zT,{entry:e},`${e.lineNumber}:${e.type}:${e.raw.slice(0,24)}`))}),l.hasMoreBefore&&(0,W.jsx)(`button`,{type:`button`,className:`btn mx-auto`,onClick:g,disabled:a,children:a?`Loading...`:`Load earlier`})]})]})]})}function HT({session:e,onClose:t,onResume:n}){let r=(0,x.useRef)(null),[i,a]=(0,x.useState)({loading:!0,error:null}),o=(0,x.useCallback)(()=>{i.loading||n(e.sessionId)},[i.loading,n,e.sessionId]);(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`?(e.stopPropagation(),t()):e.key===`Enter`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,t]),(0,x.useEffect)(()=>{r.current?.focus()},[]);let s=e.displayName||Im(e.projectPath)||e.sessionId.slice(0,8),c=Fm(e.lastActivityAt);return(0,W.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`preview-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`div`,{ref:r,tabIndex:-1,className:`flex max-h-[80vh] w-full max-w-2xl flex-col border border-border bg-elevated`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-4 py-3`,children:[(0,W.jsx)(eh,{agentType:e.agentType,className:`h-5 w-5 shrink-0 text-muted`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`h2`,{id:`preview-title`,className:`truncate text-sm font-semibold text-primary`,children:s}),(0,W.jsxs)(`p`,{className:`truncate text-xs text-muted`,title:e.projectPath,children:[Im(e.projectPath),` · `,c]})]})]}),(0,W.jsx)(VT,{session:e,className:`m-4 mt-0 flex-1 border-0 bg-transparent`,onStateChange:a}),(0,W.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border px-4 py-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:o,className:`btn btn-primary`,disabled:i.loading,children:`Wake`})]})]})})}function UT({session:e,isSelected:t,showSessionIdPrefix:n,showProjectName:r,showLastUserMessage:i,onSelect:a,onWake:o,onRename:s,onMoveToHistory:c}){let l=Fm(e.lastActivityAt),u=Im(e.projectPath),d=e.displayName||u||e.sessionId.slice(0,8),f=r&&!!u,p=i&&!!e.lastUserMessage,m=n?Rm(e.sessionId):``,h=(0,x.useRef)(null),g=(0,x.useRef)(null),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(!1),[S,C]=(0,x.useState)(d);(0,x.useEffect)(()=>{C(d)},[d]),(0,x.useEffect)(()=>{y&&g.current&&(g.current.focus(),g.current.select())},[y]);let w=()=>{let t=S.trim();t&&t!==d&&s?.(e.sessionId,t),b(!1)};return(0,x.useEffect)(()=>{if(!_)return;let e=e=>{h.current&&!h.current.contains(e.target)&&v(null)},t=e=>{e.key===`Escape`&&v(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[_]),(0,W.jsxs)(`div`,{className:`group relative cursor-pointer px-3 py-2 hover:bg-hover ${t?`bg-hover`:``}`,role:`button`,tabIndex:0,"data-testid":`hibernating-session-card`,onClick:()=>a(e.sessionId),onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),v({x:e.clientX,y:e.clientY})},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.sessionId))},children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(eh,{agentType:e.agentType,className:`h-3.5 w-3.5 shrink-0 text-muted`}),y?(0,W.jsx)(`input`,{ref:g,type:`text`,value:S,onChange:e=>C(e.target.value),onBlur:w,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),w()):e.key===`Escape`&&(e.preventDefault(),C(d),b(!1))},onClick:e=>e.stopPropagation(),className:`min-w-0 flex-1 rounded border border-border bg-surface px-1.5 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:d}),(0,W.jsx)(De,{className:`h-3 w-3 shrink-0 text-muted`,"aria-label":`Hibernating`,title:`Hibernating`}),e.lastResumeError&&(0,W.jsx)(ae,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":`Wake failed`,title:`Last wake failed: ${e.lastResumeError}`}),m&&(0,W.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:e.sessionId,children:m}),(0,W.jsx)(`span`,{className:`ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted`,children:l})]}),(f||p)&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[f&&(0,W.jsx)(ih,{name:u,fullPath:e.projectPath}),p&&(0,W.jsxs)(`span`,{className:`line-clamp-2 text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`...`:e.lastUserMessage,`"`]})]})]}),_&&(0,W.jsxs)(`div`,{ref:h,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:_.x,top:_.y},role:`menu`,children:[o&&(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),o(e.sessionId)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(je,{width:14,height:14}),`Wake`]}),s&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),v(null),b(!0)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(_e,{width:14,height:14}),`Rename`]}),e.logFilePath&&(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),zm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,W.jsx)(ye,{width:14,height:14}),`Copy Log Path`]}),c&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),c(e.sessionId)},className:`w-full px-3 py-2 text-left text-sm text-danger hover:bg-danger/10 flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(Ue,{width:14,height:14}),`Move to History`]})]})]})]})}var WT={working:`bg-green-500/20 text-green-600`,waiting:`bg-zinc-500/20 text-zinc-400`,permission:`bg-amber-500/20 text-amber-600`,unknown:`bg-zinc-500/20 text-zinc-400`};function GT(){let[,e]=(0,x.useState)(0);(0,x.useEffect)(()=>{let t=setInterval(()=>e(e=>e+1),3e4);return()=>clearInterval(t)},[])}function KT({sessions:e,hibernatingSessions:t=[],historySessions:n=[],selectedSessionId:r,selectedHibernatingSessionId:i=null,loading:a,error:o,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onKill:f,onDuplicate:p,onMoveToHistory:m,onNewSession:h}){GT();let g=(0,x.useMemo)(()=>typeof navigator>`u`?!1:/^((?!chrome|android).)*safari/i.test(navigator.userAgent),[]),[_,v]=(0,x.useState)(null),y=H(e=>e.historySessionsExpanded),b=H(e=>e.setHistorySessionsExpanded),S=H(e=>e.hibernatingSessionsExpanded),C=H(e=>e.setHibernatingSessionsExpanded),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(20),O=pd(),k=g&&!O,A=(0,x.useMemo)(()=>[...t,...n],[t,n]);(0,x.useEffect)(()=>{y||D(20)},[y]);let[j,M]=Jm(e.length,200),[N,P]=Jm(n.length,200,!0),F=(0,x.useRef)(new Set(e.map(e=>e.id))),I=(0,x.useRef)(new Set([...t,...n].map(e=>e.sessionId))),[L,ee]=(0,x.useState)(new Set);(0,x.useEffect)(()=>{let r=new Set(e.map(e=>e.id)),i=new Set([...t,...n].map(e=>e.sessionId)),a=new Set;for(let e of r)F.current.has(e)||a.add(e);for(let t of e){let e=t.agentSessionId?.trim();e&&I.current.has(e)&&!i.has(e)&&a.add(t.id)}F.current=r,I.current=i,a.size>0&&ee(a)},[e,t,n]),(0,x.useEffect)(()=>{if(L.size===0)return;let e=setTimeout(()=>ee(new Set),500);return()=>clearTimeout(e)},[L]);let R=Ye(qe(H(e=>e.shortcutModifier))),z=H(e=>e.sessionSortMode),B=H(e=>e.setSessionSortMode),te=H(e=>e.sessionSortDirection),V=H(e=>e.manualSessionOrder),ne=H(e=>e.setManualSessionOrder),re=H(e=>e.showProjectName),U=H(e=>e.showLastUserMessage),ie=H(e=>e.showSessionIdPrefix),ae=H(e=>e.projectFilters),oe=H(e=>e.setProjectFilters),ce=H(e=>e.hostFilters),ue=H(e=>e.setHostFilters),de=qm(e=>e.exitingSessions),fe=qm(e=>e.clearExitingSession),pe=qm(e=>e.hostStatuses),me=qm(e=>e.remoteAllowControl);Ym(e,de,fe,200),(0,x.useEffect)(()=>{if(V.length===0)return;let t=new Set;for(let n of e)t.add(Am(n)),t.add(n.id);for(let e of A)t.add(e.sessionId);let n=V.filter(e=>t.has(e));n.length!==V.length&&ne(n)},[e,A,V,ne]);let he=(0,x.useMemo)(()=>Mm(e,{mode:z,direction:te,manualOrder:V}),[e,z,te,V]),ge=(0,x.useMemo)(()=>Nm(e,A),[e,A]),_e=(0,x.useMemo)(()=>{let t=Pm(e,A),n=pe.map(e=>e.host),r=new Set,i=[];for(let e of n)!e||r.has(e)||(r.add(e),i.push(e));for(let e of t)!e||r.has(e)||(r.add(e),i.push(e));return i},[e,A,pe]),ve=(0,x.useMemo)(()=>_e.length>1,[_e]),ye=(0,x.useMemo)(()=>{let e=he;return ae.length>0&&(e=e.filter(e=>ae.includes(e.projectPath))),ce.length>0&&(e=e.filter(e=>ce.includes(e.host??``))),e},[he,ae,ce]),be=(0,x.useMemo)(()=>`${ae.length===0?`all-projects`:ae.join(`|`)}::${ce.length===0?`all-hosts`:ce.join(`|`)}`,[ae,ce]),xe=(0,x.useRef)(new Set(ye.map(e=>e.id))),[Se,Ce]=(0,x.useState)(new Set);(0,x.useEffect)(()=>{let e=new Set(ye.map(e=>e.id)),t=new Set;for(let n of e)xe.current.has(n)||L.has(n)||t.add(n);xe.current=e,t.size>0&&Ce(t)},[ye,L]),(0,x.useEffect)(()=>{if(Se.size===0)return;let e=setTimeout(()=>Ce(new Set),500);return()=>clearTimeout(e)},[Se]);let we=(0,x.useMemo)(()=>{let e=t;return ae.length>0&&(e=e.filter(e=>ae.includes(e.projectPath))),ce.length>0&&(e=e.filter(e=>ce.includes(e.host??``))),e},[t,ae,ce]),Te=(0,x.useMemo)(()=>{let e=n;return ae.length>0&&(e=e.filter(e=>ae.includes(e.projectPath))),ce.length>0&&(e=e.filter(e=>ce.includes(e.host??``))),e},[n,ae,ce]),Ee=(0,x.useMemo)(()=>{if(ae.length===0)return 0;let t=new Set(ae);return e.filter(e=>!t.has(e.projectPath)&&e.status===`permission`).length},[e,ae]);(0,x.useEffect)(()=>{if(ae.length===0||ge.length===0)return;let e=new Set(ge),t=ae.filter(t=>e.has(t));t.length!==ae.length&&oe(t)},[ae,ge,oe]),(0,x.useEffect)(()=>{if(ce.length===0||_e.length===0)return;let e=new Set(_e),t=ce.filter(t=>e.has(t));t.length!==ce.length&&ue(t)},[ce,_e,ue]);let De=tf(ef(np,{activationConstraint:{distance:8}})),[Oe,ke]=(0,x.useState)(null),[Ae,je]=(0,x.useState)(null),Me=(0,x.useCallback)(e=>{ke(e.active.id)},[]),Pe=(0,x.useCallback)(e=>{je(e.over?.id)},[]),Fe=(0,x.useCallback)(e=>{let{active:t,over:n}=e;if(ke(null),je(null),!n||t.id===n.id)return;let r=ye.findIndex(e=>e.id===t.id),i=ye.findIndex(e=>e.id===n.id);if(r===-1||i===-1)return;let a=ye.map(e=>Am(e)),[o]=a.splice(r,1);a.splice(i,0,o);let s=he.map(e=>Am(e)),c=new Set(a),l=0,u=s.map(e=>{if(!c.has(e))return e;let t=a[l];return l+=1,t});z!==`manual`&&B(`manual`),ne(u)},[ye,he,z,B,ne]),Ie=(0,x.useCallback)(()=>{ke(null),je(null)},[]);(0,x.useEffect)(()=>{if(!Oe&&!Ae)return;let e=new Set(ye.map(e=>e.id));Oe&&!e.has(Oe)&&ke(null),Ae&&!e.has(Ae)&&je(null)},[ye,Oe,Ae]);let Le=(e,t)=>{l(e,t),v(null)};return(0,W.jsxs)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-r border-border bg-elevated`,children:[o&&(0,W.jsx)(`div`,{className:`shrink-0 border-b border-danger/30 bg-danger/10 px-3 py-2 text-xs text-danger`,children:o}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,W.jsxs)(`div`,{className:`sticky top-0 z-10 flex h-10 items-center justify-start gap-2 border-b border-border bg-elevated px-3`,children:[ve&&(0,W.jsx)(sh,{hosts:_e,selectedHosts:ce,onSelect:ue,statuses:pe}),(0,W.jsx)(ch,{projects:ge,selectedProjects:ae,onSelect:oe,hasHiddenPermissions:Ee>0})]}),a?(0,W.jsx)(`div`,{className:`space-y-1 p-2`,children:[0,1,2].map(e=>(0,W.jsx)(`div`,{className:`h-14 animate-pulse rounded bg-surface`},e))}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 text-xs font-medium uppercase tracking-wider text-muted`,children:[(0,W.jsx)(`span`,{children:`Active`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ye.length===0&&h&&(0,W.jsxs)(`button`,{type:`button`,onClick:h,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium normal-case tracking-normal text-accent hover:bg-hover`,title:`Start a new session`,children:[(0,W.jsx)(Ne,{className:`h-3.5 w-3.5`}),`New session`]}),(0,W.jsx)(fd.span,{className:`w-8 text-right text-xs`,animate:j&&!O?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:M,children:ye.length})]})]}),ye.length>0&&(0,W.jsx)($p,{sensors:De,collisionDetection:lf,onDragStart:Me,onDragOver:Pe,onDragEnd:Fe,onDragCancel:Ie,children:(0,W.jsx)(ym,{items:ye.map(e=>e.id),strategy:hm,children:(0,W.jsx)(`div`,{children:(0,W.jsx)($a,{initial:!1,mode:`sync`,children:ye.map((e,t)=>{let n=L.has(e.id),i=Se.has(e.id),a=e.remote===!0,o=e.source===`managed`,c=!a||me&&o,l=!!(d&&!a&&o&&e.agentSessionId?.trim()),u=Oe?ye.findIndex(e=>e.id===Oe):-1,m=Ae===e.id&&Oe!==e.id?u>t?`above`:`below`:null;return(0,W.jsx)(qT,{session:e,isNew:n||i,exitDuration:200,prefersReducedMotion:O,useSafariLayoutFallback:k,isSelected:e.id===r,isEditing:e.id===_,showSessionIdPrefix:ie,showProjectName:re,showLastUserMessage:U,showHostInfo:ve,dropIndicator:m,onSelect:()=>s(e.id),onStartEdit:c?()=>v(e.id):void 0,onCancelEdit:()=>v(null),onRename:t=>Le(e.id,t),onHibernate:l?()=>d?.(e.agentSessionId.trim()):void 0,onKill:f&&c?()=>f(e.id,`session_list_context_menu`):void 0,onDuplicate:p&&c?()=>p(e.id):void 0},e.id)})})},be)})}),we.length>0&&(0,W.jsxs)(`div`,{className:`border-t border-border`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>C(!S),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-muted hover:text-primary`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[S?(0,W.jsx)(se,{className:`h-4 w-4`}):(0,W.jsx)(le,{className:`h-4 w-4`}),`Hibernating`]}),(0,W.jsx)(`span`,{className:`w-8 text-right text-xs text-muted`,children:we.length})]}),S&&(0,W.jsx)(`div`,{className:`py-1`,children:we.map(e=>(0,W.jsx)(UT,{session:e,isSelected:i===e.sessionId,showSessionIdPrefix:ie,showProjectName:re,showLastUserMessage:U,onSelect:e=>c?.(e),onWake:e=>u?.(e),onRename:(e,t)=>Le(e,t),onMoveToHistory:m},e.sessionId))})]})]}),Te.length>0&&(0,W.jsxs)(`div`,{className:`border-t border-border`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>b(!y),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-muted hover:text-primary`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[y?(0,W.jsx)(se,{className:`h-4 w-4`}):(0,W.jsx)(le,{className:`h-4 w-4`}),`History`]}),(0,W.jsx)(fd.span,{className:`w-8 text-right text-xs`,animate:N&&!O?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:P,children:Te.length})]}),y&&(0,W.jsxs)(`div`,{className:`py-1`,children:[Te.slice(0,E).map(e=>(0,W.jsx)(ah,{session:e,showSessionIdPrefix:ie,showProjectName:re,showLastUserMessage:U,onResume:e=>u?.(e),onPreview:T},e.sessionId)),Te.length>E&&(0,W.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>e+20),className:`w-full px-3 py-2 text-center text-xs text-muted hover:text-primary hover:bg-hover`,children:[`Show more (`,Te.length-E,` remaining)`]})]})]})]}),(0,W.jsx)(`div`,{className:`hidden shrink-0 border-t border-border px-3 py-2 md:block`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted`,children:[(0,W.jsxs)(`span`,{children:[R,`[ ] nav`]}),(0,W.jsxs)(`span`,{children:[R,`N new`]}),(0,W.jsxs)(`span`,{children:[R,`X kill`]})]})}),w&&(0,W.jsx)(HT,{session:w,onClose:()=>T(null),onResume:e=>{T(null),u?.(e)}})]})}var qT=(0,x.forwardRef)(function({session:e,isNew:t,exitDuration:n,prefersReducedMotion:r,useSafariLayoutFallback:i,isSelected:a,isEditing:o,showSessionIdPrefix:s,showProjectName:c,showLastUserMessage:l,showHostInfo:u,dropIndicator:d,onSelect:f,onStartEdit:p,onCancelEdit:m,onRename:h,onHibernate:g,onKill:_,onDuplicate:v},y){let{attributes:b,listeners:S,setNodeRef:C,transform:w,transition:T,isDragging:E}=Dm({id:e.id,animateLayoutChanges:({isSorting:e,wasDragging:t})=>e||t}),D=zd.Transform.toString(w),O={...r&&D?{transform:D,transition:T}:{},zIndex:E?10:void 0,opacity:E?.9:void 0},k=(0,x.useCallback)(e=>{C(e),typeof y==`function`?y(e):y&&(y.current=e)},[C,y]);return(0,W.jsxs)(fd.div,{ref:k,style:{...O,overflow:`hidden`},className:`relative`,transformTemplate:(e,t)=>Bm({useSafariLayoutFallback:i,isDragging:E,dndTransform:D,generatedTransform:t}),initial:r||!t?!1:i?{opacity:0}:{opacity:0,scale:.97},animate:r?{opacity:1}:t?i?{opacity:1}:{opacity:1,scale:[1.02,.99,1]}:{opacity:1,scale:1},exit:r?{opacity:0}:i?{opacity:0,height:0}:{opacity:0,height:0,scale:.97},transition:r?{duration:0}:i?{opacity:{duration:n/1e3},height:{duration:n/1e3,ease:`easeOut`}}:{opacity:{duration:n/1e3},scale:{duration:n/1e3,ease:[.34,1.56,.64,1]},height:{duration:n/1e3,ease:`easeOut`}},...b,...S,children:[d===`above`&&(0,W.jsx)(`div`,{className:`absolute -top-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent`}),(0,W.jsx)(JT,{session:e,isSelected:a,isEditing:o,showSessionIdPrefix:s,showProjectName:c,showLastUserMessage:l,showHostInfo:u,isDragging:E,onSelect:f,onStartEdit:p,onCancelEdit:m,onRename:h,onHibernate:g,onKill:_,onDuplicate:v}),d===`below`&&(0,W.jsx)(`div`,{className:`absolute -bottom-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent`})]})});qT.displayName=`SortableSessionItem`;function JT({session:e,isSelected:t,isEditing:n,showSessionIdPrefix:r,showProjectName:i,showLastUserMessage:a,showHostInfo:o,isDragging:s=!1,onSelect:c,onStartEdit:l,onCancelEdit:u,onRename:d,onHibernate:f,onKill:p,onDuplicate:m}){let h=Fm(e.lastActivity),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=e.agentSessionName?.trim()||e.name?.trim()||e.id,[y,b]=(0,x.useState)(v),S=(0,x.useRef)(null),[C,w]=(0,x.useState)(null),T=Im(e.projectPath),E=e.host?.trim(),D=e.status===`permission`,O=e.agentSessionId?.trim(),k=r&&O?Rm(O):``,A=i&&!!T,j=o&&!!E,M=a&&!!e.lastUserMessage,N=(0,x.useRef)(e.status),[P,F]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let t=N.current,n=e.status;t===`working`&&n===`waiting`?F(!0):N.current=n},[e.status]);let I=()=>{F(!1),N.current=e.status};(0,x.useEffect)(()=>{n&&g.current&&(g.current.focus(),g.current.select())},[n]),(0,x.useEffect)(()=>{b(v)},[v]);let L=()=>{let e=y.trim();e&&e!==v?d(e):u()},ee=e=>{e.key===`Enter`?(e.preventDefault(),L()):e.key===`Escape`&&(e.preventDefault(),b(v),u())},R=(0,x.useRef)(null),z=e=>{if(s)return;let t=e.touches[0];R.current={x:t.clientX,y:t.clientY},S.current=setTimeout(()=>{R.current&&w(R.current)},500)},B=()=>{S.current&&=(clearTimeout(S.current),null)};return(0,x.useEffect)(()=>{if(!C)return;let e=e=>{_.current&&!_.current.contains(e.target)&&w(null)},t=e=>{e.key===`Escape`&&w(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[C]),(0,W.jsxs)(`div`,{className:`session-row group cursor-pointer select-none px-3 py-2 ${t?`selected`:``} ${s?`cursor-grabbing shadow-lg ring-1 ring-accent/30 bg-elevated`:`cursor-grab`}`,role:`button`,tabIndex:0,"data-testid":`session-card`,"data-session-id":e.id,onClick:s?void 0:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&c()},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),w({x:e.clientX,y:e.clientY})},onTouchStart:z,onTouchEnd:B,onTouchCancel:B,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-0.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(eh,{agentType:e.agentType,command:e.command,className:`h-3.5 w-3.5 shrink-0 text-muted`}),n?(0,W.jsx)(`input`,{ref:g,type:`text`,value:y,onChange:e=>b(e.target.value),onBlur:L,onKeyDown:ee,onClick:e=>e.stopPropagation(),className:`min-w-0 flex-1 rounded border border-border bg-surface px-1.5 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:v}),k&&(0,W.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:O,children:k}),D?(0,W.jsx)(`span`,{className:`ml-1 flex shrink-0 items-center justify-center rounded-full px-1.5 py-0.5 ${WT[e.status]} pulse-approval`,onAnimationEnd:I,children:(0,W.jsx)(Ce,{className:`h-3 w-3`,"aria-label":`Needs input`})}):(0,W.jsx)(`span`,{className:`ml-1 shrink-0 rounded-full px-1.5 py-0.5 text-right text-xs tabular-nums ${WT[e.status]}${P?` pulse-complete`:``}`,onAnimationEnd:I,children:h})]}),(A||j||M)&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[j&&(0,W.jsx)(oh,{name:E}),A&&(0,W.jsx)(ih,{name:T,fullPath:e.projectPath}),M&&(0,W.jsxs)(`span`,{className:`line-clamp-2 text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`…`:e.lastUserMessage,`"`]})]})]}),C&&(0,W.jsxs)(`div`,{ref:_,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:C.x,top:C.y},role:`menu`,children:[l&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),l()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(_e,{width:14,height:14}),`Rename`]}),m&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),m()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:`Create a copy in a new tmux window`,children:[(0,W.jsx)(de,{width:14,height:14}),`Duplicate`]}),f&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),f()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:`Close the live window and keep this session ready to wake`,children:[(0,W.jsx)(De,{width:14,height:14}),`Hibernate`]}),e.logFilePath&&(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),w(null),e.logFilePath&&zm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,W.jsx)(ye,{width:14,height:14}),`Copy Log Path`]}),p&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),p()},className:`w-full px-3 py-2 text-left text-sm text-danger hover:bg-danger/10 flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(Ue,{width:14,height:14}),`Kill Session`]})]})]})]})}var YT={debug:0,info:1,warn:2,error:3},XT=`info`;function ZT(e){let t=e.toLowerCase();t in YT&&(XT=t)}function QT(e,t,n=`debug`){if(!(YT[n]<YT[XT]))try{fetch(`/api/client-log`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:e,data:t,level:n})}).catch(()=>{})}catch{}}var $T=Object.defineProperty,eE=Object.getOwnPropertyDescriptor,tE=(e,t)=>{for(var n in t)$T(e,n,{get:t[n],enumerable:!0})},nE=(e,t,n,r)=>{for(var i=r>1?void 0:r?eE(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&$T(t,n,i),i},Y=(e,t)=>(n,r)=>t(n,r,e),rE=`Terminal input`,iE={get:()=>rE,set:e=>rE=e},aE=`Too much output to announce, navigate to rows manually to read`,oE={get:()=>aE,set:e=>aE=e};function sE(e){return e.replace(/\r?\n/g,`\r`)}function cE(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function lE(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function uE(e,t,n,r){e.stopPropagation(),e.clipboardData&&dE(e.clipboardData.getData(`text/plain`),t,n,r)}function dE(e,t,n,r){e=sE(e),e=cE(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function fE(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function pE(e,t,n,r,i){fE(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function mE(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function hE(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var gE=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},_E=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},vE=``,yE=` `,bE=class e{constructor(){this.fg=0,this.bg=0,this.extended=new xE}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},xE=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},SE=class e extends bE{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new xE,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?mE(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},CE=`di$target`,wE=`di$dependencies`,TE=new Map;function EE(e){return e[wE]||[]}function DE(e){if(TE.has(e))return TE.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);OE(t,e,r)};return t._id=e,TE.set(e,t),t}function OE(e,t,n){t[CE]===t?t[wE].push({id:e,index:n}):(t[wE]=[{id:e,index:n}],t[CE]=t)}var kE=DE(`BufferService`),AE=DE(`CoreMouseService`),jE=DE(`CoreService`),ME=DE(`CharsetService`),NE=DE(`InstantiationService`),PE=DE(`LogService`),FE=DE(`OptionsService`),IE=DE(`OscLinkService`),LE=DE(`UnicodeService`),RE=DE(`DecorationService`),zE=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new SE,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):BE(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};zE=nE([Y(0,kE),Y(1,FE),Y(2,IE)],zE);function BE(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
50
|
+
`);let t=lh(e);if(!t)return xT(e);let n=uh(t.type);return n===`thinking`?``:n===`tool_use`?`[Tool: ${uh(t.name)??`tool`}]`:ST(t.content)||ST(t.message)||(uh(t.text)??uh(t.output)??``)}function CT(e){let t=mh(e);if(t===`pi`)return`pi`;let n=uh(e.type)??``,r=uh(lh(e.payload)?.type)??``;return n===`event_msg`||n===`response_item`||r?`codex`:t===`claude`||n===`tool_result`?`claude`:`log`}function wT(e,t,n,r){try{let i=JSON.parse(e),a=lh(i);if(!a)return{lineNumber:n,sourceKey:t,exactLineNumber:r,parsed:!0,raw:e,source:`json`,type:Array.isArray(i)?`array`:typeof i,prominence:`plain`,title:Array.isArray(i)?`JSON array`:`JSON value`,body:xT(i),details:[]};let o=lh(a.payload),s=lh(a.message),c=uh(a.type)??`unknown`,l=uh(o?.type),u=uh(a.role)??uh(s?.role)??uh(o?.role),d=yT(a),f=CT(a),p=TT(c,l??void 0,u??void 0),m=[l?`${c} / ${l}`:c,u].filter(Boolean),h=ST(s?.content)||ST(s?.message)||ST(o?.message)||ST(o?.content)||ST(o?.text)||uh(a.result)||uh(a.name)||ST(a.content)||ST(a.text);c===`tool_use`&&uh(a.name)&&(h=`[Tool: ${uh(a.name)}]`);let g=[{label:`uuid`,value:uh(a.uuid)??``},{label:`parent`,value:uh(a.parentUuid)??``},{label:`session`,value:uh(a.sessionId)??uh(o?.session_id)??``},{label:`cwd`,value:uh(a.cwd)??``},{label:`metadata`,value:xT(a.metadata??o?.metadata)},{label:`payload`,value:o?xT(o):``}].filter(e=>e.value);return{lineNumber:n,sourceKey:t,exactLineNumber:r,parsed:!0,raw:e,source:f,type:l?`${c}:${l}`:c,prominence:p,...u?{role:u}:{},...d?{timestamp:d}:{},title:m.join(` · `),...h?{body:h}:{},details:g}}catch{return{lineNumber:n,sourceKey:t,exactLineNumber:r,parsed:!1,raw:e,source:`text`,type:`plain`,prominence:`plain`,title:`Plain text`,body:e,details:[]}}}function TT(e,t,n){return n===`user`||n===`assistant`||e===`user`||e===`assistant`||t===`user_message`||t===`assistant_message`||t===`agent_message`||t===`message`?`message`:e===`tool_use`||e===`tool_result`||e===`result`||e.includes(`tool`)||t?.includes(`tool`)||t===`function_call`||t===`function_call_output`||t===`custom_tool_call_output`?`tool`:e===`plain`?`plain`:`system`}function ET(e){return e===`user`?`user`:e===`assistant`?`assistant`:e===`system`?`system`:e===`tool`?`tool`:`other`}function DT(e,t,n,r){let i=Eh(e);if(!i)return[];let a=i.parsed?lh(i.raw):null,o=a?yT(a):null,s=i.events.map((i,a)=>({type:ET(i.role),kind:i.kind,content:i.text.trim(),raw:e,sourceKey:t,lineNumber:n,seq:a,exactLineNumber:r,...o?{timestamp:o}:{}})).filter(e=>e.content.length>0);return s.length>0?s:!i.parsed&&e.trim()?[{type:`other`,kind:`unknown`,content:e.trim(),raw:e,sourceKey:t,lineNumber:n,seq:0,exactLineNumber:r}]:[]}function OT(e){let t=[];for(let n of e){let e=t[t.length-1];e&&n.kind===`message`&&e.kind===`message`&&n.type===e.type&&n.content===e.content||t.push(n)}return t}function kT(e){return e.kind===`tool_call`||e.kind===`result`}function AT(e){let t=[],n=null;for(let r of e)(t.length===0||!kT(r)&&r.type!==n)&&(t.push([]),kT(r)||(n=r.type)),t[t.length-1].push(r);let r=[];for(let e=t.length-1;e>=0;e--){let n=!1;for(let i of t[e]){let e=!kT(i)&&!n;e&&(n=!0),r.push({entry:i,showRole:e})}}return r}function jT(e){return`${e.sourceKey}:${e.seq}`}function MT(e,t,n){return n?t?`Line ${e+1} · ${t}`:void 0:t}function NT(e,t,n){return bT(t)||(n?`Line ${e+1}`:`Entry`)}function PT(e){return e.type===`user`?`User`:e.type===`assistant`?`Assistant`:e.type===`system`?`System`:e.type===`tool`?`Tool`:`Log`}function FT(e){return e.type===`user`?`text-blue-400`:e.type===`assistant`?`text-emerald-400`:e.type===`system`?`text-yellow-400`:`text-muted`}function IT({entry:e}){let[t,n]=(0,x.useState)(!1),r=NT(e.lineNumber,e.timestamp,e.exactLineNumber),i=e.kind===`tool_call`?e.content:`Result`;return(0,W.jsxs)(`div`,{className:`rounded-md border border-border bg-surface/40`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-xs text-muted hover:text-primary`,onClick:()=>n(e=>!e),"aria-expanded":t,children:[(0,W.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,W.jsx)(`span`,{className:`mr-2 text-[10px] uppercase tracking-wide text-muted`,title:MT(e.lineNumber,e.timestamp,e.exactLineNumber),children:r}),i]}),(0,W.jsx)(`span`,{className:`shrink-0 text-[11px]`,children:t?`Hide`:`Show`})]}),t&&(0,W.jsx)(`pre`,{className:`max-h-80 overflow-auto border-t border-border px-3 py-2 whitespace-pre-wrap break-words text-xs leading-relaxed text-secondary`,children:e.content})]})}var LT={p:({children:e})=>(0,W.jsx)(`p`,{className:`my-2 first:mt-0 last:mb-0`,children:e}),a:({children:e,href:t})=>(0,W.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer noopener`,className:`text-accent underline underline-offset-2 hover:text-primary`,children:e}),ul:({children:e})=>(0,W.jsx)(`ul`,{className:`my-2 list-disc space-y-1 pl-5`,children:e}),ol:({children:e})=>(0,W.jsx)(`ol`,{className:`my-2 list-decimal space-y-1 pl-5`,children:e}),li:({children:e})=>(0,W.jsx)(`li`,{className:`leading-6`,children:e}),h1:({children:e})=>(0,W.jsx)(`h1`,{className:`mb-1 mt-3 text-base font-semibold first:mt-0`,children:e}),h2:({children:e})=>(0,W.jsx)(`h2`,{className:`mb-1 mt-3 text-sm font-semibold first:mt-0`,children:e}),h3:({children:e})=>(0,W.jsx)(`h3`,{className:`mb-1 mt-3 text-sm font-semibold first:mt-0`,children:e}),strong:({children:e})=>(0,W.jsx)(`strong`,{className:`font-semibold text-primary`,children:e}),em:({children:e})=>(0,W.jsx)(`em`,{className:`italic`,children:e}),blockquote:({children:e})=>(0,W.jsx)(`blockquote`,{className:`my-2 border-l-2 border-border pl-3 text-secondary`,children:e}),hr:()=>(0,W.jsx)(`hr`,{className:`my-3 border-border`}),pre:({children:e})=>(0,W.jsx)(`pre`,{className:`my-2 overflow-x-auto rounded bg-base p-3 text-xs leading-relaxed text-secondary`,children:e}),code:({className:e,children:t})=>{let n=String(t??``);return(e?.includes(`language-`)??!1)||n.includes(`
|
|
51
|
+
`)?(0,W.jsx)(`code`,{className:e,children:t}):(0,W.jsx)(`code`,{className:`rounded bg-surface px-1 py-0.5 text-[0.9em] text-primary`,children:t})},table:({children:e})=>(0,W.jsx)(`div`,{className:`my-2 overflow-x-auto`,children:(0,W.jsx)(`table`,{className:`w-full border-collapse text-xs`,children:e})}),th:({children:e})=>(0,W.jsx)(`th`,{className:`border border-border px-2 py-1 text-left font-semibold`,children:e}),td:({children:e})=>(0,W.jsx)(`td`,{className:`border border-border px-2 py-1 align-top`,children:e})};function RT({content:e}){return(0,W.jsx)(`div`,{className:`min-w-0 break-words text-sm leading-6 text-primary [overflow-wrap:anywhere]`,children:(0,W.jsx)(lS,{remarkPlugins:[pT,gT],components:LT,children:e})})}function zT({entry:e,showRole:t=!0}){if(kT(e))return(0,W.jsx)(IT,{entry:e});let n=NT(e.lineNumber,e.timestamp,e.exactLineNumber);return(0,W.jsxs)(`article`,{className:`grid grid-cols-[5.75rem_minmax(0,1fr)] gap-3 pb-2 sm:grid-cols-[6.75rem_minmax(0,1fr)] ${t?`mt-4 border-t border-border/60 pt-4 first:mt-0 first:border-t-0 first:pt-0`:`pt-1`}`,children:[(0,W.jsxs)(`div`,{className:`select-none pt-0.5 text-right`,children:[t&&(0,W.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide ${FT(e)}`,children:PT(e)}),(0,W.jsx)(`div`,{className:`text-[10px] tabular-nums text-muted ${t?`mt-1`:``}`,title:MT(e.lineNumber,e.timestamp,e.exactLineNumber),children:n})]}),(0,W.jsx)(RT,{content:e.content})]})}function BT({entry:e}){let[t,n]=(0,x.useState)(!1),r=e.prominence===`system`||e.prominence===`plain`,i=e.prominence===`tool`&&!!(e.body&&e.body.length>160),a=bT(e.timestamp),o=r?`border-border/70 bg-surface/20 opacity-80`:e.prominence===`tool`?`border-border bg-surface/35`:`border-border bg-surface/50`,s=e.prominence===`message`?`bg-accent/15 text-accent`:`bg-surface text-muted`;return(0,W.jsx)(`article`,{className:`rounded-md border ${o}`,children:(0,W.jsxs)(`div`,{className:`grid grid-cols-[5.75rem_minmax(0,1fr)] gap-3 px-3 py-2 sm:grid-cols-[6.75rem_minmax(0,1fr)]`,children:[(0,W.jsx)(`div`,{className:`select-none text-right text-[11px] tabular-nums text-muted`,title:MT(e.lineNumber,e.timestamp,e.exactLineNumber),children:a??(e.exactLineNumber?`Line ${e.lineNumber+1}`:`Entry`)}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${s}`,children:e.source}),(0,W.jsx)(`span`,{className:`min-w-0 break-words text-xs font-semibold text-primary`,children:e.title})]}),e.body&&!i&&(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded bg-base px-3 py-2 text-xs leading-relaxed text-secondary`,children:e.body}),e.body&&i&&(0,W.jsxs)(`div`,{className:`rounded bg-base px-3 py-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`select-none text-[11px] text-muted hover:text-primary`,"aria-expanded":t,onClick:()=>n(e=>!e),children:`Output`}),t&&(0,W.jsx)(`pre`,{className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words text-xs leading-relaxed text-secondary`,children:e.body})]}),e.details.length>0&&(0,W.jsxs)(`details`,{className:`group`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer select-none text-[11px] text-muted hover:text-primary`,children:`Details`}),(0,W.jsx)(`div`,{className:`mt-2 space-y-2`,children:e.details.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted`,children:e.label}),(0,W.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded bg-base px-3 py-2 text-[11px] leading-relaxed text-muted`,children:e.value})]},e.label))})]})]})]})})}async function VT(e,t){let n=await fetch(e,{signal:t});if(!n.ok){let e=`Failed to load preview (HTTP ${n.status})`;try{let t=await n.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return await n.json()}function HT({session:e,className:t=``,onStateChange:n}){let[r,i]=(0,x.useState)(!0),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(`messages`),p=(0,x.useRef)(null),m=(0,x.useRef)(!1),h=(0,x.useRef)(!1);(0,x.useEffect)(()=>{let t=!1,n=new AbortController,r=setTimeout(()=>n.abort(),_T);return(async()=>{i(!0),c(null),u(null);try{let r=await VT(`/api/session-preview/${e.sessionId}?limit=${vT}`,n.signal);t||u(r)}catch(e){if(t)return;n.signal.aborted?c(`Preview timed out`):c(e instanceof Error?e.message:`Failed to load preview`)}finally{t||i(!1)}})(),()=>{t=!0,clearTimeout(r),n.abort()}},[e.sessionId]);let g=async()=>{if(!l||h.current||!l.hasMoreBefore)return;h.current=!0,m.current=!0;let t=new AbortController,n=setTimeout(()=>t.abort(),_T);o(!0),c(null);try{let n=new URLSearchParams({limit:String(vT)});typeof l.startByte==`number`?n.set(`beforeByte`,String(l.startByte)):n.set(`beforeLine`,String(l.startLine));let r=await VT(`/api/session-preview/${e.sessionId}?${n.toString()}`,t.signal);u(e=>e?{...e,totalLines:r.totalLines??e.totalLines,startLine:r.startLine,endLine:e.endLine,hasMoreBefore:r.hasMoreBefore,startByte:r.startByte,endByte:e.endByte,lines:[...r.lines,...e.lines],lineKeys:[...r.lineKeys??r.lines.map((e,t)=>String(r.startLine+t)),...e.lineKeys??e.lines.map((t,n)=>String(e.startLine+n))]}:r)}catch(e){m.current=!1,t.signal.aborted?c(`Preview timed out`):c(e instanceof Error?e.message:`Failed to load preview`)}finally{clearTimeout(n),h.current=!1,o(!1)}};(0,x.useEffect)(()=>{n?.({loading:r,error:s})},[s,r,n]),(0,x.useLayoutEffect)(()=>{if(!(!p.current||!l)){if(m.current){m.current=!1;return}p.current.scrollTop=0}},[l,d]);let _=(0,x.useMemo)(()=>l?.lines.flatMap((e,t)=>{let n=l.totalLines!==null,r=n?l.startLine+t:(l.startByte??0)+t;return DT(e,l.lineKeys?.[t]??String(r),r,n)})??[],[l]),v=(0,x.useMemo)(()=>l?.lines.map((e,t)=>{let n=l.totalLines!==null,r=n?l.startLine+t:(l.startByte??0)+t;return wT(e,l.lineKeys?.[t]??String(r),r,n)})??[],[l]),y=(0,x.useMemo)(()=>OT(_),[_]),b=(0,x.useMemo)(()=>AT(y),[y]),S=(0,x.useMemo)(()=>v.slice().reverse(),[v]),C=l?l.totalLines===0?`No transcript entries`:l.totalLines===null?`Showing ${l.lines.length} recent log entries`:`Showing ${l.lines.length} of ${l.totalLines} log entries`:`Derived from the saved session log.`;return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-elevated ${t}`.trim(),children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-border px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-primary`,children:`Transcript`}),(0,W.jsx)(`p`,{className:`text-xs text-muted`,children:C})]}),(0,W.jsxs)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-base p-0.5`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>f(`messages`),className:`rounded px-2.5 py-1 text-xs transition-colors ${d===`messages`?`bg-accent text-white`:`text-muted hover:text-primary`}`,"aria-pressed":d===`messages`,children:`Messages`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>f(`events`),className:`rounded px-2.5 py-1 text-xs transition-colors ${d===`events`?`bg-accent text-white`:`text-muted hover:text-primary`}`,"aria-pressed":d===`events`,children:`Events`})]})]}),(0,W.jsxs)(`div`,{ref:p,className:`flex-1 overflow-y-auto p-4 font-mono text-xs`,children:[r&&(0,W.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted`,children:`Loading preview...`}),s&&(0,W.jsx)(`div`,{className:`flex items-center justify-center py-8 text-danger`,children:s}),l&&d===`messages`&&(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-4xl flex-col`,children:[b.length===0?(0,W.jsx)(`div`,{className:`py-8 text-center text-muted`,children:`No readable messages found. Try Events.`}):b.map(({entry:e,showRole:t})=>(0,W.jsx)(zT,{entry:e,showRole:t},jT(e))),l.hasMoreBefore&&(0,W.jsx)(`button`,{type:`button`,className:`btn mx-auto mt-3`,onClick:g,disabled:a,children:a?`Loading...`:`Load earlier`})]}),l&&d===`events`&&(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-2`,children:[(0,W.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,W.jsx)(BT,{entry:e},`${e.lineNumber}:${e.type}:${e.raw.slice(0,24)}`))}),l.hasMoreBefore&&(0,W.jsx)(`button`,{type:`button`,className:`btn mx-auto`,onClick:g,disabled:a,children:a?`Loading...`:`Load earlier`})]})]})]})}function UT({session:e,onClose:t,onResume:n}){let r=(0,x.useRef)(null),[i,a]=(0,x.useState)({loading:!0,error:null}),o=(0,x.useCallback)(()=>{i.loading||n(e.sessionId)},[i.loading,n,e.sessionId]);(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`?(e.stopPropagation(),t()):e.key===`Enter`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,t]),(0,x.useEffect)(()=>{r.current?.focus()},[]);let s=e.displayName||Im(e.projectPath)||e.sessionId.slice(0,8),c=Fm(e.lastActivityAt);return(0,W.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`preview-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`div`,{ref:r,tabIndex:-1,className:`flex max-h-[80vh] w-full max-w-2xl flex-col border border-border bg-elevated`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-4 py-3`,children:[(0,W.jsx)(eh,{agentType:e.agentType,className:`h-5 w-5 shrink-0 text-muted`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`h2`,{id:`preview-title`,className:`truncate text-sm font-semibold text-primary`,children:s}),(0,W.jsxs)(`p`,{className:`truncate text-xs text-muted`,title:e.projectPath,children:[Im(e.projectPath),` · `,c]})]})]}),(0,W.jsx)(HT,{session:e,className:`m-4 mt-0 flex-1 border-0 bg-transparent`,onStateChange:a}),(0,W.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border px-4 py-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:o,className:`btn btn-primary`,disabled:i.loading,children:`Wake`})]})]})})}function WT({session:e,isSelected:t,showSessionIdPrefix:n,showProjectName:r,showLastUserMessage:i,onSelect:a,onWake:o,onRename:s,onMoveToHistory:c}){let l=Fm(e.lastActivityAt),u=Im(e.projectPath),d=e.displayName||u||e.sessionId.slice(0,8),f=r&&!!u,p=i&&!!e.lastUserMessage,m=n?Rm(e.sessionId):``,h=(0,x.useRef)(null),g=(0,x.useRef)(null),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(!1),[S,C]=(0,x.useState)(d);(0,x.useEffect)(()=>{C(d)},[d]),(0,x.useEffect)(()=>{y&&g.current&&(g.current.focus(),g.current.select())},[y]);let w=()=>{let t=S.trim();t&&t!==d&&s?.(e.sessionId,t),b(!1)};return(0,x.useEffect)(()=>{if(!_)return;let e=e=>{h.current&&!h.current.contains(e.target)&&v(null)},t=e=>{e.key===`Escape`&&v(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[_]),(0,W.jsxs)(`div`,{className:`group relative cursor-pointer px-3 py-2 hover:bg-hover ${t?`bg-hover`:``}`,role:`button`,tabIndex:0,"data-testid":`hibernating-session-card`,onClick:()=>a(e.sessionId),onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),v({x:e.clientX,y:e.clientY})},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.sessionId))},children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(eh,{agentType:e.agentType,className:`h-3.5 w-3.5 shrink-0 text-muted`}),y?(0,W.jsx)(`input`,{ref:g,type:`text`,value:S,onChange:e=>C(e.target.value),onBlur:w,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),w()):e.key===`Escape`&&(e.preventDefault(),C(d),b(!1))},onClick:e=>e.stopPropagation(),className:`min-w-0 flex-1 rounded border border-border bg-surface px-1.5 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:d}),(0,W.jsx)(De,{className:`h-3 w-3 shrink-0 text-muted`,"aria-label":`Hibernating`,title:`Hibernating`}),e.lastResumeError&&(0,W.jsx)(ae,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":`Wake failed`,title:`Last wake failed: ${e.lastResumeError}`}),m&&(0,W.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:e.sessionId,children:m}),(0,W.jsx)(`span`,{className:`ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted`,children:l})]}),(f||p)&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[f&&(0,W.jsx)(ih,{name:u,fullPath:e.projectPath}),p&&(0,W.jsxs)(`span`,{className:`line-clamp-2 text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`...`:e.lastUserMessage,`"`]})]})]}),_&&(0,W.jsxs)(`div`,{ref:h,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:_.x,top:_.y},role:`menu`,children:[o&&(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),o(e.sessionId)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(je,{width:14,height:14}),`Wake`]}),s&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),v(null),b(!0)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(_e,{width:14,height:14}),`Rename`]}),e.logFilePath&&(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),zm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,W.jsx)(ye,{width:14,height:14}),`Copy Log Path`]}),c&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),c(e.sessionId)},className:`w-full px-3 py-2 text-left text-sm text-danger hover:bg-danger/10 flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(Ue,{width:14,height:14}),`Move to History`]})]})]})]})}var GT={working:`bg-green-500/20 text-green-600`,waiting:`bg-zinc-500/20 text-zinc-400`,permission:`bg-amber-500/20 text-amber-600`,unknown:`bg-zinc-500/20 text-zinc-400`};function KT(){let[,e]=(0,x.useState)(0);(0,x.useEffect)(()=>{let t=setInterval(()=>e(e=>e+1),3e4);return()=>clearInterval(t)},[])}function qT({sessions:e,hibernatingSessions:t=[],historySessions:n=[],selectedSessionId:r,selectedHibernatingSessionId:i=null,loading:a,error:o,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onKill:f,onDuplicate:p,onMoveToHistory:m,onNewSession:h}){KT();let g=(0,x.useMemo)(()=>typeof navigator>`u`?!1:/^((?!chrome|android).)*safari/i.test(navigator.userAgent),[]),[_,v]=(0,x.useState)(null),y=H(e=>e.historySessionsExpanded),b=H(e=>e.setHistorySessionsExpanded),S=H(e=>e.hibernatingSessionsExpanded),C=H(e=>e.setHibernatingSessionsExpanded),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(20),O=pd(),k=g&&!O,A=(0,x.useMemo)(()=>[...t,...n],[t,n]);(0,x.useEffect)(()=>{y||D(20)},[y]);let[j,M]=Jm(e.length,200),[N,P]=Jm(n.length,200,!0),F=(0,x.useRef)(new Set(e.map(e=>e.id))),I=(0,x.useRef)(new Set([...t,...n].map(e=>e.sessionId))),[L,ee]=(0,x.useState)(new Set);(0,x.useEffect)(()=>{let r=new Set(e.map(e=>e.id)),i=new Set([...t,...n].map(e=>e.sessionId)),a=new Set;for(let e of r)F.current.has(e)||a.add(e);for(let t of e){let e=t.agentSessionId?.trim();e&&I.current.has(e)&&!i.has(e)&&a.add(t.id)}F.current=r,I.current=i,a.size>0&&ee(a)},[e,t,n]),(0,x.useEffect)(()=>{if(L.size===0)return;let e=setTimeout(()=>ee(new Set),500);return()=>clearTimeout(e)},[L]);let R=Ye(qe(H(e=>e.shortcutModifier))),z=H(e=>e.sessionSortMode),B=H(e=>e.setSessionSortMode),te=H(e=>e.sessionSortDirection),V=H(e=>e.manualSessionOrder),ne=H(e=>e.setManualSessionOrder),re=H(e=>e.showProjectName),U=H(e=>e.showLastUserMessage),ie=H(e=>e.showSessionIdPrefix),ae=H(e=>e.projectFilters),oe=H(e=>e.setProjectFilters),ce=H(e=>e.hostFilters),ue=H(e=>e.setHostFilters),de=qm(e=>e.exitingSessions),fe=qm(e=>e.clearExitingSession),pe=qm(e=>e.hostStatuses),me=qm(e=>e.remoteAllowControl);Ym(e,de,fe,200),(0,x.useEffect)(()=>{if(V.length===0)return;let t=new Set;for(let n of e)t.add(Am(n)),t.add(n.id);for(let e of A)t.add(e.sessionId);let n=V.filter(e=>t.has(e));n.length!==V.length&&ne(n)},[e,A,V,ne]);let he=(0,x.useMemo)(()=>Mm(e,{mode:z,direction:te,manualOrder:V}),[e,z,te,V]),ge=(0,x.useMemo)(()=>Nm(e,A),[e,A]),_e=(0,x.useMemo)(()=>{let t=Pm(e,A),n=pe.map(e=>e.host),r=new Set,i=[];for(let e of n)!e||r.has(e)||(r.add(e),i.push(e));for(let e of t)!e||r.has(e)||(r.add(e),i.push(e));return i},[e,A,pe]),ve=(0,x.useMemo)(()=>_e.length>1,[_e]),ye=(0,x.useMemo)(()=>{let e=he;return ae.length>0&&(e=e.filter(e=>ae.includes(e.projectPath))),ce.length>0&&(e=e.filter(e=>ce.includes(e.host??``))),e},[he,ae,ce]),be=(0,x.useMemo)(()=>`${ae.length===0?`all-projects`:ae.join(`|`)}::${ce.length===0?`all-hosts`:ce.join(`|`)}`,[ae,ce]),xe=(0,x.useRef)(new Set(ye.map(e=>e.id))),[Se,Ce]=(0,x.useState)(new Set);(0,x.useEffect)(()=>{let e=new Set(ye.map(e=>e.id)),t=new Set;for(let n of e)xe.current.has(n)||L.has(n)||t.add(n);xe.current=e,t.size>0&&Ce(t)},[ye,L]),(0,x.useEffect)(()=>{if(Se.size===0)return;let e=setTimeout(()=>Ce(new Set),500);return()=>clearTimeout(e)},[Se]);let we=(0,x.useMemo)(()=>{let e=t;return ae.length>0&&(e=e.filter(e=>ae.includes(e.projectPath))),ce.length>0&&(e=e.filter(e=>ce.includes(e.host??``))),e},[t,ae,ce]),Te=(0,x.useMemo)(()=>{let e=n;return ae.length>0&&(e=e.filter(e=>ae.includes(e.projectPath))),ce.length>0&&(e=e.filter(e=>ce.includes(e.host??``))),e},[n,ae,ce]),Ee=(0,x.useMemo)(()=>{if(ae.length===0)return 0;let t=new Set(ae);return e.filter(e=>!t.has(e.projectPath)&&e.status===`permission`).length},[e,ae]);(0,x.useEffect)(()=>{if(ae.length===0||ge.length===0)return;let e=new Set(ge),t=ae.filter(t=>e.has(t));t.length!==ae.length&&oe(t)},[ae,ge,oe]),(0,x.useEffect)(()=>{if(ce.length===0||_e.length===0)return;let e=new Set(_e),t=ce.filter(t=>e.has(t));t.length!==ce.length&&ue(t)},[ce,_e,ue]);let De=tf(ef(np,{activationConstraint:{distance:8}})),[Oe,ke]=(0,x.useState)(null),[Ae,je]=(0,x.useState)(null),Me=(0,x.useCallback)(e=>{ke(e.active.id)},[]),Pe=(0,x.useCallback)(e=>{je(e.over?.id)},[]),Fe=(0,x.useCallback)(e=>{let{active:t,over:n}=e;if(ke(null),je(null),!n||t.id===n.id)return;let r=ye.findIndex(e=>e.id===t.id),i=ye.findIndex(e=>e.id===n.id);if(r===-1||i===-1)return;let a=ye.map(e=>Am(e)),[o]=a.splice(r,1);a.splice(i,0,o);let s=he.map(e=>Am(e)),c=new Set(a),l=0,u=s.map(e=>{if(!c.has(e))return e;let t=a[l];return l+=1,t});z!==`manual`&&B(`manual`),ne(u)},[ye,he,z,B,ne]),Ie=(0,x.useCallback)(()=>{ke(null),je(null)},[]);(0,x.useEffect)(()=>{if(!Oe&&!Ae)return;let e=new Set(ye.map(e=>e.id));Oe&&!e.has(Oe)&&ke(null),Ae&&!e.has(Ae)&&je(null)},[ye,Oe,Ae]);let Le=(e,t)=>{l(e,t),v(null)};return(0,W.jsxs)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-r border-border bg-elevated`,children:[o&&(0,W.jsx)(`div`,{className:`shrink-0 border-b border-danger/30 bg-danger/10 px-3 py-2 text-xs text-danger`,children:o}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,W.jsxs)(`div`,{className:`sticky top-0 z-10 flex h-10 items-center justify-start gap-2 border-b border-border bg-elevated px-3`,children:[ve&&(0,W.jsx)(sh,{hosts:_e,selectedHosts:ce,onSelect:ue,statuses:pe}),(0,W.jsx)(ch,{projects:ge,selectedProjects:ae,onSelect:oe,hasHiddenPermissions:Ee>0})]}),a?(0,W.jsx)(`div`,{className:`space-y-1 p-2`,children:[0,1,2].map(e=>(0,W.jsx)(`div`,{className:`h-14 animate-pulse rounded bg-surface`},e))}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 text-xs font-medium uppercase tracking-wider text-muted`,children:[(0,W.jsx)(`span`,{children:`Active`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ye.length===0&&h&&(0,W.jsxs)(`button`,{type:`button`,onClick:h,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium normal-case tracking-normal text-accent hover:bg-hover`,title:`Start a new session`,children:[(0,W.jsx)(Ne,{className:`h-3.5 w-3.5`}),`New session`]}),(0,W.jsx)(fd.span,{className:`w-8 text-right text-xs`,animate:j&&!O?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:M,children:ye.length})]})]}),ye.length>0&&(0,W.jsx)($p,{sensors:De,collisionDetection:lf,onDragStart:Me,onDragOver:Pe,onDragEnd:Fe,onDragCancel:Ie,children:(0,W.jsx)(ym,{items:ye.map(e=>e.id),strategy:hm,children:(0,W.jsx)(`div`,{children:(0,W.jsx)($a,{initial:!1,mode:`sync`,children:ye.map((e,t)=>{let n=L.has(e.id),i=Se.has(e.id),a=e.remote===!0,o=e.source===`managed`,c=!a||me&&o,l=!!(d&&!a&&o&&e.agentSessionId?.trim()),u=Oe?ye.findIndex(e=>e.id===Oe):-1,m=Ae===e.id&&Oe!==e.id?u>t?`above`:`below`:null;return(0,W.jsx)(JT,{session:e,isNew:n||i,exitDuration:200,prefersReducedMotion:O,useSafariLayoutFallback:k,isSelected:e.id===r,isEditing:e.id===_,showSessionIdPrefix:ie,showProjectName:re,showLastUserMessage:U,showHostInfo:ve,dropIndicator:m,onSelect:()=>s(e.id),onStartEdit:c?()=>v(e.id):void 0,onCancelEdit:()=>v(null),onRename:t=>Le(e.id,t),onHibernate:l?()=>d?.(e.agentSessionId.trim()):void 0,onKill:f&&c?()=>f(e.id,`session_list_context_menu`):void 0,onDuplicate:p&&c?()=>p(e.id):void 0},e.id)})})},be)})}),we.length>0&&(0,W.jsxs)(`div`,{className:`border-t border-border`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>C(!S),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-muted hover:text-primary`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[S?(0,W.jsx)(se,{className:`h-4 w-4`}):(0,W.jsx)(le,{className:`h-4 w-4`}),`Hibernating`]}),(0,W.jsx)(`span`,{className:`w-8 text-right text-xs text-muted`,children:we.length})]}),S&&(0,W.jsx)(`div`,{className:`py-1`,children:we.map(e=>(0,W.jsx)(WT,{session:e,isSelected:i===e.sessionId,showSessionIdPrefix:ie,showProjectName:re,showLastUserMessage:U,onSelect:e=>c?.(e),onWake:e=>u?.(e),onRename:(e,t)=>Le(e,t),onMoveToHistory:m},e.sessionId))})]})]}),Te.length>0&&(0,W.jsxs)(`div`,{className:`border-t border-border`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>b(!y),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-muted hover:text-primary`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[y?(0,W.jsx)(se,{className:`h-4 w-4`}):(0,W.jsx)(le,{className:`h-4 w-4`}),`History`]}),(0,W.jsx)(fd.span,{className:`w-8 text-right text-xs`,animate:N&&!O?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:P,children:Te.length})]}),y&&(0,W.jsxs)(`div`,{className:`py-1`,children:[Te.slice(0,E).map(e=>(0,W.jsx)(ah,{session:e,showSessionIdPrefix:ie,showProjectName:re,showLastUserMessage:U,onResume:e=>u?.(e),onPreview:T},e.sessionId)),Te.length>E&&(0,W.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>e+20),className:`w-full px-3 py-2 text-center text-xs text-muted hover:text-primary hover:bg-hover`,children:[`Show more (`,Te.length-E,` remaining)`]})]})]})]}),(0,W.jsx)(`div`,{className:`hidden shrink-0 border-t border-border px-3 py-2 md:block`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted`,children:[(0,W.jsxs)(`span`,{children:[R,`[ ] nav`]}),(0,W.jsxs)(`span`,{children:[R,`N new`]}),(0,W.jsxs)(`span`,{children:[R,`X kill`]})]})}),w&&(0,W.jsx)(UT,{session:w,onClose:()=>T(null),onResume:e=>{T(null),u?.(e)}})]})}var JT=(0,x.forwardRef)(function({session:e,isNew:t,exitDuration:n,prefersReducedMotion:r,useSafariLayoutFallback:i,isSelected:a,isEditing:o,showSessionIdPrefix:s,showProjectName:c,showLastUserMessage:l,showHostInfo:u,dropIndicator:d,onSelect:f,onStartEdit:p,onCancelEdit:m,onRename:h,onHibernate:g,onKill:_,onDuplicate:v},y){let{attributes:b,listeners:S,setNodeRef:C,transform:w,transition:T,isDragging:E}=Dm({id:e.id,animateLayoutChanges:({isSorting:e,wasDragging:t})=>e||t}),D=zd.Transform.toString(w),O={...r&&D?{transform:D,transition:T}:{},zIndex:E?10:void 0,opacity:E?.9:void 0},k=(0,x.useCallback)(e=>{C(e),typeof y==`function`?y(e):y&&(y.current=e)},[C,y]);return(0,W.jsxs)(fd.div,{ref:k,style:{...O,overflow:`hidden`},className:`relative`,transformTemplate:(e,t)=>Bm({useSafariLayoutFallback:i,isDragging:E,dndTransform:D,generatedTransform:t}),initial:r||!t?!1:i?{opacity:0}:{opacity:0,scale:.97},animate:r?{opacity:1}:t?i?{opacity:1}:{opacity:1,scale:[1.02,.99,1]}:{opacity:1,scale:1},exit:r?{opacity:0}:i?{opacity:0,height:0}:{opacity:0,height:0,scale:.97},transition:r?{duration:0}:i?{opacity:{duration:n/1e3},height:{duration:n/1e3,ease:`easeOut`}}:{opacity:{duration:n/1e3},scale:{duration:n/1e3,ease:[.34,1.56,.64,1]},height:{duration:n/1e3,ease:`easeOut`}},...b,...S,children:[d===`above`&&(0,W.jsx)(`div`,{className:`absolute -top-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent`}),(0,W.jsx)(YT,{session:e,isSelected:a,isEditing:o,showSessionIdPrefix:s,showProjectName:c,showLastUserMessage:l,showHostInfo:u,isDragging:E,onSelect:f,onStartEdit:p,onCancelEdit:m,onRename:h,onHibernate:g,onKill:_,onDuplicate:v}),d===`below`&&(0,W.jsx)(`div`,{className:`absolute -bottom-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent`})]})});JT.displayName=`SortableSessionItem`;function YT({session:e,isSelected:t,isEditing:n,showSessionIdPrefix:r,showProjectName:i,showLastUserMessage:a,showHostInfo:o,isDragging:s=!1,onSelect:c,onStartEdit:l,onCancelEdit:u,onRename:d,onHibernate:f,onKill:p,onDuplicate:m}){let h=Fm(e.lastActivity),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=e.agentSessionName?.trim()||e.name?.trim()||e.id,[y,b]=(0,x.useState)(v),S=(0,x.useRef)(null),[C,w]=(0,x.useState)(null),T=Im(e.projectPath),E=e.host?.trim(),D=e.status===`permission`,O=e.agentSessionId?.trim(),k=r&&O?Rm(O):``,A=i&&!!T,j=o&&!!E,M=a&&!!e.lastUserMessage,N=(0,x.useRef)(e.status),[P,F]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let t=N.current,n=e.status;t===`working`&&n===`waiting`?F(!0):N.current=n},[e.status]);let I=()=>{F(!1),N.current=e.status};(0,x.useEffect)(()=>{n&&g.current&&(g.current.focus(),g.current.select())},[n]),(0,x.useEffect)(()=>{b(v)},[v]);let L=()=>{let e=y.trim();e&&e!==v?d(e):u()},ee=e=>{e.key===`Enter`?(e.preventDefault(),L()):e.key===`Escape`&&(e.preventDefault(),b(v),u())},R=(0,x.useRef)(null),z=e=>{if(s)return;let t=e.touches[0];R.current={x:t.clientX,y:t.clientY},S.current=setTimeout(()=>{R.current&&w(R.current)},500)},B=()=>{S.current&&=(clearTimeout(S.current),null)};return(0,x.useEffect)(()=>{if(!C)return;let e=e=>{_.current&&!_.current.contains(e.target)&&w(null)},t=e=>{e.key===`Escape`&&w(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[C]),(0,W.jsxs)(`div`,{className:`session-row group cursor-pointer select-none px-3 py-2 ${t?`selected`:``} ${s?`cursor-grabbing shadow-lg ring-1 ring-accent/30 bg-elevated`:`cursor-grab`}`,role:`button`,tabIndex:0,"data-testid":`session-card`,"data-session-id":e.id,onClick:s?void 0:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&c()},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),w({x:e.clientX,y:e.clientY})},onTouchStart:z,onTouchEnd:B,onTouchCancel:B,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-0.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(eh,{agentType:e.agentType,command:e.command,className:`h-3.5 w-3.5 shrink-0 text-muted`}),n?(0,W.jsx)(`input`,{ref:g,type:`text`,value:y,onChange:e=>b(e.target.value),onBlur:L,onKeyDown:ee,onClick:e=>e.stopPropagation(),className:`min-w-0 flex-1 rounded border border-border bg-surface px-1.5 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:v}),k&&(0,W.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:O,children:k}),D?(0,W.jsx)(`span`,{className:`ml-1 flex shrink-0 items-center justify-center rounded-full px-1.5 py-0.5 ${GT[e.status]} pulse-approval`,onAnimationEnd:I,children:(0,W.jsx)(Ce,{className:`h-3 w-3`,"aria-label":`Needs input`})}):(0,W.jsx)(`span`,{className:`ml-1 shrink-0 rounded-full px-1.5 py-0.5 text-right text-xs tabular-nums ${GT[e.status]}${P?` pulse-complete`:``}`,onAnimationEnd:I,children:h})]}),(A||j||M)&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[j&&(0,W.jsx)(oh,{name:E}),A&&(0,W.jsx)(ih,{name:T,fullPath:e.projectPath}),M&&(0,W.jsxs)(`span`,{className:`line-clamp-2 text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`…`:e.lastUserMessage,`"`]})]})]}),C&&(0,W.jsxs)(`div`,{ref:_,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:C.x,top:C.y},role:`menu`,children:[l&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),l()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(_e,{width:14,height:14}),`Rename`]}),m&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),m()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:`Create a copy in a new tmux window`,children:[(0,W.jsx)(de,{width:14,height:14}),`Duplicate`]}),f&&(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),f()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:`Close the live window and keep this session ready to wake`,children:[(0,W.jsx)(De,{width:14,height:14}),`Hibernate`]}),e.logFilePath&&(0,W.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),w(null),e.logFilePath&&zm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,W.jsx)(ye,{width:14,height:14}),`Copy Log Path`]}),p&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,W.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),p()},className:`w-full px-3 py-2 text-left text-sm text-danger hover:bg-danger/10 flex items-center gap-2`,role:`menuitem`,children:[(0,W.jsx)(Ue,{width:14,height:14}),`Kill Session`]})]})]})]})}var XT={debug:0,info:1,warn:2,error:3},ZT=`info`;function QT(e){let t=e.toLowerCase();t in XT&&(ZT=t)}function J(e,t,n=`debug`){if(!(XT[n]<XT[ZT]))try{fetch(`/api/client-log`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:e,data:t,level:n})}).catch(()=>{})}catch{}}var $T=Object.defineProperty,eE=Object.getOwnPropertyDescriptor,tE=(e,t)=>{for(var n in t)$T(e,n,{get:t[n],enumerable:!0})},nE=(e,t,n,r)=>{for(var i=r>1?void 0:r?eE(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&$T(t,n,i),i},Y=(e,t)=>(n,r)=>t(n,r,e),rE=`Terminal input`,iE={get:()=>rE,set:e=>rE=e},aE=`Too much output to announce, navigate to rows manually to read`,oE={get:()=>aE,set:e=>aE=e};function sE(e){return e.replace(/\r?\n/g,`\r`)}function cE(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function lE(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function uE(e,t,n,r){e.stopPropagation(),e.clipboardData&&dE(e.clipboardData.getData(`text/plain`),t,n,r)}function dE(e,t,n,r){e=sE(e),e=cE(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function fE(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function pE(e,t,n,r,i){fE(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function mE(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function hE(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var gE=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},_E=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},vE=``,yE=` `,bE=class e{constructor(){this.fg=0,this.bg=0,this.extended=new xE}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},xE=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},SE=class e extends bE{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new xE,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?mE(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},CE=`di$target`,wE=`di$dependencies`,TE=new Map;function EE(e){return e[wE]||[]}function DE(e){if(TE.has(e))return TE.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);OE(t,e,r)};return t._id=e,TE.set(e,t),t}function OE(e,t,n){t[CE]===t?t[wE].push({id:e,index:n}):(t[wE]=[{id:e,index:n}],t[CE]=t)}var kE=DE(`BufferService`),AE=DE(`CoreMouseService`),jE=DE(`CoreService`),ME=DE(`CharsetService`),NE=DE(`InstantiationService`),PE=DE(`LogService`),FE=DE(`OptionsService`),IE=DE(`OscLinkService`),LE=DE(`UnicodeService`),RE=DE(`DecorationService`),zE=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new SE,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):BE(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};zE=nE([Y(0,kE),Y(1,FE),Y(2,IE)],zE);function BE(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
52
52
|
|
|
53
53
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var VE=DE(`CharSizeService`),HE=DE(`CoreBrowserService`),UE=DE(`MouseService`),WE=DE(`RenderService`),GE=DE(`SelectionService`),KE=DE(`CharacterJoinerService`),qE=DE(`ThemeService`),JE=DE(`LinkProviderService`),YE=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?tD.isErrorNoTelemetry(e)?new tD(e.message+`
|
|
54
54
|
|
|
@@ -193,7 +193,7 @@ ${s.join(`
|
|
|
193
193
|
`)),e.length=0)},3e3),nV=new FinalizationRegistry(t=>{typeof t==`string`&&e.push(t)})}var rV=class{constructor(e){this._size=0,this._options=e,this._leakageMon=KB>0||this._options?.leakWarningThreshold?new JB(e?.onListenerError??sB,this._options?.leakWarningThreshold??KB):void 0,this._perfMon=this._options?._profName?new GB(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(VB){let e=this._listeners;queueMicrotask(()=>{tV(e,e=>e.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new ZB(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||sB)(n),FB.None}if(this._disposed)return FB.None;t&&(e=e.bind(t));let r=new $B(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=YB.create(),i=this._leakageMon.check(r.stack,this._size+1)),VB&&(r.stack=YB.create()),this._listeners?this._listeners instanceof $B?(this._deliveryQueue??=new iV,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=MB(()=>{nV?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof PB?n.add(a):Array.isArray(n)&&n.push(a),nV){let e=Error().stack.split(`
|
|
194
194
|
`).slice(2,3).join(`
|
|
195
195
|
`).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);nV.register(a,t?.[2]??e,a)}return a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*eV<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||sB;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof $B)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},iV=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},aV=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),oV;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof sV?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:UB.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:aV})})(oV||={});var sV=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?aV:(this._emitter||=new rV,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},cV=`en`,lV=!1,uV=!1,dV=cV,fV,pV=globalThis,mV;typeof pV.vscode<`u`&&typeof pV.vscode.process<`u`?mV=pV.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(mV=process);var hV=typeof mV?.versions?.electron==`string`&&mV?.type===`renderer`;if(typeof mV==`object`){mV.platform,mV.platform,lV=mV.platform===`linux`,lV&&mV.env.SNAP&&mV.env.SNAP_REVISION,mV.env.CI||mV.env.BUILD_ARTIFACTSTAGINGDIRECTORY,dV=cV;let e=mV.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,dV=t.resolvedLanguage||cV,t.languagePack?.translationsConfigFile}catch{}}else typeof navigator==`object`&&!hV?(fV=navigator.userAgent,fV.indexOf(`Windows`),fV.indexOf(`Macintosh`),(fV.indexOf(`Macintosh`)>=0||fV.indexOf(`iPad`)>=0||fV.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,lV=fV.indexOf(`Linux`)>=0,fV?.indexOf(`Mobi`),uV=!0,dV=globalThis._VSCODE_NLS_LANGUAGE||cV,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);uV&&typeof pV.importScripts==`function`&&pV.origin;var gV=fV,_V=dV,vV;(e=>{function t(){return _V}e.value=t;function n(){return _V.length===2?_V===`en`:_V.length>=3?_V[0]===`e`&&_V[1]===`n`&&_V[2]===`-`:!1}e.isDefaultVariant=n;function r(){return _V===`en`}e.isDefault=r})(vV||={});var yV=typeof pV.postMessage==`function`&&!pV.importScripts;(()=>{if(yV){let e=[];pV.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),pV.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var bV=!!(gV&&gV.indexOf(`Chrome`)>=0);gV&&gV.indexOf(`Firefox`),!bV&&gV&&gV.indexOf(`Safari`),gV&&gV.indexOf(`Edg/`),gV&&gV.indexOf(`Android`);function xV(e,t=0,n){let r=setTimeout(()=>{e(),n&&i.dispose()},t),i=MB(()=>{clearTimeout(r),n?.deleteAndLeak(i)});return n?.add(i),i}(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var SV;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(SV||={});var CV=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new rV,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await UB.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};CV.EMPTY=CV.fromArray([]);var wV=class extends FB{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new IB),this._linesCacheDisposables=this._register(new IB),this._register(MB(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=jB(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=xV(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let n=[],r=[0],i=this._terminal.buffer.active.getLine(e);for(;i;){let a=this._terminal.buffer.active.getLine(e+1),o=a?a.isWrapped:!1,s=i.translateToString(!o&&t);if(o&&a){let e=i.getCell(i.length-1);e&&e.getCode()===0&&e.getWidth()===1&&a.getCell(0)?.getWidth()===2&&(s=s.slice(0,-1))}if(n.push(s),o)r.push(r[r.length-1]+s.length);else break;e++,i=a}return[n.join(``),r]}},TV=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},EV=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,n,r){if(!e||e.length===0){this._terminal.clearSelection();return}if(n>this._terminal.cols)throw Error(`Invalid col: ${n} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let i={startRow:t,startCol:n},a=this._findInLine(e,i,r);if(!a)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(i.startRow=n,i.startCol=0,a=this._findInLine(e,i,r),!a);n++);return a}findNextWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=0,a=0;r&&(n===e?(i=r.end.x,a=r.end.y):(i=r.start.x,a=r.start.y)),this._lineCache.initLinesCache();let o={startRow:a,startCol:i},s=this._findInLine(e,o,t);if(!s)for(let n=a+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);if(!s&&a!==0)for(let n=0;n<a&&(o.startRow=n,o.startCol=0,s=this._findInLine(e,o,t),!s);n++);return!s&&r&&(o.startRow=r.start.y,o.startCol=0,s=this._findInLine(e,o,t)),s}findPreviousWithSelection(e,t,n){if(!e||e.length===0){this._terminal.clearSelection();return}let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let i=this._terminal.buffer.active.baseY+this._terminal.rows-1,a=this._terminal.cols;this._lineCache.initLinesCache();let o={startRow:i,startCol:a},s;if(r&&(o.startRow=i=r.start.y,o.startCol=a=r.start.x,n!==e&&(s=this._findInLine(e,o,t,!1),s||(o.startRow=i=r.end.y,o.startCol=a=r.end.x))),s||=this._findInLine(e,o,t,!0),!s){o.startCol=Math.max(o.startCol,this._terminal.cols);for(let n=i-1;n>=0&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);}if(!s&&i!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let n=this._terminal.buffer.active.baseY+this._terminal.rows-1;n>=i&&(o.startRow=n,s=this._findInLine(e,o,t,!0),!s);n--);return s}_isWholeWord(e,t,n){return(e===0||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e-1]))&&(e+n.length===t.length||` ~!@#$%^&*()+\`-=[]{}|\\;:"',./<>?`.includes(t[e+n.length]))}_findInLine(e,t,n={},r=!1){let i=t.startRow,a=t.startCol;if(this._terminal.buffer.active.getLine(i)?.isWrapped){if(r){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,n)}let o=this._lineCache.getLineFromCache(i);o||(o=this._lineCache.translateBufferLineToStringWithWrap(i,!0),this._lineCache.setLineInCache(i,o));let[s,c]=o,l=this._bufferColsToStringOffset(i,a),u=e,d=s;n.regex||(u=n.caseSensitive?e:e.toLowerCase(),d=n.caseSensitive?s:s.toLowerCase());let f=-1;if(n.regex){let t=RegExp(u,n.caseSensitive?`g`:`gi`),i;if(r)for(;i=t.exec(d.slice(0,l));)f=t.lastIndex-i[0].length,e=i[0],t.lastIndex-=e.length-1;else i=t.exec(d.slice(l)),i&&i[0].length>0&&(f=l+(t.lastIndex-i[0].length),e=i[0])}else r?l-u.length>=0&&(f=d.lastIndexOf(u,l-u.length)):f=d.indexOf(u,l);if(f>=0){if(n.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<c.length-1&&f>=c[t+1];)t++;let r=t;for(;r<c.length-1&&f+e.length>=c[r+1];)r++;let a=f-c[t],o=f+e.length-c[r],s=this._stringLengthToBufferSize(i+t,a),l=this._stringLengthToBufferSize(i+r,o)-s+this._terminal.cols*(r-t);return{term:e,col:s,row:i+t,size:l}}}_stringLengthToBufferSize(e,t){let n=this._terminal.buffer.active.getLine(e);if(!n)return 0;for(let e=0;e<t;e++){let r=n.getCell(e);if(!r)break;let i=r.getChars();i.length>1&&(t-=i.length-1);let a=n.getCell(e+1);a&&a.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let n=e,r=0,i=this._terminal.buffer.active.getLine(n);for(;t>0&&i;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=i.getCell(e);if(!t)break;t.getWidth()&&(r+=t.getCode()===0?1:t.getChars().length)}if(n++,i=this._terminal.buffer.active.getLine(n),i&&!i.isWrapped)break;t-=this._terminal.cols}return r}},DV=class extends FB{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(MB(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let n of e){let e=this._createResultDecorations(n,t,!1);if(e)for(let t of e)this._storeDecoration(t,n)}}createActiveDecoration(e,t){let n=this._createResultDecorations(e,t,!0);if(n)return{decorations:n,match:e,dispose(){AB(n)}}}clearHighlightDecorations(){AB(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,n){e.classList.contains(`xterm-find-result-decoration`)||(e.classList.add(`xterm-find-result-decoration`),t&&(e.style.outline=`1px solid ${t}`)),n&&e.classList.add(`xterm-find-active-result-decoration`)}_createResultDecorations(e,t,n){let r=[],i=e.col,a=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;a>0;){let e=Math.min(this._terminal.cols-i,a);r.push([o,i,e]),i=0,a-=e,o++}let s=[];for(let e of r){let r=this._terminal.registerMarker(e[0]),i=this._terminal.registerDecoration({marker:r,x:e[1],width:e[2],backgroundColor:n?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(r.line)?void 0:{color:n?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:`center`}});if(i){let e=[];e.push(r),e.push(i.onRender(e=>this._applyStyles(e,n?t.activeMatchBorder:t.matchBorder,!1))),e.push(i.onDispose(()=>AB(e))),s.push(i)}}return s.length===0?void 0:s}},OV=class extends FB{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new rV)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&=(this._selectedDecoration.dispose(),void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let n=this._searchResults[t];if(n.row===e.row&&n.col===e.col&&n.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},kV=class extends FB{constructor(e){super(),this._highlightTimeout=this._register(new IB),this._lineCache=this._register(new IB),this._state=new TV,this._resultTracker=this._register(new OV),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new wV(e),this._engine=new EV(e,this._lineCache.value),this._decorationManager=new DV(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(MB(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=xV(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error(`Cannot use addon until it has been loaded`);if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let n=[],r,i=this._engine.find(e,0,0,t);for(;i&&(r?.row!==i.row||r?.col!==i.col)&&!(n.length>=this._highlightLimit);)r=i,n.push(r),i=this._engine.find(e,r.col+r.term.length>=this._terminal.cols?r.row+1:r.row,r.col+r.term.length>=this._terminal.cols?0:r.col+1,t);this._resultTracker.updateResults(n,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(n,t.decorations)}_findNextAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}findPrevious(e,t,n){if(!this._terminal||!this._engine)throw Error(`Cannot use addon until it has been loaded`);this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,n);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,n){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,t?.decorations,n?.noScroll)}_selectResult(e,t,n){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let n=this._decorationManager.createActiveDecoration(e,t);n&&(this._resultTracker.selectedDecoration=n)}if(!n&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},AV=0,jV=0,MV=0,NV=0,PV;(e=>{function t(e,t,n,r){return r===void 0?`#${zV(e)}${zV(t)}${zV(n)}`:`#${zV(e)}${zV(t)}${zV(n)}${zV(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(PV||={});var FV;(e=>{function t(e,t){if(NV=(t.rgba&255)/255,NV===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return AV=a+Math.round((n-a)*NV),jV=o+Math.round((r-o)*NV),MV=s+Math.round((i-s)*NV),{css:PV.toCss(AV,jV,MV),rgba:PV.toRgba(AV,jV,MV)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=RV.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return PV.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[AV,jV,MV]=RV.toChannels(t),{css:PV.toCss(AV,jV,MV),rgba:t}}e.opaque=i;function a(e,t){return NV=Math.round(t*255),[AV,jV,MV]=RV.toChannels(e.rgba),{css:PV.toCss(AV,jV,MV,NV),rgba:PV.toRgba(AV,jV,MV,NV)}}e.opacity=a;function o(e,t){return NV=e.rgba&255,a(e,NV*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(FV||={});var IV;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return AV=parseInt(e.slice(1,2).repeat(2),16),jV=parseInt(e.slice(2,3).repeat(2),16),MV=parseInt(e.slice(3,4).repeat(2),16),PV.toColor(AV,jV,MV);case 5:return AV=parseInt(e.slice(1,2).repeat(2),16),jV=parseInt(e.slice(2,3).repeat(2),16),MV=parseInt(e.slice(3,4).repeat(2),16),NV=parseInt(e.slice(4,5).repeat(2),16),PV.toColor(AV,jV,MV,NV);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return AV=parseInt(r[1]),jV=parseInt(r[2]),MV=parseInt(r[3]),NV=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),PV.toColor(AV,jV,MV,NV);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[AV,jV,MV,NV]=t.getImageData(0,0,1,1).data,NV!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:PV.toRgba(AV,jV,MV,NV),css:e}}e.toColor=r})(IV||={});var LV;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(LV||={});var RV;(e=>{function t(e,t){if(NV=(t&255)/255,NV===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return AV=a+Math.round((n-a)*NV),jV=o+Math.round((r-o)*NV),MV=s+Math.round((i-s)*NV),PV.toRgba(AV,jV,MV)}e.blend=t;function n(e,t,n){let a=LV.relativeLuminance(e>>8),o=LV.relativeLuminance(t>>8);if(BV(a,o)<n){if(o<a){let o=r(e,t,n),s=BV(a,LV.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>BV(a,LV.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=BV(a,LV.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>BV(a,LV.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=BV(LV.relativeLuminance2(o,s,c),LV.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=BV(LV.relativeLuminance2(o,s,c),LV.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=BV(LV.relativeLuminance2(o,s,c),LV.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=BV(LV.relativeLuminance2(o,s,c),LV.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(RV||={});function zV(e){let t=e.toString(16);return t.length<2?`0`+t:t}function BV(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var VV=Object.freeze((()=>{let e=[IV.toColor(`#2e3436`),IV.toColor(`#cc0000`),IV.toColor(`#4e9a06`),IV.toColor(`#c4a000`),IV.toColor(`#3465a4`),IV.toColor(`#75507b`),IV.toColor(`#06989a`),IV.toColor(`#d3d7cf`),IV.toColor(`#555753`),IV.toColor(`#ef2929`),IV.toColor(`#8ae234`),IV.toColor(`#fce94f`),IV.toColor(`#729fcf`),IV.toColor(`#ad7fa8`),IV.toColor(`#34e2e2`),IV.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:PV.toCss(r,i,a),rgba:PV.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:PV.toCss(n,n,n),rgba:PV.toRgba(n,n,n)})}return e})());function HV(e,t,n){return Math.max(t,Math.min(e,n))}function UV(e){switch(e){case`&`:return`&`;case`<`:return`<`}return e}var WV=class{constructor(e){this._buffer=e}serialize(e,t){let n=this._buffer.getNullCell(),r=this._buffer.getNullCell(),i=n,a=e.start.y,o=e.end.y,s=e.start.x,c=e.end.x;this._beforeSerialize(o-a,a,o);for(let t=a;t<=o;t++){let a=this._buffer.getLine(t);if(a){let o=t===e.start.y?s:0,l=t===e.end.y?c:a.length;for(let e=o;e<l;e++){let o=a.getCell(e,i===n?r:n);if(!o){console.warn(`Can't get cell at row=${t}, col=${e}`);continue}this._nextCell(o,i,t,e),i=o}}this._rowEnd(t,t===o)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,n,r){}_rowEnd(e,t){}_beforeSerialize(e,t,n){}_afterSerialize(){}_serializeString(e){return``}};function GV(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function KV(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function qV(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}var JV=class extends WV{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=[],this._allRowSeparators=[],this._currentRow=``,this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,n){this._allRows=Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){this._nullCellCount>0&&!KV(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let n=``;if(!t){e-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let t=this._buffer.getLine(e),r=this._buffer.getLine(e+1);if(!r.isWrapped)n=`\r
|
|
196
|
-
`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n=``;let i=t.getCell(t.length-1,this._thisRowLastChar),a=t.getCell(t.length-2,this._thisRowLastSecondChar),o=r.getCell(0,this._nextRowFirstChar),s=o.getWidth()>1,c=!1;(o.getChars()&&s?this._nullCellCount<=1:this._nullCellCount<=0)&&((i.getChars()||i.getWidth()===0)&&KV(i,o)&&(c=!0),s&&(a.getChars()||a.getWidth()===0)&&KV(i,o)&&KV(a,o)&&(c=!0)),c||(n=`-`.repeat(this._nullCellCount+1),n+=`\x1B[1D\x1B[1X`,this._nullCellCount>0&&(n+=`\x1B[A`,n+=`\x1B[${t.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${t.length-this._nullCellCount}D`,n+=`\x1B[B`),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow=``,this._nullCellCount=0}_diffStyle(e,t){let n=[],r=!GV(e,t),i=!KV(e,t),a=!qV(e,t);if(r||i||a)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(r){let t=e.getFgColor();e.isFgRGB()?n.push(38,2,t>>>16&255,t>>>8&255,t&255):e.isFgPalette()?t>=16?n.push(38,5,t):n.push(t&8?90+(t&7):30+(t&7)):n.push(39)}if(i){let t=e.getBgColor();e.isBgRGB()?n.push(48,2,t>>>16&255,t>>>8&255,t&255):e.isBgPalette()?t>=16?n.push(48,5,t):n.push(t&8?100+(t&7):40+(t&7)):n.push(49)}a&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,this._cursorStyle);if(i?!KV(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(KV(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r,this._currentRow+=`\x1B[${a.join(`;`)}m`;let e=this._buffer.getLine(n);e!==void 0&&(e.getCell(r,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=r)}i?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(KV(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n=``;for(let e=0;e<t;e++)n+=this._allRows[e],e+1<t&&(n+=this._allRowSeparators[e]);if(!e){let e=this._buffer.baseY+this._buffer.cursorY,t=this._buffer.cursorX;(e!==this._lastCursorRow||t!==this._lastCursorCol)&&((e=>{e>0?n+=`\x1B[${e}B`:e<0&&(n+=`\x1B[${-e}A`)})(e-this._lastCursorRow),(e=>{e>0?n+=`\x1B[${e}C`:e<0&&(n+=`\x1B[${-e}D`)})(t-this._lastCursorCol))}let r=this._terminal._core._inputHandler._curAttrData,i=this._diffStyle(r,this._cursorStyle);return i.length>0&&(n+=`\x1B[${i.join(`;`)}m`),n}},YV=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let r=t.length,i=n===void 0?r:HV(n+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,n,r){return new JV(t,e).serialize({start:{x:0,y:typeof n.start==`number`?n.start:n.start.line},end:{x:e.cols,y:typeof n.end==`number`?n.end:n.end.line}},r)}_serializeBufferAsHTML(e,t){let n=e.buffer.active,r=new XV(n,e,t),i=t.onlySelection??!1,a=t.range;if(a)return r.serialize({start:{x:a.startCol,y:(a.startLine,a.startLine)},end:{x:e.cols,y:(a.endLine,a.endLine)}});if(!i){let i=n.length,a=t.scrollback,o=a===void 0?i:HV(a+e.rows,0,i);return r.serialize({start:{x:0,y:i-o},end:{x:e.cols,y:i-1}})}let o=this._terminal?.getSelectionPosition();return o===void 0?``:r.serialize({start:{x:o.start.x,y:o.start.y},end:{x:o.end.x,y:o.end.y}})}_serializeModes(e){let t=``,n=e.modes;if(n.applicationCursorKeysMode&&(t+=`\x1B[?1h`),n.applicationKeypadMode&&(t+=`\x1B[?66h`),n.bracketedPasteMode&&(t+=`\x1B[?2004h`),n.insertMode&&(t+=`\x1B[4h`),n.originMode&&(t+=`\x1B[?6h`),n.reverseWraparoundMode&&(t+=`\x1B[?45h`),n.sendFocusMode&&(t+=`\x1B[?1004h`),n.wraparoundMode===!1&&(t+=`\x1B[?7l`),n.mouseTrackingMode!==`none`)switch(n.mouseTrackingMode){case`x10`:t+=`\x1B[?9h`;break;case`vt200`:t+=`\x1B[?1000h`;break;case`drag`:t+=`\x1B[?1002h`;break;case`any`:t+=`\x1B[?1003h`;break}return t}serialize(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let t=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);if(!e?.excludeAltBuffer&&this._terminal.buffer.active.type===`alternate`){let e=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${e}`}return e?.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},XV=class extends WV{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow=``,this._htmlContent=``,t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=VV}_padStart(e,t,n){return t>>=0,n??=` `,e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){this._htmlContent+=`<html><body><!--StartFragment--><pre>`;let r=`#000000`,i=`#ffffff`;(this._options.includeGlobalBackground??!1)&&(r=this._terminal.options.theme?.foreground??`#ffffff`,i=this._terminal.options.theme?.background??`#000000`);let a=[];a.push(`color: `+r+`;`),a.push(`background-color: `+i+`;`),a.push(`font-family: `+this._terminal.options.fontFamily+`;`),a.push(`font-size: `+this._terminal.options.fontSize+`px;`),this._htmlContent+=`<div style='`+a.join(` `)+`'>`}_afterSerialize(){this._htmlContent+=`</div>`,this._htmlContent+=`</pre><!--EndFragment--></body></html>`}_rowEnd(e,t){this._htmlContent+=`<div><span>`+this._currentRow+`</span></div>`,this._currentRow=``}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return`#`+[n>>16&255,n>>8&255,n&255].map(e=>this._padStart(e.toString(16),2,`0`)).join(``);if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],r=!GV(e,t),i=!KV(e,t),a=!qV(e,t);if(r||i||a){let t=this._getHexColor(e,!0);t&&n.push(`color: `+t+`;`);let r=this._getHexColor(e,!1);return r&&n.push(`background-color: `+r+`;`),e.isInverse()&&n.push(`color: #000000; background-color: #BFBFBF;`),e.isBold()&&n.push(`font-weight: bold;`),e.isUnderline()&&e.isOverline()?n.push(`text-decoration: overline underline;`):e.isUnderline()?n.push(`text-decoration: underline;`):e.isOverline()&&n.push(`text-decoration: overline;`),e.isBlink()&&n.push(`text-decoration: blink;`),e.isInvisible()&&n.push(`visibility: hidden;`),e.isItalic()&&n.push(`font-style: italic;`),e.isDim()&&n.push(`opacity: 0.5;`),e.isStrikethrough()&&n.push(`text-decoration: line-through;`),n}}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,t);a&&(this._currentRow+=a.length===0?`</span><span>`:`</span><span style='`+a.join(` `)+`'>`),i?this._currentRow+=` `:this._currentRow+=UV(e.getChars())}_serializeString(){return this._htmlContent}};function ZV(e){let t=0;for(let n=0;n<e.length;++n){let r=e.charCodeAt(n);if(r<48||57<r)return-1;t=t*10+r-48}return t}var QV=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,e=>{if(!e.startsWith(`4;`))return!1;let t=e.split(`;`);if(t.length>3)return!0;t.length===2&&t.push(``);let n=ZV(t[1]),r=ZV(t[2]);switch(n){case 0:this.progress={state:n,value:0};break;case 1:if(r<0)return!0;this.progress={state:n,value:r};break;case 2:case 4:if(r<0)return!0;this.progress={state:n,value:r||this._pr};break;case 3:this.progress={state:n,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn(`progress state out of bounds, not applied`);return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};function $V(e){return`\x1b[200~${e}\x1b[201~`}function eH(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function tH(e,t){let n=eH(e);return t===`codex`?n:$V(n)}var nH=40*1024*1024,rH=`40 MB`;function iH(e){if(!e)return[];let t=Array.from(e.files??[]).filter(e=>e instanceof File);return t.length?t:Array.from(e.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile?.()).filter(e=>e instanceof File)}function aH(e){let t=e.find(e=>e.type.startsWith(`image/`)&&e.size===0);if(t)return`${t.name} contains no image data. Choose the file to upload it.`;let n=e.find(e=>e.size>nH);return n?`${n.name} exceeds the ${rH} limit`:null}async function oH(e,t){let n=aH([e]);if(n)throw Error(n);let r=new FormData,i=/^image\/(png|jpeg|gif|webp)$/.test(e.type);r.append(i?`image`:`file`,e,e.name);let a;try{a=await fetch(i?`/api/paste-image`:`/api/paste-file`,{method:`POST`,body:r,signal:t})}catch(n){throw t?.aborted?n:Error(`Could not upload ${e.name}. Check your connection and try again.`)}let o=await a.json().catch(()=>null);if(!a.ok||typeof o?.path!=`string`||!o.path.startsWith(`/`))throw Error(typeof o?.error==`string`?o.error:`Could not upload ${e.name}. Try again.`);return o.path}function sH(e){return`'${e.replace(/[\x00-\x1f\x7f]/g,``).replace(/'/g,`'\\''`)}'`}async function cH(){try{let e=await navigator.clipboard.read(),t=[],n=``;for(let r of e){let e=r.types.find(e=>e.startsWith(`image/`));e?t.push(new File([await r.getType(e)],`clipboard.${e.split(`/`)[1]||`png`}`,{type:e})):r.types.includes(`text/plain`)&&(n+=await(await r.getType(`text/plain`)).text())}return{text:n,files:t}}catch{return{text:await navigator.clipboard.readText(),files:[]}}}var lH=new Map,uH=20;function dH(e){lH.delete(e)}function fH(){lH.clear()}var pH=/https?:\/\/[^\s"'<>]+|\b(?:localhost|\d{1,3}(?:\.\d{1,3}){3}):\d{1,5}(?:\/[^\s"'<>]*)?\b/,mH=/[.,;:!?]+$/,hH=[[`(`,`)`],[`[`,`]`],[`{`,`}`]],gH=(e,t)=>e.split(t).length-1;function _H(e){let t=e.trim();if(!t)return t;let n=()=>{t=t.replace(mH,``)};n();let r=!0;for(;r;){r=!1;for(let[e,n]of hH){if(!t.endsWith(n))continue;let i=gH(t,e);gH(t,n)>i&&(t=t.slice(0,-1),r=!0)}}return n(),t}var vH=()=>typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),yH=`\x1B[200~\x1B[201~`,bH=``,xH=`\x1B[?1000h\x1B[?1002h\x1B[?1006h`,SH=`\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l`;async function CH(e){try{let t=(e.type.split(`/`)[1]||`png`).toLowerCase(),n=new FormData;n.append(`image`,e,`paste.${t}`);let r=await fetch(`/api/paste-image`,{method:`POST`,body:n});if(!r.ok)return null;let i=await r.json();return typeof i.path==`string`?i.path:null}catch{return null}}async function wH(){try{let e=await fetch(`/api/clipboard-file-path`);if(!e.ok)return null;let t=await e.json();return t.isImage===!0&&typeof t.path==`string`?t.path:null}catch{return null}}async function TH(e,t){if(e===`codex`)return bH;let n=t.path??null;return!n&&t.blob&&(n=await CH(t.blob)),n||=await wH(),n?$V(eH(n)):yH}var EH=/\/Users\/[^/\n]+\/Library\/Group Containers\/group\.com\.apple\.coreservices\.useractivityd\/shared-pasteboard\/items\//;function DH(e){return EH.test(e)}function OH(e){if(!e)return!1;for(let t of Array.from(e.files??[]))if(t?.type?.startsWith(`image/`))return!0;for(let t of Array.from(e.items??[]))if(t?.type?.startsWith(`image/`))return!0;return!1}function kH(e){if(!e)return null;for(let t of Array.from(e.files??[]))if(t?.type?.startsWith(`image/`))return t;for(let t of Array.from(e.items??[]))if(t?.kind===`file`&&t.type?.startsWith(`image/`)){let e=t.getAsFile?.();if(e)return e}return null}var AH=class{constructor(e={}){this.callbacks=e}async readText(e){if(e!==`c`)return``;try{return await navigator.clipboard.readText()}catch{return``}}async writeText(e,t){if(e!==`c`||!t?.trim())return;let n=performance.now();try{if(!navigator.clipboard?.writeText)throw Error(`navigator.clipboard.writeText unavailable`);await navigator.clipboard.writeText(t),QT(`clipboard_write_success`,{source:`osc52`,chars:t.length,durationMs:Math.round(performance.now()-n)})}catch(e){QT(`clipboard_write_failed`,{source:`osc52`,chars:t.length,error:e instanceof Error?e.message:String(e)},`warn`),this.callbacks.onWriteFailed?.(t,`osc52`)}}},jH=`︎`,MH=[`⏺`],NH=new RegExp(MH.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),`g`);function PH(e){for(let t of MH)if(e.indexOf(t)!==-1)return e.replace(NH,`$&${jH}`);return e}function FH({sessionId:e,tmuxTarget:t,agentType:n,allowAttach:r=!0,connectionStatus:i=`connected`,connectionEpoch:a=0,sendMessage:o,subscribe:s,theme:c,fontSize:l,lineHeight:u,letterSpacing:d,fontFamily:f,useWebGL:p,onScrollChange:m,onPasteFiles:h,onPasteError:g}){let _=(0,x.useRef)(h);_.current=h;let v=(0,x.useRef)(g);v.current=g;let y=()=>!_.current||typeof location<`u`&&[`localhost`,`127.0.0.1`,`[::1]`].includes(location.hostname),b=We(),S=(0,x.useRef)(null),C=(0,x.useRef)(null),w=(0,x.useRef)(!1),T=(0,x.useRef)(null),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=(0,x.useRef)(null),A=(0,x.useRef)(null),j=(0,x.useRef)(null),M=(0,x.useRef)(null),N=(0,x.useRef)(null),P=(0,x.useRef)(null),F=(0,x.useRef)(0),I=(0,x.useRef)(!1),[L,ee]=(0,x.useState)(!1),R=(0,x.useRef)(!1),z=(0,x.useRef)(!1),B=(0,x.useRef)(null),te=(0,x.useRef)(0),[V,ne]=(0,x.useState)(null),re=(0,x.useCallback)((e,t)=>{e?.trim()&&(te.current+=1,ne({id:te.current,text:e,source:t}))},[]),U=(0,x.useCallback)(()=>{V&&(zm(V.text),QT(`clipboard_manual_copy`,{source:V.source,chars:V.text.length},`info`),ne(null))},[V]),ie=(0,x.useCallback)(()=>{ne(null)},[]),ae=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(e&&r&&i===`connected`?e:null),ce=(0,x.useRef)(null),le=(0,x.useRef)(-1),ue=(0,x.useRef)(null),de=(0,x.useRef)(null),fe=(0,x.useRef)(o),pe=(0,x.useRef)(n),me=(0,x.useRef)(m),he=(0,x.useRef)(p),ge=(0,x.useRef)([]),_e=(0,x.useRef)(null),ve=(0,x.useRef)(null),ye=(0,x.useRef)(!1),[be,xe]=(0,x.useState)(!1),Se=(0,x.useRef)(null),Ce=(0,x.useRef)(null),we=(0,x.useRef)(null),Te=()=>{if(Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null),Ce.current!==null&&(cancelAnimationFrame(Ce.current),Ce.current=null),we.current!==null){let e=S.current;e&&(e.style.display=we.current),we.current=null}},Ee=(e,t)=>{let n=S.current;n&&(Te(),QT(`ios_repaint_schedule`,{delayMs:e,trigger:t,sessionId:oe.current}),Se.current=window.setTimeout(()=>{Se.current=null;let e=C.current;e&&e.refresh(0,e.rows-1),QT(`ios_repaint_exec`,{trigger:t,hasContent:e?e.buffer.active.length>0:!1,bufferLines:e?.buffer.active.length??0,sessionId:oe.current}),we.current=n.style.display,n.style.display=`none`,Ce.current=requestAnimationFrame(()=>{Ce.current=requestAnimationFrame(()=>{Ce.current=null,n.style.display=we.current??``,we.current=null})})},e))};(0,x.useEffect)(()=>{fe.current=o},[o]),(0,x.useEffect)(()=>{pe.current=n},[n]),(0,x.useEffect)(()=>{me.current=m},[m]);let De=(0,x.useCallback)(()=>{let e=C.current;if(!e||!me.current)return;let t=e.buffer.active,n=!I.current&&t.viewportY>=t.baseY;me.current(n)},[]),Oe=(0,x.useCallback)(e=>{if(I.current===e)return;I.current=e,ee(e);let t=C.current;t&&e&&t.write(SH),De()},[De]),ke=(0,x.useCallback)(()=>{let e=se.current;e&&(B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,fe.current({type:`tmux-check-copy-mode`,sessionId:e})},150))},[]),Ae=(0,x.useCallback)(()=>{let e=C.current,t=T.current;if(!e||!t)return;t.fit();let n=oe.current;n&&fe.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})},[]);return(0,x.useEffect)(()=>{let t=S.current;if(!t||C.current)return;let n=!1;t.innerHTML=``;let r=new SP({fontFamily:f,fontSize:l,lineHeight:((e,t)=>Math.round(e*t)/e)(l,u),letterSpacing:d,scrollback:0,cursorBlink:!1,cursorStyle:`underline`,convertEol:!1,theme:c,screenReaderMode:b,minimumContrastRatio:4.5}),i=new TP;r.loadAddon(i),r.loadAddon(new rB(void 0,new AH({onWriteFailed:re})));let a=new kV;r.loadAddon(a),k.current=a;let o=new YV;r.loadAddon(o),A.current=o;let s=new QV;r.loadAddon(s),j.current=s;let p=()=>{if(!n){if(he.current)try{let t=new pz;t.onContextLoss(()=>{QT(`webgl_context_loss`,{sessionId:e},`info`);try{t.dispose()}catch{}E.current=null}),r.loadAddon(t),E.current=t}catch{}r.open(t),i.fit(),w.current||(w.current=!0,QT(`terminal_init`,{isiOS:b,useWebGL:he.current,hasWebGL:!!E.current,userAgent:navigator.userAgent.slice(0,120),platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints},`info`)),m&&r.element&&r.element.appendChild(m)}};document.fonts?.ready?document.fonts.ready.then(p).catch(p):p();let m=null,h=null,g=null;typeof document<`u`&&document.createElement&&(m=document.createElement(`div`),m.className=`xterm-hover`,m.style.cssText=`
|
|
196
|
+
`,this._lastCursorRow=e+1,this._lastCursorCol=0;else{n=``;let i=t.getCell(t.length-1,this._thisRowLastChar),a=t.getCell(t.length-2,this._thisRowLastSecondChar),o=r.getCell(0,this._nextRowFirstChar),s=o.getWidth()>1,c=!1;(o.getChars()&&s?this._nullCellCount<=1:this._nullCellCount<=0)&&((i.getChars()||i.getWidth()===0)&&KV(i,o)&&(c=!0),s&&(a.getChars()||a.getWidth()===0)&&KV(i,o)&&KV(a,o)&&(c=!0)),c||(n=`-`.repeat(this._nullCellCount+1),n+=`\x1B[1D\x1B[1X`,this._nullCellCount>0&&(n+=`\x1B[A`,n+=`\x1B[${t.length-this._nullCellCount}C`,n+=`\x1B[${this._nullCellCount}X`,n+=`\x1B[${t.length-this._nullCellCount}D`,n+=`\x1B[B`),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=n,this._currentRow=``,this._nullCellCount=0}_diffStyle(e,t){let n=[],r=!GV(e,t),i=!KV(e,t),a=!qV(e,t);if(r||i||a)if(e.isAttributeDefault())t.isAttributeDefault()||n.push(0);else{if(r){let t=e.getFgColor();e.isFgRGB()?n.push(38,2,t>>>16&255,t>>>8&255,t&255):e.isFgPalette()?t>=16?n.push(38,5,t):n.push(t&8?90+(t&7):30+(t&7)):n.push(39)}if(i){let t=e.getBgColor();e.isBgRGB()?n.push(48,2,t>>>16&255,t>>>8&255,t&255):e.isBgPalette()?t>=16?n.push(48,5,t):n.push(t&8?100+(t&7):40+(t&7)):n.push(49)}a&&(e.isInverse()!==t.isInverse()&&n.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&n.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&n.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&n.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&n.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&n.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&n.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&n.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&n.push(e.isStrikethrough()?9:29))}return n}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,this._cursorStyle);if(i?!KV(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(KV(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r,this._currentRow+=`\x1B[${a.join(`;`)}m`;let e=this._buffer.getLine(n);e!==void 0&&(e.getCell(r,this._cursorStyle),this._cursorStyleRow=n,this._cursorStyleCol=r)}i?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(KV(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=n,this._lastContentCursorCol=this._lastCursorCol=r+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let n=``;for(let e=0;e<t;e++)n+=this._allRows[e],e+1<t&&(n+=this._allRowSeparators[e]);if(!e){let e=this._buffer.baseY+this._buffer.cursorY,t=this._buffer.cursorX;(e!==this._lastCursorRow||t!==this._lastCursorCol)&&((e=>{e>0?n+=`\x1B[${e}B`:e<0&&(n+=`\x1B[${-e}A`)})(e-this._lastCursorRow),(e=>{e>0?n+=`\x1B[${e}C`:e<0&&(n+=`\x1B[${-e}D`)})(t-this._lastCursorCol))}let r=this._terminal._core._inputHandler._curAttrData,i=this._diffStyle(r,this._cursorStyle);return i.length>0&&(n+=`\x1B[${i.join(`;`)}m`),n}},YV=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,n){let r=t.length,i=n===void 0?r:HV(n+e.rows,0,r);return this._serializeBufferByRange(e,t,{start:r-i,end:r-1},!1)}_serializeBufferByRange(e,t,n,r){return new JV(t,e).serialize({start:{x:0,y:typeof n.start==`number`?n.start:n.start.line},end:{x:e.cols,y:typeof n.end==`number`?n.end:n.end.line}},r)}_serializeBufferAsHTML(e,t){let n=e.buffer.active,r=new XV(n,e,t),i=t.onlySelection??!1,a=t.range;if(a)return r.serialize({start:{x:a.startCol,y:(a.startLine,a.startLine)},end:{x:e.cols,y:(a.endLine,a.endLine)}});if(!i){let i=n.length,a=t.scrollback,o=a===void 0?i:HV(a+e.rows,0,i);return r.serialize({start:{x:0,y:i-o},end:{x:e.cols,y:i-1}})}let o=this._terminal?.getSelectionPosition();return o===void 0?``:r.serialize({start:{x:o.start.x,y:o.start.y},end:{x:o.end.x,y:o.end.y}})}_serializeModes(e){let t=``,n=e.modes;if(n.applicationCursorKeysMode&&(t+=`\x1B[?1h`),n.applicationKeypadMode&&(t+=`\x1B[?66h`),n.bracketedPasteMode&&(t+=`\x1B[?2004h`),n.insertMode&&(t+=`\x1B[4h`),n.originMode&&(t+=`\x1B[?6h`),n.reverseWraparoundMode&&(t+=`\x1B[?45h`),n.sendFocusMode&&(t+=`\x1B[?1004h`),n.wraparoundMode===!1&&(t+=`\x1B[?7l`),n.mouseTrackingMode!==`none`)switch(n.mouseTrackingMode){case`x10`:t+=`\x1B[?9h`;break;case`vt200`:t+=`\x1B[?1000h`;break;case`drag`:t+=`\x1B[?1002h`;break;case`any`:t+=`\x1B[?1003h`;break}return t}serialize(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);let t=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);if(!e?.excludeAltBuffer&&this._terminal.buffer.active.type===`alternate`){let e=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${e}`}return e?.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw Error(`Cannot use addon until it has been loaded`);return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},XV=class extends WV{constructor(e,t,n){super(e),this._terminal=t,this._options=n,this._currentRow=``,this._htmlContent=``,t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=VV}_padStart(e,t,n){return t>>=0,n??=` `,e.length>t?e:(t-=e.length,t>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}_beforeSerialize(e,t,n){this._htmlContent+=`<html><body><!--StartFragment--><pre>`;let r=`#000000`,i=`#ffffff`;(this._options.includeGlobalBackground??!1)&&(r=this._terminal.options.theme?.foreground??`#ffffff`,i=this._terminal.options.theme?.background??`#000000`);let a=[];a.push(`color: `+r+`;`),a.push(`background-color: `+i+`;`),a.push(`font-family: `+this._terminal.options.fontFamily+`;`),a.push(`font-size: `+this._terminal.options.fontSize+`px;`),this._htmlContent+=`<div style='`+a.join(` `)+`'>`}_afterSerialize(){this._htmlContent+=`</div>`,this._htmlContent+=`</pre><!--EndFragment--></body></html>`}_rowEnd(e,t){this._htmlContent+=`<div><span>`+this._currentRow+`</span></div>`,this._currentRow=``}_getHexColor(e,t){let n=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return`#`+[n>>16&255,n>>8&255,n&255].map(e=>this._padStart(e.toString(16),2,`0`)).join(``);if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[n].css}_diffStyle(e,t){let n=[],r=!GV(e,t),i=!KV(e,t),a=!qV(e,t);if(r||i||a){let t=this._getHexColor(e,!0);t&&n.push(`color: `+t+`;`);let r=this._getHexColor(e,!1);return r&&n.push(`background-color: `+r+`;`),e.isInverse()&&n.push(`color: #000000; background-color: #BFBFBF;`),e.isBold()&&n.push(`font-weight: bold;`),e.isUnderline()&&e.isOverline()?n.push(`text-decoration: overline underline;`):e.isUnderline()?n.push(`text-decoration: underline;`):e.isOverline()&&n.push(`text-decoration: overline;`),e.isBlink()&&n.push(`text-decoration: blink;`),e.isInvisible()&&n.push(`visibility: hidden;`),e.isItalic()&&n.push(`font-style: italic;`),e.isDim()&&n.push(`opacity: 0.5;`),e.isStrikethrough()&&n.push(`text-decoration: line-through;`),n}}_nextCell(e,t,n,r){if(e.getWidth()===0)return;let i=e.getChars()===``,a=this._diffStyle(e,t);a&&(this._currentRow+=a.length===0?`</span><span>`:`</span><span style='`+a.join(` `)+`'>`),i?this._currentRow+=` `:this._currentRow+=UV(e.getChars())}_serializeString(){return this._htmlContent}};function ZV(e){let t=0;for(let n=0;n<e.length;++n){let r=e.charCodeAt(n);if(r<48||57<r)return-1;t=t*10+r-48}return t}var QV=class{constructor(){this._st=0,this._pr=0}dispose(){this._seqHandler?.dispose(),this._onChange?.dispose()}activate(e){this._seqHandler=e.parser.registerOscHandler(9,e=>{if(!e.startsWith(`4;`))return!1;let t=e.split(`;`);if(t.length>3)return!0;t.length===2&&t.push(``);let n=ZV(t[1]),r=ZV(t[2]);switch(n){case 0:this.progress={state:n,value:0};break;case 1:if(r<0)return!0;this.progress={state:n,value:r};break;case 2:case 4:if(r<0)return!0;this.progress={state:n,value:r||this._pr};break;case 3:this.progress={state:n,value:this._pr};break}return!0}),this._onChange=new e._core._onData.constructor,this.onChange=this._onChange.event}get progress(){return{state:this._st,value:this._pr}}set progress(e){if(e.state<0||e.state>4){console.warn(`progress state out of bounds, not applied`);return}this._st=e.state,this._pr=Math.min(Math.max(e.value,0),100),this._onChange?.fire({state:this._st,value:this._pr})}};function $V(e){return`\x1b[200~${e}\x1b[201~`}function eH(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function tH(e,t){let n=eH(e);return t===`codex`?n:$V(n)}var nH=40*1024*1024,rH=`40 MB`;function iH(e){if(!e)return[];let t=Array.from(e.files??[]).filter(e=>e instanceof File);return t.length?t:Array.from(e.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile?.()).filter(e=>e instanceof File)}function aH(e){let t=e.find(e=>e.type.startsWith(`image/`)&&e.size===0);if(t)return`${t.name} contains no image data. Choose the file to upload it.`;let n=e.find(e=>e.size>nH);return n?`${n.name} exceeds the ${rH} limit`:null}async function oH(e,t){let n=aH([e]);if(n)throw Error(n);let r=new FormData,i=/^image\/(png|jpeg|gif|webp)$/.test(e.type);r.append(i?`image`:`file`,e,e.name);let a;try{a=await fetch(i?`/api/paste-image`:`/api/paste-file`,{method:`POST`,body:r,signal:t})}catch(n){throw t?.aborted?n:Error(`Could not upload ${e.name}. Check your connection and try again.`)}let o=await a.json().catch(()=>null);if(!a.ok||typeof o?.path!=`string`||!o.path.startsWith(`/`))throw Error(typeof o?.error==`string`?o.error:`Could not upload ${e.name}. Try again.`);return o.path}function sH(e){return`'${e.replace(/[\x00-\x1f\x7f]/g,``).replace(/'/g,`'\\''`)}'`}async function cH(){try{let e=await navigator.clipboard.read(),t=[],n=``;for(let r of e){let e=r.types.find(e=>e.startsWith(`image/`));e?t.push(new File([await r.getType(e)],`clipboard.${e.split(`/`)[1]||`png`}`,{type:e})):r.types.includes(`text/plain`)&&(n+=await(await r.getType(`text/plain`)).text())}return{text:n,files:t}}catch{return{text:await navigator.clipboard.readText(),files:[]}}}var lH=new Map,uH=20;function dH(e){lH.delete(e)}function fH(){lH.clear()}var pH=/https?:\/\/[^\s"'<>]+|\b(?:localhost|\d{1,3}(?:\.\d{1,3}){3}):\d{1,5}(?:\/[^\s"'<>]*)?\b/,mH=/[.,;:!?]+$/,hH=[[`(`,`)`],[`[`,`]`],[`{`,`}`]],gH=(e,t)=>e.split(t).length-1;function _H(e){let t=e.trim();if(!t)return t;let n=()=>{t=t.replace(mH,``)};n();let r=!0;for(;r;){r=!1;for(let[e,n]of hH){if(!t.endsWith(n))continue;let i=gH(t,e);gH(t,n)>i&&(t=t.slice(0,-1),r=!0)}}return n(),t}var vH=()=>typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform),yH=`\x1B[200~\x1B[201~`,bH=``,xH=`\x1B[?1000h\x1B[?1002h\x1B[?1006h`,SH=`\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l`;async function CH(e){try{let t=(e.type.split(`/`)[1]||`png`).toLowerCase(),n=new FormData;n.append(`image`,e,`paste.${t}`);let r=await fetch(`/api/paste-image`,{method:`POST`,body:n});if(!r.ok)return null;let i=await r.json();return typeof i.path==`string`?i.path:null}catch{return null}}async function wH(){try{let e=await fetch(`/api/clipboard-file-path`);if(!e.ok)return null;let t=await e.json();return t.isImage===!0&&typeof t.path==`string`?t.path:null}catch{return null}}async function TH(e,t){if(e===`codex`)return bH;let n=t.path??null;return!n&&t.blob&&(n=await CH(t.blob)),n||=await wH(),n?$V(eH(n)):yH}var EH=/\/Users\/[^/\n]+\/Library\/Group Containers\/group\.com\.apple\.coreservices\.useractivityd\/shared-pasteboard\/items\//;function DH(e){return EH.test(e)}function OH(e){if(!e)return!1;for(let t of Array.from(e.files??[]))if(t?.type?.startsWith(`image/`))return!0;for(let t of Array.from(e.items??[]))if(t?.type?.startsWith(`image/`))return!0;return!1}function kH(e){if(!e)return null;for(let t of Array.from(e.files??[]))if(t?.type?.startsWith(`image/`))return t;for(let t of Array.from(e.items??[]))if(t?.kind===`file`&&t.type?.startsWith(`image/`)){let e=t.getAsFile?.();if(e)return e}return null}var AH=class{constructor(e={}){this.callbacks=e}async readText(e){if(e!==`c`)return``;try{return await navigator.clipboard.readText()}catch{return``}}async writeText(e,t){if(e!==`c`||!t?.trim())return;let n=performance.now();try{if(!navigator.clipboard?.writeText)throw Error(`navigator.clipboard.writeText unavailable`);await navigator.clipboard.writeText(t),J(`clipboard_write_success`,{source:`osc52`,chars:t.length,durationMs:Math.round(performance.now()-n)})}catch(e){J(`clipboard_write_failed`,{source:`osc52`,chars:t.length,error:e instanceof Error?e.message:String(e)},`warn`),this.callbacks.onWriteFailed?.(t,`osc52`)}}},jH=`︎`,MH=[`⏺`],NH=new RegExp(MH.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),`g`);function PH(e){for(let t of MH)if(e.indexOf(t)!==-1)return e.replace(NH,`$&${jH}`);return e}function FH({sessionId:e,tmuxTarget:t,agentType:n,allowAttach:r=!0,connectionStatus:i=`connected`,connectionEpoch:a=0,sendMessage:o,subscribe:s,theme:c,fontSize:l,lineHeight:u,letterSpacing:d,fontFamily:f,useWebGL:p,onScrollChange:m,onPasteFiles:h,onPasteError:g}){let _=(0,x.useRef)(h);_.current=h;let v=(0,x.useRef)(g);v.current=g;let y=()=>!_.current||typeof location<`u`&&[`localhost`,`127.0.0.1`,`[::1]`].includes(location.hostname),b=We(),S=(0,x.useRef)(null),C=(0,x.useRef)(null),w=(0,x.useRef)(!1),T=(0,x.useRef)(null),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=(0,x.useRef)(null),A=(0,x.useRef)(null),j=(0,x.useRef)(null),M=(0,x.useRef)(null),N=(0,x.useRef)(null),P=(0,x.useRef)(null),F=(0,x.useRef)(0),I=(0,x.useRef)(!1),[L,ee]=(0,x.useState)(!1),R=(0,x.useRef)(!1),z=(0,x.useRef)(!1),B=(0,x.useRef)(null),te=(0,x.useRef)(0),[V,ne]=(0,x.useState)(null),re=(0,x.useCallback)((e,t)=>{e?.trim()&&(te.current+=1,ne({id:te.current,text:e,source:t}))},[]),U=(0,x.useCallback)(()=>{V&&(zm(V.text),J(`clipboard_manual_copy`,{source:V.source,chars:V.text.length},`info`),ne(null))},[V]),ie=(0,x.useCallback)(()=>{ne(null)},[]),ae=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(e&&r&&i===`connected`?e:null),ce=(0,x.useRef)(null),le=(0,x.useRef)(-1),ue=(0,x.useRef)(null),de=(0,x.useRef)(null),fe=(0,x.useRef)(o),pe=(0,x.useRef)(n),me=(0,x.useRef)(m),he=(0,x.useRef)(p),ge=(0,x.useRef)([]),_e=(0,x.useRef)(null),ve=(0,x.useRef)(null),ye=(0,x.useRef)(!1),[be,xe]=(0,x.useState)(!1),Se=(0,x.useRef)(null),Ce=(0,x.useRef)(null),we=(0,x.useRef)(null),Te=()=>{if(Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null),Ce.current!==null&&(cancelAnimationFrame(Ce.current),Ce.current=null),we.current!==null){let e=S.current;e&&(e.style.display=we.current),we.current=null}},Ee=(e,t)=>{let n=S.current;n&&(Te(),J(`ios_repaint_schedule`,{delayMs:e,trigger:t,sessionId:oe.current}),Se.current=window.setTimeout(()=>{Se.current=null;let e=C.current;e&&e.refresh(0,e.rows-1),J(`ios_repaint_exec`,{trigger:t,hasContent:e?e.buffer.active.length>0:!1,bufferLines:e?.buffer.active.length??0,sessionId:oe.current}),we.current=n.style.display,n.style.display=`none`,Ce.current=requestAnimationFrame(()=>{Ce.current=requestAnimationFrame(()=>{Ce.current=null,n.style.display=we.current??``,we.current=null})})},e))};(0,x.useEffect)(()=>{fe.current=o},[o]),(0,x.useEffect)(()=>{pe.current=n},[n]),(0,x.useEffect)(()=>{me.current=m},[m]);let De=(0,x.useCallback)(()=>{let e=C.current;if(!e||!me.current)return;let t=e.buffer.active,n=!I.current&&t.viewportY>=t.baseY;me.current(n)},[]),Oe=(0,x.useCallback)(e=>{if(I.current===e)return;I.current=e,ee(e);let t=C.current;t&&e&&t.write(SH),De()},[De]),ke=(0,x.useCallback)(()=>{let e=se.current;e&&(B.current!==null&&window.clearTimeout(B.current),B.current=window.setTimeout(()=>{B.current=null,fe.current({type:`tmux-check-copy-mode`,sessionId:e})},150))},[]),Ae=(0,x.useCallback)(()=>{let e=C.current,t=T.current;if(!e||!t)return;t.fit();let n=oe.current;n&&fe.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})},[]);return(0,x.useEffect)(()=>{let t=S.current;if(!t||C.current)return;let n=!1;t.innerHTML=``;let r=new SP({fontFamily:f,fontSize:l,lineHeight:((e,t)=>Math.round(e*t)/e)(l,u),letterSpacing:d,scrollback:0,cursorBlink:!1,cursorStyle:`underline`,convertEol:!1,theme:c,screenReaderMode:b,minimumContrastRatio:4.5}),i=new TP;r.loadAddon(i),r.loadAddon(new rB(void 0,new AH({onWriteFailed:re})));let a=new kV;r.loadAddon(a),k.current=a;let o=new YV;r.loadAddon(o),A.current=o;let s=new QV;r.loadAddon(s),j.current=s;let p=()=>{if(!n){if(he.current)try{let t=new pz;t.onContextLoss(()=>{J(`webgl_context_loss`,{sessionId:e},`info`);try{t.dispose()}catch{}E.current=null}),r.loadAddon(t),E.current=t}catch{}r.open(t),i.fit(),w.current||(w.current=!0,J(`terminal_init`,{isiOS:b,useWebGL:he.current,hasWebGL:!!E.current,userAgent:navigator.userAgent.slice(0,120),platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints},`info`)),m&&r.element&&r.element.appendChild(m)}};document.fonts?.ready?document.fonts.ready.then(p).catch(p):p();let m=null,h=null,g=null;typeof document<`u`&&document.createElement&&(m=document.createElement(`div`),m.className=`xterm-hover`,m.style.cssText=`
|
|
197
197
|
position: absolute;
|
|
198
198
|
display: none;
|
|
199
199
|
z-index: 20;
|
|
@@ -209,7 +209,7 @@ ${s.join(`
|
|
|
209
209
|
word-break: break-all;
|
|
210
210
|
`,h=document.createElement(`div`),m.appendChild(h),g=document.createElement(`div`),g.style.color=`var(--text-muted)`,g.style.marginTop=`2px`,g.style.fontSize=`11px`,m.appendChild(g),O.current=m);let x=(e,t)=>{if(!r.element||!m||!h||!g)return;let n=_H(t);if(!n)return;let i=r.element.getBoundingClientRect(),a=n.length>60?n.slice(0,57)+`...`:n;h.textContent=a,g.textContent=`${vH()?`⌘`:`Ctrl`}+click to open`,m.style.left=`${e.clientX-i.left+10}px`,m.style.top=`${e.clientY-i.top+10}px`,m.style.display=`block`},M=()=>{m&&(m.style.display=`none`)},P=null,L=!1,ee=null,z={activate:(e,t)=>{if(!L&&(e.metaKey||e.ctrlKey)){let e=_H(t);if(!e)return;window.open(e,`_blank`,`noopener`)}},hover:(e,t)=>{P=_H(t)||null,x(e,t)},leave:()=>{P=null,M()}},te=e=>{P&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.stopPropagation(),L=!0,window.open(P,`_blank`,`noopener`),ee&&clearTimeout(ee),ee=setTimeout(()=>{L=!1},100))};t.addEventListener(`mousedown`,te,!0),r.options.linkHandler=z;let V=new yz((e,t)=>z.activate(e,t),{urlRegex:pH,hover:(e,t)=>z.hover(e,t),leave:()=>z.leave()});r.loadAddon(V),D.current=V;let ne=null,U=null,ie=vH()?`metaKey`:`ctrlKey`,ae=(e,t)=>{t&&oe.current===e&&se.current===e&&(I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:e}),Oe(!1)),fe.current({type:`terminal-input`,sessionId:e,data:t}))};r.attachCustomKeyEventHandler(e=>{if(e.type===`keydown`&&/^Digit[1-9]$/.test(e.code)&&Xe(e,qe(H.getState().shortcutModifier)))return!1;if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`c`&&r.hasSelection()){let e=r.getSelection();return e?.trim()&&navigator.clipboard&&navigator.clipboard.writeText(e),!1}if(vH()&&!b&&e.ctrlKey&&!e.metaKey&&e.key.toLowerCase()===`v`&&e.type===`keydown`){let e=se.current;if(e){if(!y())return v.current?.(`Use browser paste or choose a file from this device.`),!1;I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:e}),Oe(!1)),(async()=>{ae(e,await TH(pe.current,{}))})()}return!e}if(e[ie]&&e.key.toLowerCase()===`v`&&e.type===`keydown`){U!==null&&(clearTimeout(U),U=null),ne=null;let e=new Promise(e=>{U=setTimeout(()=>{U=null,ne=null,e(null)},100),ne=t=>{U!==null&&(clearTimeout(U),U=null),e(t)}});return(async()=>{try{let t=se.current;if(!t)return;let n=await e;if(!n&&_.current)return;let r=n?.text??null;if(r===null)try{r=await navigator.clipboard.readText()}catch{r=``}if(n?.files.length&&_.current){if(oe.current===t&&se.current===t){let e=n.files.map(e=>e.name).join(`
|
|
211
211
|
`);_.current({files:n.files,text:r.trim()===e?``:r})}return}if(n?.hasImage&&vH()&&!b){if(!y()){if(n.imageBlob){let e=n.imageBlob;_.current?.({text:``,files:[new File([e],`clipboard.${e.type.split(`/`)[1]||`png`}`,{type:e.type})]})}else v.current?.(`The browser did not provide image data. Choose the file to upload it.`);return}ae(t,await TH(pe.current,{blob:n.imageBlob}));return}if(n?.hasFiles&&!y()){v.current?.(`The browser did not provide file data. Drop the file onto the terminal or choose it to upload.`);return}if((!r||n?.hasFiles)&&vH()&&!b&&y())try{let e=await fetch(`/api/clipboard-file-path`);if(e.ok){let{path:n,isImage:r}=await e.json();if(n){if(r){ae(t,await TH(pe.current,{path:n}));return}ae(t,eH(n));return}}}catch{}if(r&&!DH(r)){oe.current===t&&se.current===t&&(I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:t}),Oe(!1)),fe.current({type:`terminal-paste`,sessionId:t,data:r}));return}vH()&&!b&&y()&&ae(t,await TH(pe.current,{}))}finally{ne=null}})(),!!_.current&&ie===`metaKey`}if(e.ctrlKey&&e.key===`Backspace`&&e.type===`keydown`){let e=se.current;return e&&fe.current({type:`terminal-input`,sessionId:e,data:``}),!1}return!0});let ce=e=>{if(!ne){let t=iH(e.clipboardData),n=e.clipboardData?.getData(`text/plain`)??``;if(!t.length&&!n||!_.current)return;if(e.preventDefault(),e.stopPropagation(),se.current&&se.current===oe.current){let e=t.map(e=>e.name).join(`
|
|
212
|
-
`);_.current({text:t.length&&n.trim()===e?``:n,files:t})}return}e.preventDefault(),e.stopPropagation();let t=e.clipboardData?.getData(`text/plain`)??``,n=kH(e.clipboardData),r=n!==null||OH(e.clipboardData),i=ne;ne=null,i({text:t,hasImage:r,hasFiles:(e.clipboardData?.files?.length??0)>0||Array.from(e.clipboardData?.items??[]).some(e=>e.kind===`file`)||Array.from(e.clipboardData?.types??[]).includes(`Files`),imageBlob:n,files:iH(e.clipboardData)})};return t.addEventListener(`paste`,ce,{capture:!0}),r.onData(e=>{let t=se.current;if(t){let n=/^\x1b\[(<[\d;]+[Mm]|[\d;]+M|M[\x20-\xff]{3})$/.test(e);if(I.current&&n)return;I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:t}),Oe(!1)),fe.current({type:`terminal-input`,sessionId:t,data:e})}}),r.attachCustomWheelEventHandler(e=>{let t=se.current;if(!t||e.target?.closest(`input, textarea, [contenteditable="true"], .xterm-hover`)||r.hasSelection()||e.shiftKey)return!0;F.current+=e.deltaY;let n=r.cols,i=r.rows,a=Math.floor(n/2),o=Math.floor(i/2),s=!1,c=!1;for(;Math.abs(F.current)>=30;){c=!0;let e=F.current>0;F.current+=e?-30:30;let n=e?65:64;e||(s=!0),fe.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${n};${a};${o}M`})}return s&&!R.current&&Oe(!0),c&&!R.current&&ke(),!1}),C.current=r,T.current=i,()=>{if(n=!0,ee&&clearTimeout(ee),P=null,t.removeEventListener(`mousedown`,te,!0),t.removeEventListener(`paste`,ce,!0),U!==null&&(clearTimeout(U),U=null),ne=null,O.current&&=(O.current.remove(),null),D.current){try{D.current.dispose()}catch{}D.current=null}if(E.current){try{E.current.dispose()}catch{}E.current=null}try{r.dispose()}catch{}t&&(t.innerHTML=``),C.current=null,T.current=null,k.current=null,A.current=null,j.current=null,N.current&&window.clearTimeout(N.current),B.current!==null&&window.clearTimeout(B.current)}},[Ae]),(0,x.useEffect)(()=>{C.current&&(C.current.options.theme=c)},[c]),(0,x.useEffect)(()=>{let e=C.current,t=T.current;if(e&&t){e.options.fontFamily=f,e.options.fontSize=l,e.options.lineHeight=Math.round(l*u)/l,e.options.letterSpacing=d,t.fit();let n=oe.current;n&&fe.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})}},[l,u,d,f]),(0,x.useEffect)(()=>{let e=C.current;if(!e)return;let t=he.current;if(he.current=p,t!==p){if(p){if(!E.current)try{let t=new pz;t.onContextLoss(()=>{try{t.dispose()}catch{}E.current=null}),e.loadAddon(t),E.current=t}catch{}}else if(E.current){try{E.current.dispose()}catch{}E.current=null}}},[p]),(0,x.useLayoutEffect)(()=>{(se.current!==e||!r||i!==`connected`||le.current>=0&&le.current!==a)&&(se.current=null,e&&r&&i===`connected`&&xe(!0))},[e,r,i,a]),(0,x.useEffect)(()=>{let n=C.current;if(!n)return;let o=oe.current,s=ce.current;if(!r){se.current=null,P.current!==null&&(window.clearTimeout(P.current),P.current=null),o&&(fe.current({type:`terminal-detach`,sessionId:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)),n.reset(),ye.current=!1,xe(!1);return}if(i!==`connected`){se.current=null,P.current!==null&&(window.clearTimeout(P.current),P.current=null),o&&(QT(`terminal_detach_on_disconnect`,{connectionStatus:i,prevAttached:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)),fH(),ye.current=!1,xe(!1);return}if(o&&o!==e){se.current=null;try{let e=A.current?.serialize();if(e&&(lH.set(o,e),lH.size>uH)){let e=lH.keys().next().value;e&&lH.delete(e)}}catch{}fe.current({type:`terminal-detach`,sessionId:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)}let c=le.current,l=a!==c;if(e&&(e!==o||t!==s||l)){QT(`terminal_attach`,{sessionId:e,tmuxTarget:t,prevAttached:o,prevTarget:s,connectionStatus:i,connectionEpoch:a,attachedEpoch:c});let r=performance.now();ge.current=[],_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),ye.current=!0,xe(!0),o!==null&&(se.current=null);let l=lH.get(e);l&&(n.reset(),n.write(l));let u=T.current;u&&u.fit();let d=performance.now();oe.current=e,ce.current=t??null,le.current=a,ue.current=e,de.current=r,P.current!==null&&(window.clearTimeout(P.current),P.current=null);let f={type:`terminal-attach`,sessionId:e,tmuxTarget:t??void 0,cols:n.cols,rows:n.rows},p=o!==null&&o!==e;if(p){let t=e;queueMicrotask(()=>{oe.current===t&&(fe.current(f),fe.current({type:`tmux-check-copy-mode`,sessionId:e}))})}else P.current=window.setTimeout(()=>{P.current=null,fe.current(f),fe.current({type:`tmux-check-copy-mode`,sessionId:e})},50);QT(`switch_attach_sent`,{sessionId:e,fitMs:Math.round(d-r),totalMs:Math.round(performance.now()-r),from:o??null,immediate:p})}return e&&e===o&&t===s&&!l&&QT(`terminal_attach_skip`,{sessionId:e,prevAttached:o,connectionStatus:i,connectionEpoch:a,attachedEpoch:c}),!e&&o&&(P.current!==null&&(window.clearTimeout(P.current),P.current=null),oe.current=null,ce.current=null,le.current=-1,ue.current=null,se.current=null),()=>{P.current!==null&&(QT(`attach_debounce_cancelled`,{sessionId:e,attachedSession:oe.current},`info`),window.clearTimeout(P.current),P.current=null)}},[e,t,r,i,a,De,Oe]),(0,x.useEffect)(()=>{if(ae.current!==null&&(globalThis.clearInterval(ae.current),ae.current=null),!(!e||!r||i!==`connected`))return ae.current=globalThis.setInterval(()=>{oe.current===e&&fe.current({type:`tmux-check-copy-mode`,sessionId:e})},750),()=>{ae.current!==null&&(globalThis.clearInterval(ae.current),ae.current=null)}},[e,r,i]),(0,x.useEffect)(()=>{let e=()=>{_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null);let e=C.current,t=ge.current;if(!e||t.length===0)return;ge.current=[];let n=t.join(``);ye.current&&=(e.reset(),!1);let r=performance.now(),i=n.length;e.write(n,()=>{let e=Math.round(performance.now()-r);e>50&&QT(`switch_write_slow`,{sessionId:oe.current,writeMs:e,bytes:i}),b&&e>50&&QT(`ios_write_slow`,{sessionId:oe.current,writeMs:e,bytes:i}),De()})},t=()=>{_e.current!==null&&window.clearTimeout(_e.current),_e.current=window.setTimeout(e,2),ve.current===null&&(ve.current=window.setTimeout(e,16))},n=s(n=>{let r=oe.current;if(n.type===`terminal-output`&&(!r||n.sessionId!==r)&&QT(`terminal_output_dropped`,{messageSessionId:n.sessionId,attachedSession:r,bytes:n.data.length,hasSwitchStart:de.current!==null},`info`),n.type===`terminal-output`&&r&&n.sessionId===r){let e=de.current;e&&(QT(`switch_first_output`,{sessionId:n.sessionId,serverRoundtripMs:Math.round(performance.now()-e),bytes:n.data.length,parseMs:n._parseMs??-1,rawLength:n._rawLength??-1}),de.current=null),ge.current.push(b?PH(n.data):n.data),t()}if(n.type===`terminal-ready`&&r&&n.sessionId===r){se.current=n.sessionId,ye.current&&ge.current.length>0?e():ye.current&&=(C.current?.reset(),!1),xe(!1);let t=de.current;t&&(QT(`switch_ready`,{sessionId:n.sessionId,totalMs:Math.round(performance.now()-t)}),de.current=null),ue.current===n.sessionId&&(C.current?.focus(),ue.current=null),b&&(e(),Ee(50,`terminal-ready`))}if(n.type===`terminal-error`&&r&&(!n.sessionId||n.sessionId===r)&&(se.current=null,ye.current=!1,xe(!1)),n.type===`clipboard-offer`&&r&&n.sessionId===r){let e=n.text;if(!e?.trim())return;if(!b&&navigator.clipboard?.writeText){let t=performance.now();navigator.clipboard.writeText(e).then(()=>{QT(`clipboard_write_success`,{source:n.source,chars:e.length,durationMs:Math.round(performance.now()-t)})}).catch(t=>{QT(`clipboard_write_failed`,{source:n.source,chars:e.length,error:t instanceof Error?t.message:String(t)},`warn`),re(e,n.source)})}else re(e,n.source)}if(n.type===`tmux-copy-mode-status`&&r&&n.sessionId===r){let e=n.appMouse===!0&&!n.inCopyMode,t=R.current;R.current=e,z.current=n.altScreen===!0,!t&&e&&C.current?.write(xH),Oe(n.inCopyMode)}});return()=>{n(),e(),Te()}},[s,De,Oe,re]),(0,x.useEffect)(()=>{let e=S.current,t=C.current,n=T.current;if(!e||!t||!n)return;let r=()=>{M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{Ae()},150)},i=new ResizeObserver(r);return i.observe(e),r(),()=>{i.disconnect(),M.current&&window.clearTimeout(M.current)}},[]),(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=()=>{document.visibilityState!==`hidden`&&QT(`terminal_visibility_resume`,{isiOS:b,hasWebGL:!!E.current,useWebGL:he.current,hasTerminal:!!C.current,bufferLines:C.current?.buffer.active.length??0,sessionId:oe.current},`info`)};if(document.addEventListener(`visibilitychange`,e),!b)return()=>{document.removeEventListener(`visibilitychange`,e)};let t=e=>{let t=C.current;if(t&&E.current&&he.current){try{E.current.dispose()}catch{}E.current=null;try{let n=new pz;n.onContextLoss(()=>{QT(`webgl_context_loss`,{sessionId:oe.current},`info`);try{n.dispose()}catch{}E.current=null}),t.loadAddon(n),E.current=n,QT(`ios_webgl_recreated`,{trigger:e},`info`)}catch{QT(`ios_webgl_recreate_failed`,{trigger:e},`info`)}}},n=()=>{document.visibilityState!==`hidden`&&(t(`visibilitychange`),Ee(200,`visibilitychange`))},r=e=>{e.persisted&&(t(`pageshow`),Ee(200,`pageshow`))},i=()=>{t(`focus`),Ee(200,`focus`)};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`pageshow`,r),window.addEventListener(`focus`,i),()=>{document.removeEventListener(`visibilitychange`,e),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`pageshow`,r),window.removeEventListener(`focus`,i),Te()}},[]),{containerRef:S,terminalRef:C,searchAddonRef:k,serializeAddonRef:A,progressAddonRef:j,inTmuxCopyModeRef:I,isTmuxCopyMode:L,appMouseRef:R,setTmuxCopyMode:Oe,isSwitching:be,isInputReady:!!e&&r&&i===`connected`&&se.current===e,pendingClipboardOffer:V,copyPendingClipboardOffer:U,dismissPendingClipboardOffer:ie}}function IH(e=`(max-width: 767px)`){let[t,n]=(0,x.useState)(()=>typeof window>`u`||!window.matchMedia?!1:window.matchMedia(e).matches);return(0,x.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),typeof t.addEventListener==`function`?(t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)):(t.addListener(r),()=>t.removeListener(r))},[e]),t}function LH(e,t,n){(0,x.useEffect)(()=>{if(!t)return;let r=t=>{e.current&&!e.current.contains(t.target)&&n()};return document.addEventListener(`mousedown`,r),document.addEventListener(`touchstart`,r),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`touchstart`,r)}},[e,t,n])}function RH(e,t){(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t])}function zH({enabled:e,isOpen:t,onOpen:n,edgeThresholdPx:r=30,swipeDistancePx:i=50,swipeRatio:a=1.5}){let o=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{if(!e)return;let s=0,c=0,l=!1,u=e=>{if(t)return;let n=e.touches[0];n.clientX<=r?(s=n.clientX,c=n.clientY,l=!0,o.current=!0):l=!1},d=e=>{if(o.current=!1,!l||t)return;let r=e.changedTouches[0],u=r.clientX-s,d=Math.abs(r.clientY-c);u>=i&&u>d*a&&n(),l=!1};return document.addEventListener(`touchstart`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{o.current=!1,document.removeEventListener(`touchstart`,u),document.removeEventListener(`touchend`,d)}},[e,t,n,r,i,a]),o}var BH=T()(k(e=>({theme:`dark`,setTheme:t=>e({theme:t}),toggleTheme:()=>e(e=>({theme:e.theme===`dark`?`light`:`dark`}))}),{name:`agentboard-theme`,storage:D(()=>M)})),VH={dark:{background:`#2d2d2d`,foreground:`#d4d4d4`,cursor:`#3b82f6`,cursorAccent:`#2d2d2d`,selectionBackground:`rgba(59, 130, 246, 0.35)`,selectionForeground:`#ffffff`,black:`#808080`,red:`#f87171`,green:`#4ade80`,yellow:`#fbbf24`,blue:`#60a5fa`,magenta:`#c084fc`,cyan:`#22d3ee`,white:`#d4d4d4`,brightBlack:`#a0a0a0`,brightRed:`#fca5a5`,brightGreen:`#86efac`,brightYellow:`#fde047`,brightBlue:`#93c5fd`,brightMagenta:`#d8b4fe`,brightCyan:`#67e8f9`,brightWhite:`#ffffff`},light:{background:`#fafafa`,foreground:`#171717`,cursor:`#2563eb`,cursorAccent:`#fafafa`,selectionBackground:`rgba(37, 99, 235, 0.2)`,selectionForeground:`#000000`,black:`#171717`,red:`#dc2626`,green:`#16a34a`,yellow:`#ca8a04`,blue:`#2563eb`,magenta:`#9333ea`,cyan:`#0891b2`,white:`#f5f5f5`,brightBlack:`#737373`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#eab308`,brightBlue:`#3b82f6`,brightMagenta:`#a855f7`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`}},HH=new WeakSet;function UH(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return!n?.get||!n.set?null:{get:n.get,set:n.set,enumerable:n.enumerable??!0,configurable:n.configurable??!0}}var WH=!1,GH=null,KH=null;function qH(){WH||(WH=!0,!(typeof Node>`u`||typeof HTMLElement>`u`)&&(GH=UH(Node.prototype,`textContent`),KH=UH(HTMLElement.prototype,`innerText`)))}function JH(e){if(HH.has(e))return;HH.add(e);let t=GH?.get;if(t)for(let[n,r]of[[`textContent`,GH],[`innerText`,KH]])r&&Object.defineProperty(e,n,{configurable:r.configurable,enumerable:r.enumerable,get(){return r.get.call(this)},set(e){t.call(this)!==e&&r.set.call(this,e)}})}function YH(e){qH();let t=()=>{for(let t of Array.from(e.children))t instanceof HTMLElement&&JH(t)};t();let n=new MutationObserver(t);return n.observe(e,{childList:!0}),()=>n.disconnect()}var XH={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},ZH=44,QH=6,$H=8,eU=10,tU=8,nU=700;3*ZH+2*QH+2*$H,2*ZH+QH+2*$H;var rU={up:`↑`,down:`↓`,left:`←`,right:`→`},iU={up:`1 / 2 / 2 / 3`,left:`2 / 1 / 3 / 2`,down:`2 / 2 / 3 / 3`,right:`2 / 3 / 3 / 4`};function aU(e=10){typeof navigator<`u`&&`vibrate`in navigator&&navigator.vibrate(e)}function oU(e,t){let n=e.left-t.left+e.width/2,r=tU+160/2,i=t.width-tU-160/2;return r>i?t.width/2:Math.max(r,Math.min(i,n))}function sU({onSendKey:e,disabled:t=!1,onRefocus:n,isKeyboardVisible:r,sessionKey:i=null}){let[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(0),[l,u]=(0,x.useState)(null),d=(0,x.useId)(),f=(0,x.useRef)(null),p=(0,x.useRef)(!1),m=(0,x.useRef)(null),h=(0,x.useRef)(null),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=(0,x.useRef)(0),y=(0,x.useRef)(e),b=(0,x.useRef)(t);y.current=e,b.current=t;let S=(0,x.useCallback)(()=>{m.current&&=(clearTimeout(m.current),null),h.current&&=(clearInterval(h.current),null),g.current=null,_.current=null},[]),C=(0,x.useCallback)(()=>{S(),u(null)},[S]),w=(0,x.useCallback)(()=>{C(),o(!1),p.current&&n?.()},[C,n]),T=(0,x.useCallback)(()=>{let e=f.current,t=e?.getBoundingClientRect?.(),n=e?.closest?.(`.terminal-controls`)?.getBoundingClientRect?.();if(!t||!n){c(160/2+tU);return}c(oU(t,n))},[]),E=(0,x.useCallback)(()=>{p.current=r?.()??!1,T(),o(!0)},[r,T]),D=(0,x.useCallback)(()=>{t||(aU(),a?w():E())},[t,a,w,E]),O=(0,x.useCallback)(e=>{e.preventDefault(),v.current=Date.now(),D()},[D]),k=(0,x.useCallback)(()=>Date.now()-v.current<nU,[]),A=(0,x.useCallback)(e=>{k()||D()},[k,D]),j=(0,x.useCallback)(e=>{b.current||y.current(XH[e])},[]),M=(0,x.useCallback)(e=>{S(),g.current=e,u(e),aU(8),j(e),m.current=setTimeout(()=>{h.current=setInterval(()=>{g.current===e&&(aU(5),j(e))},100)},400)},[S,j]),N=(0,x.useCallback)(e=>n=>{t||(n.preventDefault(),_.current===null&&(n.currentTarget.setPointerCapture?.(n.pointerId),v.current=Date.now(),M(e),_.current=n.pointerId))},[t,M]),P=(0,x.useCallback)(e=>{e.preventDefault(),!(_.current!==null&&e.pointerId!==_.current)&&C()},[C]),F=(0,x.useCallback)(e=>n=>{t||k()||(aU(8),j(e))},[t,k,j]),I=(0,x.useCallback)(e=>{e.preventDefault(),w()},[w]);(0,x.useEffect)(()=>{t&&a&&w()},[t,a,w]);let L=(0,x.useRef)(i);return(0,x.useEffect)(()=>{L.current!==i&&(L.current=i,C())},[i,C]),(0,x.useEffect)(()=>{if(!a)return;let e=f.current?.parentElement;if(e?.addEventListener)return e.addEventListener(`scroll`,T,{passive:!0}),()=>e.removeEventListener(`scroll`,T)},[a,T]),(0,x.useEffect)(()=>S,[S]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{ref:f,type:`button`,"aria-label":`Arrow keys`,"aria-haspopup":`true`,"aria-expanded":a,"aria-controls":a?d:void 0,className:`
|
|
212
|
+
`);_.current({text:t.length&&n.trim()===e?``:n,files:t})}return}e.preventDefault(),e.stopPropagation();let t=e.clipboardData?.getData(`text/plain`)??``,n=kH(e.clipboardData),r=n!==null||OH(e.clipboardData),i=ne;ne=null,i({text:t,hasImage:r,hasFiles:(e.clipboardData?.files?.length??0)>0||Array.from(e.clipboardData?.items??[]).some(e=>e.kind===`file`)||Array.from(e.clipboardData?.types??[]).includes(`Files`),imageBlob:n,files:iH(e.clipboardData)})};return t.addEventListener(`paste`,ce,{capture:!0}),r.onData(e=>{let t=se.current;if(t){let n=/^\x1b\[(<[\d;]+[Mm]|[\d;]+M|M[\x20-\xff]{3})$/.test(e);if(I.current&&n)return;I.current&&(fe.current({type:`tmux-cancel-copy-mode`,sessionId:t}),Oe(!1)),fe.current({type:`terminal-input`,sessionId:t,data:e})}}),r.attachCustomWheelEventHandler(e=>{let t=se.current;if(!t||e.target?.closest(`input, textarea, [contenteditable="true"], .xterm-hover`)||r.hasSelection()||e.shiftKey)return!0;F.current+=e.deltaY;let n=r.cols,i=r.rows,a=Math.floor(n/2),o=Math.floor(i/2),s=!1,c=!1;for(;Math.abs(F.current)>=30;){c=!0;let e=F.current>0;F.current+=e?-30:30;let n=e?65:64;e||(s=!0),fe.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${n};${a};${o}M`})}return s&&!R.current&&Oe(!0),c&&!R.current&&ke(),!1}),C.current=r,T.current=i,()=>{if(n=!0,ee&&clearTimeout(ee),P=null,t.removeEventListener(`mousedown`,te,!0),t.removeEventListener(`paste`,ce,!0),U!==null&&(clearTimeout(U),U=null),ne=null,O.current&&=(O.current.remove(),null),D.current){try{D.current.dispose()}catch{}D.current=null}if(E.current){try{E.current.dispose()}catch{}E.current=null}try{r.dispose()}catch{}t&&(t.innerHTML=``),C.current=null,T.current=null,k.current=null,A.current=null,j.current=null,N.current&&window.clearTimeout(N.current),B.current!==null&&window.clearTimeout(B.current)}},[Ae]),(0,x.useEffect)(()=>{C.current&&(C.current.options.theme=c)},[c]),(0,x.useEffect)(()=>{let e=C.current,t=T.current;if(e&&t){e.options.fontFamily=f,e.options.fontSize=l,e.options.lineHeight=Math.round(l*u)/l,e.options.letterSpacing=d,t.fit();let n=oe.current;n&&fe.current({type:`terminal-resize`,sessionId:n,cols:e.cols,rows:e.rows})}},[l,u,d,f]),(0,x.useEffect)(()=>{let e=C.current;if(!e)return;let t=he.current;if(he.current=p,t!==p){if(p){if(!E.current)try{let t=new pz;t.onContextLoss(()=>{try{t.dispose()}catch{}E.current=null}),e.loadAddon(t),E.current=t}catch{}}else if(E.current){try{E.current.dispose()}catch{}E.current=null}}},[p]),(0,x.useLayoutEffect)(()=>{(se.current!==e||!r||i!==`connected`||le.current>=0&&le.current!==a)&&(se.current=null,e&&r&&i===`connected`&&xe(!0))},[e,r,i,a]),(0,x.useEffect)(()=>{let n=C.current;if(!n)return;let o=oe.current,s=ce.current;if(!r){se.current=null,P.current!==null&&(window.clearTimeout(P.current),P.current=null),o&&(fe.current({type:`terminal-detach`,sessionId:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)),n.reset(),ye.current=!1,xe(!1);return}if(i!==`connected`){se.current=null,P.current!==null&&(window.clearTimeout(P.current),P.current=null),o&&(J(`terminal_detach_on_disconnect`,{connectionStatus:i,prevAttached:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)),fH(),ye.current=!1,xe(!1);return}if(o&&o!==e){se.current=null;try{let e=A.current?.serialize();if(e&&(lH.set(o,e),lH.size>uH)){let e=lH.keys().next().value;e&&lH.delete(e)}}catch{}fe.current({type:`terminal-detach`,sessionId:o}),oe.current=null,ce.current=null,le.current=-1,ue.current=null,Oe(!1)}let c=le.current,l=a!==c;if(e&&(e!==o||t!==s||l)){J(`terminal_attach`,{sessionId:e,tmuxTarget:t,prevAttached:o,prevTarget:s,connectionStatus:i,connectionEpoch:a,attachedEpoch:c});let r=performance.now();ge.current=[],_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null),ye.current=!0,xe(!0),o!==null&&(se.current=null);let l=lH.get(e);l&&(n.reset(),n.write(l));let u=T.current;u&&u.fit();let d=performance.now();oe.current=e,ce.current=t??null,le.current=a,ue.current=e,de.current=r,P.current!==null&&(window.clearTimeout(P.current),P.current=null);let f={type:`terminal-attach`,sessionId:e,tmuxTarget:t??void 0,cols:n.cols,rows:n.rows},p=o!==null&&o!==e;if(p){let t=e;queueMicrotask(()=>{oe.current===t&&(fe.current(f),fe.current({type:`tmux-check-copy-mode`,sessionId:e}))})}else P.current=window.setTimeout(()=>{P.current=null,fe.current(f),fe.current({type:`tmux-check-copy-mode`,sessionId:e})},50);J(`switch_attach_sent`,{sessionId:e,fitMs:Math.round(d-r),totalMs:Math.round(performance.now()-r),from:o??null,immediate:p})}return e&&e===o&&t===s&&!l&&J(`terminal_attach_skip`,{sessionId:e,prevAttached:o,connectionStatus:i,connectionEpoch:a,attachedEpoch:c}),!e&&o&&(P.current!==null&&(window.clearTimeout(P.current),P.current=null),oe.current=null,ce.current=null,le.current=-1,ue.current=null,se.current=null),()=>{P.current!==null&&(J(`attach_debounce_cancelled`,{sessionId:e,attachedSession:oe.current},`info`),window.clearTimeout(P.current),P.current=null)}},[e,t,r,i,a,De,Oe]),(0,x.useEffect)(()=>{if(ae.current!==null&&(globalThis.clearInterval(ae.current),ae.current=null),!(!e||!r||i!==`connected`))return ae.current=globalThis.setInterval(()=>{oe.current===e&&fe.current({type:`tmux-check-copy-mode`,sessionId:e})},750),()=>{ae.current!==null&&(globalThis.clearInterval(ae.current),ae.current=null)}},[e,r,i]),(0,x.useEffect)(()=>{let e=()=>{_e.current!==null&&(window.clearTimeout(_e.current),_e.current=null),ve.current!==null&&(window.clearTimeout(ve.current),ve.current=null);let e=C.current,t=ge.current;if(!e||t.length===0)return;ge.current=[];let n=t.join(``);ye.current&&=(e.reset(),!1);let r=performance.now(),i=n.length;e.write(n,()=>{let e=Math.round(performance.now()-r);e>50&&J(`switch_write_slow`,{sessionId:oe.current,writeMs:e,bytes:i}),b&&e>50&&J(`ios_write_slow`,{sessionId:oe.current,writeMs:e,bytes:i}),De()})},t=()=>{_e.current!==null&&window.clearTimeout(_e.current),_e.current=window.setTimeout(e,2),ve.current===null&&(ve.current=window.setTimeout(e,16))},n=s(n=>{let r=oe.current;if(n.type===`terminal-output`&&(!r||n.sessionId!==r)&&J(`terminal_output_dropped`,{messageSessionId:n.sessionId,attachedSession:r,bytes:n.data.length,hasSwitchStart:de.current!==null},`info`),n.type===`terminal-output`&&r&&n.sessionId===r){let e=de.current;e&&(J(`switch_first_output`,{sessionId:n.sessionId,serverRoundtripMs:Math.round(performance.now()-e),bytes:n.data.length,parseMs:n._parseMs??-1,rawLength:n._rawLength??-1}),de.current=null),ge.current.push(b?PH(n.data):n.data),t()}if(n.type===`terminal-ready`&&r&&n.sessionId===r){se.current=n.sessionId,ye.current&&ge.current.length>0?e():ye.current&&=(C.current?.reset(),!1),xe(!1);let t=de.current;t&&(J(`switch_ready`,{sessionId:n.sessionId,totalMs:Math.round(performance.now()-t)}),de.current=null),ue.current===n.sessionId&&(C.current?.focus(),ue.current=null),b&&(e(),Ee(50,`terminal-ready`))}if(n.type===`terminal-error`&&r&&(!n.sessionId||n.sessionId===r)&&(se.current=null,ye.current=!1,xe(!1)),n.type===`clipboard-offer`&&r&&n.sessionId===r){let e=n.text;if(!e?.trim())return;if(!b&&navigator.clipboard?.writeText){let t=performance.now();navigator.clipboard.writeText(e).then(()=>{J(`clipboard_write_success`,{source:n.source,chars:e.length,durationMs:Math.round(performance.now()-t)})}).catch(t=>{J(`clipboard_write_failed`,{source:n.source,chars:e.length,error:t instanceof Error?t.message:String(t)},`warn`),re(e,n.source)})}else re(e,n.source)}if(n.type===`tmux-copy-mode-status`&&r&&n.sessionId===r){let e=n.appMouse===!0&&!n.inCopyMode,t=R.current;R.current=e,z.current=n.altScreen===!0,!t&&e&&C.current?.write(xH),Oe(n.inCopyMode)}});return()=>{n(),e(),Te()}},[s,De,Oe,re]),(0,x.useEffect)(()=>{let e=S.current,t=C.current,n=T.current;if(!e||!t||!n)return;let r=()=>{M.current&&window.clearTimeout(M.current),M.current=window.setTimeout(()=>{Ae()},150)},i=new ResizeObserver(r);return i.observe(e),r(),()=>{i.disconnect(),M.current&&window.clearTimeout(M.current)}},[]),(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=()=>{document.visibilityState!==`hidden`&&J(`terminal_visibility_resume`,{isiOS:b,hasWebGL:!!E.current,useWebGL:he.current,hasTerminal:!!C.current,bufferLines:C.current?.buffer.active.length??0,sessionId:oe.current},`info`)};if(document.addEventListener(`visibilitychange`,e),!b)return()=>{document.removeEventListener(`visibilitychange`,e)};let t=e=>{let t=C.current;if(t&&E.current&&he.current){try{E.current.dispose()}catch{}E.current=null;try{let n=new pz;n.onContextLoss(()=>{J(`webgl_context_loss`,{sessionId:oe.current},`info`);try{n.dispose()}catch{}E.current=null}),t.loadAddon(n),E.current=n,J(`ios_webgl_recreated`,{trigger:e},`info`)}catch{J(`ios_webgl_recreate_failed`,{trigger:e},`info`)}}},n=()=>{document.visibilityState!==`hidden`&&(t(`visibilitychange`),Ee(200,`visibilitychange`))},r=e=>{e.persisted&&(t(`pageshow`),Ee(200,`pageshow`))},i=()=>{t(`focus`),Ee(200,`focus`)};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`pageshow`,r),window.addEventListener(`focus`,i),()=>{document.removeEventListener(`visibilitychange`,e),document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`pageshow`,r),window.removeEventListener(`focus`,i),Te()}},[]),{containerRef:S,terminalRef:C,searchAddonRef:k,serializeAddonRef:A,progressAddonRef:j,inTmuxCopyModeRef:I,isTmuxCopyMode:L,appMouseRef:R,setTmuxCopyMode:Oe,isSwitching:be,isInputReady:!!e&&r&&i===`connected`&&se.current===e,pendingClipboardOffer:V,copyPendingClipboardOffer:U,dismissPendingClipboardOffer:ie}}function IH(e=`(max-width: 767px)`){let[t,n]=(0,x.useState)(()=>typeof window>`u`||!window.matchMedia?!1:window.matchMedia(e).matches);return(0,x.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),typeof t.addEventListener==`function`?(t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)):(t.addListener(r),()=>t.removeListener(r))},[e]),t}function LH(e,t,n){(0,x.useEffect)(()=>{if(!t)return;let r=t=>{e.current&&!e.current.contains(t.target)&&n()};return document.addEventListener(`mousedown`,r),document.addEventListener(`touchstart`,r),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`touchstart`,r)}},[e,t,n])}function RH(e,t){(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t])}function zH({enabled:e,isOpen:t,onOpen:n,edgeThresholdPx:r=30,swipeDistancePx:i=50,swipeRatio:a=1.5}){let o=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{if(!e)return;let s=0,c=0,l=!1,u=e=>{if(t)return;let n=e.touches[0];n.clientX<=r?(s=n.clientX,c=n.clientY,l=!0,o.current=!0):l=!1},d=e=>{if(o.current=!1,!l||t)return;let r=e.changedTouches[0],u=r.clientX-s,d=Math.abs(r.clientY-c);u>=i&&u>d*a&&n(),l=!1};return document.addEventListener(`touchstart`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{o.current=!1,document.removeEventListener(`touchstart`,u),document.removeEventListener(`touchend`,d)}},[e,t,n,r,i,a]),o}var BH=T()(k(e=>({theme:`dark`,setTheme:t=>e({theme:t}),toggleTheme:()=>e(e=>({theme:e.theme===`dark`?`light`:`dark`}))}),{name:`agentboard-theme`,storage:D(()=>M)})),VH={dark:{background:`#2d2d2d`,foreground:`#d4d4d4`,cursor:`#3b82f6`,cursorAccent:`#2d2d2d`,selectionBackground:`rgba(59, 130, 246, 0.35)`,selectionForeground:`#ffffff`,black:`#808080`,red:`#f87171`,green:`#4ade80`,yellow:`#fbbf24`,blue:`#60a5fa`,magenta:`#c084fc`,cyan:`#22d3ee`,white:`#d4d4d4`,brightBlack:`#a0a0a0`,brightRed:`#fca5a5`,brightGreen:`#86efac`,brightYellow:`#fde047`,brightBlue:`#93c5fd`,brightMagenta:`#d8b4fe`,brightCyan:`#67e8f9`,brightWhite:`#ffffff`},light:{background:`#fafafa`,foreground:`#171717`,cursor:`#2563eb`,cursorAccent:`#fafafa`,selectionBackground:`rgba(37, 99, 235, 0.2)`,selectionForeground:`#000000`,black:`#171717`,red:`#dc2626`,green:`#16a34a`,yellow:`#ca8a04`,blue:`#2563eb`,magenta:`#9333ea`,cyan:`#0891b2`,white:`#f5f5f5`,brightBlack:`#737373`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#eab308`,brightBlue:`#3b82f6`,brightMagenta:`#a855f7`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`}},HH=new WeakSet;function UH(e,t){let n=Object.getOwnPropertyDescriptor(e,t);return!n?.get||!n.set?null:{get:n.get,set:n.set,enumerable:n.enumerable??!0,configurable:n.configurable??!0}}var WH=!1,GH=null,KH=null;function qH(){WH||(WH=!0,!(typeof Node>`u`||typeof HTMLElement>`u`)&&(GH=UH(Node.prototype,`textContent`),KH=UH(HTMLElement.prototype,`innerText`)))}function JH(e){if(HH.has(e))return;HH.add(e);let t=GH?.get;if(t)for(let[n,r]of[[`textContent`,GH],[`innerText`,KH]])r&&Object.defineProperty(e,n,{configurable:r.configurable,enumerable:r.enumerable,get(){return r.get.call(this)},set(e){t.call(this)!==e&&r.set.call(this,e)}})}function YH(e){qH();let t=()=>{for(let t of Array.from(e.children))t instanceof HTMLElement&&JH(t)};t();let n=new MutationObserver(t);return n.observe(e,{childList:!0}),()=>n.disconnect()}var XH={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},ZH=44,QH=6,$H=8,eU=10,tU=8,nU=700;3*ZH+2*QH+2*$H,2*ZH+QH+2*$H;var rU={up:`↑`,down:`↓`,left:`←`,right:`→`},iU={up:`1 / 2 / 2 / 3`,left:`2 / 1 / 3 / 2`,down:`2 / 2 / 3 / 3`,right:`2 / 3 / 3 / 4`};function aU(e=10){typeof navigator<`u`&&`vibrate`in navigator&&navigator.vibrate(e)}function oU(e,t){let n=e.left-t.left+e.width/2,r=tU+160/2,i=t.width-tU-160/2;return r>i?t.width/2:Math.max(r,Math.min(i,n))}function sU({onSendKey:e,disabled:t=!1,onRefocus:n,isKeyboardVisible:r,sessionKey:i=null}){let[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(0),[l,u]=(0,x.useState)(null),d=(0,x.useId)(),f=(0,x.useRef)(null),p=(0,x.useRef)(!1),m=(0,x.useRef)(null),h=(0,x.useRef)(null),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=(0,x.useRef)(0),y=(0,x.useRef)(e),b=(0,x.useRef)(t);y.current=e,b.current=t;let S=(0,x.useCallback)(()=>{m.current&&=(clearTimeout(m.current),null),h.current&&=(clearInterval(h.current),null),g.current=null,_.current=null},[]),C=(0,x.useCallback)(()=>{S(),u(null)},[S]),w=(0,x.useCallback)(()=>{C(),o(!1),p.current&&n?.()},[C,n]),T=(0,x.useCallback)(()=>{let e=f.current,t=e?.getBoundingClientRect?.(),n=e?.closest?.(`.terminal-controls`)?.getBoundingClientRect?.();if(!t||!n){c(160/2+tU);return}c(oU(t,n))},[]),E=(0,x.useCallback)(()=>{p.current=r?.()??!1,T(),o(!0)},[r,T]),D=(0,x.useCallback)(()=>{t||(aU(),a?w():E())},[t,a,w,E]),O=(0,x.useCallback)(e=>{e.preventDefault(),v.current=Date.now(),D()},[D]),k=(0,x.useCallback)(()=>Date.now()-v.current<nU,[]),A=(0,x.useCallback)(e=>{k()||D()},[k,D]),j=(0,x.useCallback)(e=>{b.current||y.current(XH[e])},[]),M=(0,x.useCallback)(e=>{S(),g.current=e,u(e),aU(8),j(e),m.current=setTimeout(()=>{h.current=setInterval(()=>{g.current===e&&(aU(5),j(e))},100)},400)},[S,j]),N=(0,x.useCallback)(e=>n=>{t||(n.preventDefault(),_.current===null&&(n.currentTarget.setPointerCapture?.(n.pointerId),v.current=Date.now(),M(e),_.current=n.pointerId))},[t,M]),P=(0,x.useCallback)(e=>{e.preventDefault(),!(_.current!==null&&e.pointerId!==_.current)&&C()},[C]),F=(0,x.useCallback)(e=>n=>{t||k()||(aU(8),j(e))},[t,k,j]),I=(0,x.useCallback)(e=>{e.preventDefault(),w()},[w]);(0,x.useEffect)(()=>{t&&a&&w()},[t,a,w]);let L=(0,x.useRef)(i);return(0,x.useEffect)(()=>{L.current!==i&&(L.current=i,C())},[i,C]),(0,x.useEffect)(()=>{if(!a)return;let e=f.current?.parentElement;if(e?.addEventListener)return e.addEventListener(`scroll`,T,{passive:!0}),()=>e.removeEventListener(`scroll`,T)},[a,T]),(0,x.useEffect)(()=>S,[S]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{ref:f,type:`button`,"aria-label":`Arrow keys`,"aria-haspopup":`true`,"aria-expanded":a,"aria-controls":a?d:void 0,className:`
|
|
213
213
|
terminal-key
|
|
214
214
|
flex items-center justify-center
|
|
215
215
|
size-[44px] p-0
|
|
@@ -225,7 +225,7 @@ ${s.join(`
|
|
|
225
225
|
rounded-lg text-xl font-bold
|
|
226
226
|
select-none transition-all duration-75
|
|
227
227
|
${l===e?`bg-accent text-white scale-110`:`bg-white/90 text-gray-800`}
|
|
228
|
-
`,style:{gridArea:iU[e],touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onPointerDown:N(e),onPointerUp:P,onPointerCancel:P,onLostPointerCapture:P,onClick:F(e),disabled:t,children:rU[e]},e))})})]})]})}var cU=150,lU=56,uU=48,dU=6,fU=8,pU=20+dU+2,
|
|
228
|
+
`,style:{gridArea:iU[e],touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onPointerDown:N(e),onPointerUp:P,onPointerCancel:P,onLostPointerCapture:P,onClick:F(e),disabled:t,children:rU[e]},e))})})]})]})}var cU=150,lU=56,uU=48,dU=6,fU=8,pU=2,mU=pU+fU,hU=20+dU+2,gU=3*lU+2*dU+2*mU,_U=3*uU+2*dU+2*mU+hU;function vU(e=10){`vibrate`in navigator&&navigator.vibrate(e)}var yU=[[`7`,`8`,`9`],[`4`,`5`,`6`],[`1`,`2`,`3`]];function bU(e,t,n){let r=n.x-gU/2,i=n.y-_U/2,a=e-r-mU,o=t-i-mU,s=3*lU+2*dU,c=3*uU+2*dU;if(a<0||a>s||o<0||o>c)return null;let l=Math.floor(a/(lU+dU)),u=Math.floor(o/(uU+dU));if(l<0||l>2||u<0||u>2)return null;let d=l*(lU+dU),f=u*(uU+dU);return a>d+lU||o>f+uU?null:yU[u]?.[l]||null}function xU({onSendKey:e,disabled:t=!1,onRefocus:n,isKeyboardVisible:r}){let[i,a]=(0,x.useState)(!1),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)({x:0,y:0}),u=(0,x.useRef)(null),d=(0,x.useRef)(!1),f=(0,x.useRef)(!1),p=(0,x.useCallback)(()=>{a(!1),s(null),f.current=!1,d.current&&n?.()},[n]),m=(0,x.useCallback)(e=>{if(t)return;e.preventDefault(),e.stopPropagation();let n=e.touches[0];d.current=r?.()??!1,f.current=!1,u.current=setTimeout(()=>{vU(15);let e=n.clientX,t=n.clientY-120;e=Math.max(10+gU/2,Math.min(window.innerWidth-10-gU/2,e)),t=Math.max(10+_U/2,t),l({x:e,y:t}),a(!0)},cU)},[t,r]),h=(0,x.useCallback)((e,t)=>bU(e,t,c),[c]),g=(0,x.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!i)return;let t=e.touches[0],n=h(t.clientX,t.clientY);n!==o&&(s(n),n&&vU(5))},[i,o,h]),_=(0,x.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),u.current&&=(clearTimeout(u.current),null),i&&o&&!f.current&&(vU(10),e(o),f.current=!0),p()},[i,o,e,p]),v=(0,x.useCallback)(e=>{e.preventDefault(),u.current&&=(clearTimeout(u.current),null),p()},[p]);return(0,x.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,className:`
|
|
229
229
|
terminal-key
|
|
230
230
|
flex items-center justify-center
|
|
231
231
|
size-[44px] p-0
|
|
@@ -237,21 +237,32 @@ ${s.join(`
|
|
|
237
237
|
text-secondary
|
|
238
238
|
${t?`opacity-50`:``}
|
|
239
239
|
${i?`bg-hover scale-95`:``}
|
|
240
|
-
`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onTouchStart:m,onTouchMove:g,onTouchEnd:_,onTouchCancel:v,disabled:t,children:`123`}),i&&(0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 select-none`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},onTouchMove:g,onTouchEnd:_,onTouchCancel:v,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 bg-black/20`}),(0,W.jsx)(`div`,{className:`absolute select-none`,style:{left:c.x,top:c.y,
|
|
240
|
+
`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`},onTouchStart:m,onTouchMove:g,onTouchEnd:_,onTouchCancel:v,disabled:t,children:`123`}),i&&(0,W.jsxs)(`div`,{className:`fixed inset-0 z-50 select-none`,style:{touchAction:`none`,WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},onTouchMove:g,onTouchEnd:_,onTouchCancel:v,children:[(0,W.jsx)(`div`,{className:`absolute inset-0 bg-black/20`}),(0,W.jsx)(`div`,{className:`absolute select-none`,style:{left:c.x-gU/2,top:c.y-_U/2,width:gU,WebkitUserSelect:`none`,userSelect:`none`},children:(0,W.jsxs)(`div`,{className:`rounded-2xl bg-black/40 backdrop-blur-md border-white/20 select-none`,style:{padding:fU,borderWidth:pU},children:[(0,W.jsx)(`div`,{className:`grid grid-cols-3 select-none`,style:{gap:dU},children:yU.flat().map((e,t)=>e?(0,W.jsx)(`div`,{className:`
|
|
241
241
|
flex items-center justify-center
|
|
242
242
|
rounded-lg text-xl font-bold
|
|
243
243
|
select-none
|
|
244
244
|
transition-all duration-75
|
|
245
245
|
${o===e?`bg-accent text-white scale-110`:`bg-white/90 text-gray-800`}
|
|
246
|
-
`,style:{width:lU,height:uU,WebkitUserSelect:`none`,userSelect:`none`},children:e},t):(0,W.jsx)(`div`,{style:{width:lU,height:uU}},t))}),(0,W.jsx)(`div`,{className:`text-center text-white text-sm font-medium select-none
|
|
247
|
-
`)
|
|
248
|
-
`);l&&r.current.onPasteText(l+(a.length?` `:``));for(let{path:e}of c)r.current.onPasteImage(tH(e,r.current.agentType)+` `);s.current=null,n({status:`idle`}),r.current.onRefocus?.()}catch(e){u()&&!i.signal.aborted&&n({status:`error`,message:e instanceof Error?e.message:`Upload failed. Try again.`})}finally{o.current===i&&(o.current=null)}}),a.current):Promise.resolve()},[]);return{state:t,paste:l,pasteClipboard:()=>l(cH(),!0),openDialog:()=>{r.current.disabled||(c(),n({status:`awaiting-paste`}))},retry:()=>s.current?l(s.current):Promise.resolve(),cancel:c,fail:e=>{c(),n({status:`error`,message:e})}}}var
|
|
246
|
+
`,style:{width:lU,height:uU,WebkitUserSelect:`none`,userSelect:`none`},children:e},t):(0,W.jsx)(`div`,{style:{width:lU,height:uU}},t))}),(0,W.jsx)(`div`,{className:`text-center text-white text-sm font-medium select-none`,style:{marginTop:dU+2,height:20},children:o?`Release to send "${o}"`:`\xA0`})]})})]})]})}function SU({state:e,cancel:t,retry:n,paste:r,allowFiles:i}){return e.status===`idle`?null:e.status===`awaiting-paste`?(0,W.jsx)(CU,{cancel:t,paste:r,allowFiles:i}):(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-border bg-elevated px-3 py-2 text-sm text-primary`,children:[(0,W.jsx)(`span`,{role:e.status===`error`?`alert`:`status`,children:e.status===`error`?e.message:e.status===`reading`?`Reading clipboard…`:`Uploading files…`}),e.status===`error`&&(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-2`,onClick:n,children:`Retry`}),(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-2 text-secondary`,onClick:t,children:e.status===`error`?`Dismiss`:`Cancel`})]})}function CU({cancel:e,paste:t,allowFiles:n}){let r=(0,x.useRef)(null),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)([]);(0,x.useLayoutEffect)(()=>{r.current?.showModal()},[]);let c=(0,W.jsx)(`dialog`,{ref:r,"aria-label":`Paste from this device`,onCancel:e,style:{top:`calc(var(--viewport-offset-top, 0px) + 1rem)`,bottom:`auto`,maxHeight:`calc(var(--visual-viewport-height, 100dvh) - 2rem)`},className:`mx-auto my-0 w-[calc(100%_-_2rem)] max-w-sm overflow-y-auto rounded-lg border border-border bg-elevated p-4 text-primary backdrop:bg-black/50`,children:(0,W.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),(i||o.length)&&(e(),t({text:i,files:o}))},children:[(0,W.jsx)(`p`,{className:`mb-3 text-sm text-primary`,children:`Type or paste text, then submit it to your terminal.`}),(0,W.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Paste here`,placeholder:`Type or paste here`,rows:4,value:i,onChange:e=>a(e.target.value),className:`w-full rounded border border-border bg-surface p-3 text-base text-primary`,onPaste:e=>{let t=iH(e.clipboardData);if(!t.length)return;e.preventDefault(),s(e=>[...e,...t]);let n=e.clipboardData.getData(`text/plain`);n&&n.trim()!==t.map(e=>e.name).join(`
|
|
247
|
+
`)&&a(e=>e+n)}}),n&&(0,W.jsxs)(`label`,{className:`mt-3 block text-sm`,children:[`Attach files`,(0,W.jsx)(`input`,{type:`file`,multiple:!0,"aria-label":`Choose files`,className:`mt-2 block w-full text-sm`,onChange:e=>{let t=Array.from(e.target.files??[]);s(e=>[...e,...t]),e.target.value=``}})]}),o.length>0&&(0,W.jsx)(`ul`,{className:`mt-2 text-sm`,children:o.map((e,t)=>(0,W.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-2`,"aria-label":`Remove ${e.name}`,onClick:()=>s(e=>e.filter((e,n)=>n!==t)),children:`Remove`})]},t))}),(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`min-h-[44px] px-3 text-secondary`,onClick:e,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,disabled:!i&&o.length===0,className:`min-h-[44px] rounded bg-accent px-3 text-white disabled:opacity-50`,children:`Submit`})]})]})});return typeof document>`u`?c:(0,U.createPortal)(c,document.body)}function wU(e){let[t,n]=(0,x.useState)({status:`idle`}),r=(0,x.useRef)(e);r.current=e;let i=(0,x.useRef)(0),a=(0,x.useRef)(Promise.resolve()),o=(0,x.useRef)(null),s=(0,x.useRef)(null),c=(0,x.useCallback)(()=>{i.current++,o.current?.abort(),o.current=null,a.current=Promise.resolve(),s.current=null,n({status:`idle`})},[]);(0,x.useLayoutEffect)(()=>(c(),()=>{i.current++,o.current?.abort()}),[e.sessionId,e.disabled,c]);let l=(0,x.useCallback)((e,t=!1)=>{let c=Promise.resolve(e).then(e=>({value:e}),e=>({error:e})),l=i.current,u=()=>l===i.current&&!r.current.disabled;return u()?(t&&n({status:`reading`}),a.current=a.current.then(async()=>{if(!u())return;let e=await c;if(!u())return;if(`error`in e){n({status:`awaiting-paste`});return}let t=e.value;s.current=t;let i=new AbortController;o.current=i;try{let e=aH(t.files);if(e)throw Error(e);if(t.files.length&&r.current.fileUploadsAllowed===!1)throw Error(`File uploads are unavailable for SSH sessions.`);t.files.length&&n({status:`uploading`});let a=[];for(let e of t.files){if(!u())return;a.push({file:e,path:await oH(e,i.signal)})}if(!u()||i.signal.aborted)return;let o=a.filter(({file:e})=>!/^image\/(png|jpeg|gif|webp)$/.test(e.type)),c=a.filter(({file:e})=>/^image\/(png|jpeg|gif|webp)$/.test(e.type)),l=[t.text,...o.map(({path:e})=>sH(e))].filter(Boolean).join(`
|
|
248
|
+
`);l&&r.current.onPasteText(l+(a.length?` `:``));for(let{path:e}of c)r.current.onPasteImage(tH(e,r.current.agentType)+` `);s.current=null,n({status:`idle`}),r.current.onRefocus?.()}catch(e){u()&&!i.signal.aborted&&n({status:`error`,message:e instanceof Error?e.message:`Upload failed. Try again.`})}finally{o.current===i&&(o.current=null)}}),a.current):Promise.resolve()},[]);return{state:t,paste:l,pasteClipboard:()=>l(cH(),!0),openDialog:()=>{r.current.disabled||(c(),n({status:`awaiting-paste`}))},retry:()=>s.current?l(s.current):Promise.resolve(),cancel:c,fail:e=>{c(),n({status:`error`,message:e})}}}var TU=(0,W.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,W.jsx)(`path`,{d:`M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z`})}),EU=(0,W.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`}),(0,W.jsx)(`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`})]}),DU=(0,W.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,ry:`2`}),(0,W.jsx)(`line`,{x1:`6`,y1:`8`,x2:`6`,y2:`8`}),(0,W.jsx)(`line`,{x1:`10`,y1:`8`,x2:`10`,y2:`8`}),(0,W.jsx)(`line`,{x1:`14`,y1:`8`,x2:`14`,y2:`8`}),(0,W.jsx)(`line`,{x1:`18`,y1:`8`,x2:`18`,y2:`8`}),(0,W.jsx)(`line`,{x1:`6`,y1:`12`,x2:`6`,y2:`12`}),(0,W.jsx)(`line`,{x1:`10`,y1:`12`,x2:`10`,y2:`12`}),(0,W.jsx)(`line`,{x1:`14`,y1:`12`,x2:`14`,y2:`12`}),(0,W.jsx)(`line`,{x1:`18`,y1:`12`,x2:`18`,y2:`12`}),(0,W.jsx)(`line`,{x1:`7`,y1:`16`,x2:`17`,y2:`16`})]}),OU={label:(0,W.jsx)(pe,{width:18,height:18}),key:`\r`,className:`bg-accent/20 text-accent border-accent/40`,ariaLabel:`Enter`},kU={label:`esc`,key:`\x1B`},AU={label:TU,key:``,ariaLabel:`Delete word`},jU={label:`tab`,key:` `},MU={label:`⇧tab`,key:`\x1B[Z`,ariaLabel:`Shift+Tab`};function NU(){`vibrate`in navigator&&navigator.vibrate(10)}function PU(e,t){if(!t||e.length!==1)return{output:e,consumeCtrl:!1};let n=e.toUpperCase().charCodeAt(0);return n>=65&&n<=90?{output:String.fromCharCode(n-64),consumeCtrl:!0}:{output:e,consumeCtrl:!0}}var FU={working:`bg-working`,waiting:`bg-waiting`,permission:`bg-approval`,unknown:`bg-muted`};function IU({onSendKey:e,onPasteText:t,onPasteImage:n,disabled:r=!1,sessions:i,currentSessionId:a,agentType:o,fileUploadsAllowed:s=!0,onSelectSession:c,hideSessionSwitcher:l=!1,onRefocus:u,isKeyboardVisible:d,onEnterTextMode:f}){let p=wU({sessionId:a,disabled:r,fileUploadsAllowed:s,agentType:o,onPasteText:t??e,onPasteImage:n??e,onRefocus:u}),[m,h]=(0,x.useState)(!1),g=(0,x.useRef)(0),_=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!m||r||p.state.status===`awaiting-paste`||typeof document>`u`)return;let t=t=>{let{output:n,consumeCtrl:r}=PU(t.key,!0);r&&(t.preventDefault(),t.stopPropagation(),NU(),e(n),h(!1))};return document.addEventListener(`keydown`,t,{capture:!0}),()=>{document.removeEventListener(`keydown`,t,{capture:!0})}},[m,r,p.state.status,e]);let v=t=>{if(r)return;let n=d?.()??!1;NU();let{output:i,consumeCtrl:a}=PU(t,m);a&&h(!1),e(i),n&&u?.()},y=()=>{r||(NU(),h(!m))},b=t=>{let{output:n,consumeCtrl:r}=PU(t,m);r&&h(!1),e(n)},S=()=>{if(!r)return NU(),p.openDialog()},C=e=>{NU(),c(e)},w=()=>{r||(NU(),d?.()?document.activeElement instanceof HTMLElement&&document.activeElement.blur():f?.())},T=i.length>1&&!l,E=e=>t=>{if(r)return;let n=_.current,i=t.changedTouches[0];!n||!i||Math.hypot(i.clientX-n.x,i.clientY-n.y)>10||(t.preventDefault(),t.stopPropagation(),g.current=Date.now(),e())},D=e=>()=>{r||Date.now()-g.current<700||e()},O=e=>(0,W.jsx)(`button`,{type:`button`,"aria-label":e.ariaLabel,className:`
|
|
249
|
+
terminal-key
|
|
250
|
+
flex items-center justify-center
|
|
251
|
+
size-[44px] p-0
|
|
252
|
+
text-sm font-medium
|
|
253
|
+
bg-surface border border-border rounded-md
|
|
254
|
+
active:bg-hover active:scale-95
|
|
255
|
+
transition-transform duration-75
|
|
256
|
+
select-none touch-manipulation
|
|
257
|
+
${e.className??`text-secondary`}
|
|
258
|
+
${r?`opacity-50`:``}
|
|
259
|
+
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:E(()=>v(e.key)),onClick:D(()=>v(e.key)),disabled:r,children:e.label},e.key);return(0,W.jsxs)(`div`,{className:`terminal-controls flex flex-col gap-[6px] border-t border-border bg-elevated p-[6px] ${We()?``:`md:hidden`}`,children:[T&&(0,W.jsxs)(`div`,{className:`relative -mx-[6px]`,children:[(0,W.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-3 bg-gradient-to-r from-elevated to-transparent z-10 pointer-events-none`}),(0,W.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-3 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,W.jsx)(`div`,{className:`flex items-center gap-[6px] overflow-x-auto px-[6px] scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:i.map((e,t)=>(0,W.jsxs)(`button`,{type:`button`,className:`
|
|
249
260
|
terminal-key flex items-center justify-center gap-1.5 shrink-0 snap-start
|
|
250
261
|
h-[44px] min-w-[44px] px-2.5 text-xs font-medium rounded-md
|
|
251
262
|
active:scale-95 transition-transform duration-75
|
|
252
263
|
select-none touch-manipulation
|
|
253
264
|
${e.id===a?`bg-accent/20 text-accent border border-accent/40`:`bg-surface border border-border text-secondary`}
|
|
254
|
-
`,onClick:()=>
|
|
265
|
+
`,onClick:()=>C(e.id),children:[(0,W.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 ${FU[e.status]}`}),(0,W.jsx)(`span`,{className:`truncate`,children:t+1})]},e.id))})]}),(0,W.jsxs)(`div`,{className:`grid grid-flow-col auto-cols-[44px] items-center gap-[4px] overflow-x-auto scrollbar-none`,onTouchStartCapture:e=>{let t=e.touches[0];_.current=t?{x:t.clientX,y:t.clientY}:null},onTouchMoveCapture:e=>{let t=_.current,n=e.touches[0];t&&n&&Math.hypot(n.clientX-t.x,n.clientY-t.y)>10&&(_.current=null)},onTouchCancel:()=>{_.current=null},children:[O(OU),O(kU),(0,W.jsx)(sU,{onSendKey:b,disabled:r,onRefocus:u,isKeyboardVisible:d,sessionKey:a}),(0,W.jsx)(`button`,{type:`button`,"aria-label":`Paste`,className:`
|
|
255
266
|
terminal-key
|
|
256
267
|
flex items-center justify-center
|
|
257
268
|
size-[44px] p-0
|
|
@@ -262,7 +273,7 @@ ${s.join(`
|
|
|
262
273
|
select-none touch-manipulation
|
|
263
274
|
text-secondary
|
|
264
275
|
${r?`opacity-50`:``}
|
|
265
|
-
`,onMouseDown:e=>e.preventDefault(),"data-native-gesture":!0,onClick:
|
|
276
|
+
`,onMouseDown:e=>e.preventDefault(),"data-native-gesture":!0,onClick:S,disabled:r,children:EU}),O(AU),(0,W.jsx)(xU,{onSendKey:b,disabled:r,onRefocus:u,isKeyboardVisible:d}),O(jU),(0,W.jsx)(`button`,{type:`button`,className:`
|
|
266
277
|
terminal-key
|
|
267
278
|
flex items-center justify-center
|
|
268
279
|
size-[44px] p-0
|
|
@@ -271,33 +282,9 @@ ${s.join(`
|
|
|
271
282
|
active:scale-95
|
|
272
283
|
transition-transform duration-75
|
|
273
284
|
select-none touch-manipulation
|
|
274
|
-
${
|
|
285
|
+
${m?`bg-accent/20 text-accent border border-accent/40`:`bg-surface border border-border text-secondary`}
|
|
275
286
|
${r?`opacity-50`:``}
|
|
276
|
-
`,onMouseDown:e=>e.preventDefault(),
|
|
277
|
-
terminal-key
|
|
278
|
-
flex items-center justify-center
|
|
279
|
-
size-[44px] p-0
|
|
280
|
-
text-sm font-medium
|
|
281
|
-
bg-surface border border-border rounded-md
|
|
282
|
-
active:bg-hover active:scale-95
|
|
283
|
-
transition-transform duration-75
|
|
284
|
-
select-none touch-manipulation
|
|
285
|
-
${e.grow?`flex-1`:``}
|
|
286
|
-
${e.className??`text-secondary`}
|
|
287
|
-
${r?`opacity-50`:``}
|
|
288
|
-
`,onMouseDown:e=>e.preventDefault(),onTouchStart:D(()=>y(e.key)),onClick:O(()=>y(e.key)),disabled:r,children:e.label},`left-${t}`)),(0,W.jsx)(yU,{onSendKey:S,disabled:r,onRefocus:u,isKeyboardVisible:d}),(0,W.jsx)(sU,{onSendKey:S,disabled:r,onRefocus:u,isKeyboardVisible:d,sessionKey:a}),EU.map((e,t)=>(0,W.jsx)(`button`,{type:`button`,"aria-label":e.ariaLabel,className:`
|
|
289
|
-
terminal-key
|
|
290
|
-
flex items-center justify-center
|
|
291
|
-
size-[44px] p-0
|
|
292
|
-
text-sm font-medium
|
|
293
|
-
bg-surface border border-border rounded-md
|
|
294
|
-
active:bg-hover active:scale-95
|
|
295
|
-
transition-transform duration-75
|
|
296
|
-
select-none touch-manipulation
|
|
297
|
-
${e.grow?`flex-1`:``}
|
|
298
|
-
${e.className??`text-secondary`}
|
|
299
|
-
${r?`opacity-50`:``}
|
|
300
|
-
`,onMouseDown:e=>e.preventDefault(),onTouchStart:D(()=>y(e.key)),onClick:O(()=>y(e.key)),disabled:r,children:e.label},`right-${t}`)),(0,W.jsx)(`button`,{type:`button`,"aria-label":`Show keyboard`,className:`
|
|
287
|
+
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:E(y),onClick:D(y),disabled:r,children:`ctrl`}),O(MU),(0,W.jsx)(`button`,{type:`button`,"aria-label":`Show keyboard`,className:`
|
|
301
288
|
terminal-key
|
|
302
289
|
flex items-center justify-center
|
|
303
290
|
size-[44px] p-0
|
|
@@ -308,11 +295,11 @@ ${s.join(`
|
|
|
308
295
|
select-none touch-manipulation
|
|
309
296
|
text-secondary
|
|
310
297
|
${r?`opacity-50`:``}
|
|
311
|
-
`,onMouseDown:e=>e.preventDefault(),onTouchStart:D(T),onClick:O(T),disabled:r,children:wU})]}),(0,W.jsx)(`input`,{ref:p,type:`file`,multiple:!0,"aria-label":`Choose files`,className:`hidden`,onChange:e=>{m.paste({text:``,files:Array.from(e.target.files??[])}),e.target.value=``}}),(0,W.jsx)(bU,{...m,chooseFiles:s?()=>p.current?.click():void 0})]})}function jU({isOpen:e,onClose:t,sessions:n,hibernatingSessions:r=[],historySessions:i=[],selectedSessionId:a,selectedHibernatingSessionId:o=null,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:p,loading:m,error:h}){let g=pd(),_=(0,x.useRef)(null),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,x.useEffect)(()=>{e?(v.current=document.activeElement,_.current?.focus()):v.current&&=(v.current.focus(),null)},[e]),(0,x.useEffect)(()=>{if(!e)return;let n=_.current;if(!n)return;let r=0,i=0,a=e=>{let t=e.touches[0];r=t.clientX,i=t.clientY},o=e=>{let n=e.changedTouches[0],a=r-n.clientX,o=Math.abs(n.clientY-i);a>=50&&a>o*1.5&&(`vibrate`in navigator&&navigator.vibrate(10),t())};return n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchend`,o,{passive:!0}),()=>{n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchend`,o)}},[e,t]);let y=e=>{s(e),t()},b=e=>{c?.(e),t()},S=g?{transition:`none`}:void 0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,W.jsx)(KT,{sessions:n,hibernatingSessions:r,historySessions:i,selectedSessionId:a,selectedHibernatingSessionId:o,onSelect:y,onSelectHibernating:b,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:()=>{p()!==!1&&t()},loading:m,error:h}),(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border px-2 pt-2`,style:{paddingBottom:`max(0.5rem, env(safe-area-inset-bottom, 0.5rem))`},children:(0,W.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var MU={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},NU={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},PU={working:`bg-green-500/35 text-white`,waiting:`bg-blue-500/35 text-white`,permission:`bg-amber-500/35 text-white`,unknown:`bg-gray-500/35 text-white`},FU={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function IU(){`vibrate`in navigator&&navigator.vibrate(10)}function LU({session:e,sessions:t,hibernatingSession:n=null,hibernatingSessions:r=[],historySessions:i=[],connectionStatus:a,connectionEpoch:o=0,sendMessage:s,subscribe:c,onClose:l,onSelectSession:u,onSelectHibernatingSession:d,onNewSession:f,onKillSession:p,onRenameSession:m,onResumeSession:h,onHibernateSession:g,onMoveToHistory:_,onOpenSettings:v,loading:y=!1,error:b=null}){let S=VH[BH(e=>e.theme)],C=H(e=>e.useWebGL),w=H(e=>e.fontSize),T=H(e=>e.lineHeight),E=H(e=>e.letterSpacing),D=ee(H(e=>e.fontOption),H(e=>e.customFontFamily)),O=Ye(qe(H(e=>e.shortcutModifier))),k=We(),A=IH(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(!1),[L,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(!1),[te,V]=(0,x.useState)(!1),[ne,re]=(0,x.useState)(``),U=(0,x.useRef)(!1),ie=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(null),ce=(0,x.useRef)(null),le=(0,x.useRef)(()=>{}),ue=(0,x.useRef)(()=>{}),fe=e?.remote===!0,pe=qm(e=>e.remoteAllowControl),me=qm(e=>e.remoteAllowAttach),ge=qm(e=>e.preferWindowName),ve=fe&&!me,ye=!fe||pe&&e?.source===`managed`,be=n?n.displayName||Im(n.projectPath)||n.sessionId.slice(0,8):``,xe=n?Im(n.projectPath):``,Se=n?Fm(n.lastActivityAt):``,Ce=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:we,terminalRef:Ee,inTmuxCopyModeRef:Oe,isTmuxCopyMode:ke,appMouseRef:Ae,setTmuxCopyMode:je,isSwitching:Me,isInputReady:Pe,pendingClipboardOffer:Fe,copyPendingClipboardOffer:Ie,dismissPendingClipboardOffer:Re}=FH({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,agentType:e?.agentType,onPasteFiles:e=>le.current(e),onPasteError:e=>ue.current(e),allowAttach:!ve,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),ze=(0,x.useCallback)(()=>{!e||ve||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1),Ee.current?.scrollToBottom())},[e,ve,s,je,Ee]),Be=(0,x.useCallback)(()=>{B(!0),IU()},[]),Ve=zH({enabled:A||k,isOpen:z,onOpen:Be});(0,x.useEffect)(()=>{!A&&!k&&z&&B(!1)},[z,A,k]),LH(oe,L,(0,x.useCallback)(()=>R(!1),[])),(0,x.useEffect)(()=>{te&&se.current&&(se.current.focus(),se.current.select())},[te]),(0,x.useEffect)(()=>{F&&ce.current&&ce.current.focus()},[F]),RH(F,(0,x.useCallback)(()=>I(!1),[]));let He=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},Ge=()=>{!e||!Ce||(g?.(e.agentSessionId.trim()),R(!1))},Ke=()=>{e&&(re(e.agentSessionName||e.name),V(!0),R(!1))},Je=()=>{if(!e)return;let t=ne.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),V(!1)},Xe=e=>{e.key===`Enter`?(e.preventDefault(),Je()):e.key===`Escape`&&(e.preventDefault(),V(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=we.current;if(!t)return;let n=e=>{let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},r=()=>{let e=t.querySelector(`.xterm-accessibility`),n=t.querySelector(`.xterm-accessibility-tree`);!e||!n||(e.style.setProperty(`opacity`,`0`),n.style.setProperty(`opacity`,`0`),e.style.setProperty(`-webkit-user-select`,`none`),e.style.setProperty(`user-select`,`none`),n.style.setProperty(`-webkit-user-select`,`none`),n.style.setProperty(`user-select`,`none`),e.offsetHeight,requestAnimationFrame(()=>{e.style.removeProperty(`opacity`),n.style.removeProperty(`opacity`),e.style.removeProperty(`-webkit-user-select`),e.style.removeProperty(`user-select`),n.style.removeProperty(`-webkit-user-select`),n.style.removeProperty(`user-select`)}))},i=()=>{U.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}Ee.current?.clearSelection(),r(),P(!1)};ie.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){U.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&U.current){i();return}U.current=t;let r=t;P(e=>e===r?e:r)},o=()=>{let e=window.getSelection();!e||e.isCollapsed||n(e)&&setTimeout(i,0)},s=null,c=!1,l=e=>{if(e.touches.length===1){let t=e.touches[0];s={x:t.clientX,y:t.clientY},c=!1}},u=e=>{if(c||!s||e.touches.length!==1)return;let t=e.touches[0],n=Math.abs(t.clientX-s.x),r=Math.abs(t.clientY-s.y);(n>10||r>10)&&(c=!0)},d=e=>{let r=c;s=null,c=!1;let a=window.getSelection();if(!a||a.rangeCount===0||a.isCollapsed){P(!1);return}let o=t.querySelector(`.xterm-accessibility-tree`);if(!o)return;if(!n(a)){P(!1);return}if(r)return;let l=e.target,u=l?o.contains(l):!1,d=!1;if(u&&l)try{d=a.containsNode(l,!0)}catch{d=!1}(!u||!d)&&setTimeout(i,0)};return document.addEventListener(`selectionchange`,a),document.addEventListener(`copy`,o),document.addEventListener(`touchstart`,l,{passive:!0}),document.addEventListener(`touchmove`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,a),document.removeEventListener(`copy`,o),document.removeEventListener(`touchstart`,l),document.removeEventListener(`touchmove`,u),document.removeEventListener(`touchend`,d),ie.current=null,U.current=!1}},[we,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=we.current;if(!t)return;let n=null,r=()=>{let e=Ee.current,r=t.querySelector(`.xterm`);if(!e||!r)return;let i=r.querySelector(`.xterm-screen`),a=r.querySelector(`.xterm-accessibility`),o=r.querySelector(`.xterm-accessibility-tree`);if(!i||!a||!o)return;n||=YH(o);let s=r.getBoundingClientRect(),c=i.getBoundingClientRect(),l=c.left-s.left,u=c.top-s.top;Object.assign(a.style,{left:`${l}px`,top:`${u}px`,right:`auto`,bottom:`auto`,width:`${c.width}px`,height:`${c.height}px`});let d=c.width/e.cols,f=c.height/e.rows,p=document.createElement(`span`);p.textContent=`0`.repeat(200),p.style.cssText=`position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px`,o.appendChild(p);let m=p.getBoundingClientRect().width/200;p.remove();let h=Math.max(-2,Math.min(2,d-m));t.style.setProperty(`--xterm-font-size`,`${e.options.fontSize}px`),t.style.setProperty(`--xterm-cell-height`,`${f}px`),t.style.setProperty(`--xterm-a11y-letter-spacing`,`${h}px`)},i=performance.now();r();let a=Math.round(performance.now()-i);a>10&&QT(`switch_a11y_overlay`,{sessionId:e?.id,a11yMs:a});let o=window.requestAnimationFrame(r),s=window.setTimeout(r,100),c=()=>window.requestAnimationFrame(r);return window.visualViewport?.addEventListener(`resize`,c),window.addEventListener(`orientationchange`,c),()=>{window.cancelAnimationFrame(o),window.clearTimeout(s),window.visualViewport?.removeEventListener(`resize`,c),window.removeEventListener(`orientationchange`,c),n?.()}},[we,w,k,e?.id,Ee]);let Ze=(0,x.useRef)(N);(0,x.useEffect)(()=>{Ze.current=N},[N]);let Qe=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Qe.current=e?.id},[e?.id]);let $e=(0,x.useRef)(s);(0,x.useEffect)(()=>{$e.current=s},[s]);let et=(0,x.useRef)(!1),tt=(0,x.useRef)(`idle`);(0,x.useEffect)(()=>{if(!k)return;let e=we.current;if(!e)return;let t=null,n=()=>e.querySelector(`.xterm-helper-textarea`),r=e=>{e.target===n()&&(tt.current=`focused`)},i=e=>{e.target===n()&&(t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null;let e=n(),r=typeof document.hasFocus!=`function`||document.hasFocus();document.activeElement!==e&&document.visibilityState!==`hidden`&&r&&(tt.current=`idle`)},0))},a=()=>{let e=n();(document.activeElement===e||tt.current===`focused`)&&(tt.current=`interrupted`)},o=()=>{tt.current===`interrupted`&&(tt.current=`armed`)},s=()=>{document.visibilityState===`hidden`?a():o()},c=e=>{e.persisted&&o()};return document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,i),document.addEventListener(`visibilitychange`,s),window.addEventListener(`blur`,a),window.addEventListener(`focus`,o),window.addEventListener(`pageshow`,c),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,i),document.removeEventListener(`visibilitychange`,s),window.removeEventListener(`blur`,a),window.removeEventListener(`focus`,o),window.removeEventListener(`pageshow`,c),t!==null&&window.clearTimeout(t),tt.current=`idle`}},[we,k,e?.id]),(0,x.useEffect)(()=>{let t=we.current;if(!t||!e?.id||!A&&!k)return;let n={x:0,y:0},r=0,i=!1,a=null,o=0,s=0,c=0,l=Math.round(w*T),u=null,d=null,f=!1,p=null,m=()=>{let e=window.getComputedStyle(t).getPropertyValue(`--xterm-cell-height`).trim(),n=Number.parseFloat(e);return!Number.isNaN(n)&&n>0?n:Math.round(w*T)},h=()=>t.querySelector(`.xterm-helper-textarea`),g=e=>{let n=Ee.current;if(!n)return null;let r=(t.querySelector(`.xterm`)?.querySelector(`.xterm-screen`))?.getBoundingClientRect();if(!r||r.width<=0||r.height<=0)return null;let i=r.width/n.cols,a=r.height/n.rows;return i<=0||a<=0?null:{col:Math.min(n.cols,Math.max(1,Math.floor((e.clientX-r.left)/i)+1)),row:Math.min(n.rows,Math.max(1,Math.floor((e.clientY-r.top)/a)+1))}},_=()=>{let e=h();e&&document.activeElement!==e&&(e.disabled=!0)},v=()=>{let e=h();e&&(e.disabled=!1)};_();let y=()=>{if(Oe.current)return;let e=h();e&&(e.disabled=!1,e.focus())},b=()=>{u!==null&&(cancelAnimationFrame(u),u=null),s=0},x=()=>{d!==null&&(clearTimeout(d),d=null)},S=(e,t,n)=>{let r=Qe.current;return r?($e.current({type:`terminal-input`,sessionId:r,data:`\x1b[<${e};${t.col};${t.row}${n}`}),!0):!1},C=e=>{let t=Qe.current;if(!t||e===0)return!1;let n=Ee.current,r=n?.cols??80,i=n?.rows??24,a=Math.floor(r/2),o=Math.floor(i/2),s=e>0?65:64,c=Math.abs(e),l=e<0;for(let e=0;e<c;e++)$e.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&!Ae.current&&je(!0),l},E=e=>{let t=Qe.current,n=g(e);return!t||!n?!1:($e.current({type:`terminal-input`,sessionId:t,data:`\x1b[<0;${n.col};${n.row}M\x1b[<0;${n.col};${n.row}m`}),!0)},D=e=>{if(!k||!Ae.current)return!1;let t=g(e);return t?(f=!0,p=t,_(),IU(),S(0,t,`M`)):!1},O=e=>{let t=g(e);return t?p&&p.col===t.col&&p.row===t.row?!0:(p=t,S(32,t,`M`)):!1},j=e=>{let t=e?g(e):p;return f=!1,p=null,t?S(0,t,`m`):!1},M=()=>{x(),f=!1,p=null,a=null,s=0,c=0},N=()=>{if(!k)return!1;let e=window.getSelection();if(!e||e.isCollapsed)return!1;let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},P=()=>{!k||!U.current||N()||ie.current?.()},F=e=>{if(b(),P(),Ve.current||z){M();return}if(Ze.current){M();return}if(tt.current===`armed`&&!Oe.current&&(tt.current=`idle`,y()),e.touches.length===1){let t=e.touches[0];if(n={x:t.clientX,y:t.clientY},r=performance.now(),i=!1,a=t.clientY,o=r,s=0,c=0,l=m(),v(),k&&Ae.current){let e={clientX:t.clientX,clientY:t.clientY};d=setTimeout(()=>{d=null,!(i||Ve.current||z)&&(Ze.current||N()||D(e))},350)}}},I=e=>{if(e.touches.length!==1||a===null)return;if(P(),Ve.current||z){M();return}let t=performance.now(),r=e.touches[0],u=r.clientX,d=r.clientY;if(f){e.preventDefault(),e.stopPropagation(),O(r),a=d,o=t;return}if(Ze.current||N()){M();return}e.preventDefault(),e.stopPropagation();let p=Math.abs(u-n.x),m=Math.abs(d-n.y);!i&&(p>6||m>6)&&(i=!0,x(),_());let h=a-d,g=t-o;if(a=d,o=t,g>0){let e=h/g;s=s*.7+e*.3}c+=h;let v=Math.max(6,l*.6),y=Math.trunc(c/v);y!==0&&(C(y),c-=y*v)},L=e=>{let t=s,n=performance.now()-r;if(x(),f){j(e.changedTouches[0]),M(),e.preventDefault(),e.stopPropagation();return}if(M(),Ve.current||z)return;let a=N();if(Ze.current&&!a&&ie.current?.(),Ze.current||a){Oe.current&&(et.current=!0);return}if(!i){if(k&&n>=350)return;if(Ae.current){let t=e.changedTouches[0];if(t&&E(t)){y(),e.preventDefault(),e.stopPropagation();return}}if(Oe.current){e.preventDefault(),e.stopPropagation(),et.current=!0;return}y();return}if(Math.abs(t)>.12){let e=t,n=performance.now(),r=()=>{let t=performance.now(),i=t-n;n=t;let a=e*i;c+=a;let o=Math.max(6,l*.6),s=Math.trunc(c/o);s!==0&&(C(s),c-=s*o),e*=.95**(i/16.67),u=Math.abs(e)>.02?requestAnimationFrame(r):null};u=requestAnimationFrame(r)}},ee=e=>{et.current&&=(e.preventDefault(),e.stopPropagation(),!1)},R={passive:!0,capture:!0},B={passive:!1,capture:!0},te={passive:!1,capture:!0},V={capture:!0};return t.addEventListener(`touchstart`,F,R),t.addEventListener(`touchmove`,I,B),t.addEventListener(`touchend`,L,te),t.addEventListener(`mousedown`,ee,V),()=>{t.removeEventListener(`touchstart`,F,R),t.removeEventListener(`touchmove`,I,B),t.removeEventListener(`touchend`,L,te),t.removeEventListener(`mousedown`,ee,V),x();let e=h();e&&(e.disabled=!1)}},[e?.id,we,Ee,k,A,z,w,T]);let nt=(0,x.useCallback)(t=>{!e||ve||!Pe||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,ve,Pe,s]),rt=(0,x.useCallback)(t=>{!e||ve||!Pe||(Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1)),s({type:`terminal-paste`,sessionId:e.id,data:t}))},[e,ve,Pe,s,Oe,je]),it=(0,x.useCallback)(t=>{!e||ve||!Pe||(Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1)),nt(t))},[e,ve,Pe,s,Oe,je,nt]),at=(0,x.useCallback)(()=>{let e=we.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[we]),ot=xU({sessionId:e?.id??null,disabled:a!==`connected`||ve||!Pe,fileUploadsAllowed:!fe,agentType:e?.agentType,onPasteText:rt,onPasteImage:it,onRefocus:at});le.current=ot.paste,ue.current=ot.fail;let st=(0,x.useCallback)(()=>{if(!e||ve||!Pe)return;Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1));let t=we.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,ve,Pe,s,we,Oe,je]),ct=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=we.current;if(!e)return!1;let t=e.querySelector(`.xterm-helper-textarea`);if(t&&document.activeElement===t)return!0;let n=document.activeElement,r=typeof HTMLInputElement<`u`&&n instanceof HTMLInputElement,i=typeof HTMLTextAreaElement<`u`&&n instanceof HTMLTextAreaElement;return r||i||n&&n.isContentEditable?!1:!!document.documentElement?.classList?.contains(`keyboard-visible`)},[we]);(0,x.useEffect)(()=>{if(!k)return;let e=we.current;if(!e)return;let t=e.querySelector(`.xterm-accessibility`),n=e.querySelector(`.xterm-accessibility-tree`);if(!t||!n)return;let r=()=>{let r=e.querySelector(`.xterm-helper-textarea`);r&&document.activeElement===r&&!Ze.current?(t.style.pointerEvents=`none`,n.style.pointerEvents=`none`):(t.style.removeProperty(`pointer-events`),n.style.removeProperty(`pointer-events`))};return r(),document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,r)}},[we,k,N]),(0,x.useEffect)(()=>{let e=we.current;e&&(e.inert=!!n)},[we,n]);let lt=(0,x.useMemo)(()=>{if(!ge||t.length===0)return!1;let e=t.map(e=>e.name.trim()).filter(Boolean);return e.length===t.length&&new Set(e).size===t.length},[ge,t]);return(0,W.jsxs)(`section`,{className:`flex flex-1 flex-col bg-base terminal-mobile-overlay md:relative md:inset-auto ${k?`ios-native-term-selection`:``}`,"data-testid":`terminal-panel`,onDragOver:t=>{Array.from(t.dataTransfer.types).includes(`Files`)&&(t.preventDefault(),t.dataTransfer.dropEffect=e&&!ve&&Pe&&!fe&&a===`connected`?`copy`:`none`)},onDrop:t=>{if(!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),!e||ve||!Pe||fe||a!==`connected`))return;let n=iH(t.dataTransfer);n.length&&ot.paste({text:``,files:n})},children:[(0,W.jsxs)(`div`,{className:`flex min-h-[52px] shrink-0 items-center justify-between border-b border-border bg-elevated px-[6px] md:h-10 md:min-h-0 md:px-3 ${e||n?``:`md:hidden`}`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[7px] md:gap-3`,children:[(0,W.jsx)(`button`,{onClick:()=>B(!0),className:`flex size-[44px] shrink-0 items-center justify-center rounded border border-border bg-surface text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95 md:hidden`,"aria-label":`Open session menu`,children:(0,W.jsx)(Te,{width:16,height:16})}),e&&ye&&(0,W.jsx)(`button`,{disabled:Me,onClick:()=>I(!0),className:`hidden md:flex h-7 w-7 items-center justify-center rounded bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20 active:scale-95 transition-all shrink-0 disabled:cursor-not-allowed disabled:opacity-40`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,W.jsx)(Ue,{width:16,height:16})}),Ce&&(0,W.jsx)(`button`,{onClick:Ge,className:`hidden md:flex h-7 w-7 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all shrink-0`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,W.jsx)(De,{width:16,height:16})}),e?(0,W.jsxs)(`div`,{className:`flex min-w-[72px] flex-col items-start gap-px leading-none md:min-w-0 md:flex-row md:items-baseline md:gap-3 md:leading-normal`,children:[te?(0,W.jsx)(`input`,{ref:se,type:`text`,value:ne,onChange:e=>re(e.target.value),onBlur:Je,onKeyDown:Xe,className:`w-full max-w-[112px] rounded border border-border bg-surface px-2 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent md:max-w-[200px]`}):(0,W.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:e.agentSessionName||e.name}),(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] md:hidden ${a===`connected`?NU[e.status]:`text-approval`}`,children:a===`connected`?MU[e.status]:a}),(0,W.jsx)(`span`,{className:`hidden shrink-0 text-xs md:inline ${NU[e.status]}`,children:MU[e.status]})]}):n?(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-px leading-none md:flex-row md:items-baseline md:gap-2 md:leading-normal`,children:[(0,W.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:be}),(0,W.jsx)(`span`,{className:`text-[10px] font-medium text-blue-400 md:rounded-full md:bg-blue-500/15 md:px-1.5 md:py-0.5 md:uppercase md:tracking-wide`,children:`Hibernating`})]}):(0,W.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[4px] md:gap-1.5`,children:[a!==`connected`&&(0,W.jsx)(`span`,{className:`hidden text-xs text-approval md:inline`,children:a}),(0,W.jsx)(`button`,{onClick:f,className:`flex size-[44px] items-center justify-center rounded bg-accent text-white transition-all hover:bg-accent/90 active:scale-95 md:hidden`,title:`New session (${O}N)`,"aria-label":`New session`,children:(0,W.jsx)(Ne,{width:16,height:16})}),e&&ye&&(0,W.jsx)(`button`,{disabled:Me,onClick:()=>I(!0),className:`flex size-[44px] items-center justify-center rounded border border-danger/30 bg-danger/10 text-danger transition-all hover:bg-danger/20 active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 md:hidden`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,W.jsx)(Ue,{width:16,height:16})}),Ce&&(0,W.jsx)(`button`,{onClick:Ge,className:`hidden size-[44px] items-center justify-center rounded border border-border text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95 min-[360px]:flex md:hidden`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,W.jsx)(De,{width:16,height:16})}),n&&(0,W.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-[44px] px-3 text-xs md:hidden`,children:`Wake`}),e&&(0,W.jsxs)(`div`,{className:`relative md:hidden`,ref:oe,children:[(0,W.jsx)(`button`,{onClick:()=>R(!L),className:`flex size-[44px] items-center justify-center rounded border border-border bg-surface text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95`,title:`More options`,"aria-label":`More options`,children:(0,W.jsx)(he,{width:16,height:16})}),L&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border bg-elevated shadow-lg py-1`,children:[ye&&(0,W.jsxs)(`button`,{onClick:Ke,className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(_e,{width:14,height:14}),`Rename`]}),Ce&&(0,W.jsxs)(`button`,{onClick:Ge,className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(De,{width:14,height:14}),`Hibernate`]}),(0,W.jsxs)(`button`,{onClick:()=>{v(),R(!1)},className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(Le,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,W.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,W.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-4 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,W.jsx)(`div`,{className:`flex items-center gap-[6px] overflow-x-auto px-[8px] py-[5px] scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:t.map((t,n)=>{let r=t.id===e.id,i=lt?t.name.trim():n+1;return(0,W.jsx)(`button`,{type:`button`,className:`
|
|
298
|
+
`,onMouseDown:e=>e.preventDefault(),onTouchEnd:E(w),onClick:D(w),disabled:r,children:DU})]}),(0,W.jsx)(SU,{...p,allowFiles:s})]})}function LU({isOpen:e,onClose:t,sessions:n,hibernatingSessions:r=[],historySessions:i=[],selectedSessionId:a,selectedHibernatingSessionId:o=null,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:p,loading:m,error:h}){let g=pd(),_=(0,x.useRef)(null),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,x.useEffect)(()=>{e?(v.current=document.activeElement,_.current?.focus()):v.current&&=(v.current.focus(),null)},[e]),(0,x.useEffect)(()=>{if(!e)return;let n=_.current;if(!n)return;let r=0,i=0,a=e=>{let t=e.touches[0];r=t.clientX,i=t.clientY},o=e=>{let n=e.changedTouches[0],a=r-n.clientX,o=Math.abs(n.clientY-i);a>=50&&a>o*1.5&&(`vibrate`in navigator&&navigator.vibrate(10),t())};return n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchend`,o,{passive:!0}),()=>{n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchend`,o)}},[e,t]);let y=e=>{s(e),t()},b=e=>{c?.(e),t()},S=g?{transition:`none`}:void 0;return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,W.jsx)(qT,{sessions:n,hibernatingSessions:r,historySessions:i,selectedSessionId:a,selectedHibernatingSessionId:o,onSelect:y,onSelectHibernating:b,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:()=>{p()!==!1&&t()},loading:m,error:h}),(0,W.jsx)(`div`,{className:`shrink-0 border-t border-border px-2 pt-2`,style:{paddingBottom:`max(0.5rem, env(safe-area-inset-bottom, 0.5rem))`},children:(0,W.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var RU={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},zU={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},BU={working:`bg-green-500/35 text-white`,waiting:`bg-blue-500/35 text-white`,permission:`bg-amber-500/35 text-white`,unknown:`bg-gray-500/35 text-white`},VU={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function HU(){`vibrate`in navigator&&navigator.vibrate(10)}function UU({session:e,sessions:t,hibernatingSession:n=null,hibernatingSessions:r=[],historySessions:i=[],connectionStatus:a,connectionEpoch:o=0,sendMessage:s,subscribe:c,onClose:l,onSelectSession:u,onSelectHibernatingSession:d,onNewSession:f,onKillSession:p,onRenameSession:m,onResumeSession:h,onHibernateSession:g,onMoveToHistory:_,onOpenSettings:v,loading:y=!1,error:b=null}){let S=VH[BH(e=>e.theme)],C=H(e=>e.useWebGL),w=H(e=>e.fontSize),T=H(e=>e.lineHeight),E=H(e=>e.letterSpacing),D=ee(H(e=>e.fontOption),H(e=>e.customFontFamily)),O=Ye(qe(H(e=>e.shortcutModifier))),k=We(),A=IH(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(!1),[L,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(!1),[te,V]=(0,x.useState)(!1),[ne,re]=(0,x.useState)(``),U=(0,x.useRef)(!1),ie=(0,x.useRef)(null),oe=(0,x.useRef)(null),se=(0,x.useRef)(null),ce=(0,x.useRef)(null),le=(0,x.useRef)(()=>{}),ue=(0,x.useRef)(()=>{}),fe=e?.remote===!0,pe=qm(e=>e.remoteAllowControl),me=qm(e=>e.remoteAllowAttach),ge=qm(e=>e.preferWindowName),ve=fe&&!me,ye=!fe||pe&&e?.source===`managed`,be=n?n.displayName||Im(n.projectPath)||n.sessionId.slice(0,8):``,xe=n?Im(n.projectPath):``,Se=n?Fm(n.lastActivityAt):``,Ce=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:we,terminalRef:Ee,inTmuxCopyModeRef:Oe,isTmuxCopyMode:ke,appMouseRef:Ae,setTmuxCopyMode:je,isSwitching:Me,isInputReady:Pe,pendingClipboardOffer:Fe,copyPendingClipboardOffer:Ie,dismissPendingClipboardOffer:Re}=FH({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,agentType:e?.agentType,onPasteFiles:e=>le.current(e),onPasteError:e=>ue.current(e),allowAttach:!ve,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),ze=(0,x.useCallback)(()=>{!e||ve||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1),Ee.current?.scrollToBottom())},[e,ve,s,je,Ee]),Be=(0,x.useCallback)(()=>{B(!0),HU()},[]),Ve=zH({enabled:A||k,isOpen:z,onOpen:Be});(0,x.useEffect)(()=>{!A&&!k&&z&&B(!1)},[z,A,k]),LH(oe,L,(0,x.useCallback)(()=>R(!1),[])),(0,x.useEffect)(()=>{te&&se.current&&(se.current.focus(),se.current.select())},[te]),(0,x.useEffect)(()=>{F&&ce.current&&ce.current.focus()},[F]),RH(F,(0,x.useCallback)(()=>I(!1),[]));let He=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},Ge=()=>{!e||!Ce||(g?.(e.agentSessionId.trim()),R(!1))},Ke=()=>{e&&(re(e.agentSessionName||e.name),V(!0),R(!1))},Je=()=>{if(!e)return;let t=ne.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),V(!1)},Xe=e=>{e.key===`Enter`?(e.preventDefault(),Je()):e.key===`Escape`&&(e.preventDefault(),V(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=we.current;if(!t)return;let n=e=>{let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},r=()=>{let e=t.querySelector(`.xterm-accessibility`),n=t.querySelector(`.xterm-accessibility-tree`);!e||!n||(e.style.setProperty(`opacity`,`0`),n.style.setProperty(`opacity`,`0`),e.style.setProperty(`-webkit-user-select`,`none`),e.style.setProperty(`user-select`,`none`),n.style.setProperty(`-webkit-user-select`,`none`),n.style.setProperty(`user-select`,`none`),e.offsetHeight,requestAnimationFrame(()=>{e.style.removeProperty(`opacity`),n.style.removeProperty(`opacity`),e.style.removeProperty(`-webkit-user-select`),e.style.removeProperty(`user-select`),n.style.removeProperty(`-webkit-user-select`),n.style.removeProperty(`user-select`)}))},i=()=>{U.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}Ee.current?.clearSelection(),r(),P(!1)};ie.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){U.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&U.current){i();return}U.current=t;let r=t;P(e=>e===r?e:r)},o=()=>{let e=window.getSelection();!e||e.isCollapsed||n(e)&&setTimeout(i,0)},s=null,c=!1,l=e=>{if(e.touches.length===1){let t=e.touches[0];s={x:t.clientX,y:t.clientY},c=!1}},u=e=>{if(c||!s||e.touches.length!==1)return;let t=e.touches[0],n=Math.abs(t.clientX-s.x),r=Math.abs(t.clientY-s.y);(n>10||r>10)&&(c=!0)},d=e=>{let r=c;s=null,c=!1;let a=window.getSelection();if(!a||a.rangeCount===0||a.isCollapsed){P(!1);return}let o=t.querySelector(`.xterm-accessibility-tree`);if(!o)return;if(!n(a)){P(!1);return}if(r)return;let l=e.target,u=l?o.contains(l):!1,d=!1;if(u&&l)try{d=a.containsNode(l,!0)}catch{d=!1}(!u||!d)&&setTimeout(i,0)};return document.addEventListener(`selectionchange`,a),document.addEventListener(`copy`,o),document.addEventListener(`touchstart`,l,{passive:!0}),document.addEventListener(`touchmove`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,a),document.removeEventListener(`copy`,o),document.removeEventListener(`touchstart`,l),document.removeEventListener(`touchmove`,u),document.removeEventListener(`touchend`,d),ie.current=null,U.current=!1}},[we,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=we.current;if(!t)return;let n=null,r=()=>{let e=Ee.current,r=t.querySelector(`.xterm`);if(!e||!r)return;let i=r.querySelector(`.xterm-screen`),a=r.querySelector(`.xterm-accessibility`),o=r.querySelector(`.xterm-accessibility-tree`);if(!i||!a||!o)return;n||=YH(o);let s=r.getBoundingClientRect(),c=i.getBoundingClientRect(),l=c.left-s.left,u=c.top-s.top;Object.assign(a.style,{left:`${l}px`,top:`${u}px`,right:`auto`,bottom:`auto`,width:`${c.width}px`,height:`${c.height}px`});let d=c.width/e.cols,f=c.height/e.rows,p=document.createElement(`span`);p.textContent=`0`.repeat(200),p.style.cssText=`position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px`,o.appendChild(p);let m=p.getBoundingClientRect().width/200;p.remove();let h=Math.max(-2,Math.min(2,d-m));t.style.setProperty(`--xterm-font-size`,`${e.options.fontSize}px`),t.style.setProperty(`--xterm-cell-height`,`${f}px`),t.style.setProperty(`--xterm-a11y-letter-spacing`,`${h}px`)},i=performance.now();r();let a=Math.round(performance.now()-i);a>10&&J(`switch_a11y_overlay`,{sessionId:e?.id,a11yMs:a});let o=window.requestAnimationFrame(r),s=window.setTimeout(r,100),c=()=>window.requestAnimationFrame(r);return window.visualViewport?.addEventListener(`resize`,c),window.addEventListener(`orientationchange`,c),()=>{window.cancelAnimationFrame(o),window.clearTimeout(s),window.visualViewport?.removeEventListener(`resize`,c),window.removeEventListener(`orientationchange`,c),n?.()}},[we,w,k,e?.id,Ee]);let Ze=(0,x.useRef)(N);(0,x.useEffect)(()=>{Ze.current=N},[N]);let Qe=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Qe.current=e?.id},[e?.id]);let $e=(0,x.useRef)(s);(0,x.useEffect)(()=>{$e.current=s},[s]);let et=(0,x.useRef)(!1),tt=(0,x.useRef)(`idle`);(0,x.useEffect)(()=>{if(!k)return;let e=we.current;if(!e)return;let t=null,n=()=>e.querySelector(`.xterm-helper-textarea`),r=e=>{e.target===n()&&(tt.current=`focused`)},i=e=>{e.target===n()&&(t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null;let e=n(),r=typeof document.hasFocus!=`function`||document.hasFocus();document.activeElement!==e&&document.visibilityState!==`hidden`&&r&&(tt.current=`idle`)},0))},a=()=>{let e=n();(document.activeElement===e||tt.current===`focused`)&&(tt.current=`interrupted`)},o=()=>{tt.current===`interrupted`&&(tt.current=`armed`)},s=()=>{document.visibilityState===`hidden`?a():o()},c=e=>{e.persisted&&o()};return document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,i),document.addEventListener(`visibilitychange`,s),window.addEventListener(`blur`,a),window.addEventListener(`focus`,o),window.addEventListener(`pageshow`,c),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,i),document.removeEventListener(`visibilitychange`,s),window.removeEventListener(`blur`,a),window.removeEventListener(`focus`,o),window.removeEventListener(`pageshow`,c),t!==null&&window.clearTimeout(t),tt.current=`idle`}},[we,k,e?.id]),(0,x.useEffect)(()=>{let t=we.current;if(!t||!e?.id||!A&&!k)return;let n={x:0,y:0},r=0,i=!1,a=null,o=0,s=0,c=0,l=Math.round(w*T),u=null,d=null,f=!1,p=null,m=()=>{let e=window.getComputedStyle(t).getPropertyValue(`--xterm-cell-height`).trim(),n=Number.parseFloat(e);return!Number.isNaN(n)&&n>0?n:Math.round(w*T)},h=()=>t.querySelector(`.xterm-helper-textarea`),g=e=>{let n=Ee.current;if(!n)return null;let r=(t.querySelector(`.xterm`)?.querySelector(`.xterm-screen`))?.getBoundingClientRect();if(!r||r.width<=0||r.height<=0)return null;let i=r.width/n.cols,a=r.height/n.rows;return i<=0||a<=0?null:{col:Math.min(n.cols,Math.max(1,Math.floor((e.clientX-r.left)/i)+1)),row:Math.min(n.rows,Math.max(1,Math.floor((e.clientY-r.top)/a)+1))}},_=()=>{let e=h();e&&document.activeElement!==e&&(e.disabled=!0)},v=()=>{let e=h();e&&(e.disabled=!1)};_();let y=()=>{if(Oe.current)return;let e=h();e&&(e.disabled=!1,e.focus())},b=()=>{u!==null&&(cancelAnimationFrame(u),u=null),s=0},x=()=>{d!==null&&(clearTimeout(d),d=null)},S=(e,t,n)=>{let r=Qe.current;return r?($e.current({type:`terminal-input`,sessionId:r,data:`\x1b[<${e};${t.col};${t.row}${n}`}),!0):!1},C=e=>{let t=Qe.current;if(!t||e===0)return!1;let n=Ee.current,r=n?.cols??80,i=n?.rows??24,a=Math.floor(r/2),o=Math.floor(i/2),s=e>0?65:64,c=Math.abs(e),l=e<0;for(let e=0;e<c;e++)$e.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&!Ae.current&&je(!0),l},E=e=>{let t=Qe.current,n=g(e);return!t||!n?!1:($e.current({type:`terminal-input`,sessionId:t,data:`\x1b[<0;${n.col};${n.row}M\x1b[<0;${n.col};${n.row}m`}),!0)},D=e=>{if(!k||!Ae.current)return!1;let t=g(e);return t?(f=!0,p=t,_(),HU(),S(0,t,`M`)):!1},O=e=>{let t=g(e);return t?p&&p.col===t.col&&p.row===t.row?!0:(p=t,S(32,t,`M`)):!1},j=e=>{let t=e?g(e):p;return f=!1,p=null,t?S(0,t,`m`):!1},M=()=>{x(),f=!1,p=null,a=null,s=0,c=0},N=()=>{if(!k)return!1;let e=window.getSelection();if(!e||e.isCollapsed)return!1;let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},P=()=>{!k||!U.current||N()||ie.current?.()},F=e=>{if(b(),P(),Ve.current||z){M();return}if(Ze.current){M();return}if(tt.current===`armed`&&!Oe.current&&(tt.current=`idle`,y()),e.touches.length===1){let t=e.touches[0];if(n={x:t.clientX,y:t.clientY},r=performance.now(),i=!1,a=t.clientY,o=r,s=0,c=0,l=m(),v(),k&&Ae.current){let e={clientX:t.clientX,clientY:t.clientY};d=setTimeout(()=>{d=null,!(i||Ve.current||z)&&(Ze.current||N()||D(e))},350)}}},I=e=>{if(e.touches.length!==1||a===null)return;if(P(),Ve.current||z){M();return}let t=performance.now(),r=e.touches[0],u=r.clientX,d=r.clientY;if(f){e.preventDefault(),e.stopPropagation(),O(r),a=d,o=t;return}if(Ze.current||N()){M();return}e.preventDefault(),e.stopPropagation();let p=Math.abs(u-n.x),m=Math.abs(d-n.y);!i&&(p>6||m>6)&&(i=!0,x(),_());let h=a-d,g=t-o;if(a=d,o=t,g>0){let e=h/g;s=s*.7+e*.3}c+=h;let v=Math.max(6,l*.6),y=Math.trunc(c/v);y!==0&&(C(y),c-=y*v)},L=e=>{let t=s,n=performance.now()-r;if(x(),f){j(e.changedTouches[0]),M(),e.preventDefault(),e.stopPropagation();return}if(M(),Ve.current||z)return;let a=N();if(Ze.current&&!a&&ie.current?.(),Ze.current||a){Oe.current&&(et.current=!0);return}if(!i){if(k&&n>=350)return;if(Ae.current){let t=e.changedTouches[0];if(t&&E(t)){y(),e.preventDefault(),e.stopPropagation();return}}if(Oe.current){e.preventDefault(),e.stopPropagation(),et.current=!0;return}y();return}if(Math.abs(t)>.12){let e=t,n=performance.now(),r=()=>{let t=performance.now(),i=t-n;n=t;let a=e*i;c+=a;let o=Math.max(6,l*.6),s=Math.trunc(c/o);s!==0&&(C(s),c-=s*o),e*=.95**(i/16.67),u=Math.abs(e)>.02?requestAnimationFrame(r):null};u=requestAnimationFrame(r)}},ee=e=>{et.current&&=(e.preventDefault(),e.stopPropagation(),!1)},R={passive:!0,capture:!0},B={passive:!1,capture:!0},te={passive:!1,capture:!0},V={capture:!0};return t.addEventListener(`touchstart`,F,R),t.addEventListener(`touchmove`,I,B),t.addEventListener(`touchend`,L,te),t.addEventListener(`mousedown`,ee,V),()=>{t.removeEventListener(`touchstart`,F,R),t.removeEventListener(`touchmove`,I,B),t.removeEventListener(`touchend`,L,te),t.removeEventListener(`mousedown`,ee,V),x();let e=h();e&&(e.disabled=!1)}},[e?.id,we,Ee,k,A,z,w,T]);let nt=(0,x.useCallback)(t=>{!e||ve||!Pe||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,ve,Pe,s]),rt=(0,x.useCallback)(t=>{!e||ve||!Pe||(Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1)),s({type:`terminal-paste`,sessionId:e.id,data:t}))},[e,ve,Pe,s,Oe,je]),it=(0,x.useCallback)(t=>{!e||ve||!Pe||(Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1)),nt(t))},[e,ve,Pe,s,Oe,je,nt]),at=(0,x.useCallback)(()=>{let e=we.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[we]),ot=wU({sessionId:e?.id??null,disabled:a!==`connected`||ve||!Pe,fileUploadsAllowed:!fe,agentType:e?.agentType,onPasteText:rt,onPasteImage:it,onRefocus:at});le.current=ot.paste,ue.current=ot.fail;let st=(0,x.useCallback)(()=>{if(!e||ve||!Pe)return;Oe.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),je(!1));let t=we.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,ve,Pe,s,we,Oe,je]),ct=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=we.current;if(!e)return!1;let t=e.querySelector(`.xterm-helper-textarea`);if(t&&document.activeElement===t)return!0;let n=document.activeElement,r=typeof HTMLInputElement<`u`&&n instanceof HTMLInputElement,i=typeof HTMLTextAreaElement<`u`&&n instanceof HTMLTextAreaElement;return r||i||n&&n.isContentEditable?!1:!!document.documentElement?.classList?.contains(`keyboard-visible`)},[we]);(0,x.useEffect)(()=>{if(!k)return;let e=we.current;if(!e)return;let t=e.querySelector(`.xterm-accessibility`),n=e.querySelector(`.xterm-accessibility-tree`);if(!t||!n)return;let r=()=>{let r=e.querySelector(`.xterm-helper-textarea`);r&&document.activeElement===r&&!Ze.current?(t.style.pointerEvents=`none`,n.style.pointerEvents=`none`):(t.style.removeProperty(`pointer-events`),n.style.removeProperty(`pointer-events`))};return r(),document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,r)}},[we,k,N]),(0,x.useEffect)(()=>{let e=we.current;e&&(e.inert=!!n)},[we,n]);let lt=(0,x.useMemo)(()=>{if(!ge||t.length===0)return!1;let e=t.map(e=>e.name.trim()).filter(Boolean);return e.length===t.length&&new Set(e).size===t.length},[ge,t]);return(0,W.jsxs)(`section`,{className:`flex flex-1 flex-col bg-base terminal-mobile-overlay md:relative md:inset-auto ${k?`ios-native-term-selection`:``}`,"data-testid":`terminal-panel`,onDragOver:t=>{Array.from(t.dataTransfer.types).includes(`Files`)&&(t.preventDefault(),t.dataTransfer.dropEffect=e&&!ve&&Pe&&!fe&&a===`connected`?`copy`:`none`)},onDrop:t=>{if(!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),!e||ve||!Pe||fe||a!==`connected`))return;let n=iH(t.dataTransfer);n.length&&ot.paste({text:``,files:n})},children:[(0,W.jsxs)(`div`,{className:`flex min-h-[52px] shrink-0 items-center justify-between border-b border-border bg-elevated px-[6px] md:h-10 md:min-h-0 md:px-3 ${e||n?``:`md:hidden`}`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[7px] md:gap-3`,children:[(0,W.jsx)(`button`,{onClick:()=>B(!0),className:`flex size-[44px] shrink-0 items-center justify-center rounded border border-border bg-surface text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95 md:hidden`,"aria-label":`Open session menu`,children:(0,W.jsx)(Te,{width:16,height:16})}),e&&ye&&(0,W.jsx)(`button`,{disabled:Me,onClick:()=>I(!0),className:`hidden md:flex h-7 w-7 items-center justify-center rounded bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20 active:scale-95 transition-all shrink-0 disabled:cursor-not-allowed disabled:opacity-40`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,W.jsx)(Ue,{width:16,height:16})}),Ce&&(0,W.jsx)(`button`,{onClick:Ge,className:`hidden md:flex h-7 w-7 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all shrink-0`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,W.jsx)(De,{width:16,height:16})}),e?(0,W.jsxs)(`div`,{className:`flex min-w-[72px] flex-col items-start gap-px leading-none md:min-w-0 md:flex-row md:items-baseline md:gap-3 md:leading-normal`,children:[te?(0,W.jsx)(`input`,{ref:se,type:`text`,value:ne,onChange:e=>re(e.target.value),onBlur:Je,onKeyDown:Xe,className:`w-full max-w-[112px] rounded border border-border bg-surface px-2 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent md:max-w-[200px]`}):(0,W.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:e.agentSessionName||e.name}),(0,W.jsx)(`span`,{className:`shrink-0 text-[10px] md:hidden ${a===`connected`?zU[e.status]:`text-approval`}`,children:a===`connected`?RU[e.status]:a}),(0,W.jsx)(`span`,{className:`hidden shrink-0 text-xs md:inline ${zU[e.status]}`,children:RU[e.status]})]}):n?(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-px leading-none md:flex-row md:items-baseline md:gap-2 md:leading-normal`,children:[(0,W.jsx)(`span`,{className:`max-w-[112px] truncate text-sm font-medium text-primary md:max-w-none`,children:be}),(0,W.jsx)(`span`,{className:`text-[10px] font-medium text-blue-400 md:rounded-full md:bg-blue-500/15 md:px-1.5 md:py-0.5 md:uppercase md:tracking-wide`,children:`Hibernating`})]}):(0,W.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[4px] md:gap-1.5`,children:[a!==`connected`&&(0,W.jsx)(`span`,{className:`hidden text-xs text-approval md:inline`,children:a}),(0,W.jsx)(`button`,{onClick:f,className:`flex size-[44px] items-center justify-center rounded bg-accent text-white transition-all hover:bg-accent/90 active:scale-95 md:hidden`,title:`New session (${O}N)`,"aria-label":`New session`,children:(0,W.jsx)(Ne,{width:16,height:16})}),e&&ye&&(0,W.jsx)(`button`,{disabled:Me,onClick:()=>I(!0),className:`flex size-[44px] items-center justify-center rounded border border-danger/30 bg-danger/10 text-danger transition-all hover:bg-danger/20 active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 md:hidden`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,W.jsx)(Ue,{width:16,height:16})}),Ce&&(0,W.jsx)(`button`,{onClick:Ge,className:`hidden size-[44px] items-center justify-center rounded border border-border text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95 min-[360px]:flex md:hidden`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,W.jsx)(De,{width:16,height:16})}),n&&(0,W.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-[44px] px-3 text-xs md:hidden`,children:`Wake`}),e&&(0,W.jsxs)(`div`,{className:`relative md:hidden`,ref:oe,children:[(0,W.jsx)(`button`,{onClick:()=>R(!L),className:`flex size-[44px] items-center justify-center rounded border border-border bg-surface text-secondary transition-all hover:bg-hover hover:text-primary active:scale-95`,title:`More options`,"aria-label":`More options`,children:(0,W.jsx)(he,{width:16,height:16})}),L&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border bg-elevated shadow-lg py-1`,children:[ye&&(0,W.jsxs)(`button`,{onClick:Ke,className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(_e,{width:14,height:14}),`Rename`]}),Ce&&(0,W.jsxs)(`button`,{onClick:Ge,className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(De,{width:14,height:14}),`Hibernate`]}),(0,W.jsxs)(`button`,{onClick:()=>{v(),R(!1)},className:`flex min-h-[44px] w-full items-center gap-2 px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary`,children:[(0,W.jsx)(Le,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,W.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,W.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-4 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,W.jsx)(`div`,{className:`flex items-center gap-[6px] overflow-x-auto px-[8px] py-[5px] scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:t.map((t,n)=>{let r=t.id===e.id,i=lt?t.name.trim():n+1;return(0,W.jsx)(`button`,{type:`button`,className:`
|
|
312
299
|
flex items-center justify-center shrink-0 snap-start
|
|
313
300
|
h-[44px] ${lt?`min-w-[44px] px-2.5 max-w-[8rem] truncate`:`w-[44px]`}
|
|
314
301
|
text-sm font-extrabold rounded-lg
|
|
315
302
|
active:scale-95 transition-all duration-75
|
|
316
303
|
select-none touch-manipulation
|
|
317
|
-
${r?
|
|
318
|
-
`,onClick:()=>{IU(),u(t.id)},title:lt?t.name:void 0,children:i},t.id)})})]}),(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(`div`,{ref:we,className:`absolute inset-0`,style:{backgroundColor:S.background}}),Me&&e&&(0,W.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute top-2 left-2 z-50 flex items-center gap-1.5 rounded-lg bg-black/60 px-2.5 py-1.5 text-xs text-white/90 shadow-lg backdrop-blur-md`,children:[(0,W.jsxs)(`svg`,{className:`h-3 w-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,W.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,W.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),Fe&&e&&(0,W.jsxs)(`div`,{className:`absolute ${j&&!N?`bottom-20`:`bottom-8`} left-1/2 z-30 flex max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2 rounded-lg border border-border bg-elevated/95 px-2 py-2 shadow-lg backdrop-blur-sm md:left-auto md:right-4 md:translate-x-0`,children:[(0,W.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,W.jsxs)(`button`,{type:`button`,onClick:Ie,className:`flex h-8 shrink-0 items-center justify-center gap-1.5 rounded bg-accent px-2.5 text-xs font-medium text-white hover:bg-accent/90 active:scale-95 transition-all`,title:`Copy selection`,"aria-label":`Copy selection`,children:[(0,W.jsx)(de,{width:14,height:14}),`Copy`]}),(0,W.jsx)(`button`,{type:`button`,onClick:Re,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all`,title:`Dismiss`,"aria-label":`Dismiss`,children:(0,W.jsx)(Ue,{width:14,height:14})})]}),!e&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted`,children:n?null:`Select a session to view terminal`}),e&&ve&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-center text-sm text-muted`,children:`Remote session (read-only). Use SSH to attach on the host.`}),n&&(0,W.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,W.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-4 p-4 md:p-6`,children:[(0,W.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,W.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:be}),(0,W.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-blue-400`,children:`Hibernating`}),xe&&(0,W.jsx)(`span`,{className:`text-muted`,children:xe}),(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,Se]})]}),n.lastResumeError&&(0,W.jsxs)(`div`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/15 px-2 py-1 text-xs text-amber-400`,title:`Last wake failed: ${n.lastResumeError}`,children:[(0,W.jsx)(ae,{width:12,height:12}),`Last wake failed`]}),n.lastUserMessage&&(0,W.jsx)(`p`,{className:`max-h-28 max-w-3xl overflow-y-auto whitespace-pre-wrap break-words pr-2 text-sm leading-6 text-secondary`,children:n.lastUserMessage})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),_&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,W.jsx)(VT,{session:n})]})}),ke&&e&&!N?(0,W.jsxs)(`button`,{type:`button`,onClick:ze,className:`absolute bottom-14 left-1/2 z-20 flex h-10 items-center justify-center overflow-hidden rounded-full border border-amber-400/35 bg-amber-500/20 text-amber-100 shadow-lg backdrop-blur-sm transition-all hover:bg-amber-500/30 active:scale-95 md:bottom-8`,style:{transform:`translateX(-50%)`},title:`Exit tmux copy mode and return to live output`,"aria-label":`Exit copy mode`,children:[(0,W.jsx)(`span`,{className:`px-3 text-[11px] font-semibold uppercase tracking-wide`,children:`Copy mode`}),(0,W.jsx)(`span`,{className:`self-stretch border-l border-amber-400/25`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`px-3 text-sm font-medium`,children:`Exit`})]}):j&&e&&!N?(0,W.jsxs)(`button`,{type:`button`,onClick:ze,className:`absolute bottom-8 left-1/2 z-20 flex h-10 px-4 items-center justify-center gap-1.5 rounded-full bg-blue-600/90 text-white shadow-lg hover:bg-blue-600 active:scale-95 transition-all`,style:{transform:`translateX(-50%)`},title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:[(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]}):null]}),(0,W.jsx)(bU,{...ot}),e&&(0,W.jsx)(AU,{onSendKey:nt,onPasteText:rt,onPasteImage:it,disabled:a!==`connected`||ve||!Pe,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,fileUploadsAllowed:!fe,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:at,isKeyboardVisible:ct,onEnterTextMode:st}),(A||k)&&(0,W.jsx)(jU,{isOpen:z,onClose:()=>B(!1),sessions:t,hibernatingSessions:r,historySessions:i,selectedSessionId:e?.id??null,selectedHibernatingSessionId:n?.sessionId??null,onSelect:u,onSelectHibernating:d,onRename:m,onResume:h,onHibernate:g,onMoveToHistory:_,onNewSession:f,loading:y,error:b}),F&&e&&(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,W.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,W.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,W.jsxs)(`p`,{className:`text-sm text-secondary mb-4 text-pretty`,children:[`Kill "`,e.agentSessionName||e.name,`"? The process will be terminated. Conversation history is preserved in logs.`]}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,W.jsx)(`button`,{ref:ce,onClick:He,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function RU({onSelect:e,onCancel:t,initialPath:n}){let[r,i]=(0,x.useState)(n||`~`),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!0),[d,f]=(0,x.useState)(-1),p=(0,x.useRef)(null),m=H(e=>e.recentPaths),h=(0,x.useCallback)(async e=>{p.current?.abort();let t=new AbortController;p.current=t;let{signal:n}=t;u(!0),c(null),o(null),f(-1),i(e);try{let r=await fetch(`/api/directories?path=${encodeURIComponent(e)}`,{signal:n});if(!r.ok){let e=await r.json();throw Error(e.message||`Failed to load directory`)}let a=await r.json();if(p.current!==t)return;o(a),i(a.path)}catch(e){if(p.current!==t)return;let n=e;n?.name!==`AbortError`&&c(n?.message||`Failed to load directory`)}finally{p.current===t&&u(!1)}},[]);(0,x.useEffect)(()=>(h(n||`~`),()=>{p.current?.abort()}),[h,n]);let g=a?.directories??[],_=a?.path||r,v=a?.parent;return(0,x.useEffect)(()=>{let n=n=>{if(n.key===`Escape`){n.preventDefault(),t();return}if(!l){if(n.key===`ArrowDown`){n.preventDefault(),f(e=>g.length===0?-1:e<0?0:Math.min(e+1,g.length-1));return}if(n.key===`ArrowUp`){n.preventDefault(),f(e=>g.length===0?-1:e<0?g.length-1:Math.max(e-1,0));return}if(n.key===`Enter`){n.preventDefault();let t=g[d];t?h(t.path):_&&e(_);return}n.key===`Backspace`&&v&&(n.preventDefault(),h(v))}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[g,_,h,d,l,t,e,v]),(0,W.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Directory browser`,className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},"data-testid":`directory-browser`,children:(0,W.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,W.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,W.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,W.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,W.jsx)(`p`,{className:`text-danger`,children:s}),(0,W.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,W.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>h(e.path),onMouseEnter:()=>f(t),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs ${t===d?`bg-hover text-primary`:`text-secondary`}`,"data-testid":`directory-entry`,"data-entry-name":e.name,"data-entry-path":e.path,children:[(0,W.jsx)(xe,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,W.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,W.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,W.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,W.jsx)(`button`,{type:`button`,className:`block w-full truncate text-left text-xs text-secondary hover:text-primary`,onClick:()=>h(e),title:e,"data-testid":`directory-recent`,"data-recent-path":e,children:e},e))})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function zU({isOpen:e,onClose:t,onCreate:n,defaultProjectDir:r,commandPresets:i,defaultPresetId:a,lastProjectPath:o,activeProjectPath:s,remoteHosts:c=[],remoteAllowControl:l=!1,initialHost:u,initialPath:d,initialCommand:f}){let[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(``),[S,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=l&&c.length>0;if((0,x.useEffect)(()=>{if(!e){m(``),g(``),v(null),b(``),C(!1),T(u??``),setTimeout(()=>{if(typeof document>`u`||typeof document.querySelector!=`function`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300);return}if(typeof document<`u`&&typeof document.querySelector==`function`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}m(d?.trim()||s?.trim()||o||r||``),g(``),T(u??``);let t=f?.trim();if(t){let e=i.find(e=>te(e)===t);e?(v(e.id),b(te(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(te(e))):i.length>0?(v(i[0].id),b(te(i[0]))):(v(null),b(``))}setTimeout(()=>{if(O.current?.focus(),D.current){let e=D.current;e.scrollLeft=e.scrollWidth}},50)},[s,i,a,r,e,o,u,d,f]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=()=>E.current?Array.from(E.current.querySelectorAll(`input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]`)):[],r=e=>{if(!S){if(e.key===`Escape`){typeof e.stopPropagation==`function`&&e.stopPropagation(),t();return}if(e.key===`Enter`){let t=document.activeElement;if(!t||t.tagName===`INPUT`||t.closest(`[data-testid="host-select"]`)||!t.closest(`[data-testid="command-select"]`))return;e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation(),E.current?.requestSubmit();return}if(e.key===`Tab`){e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation();let t=n();if(t.length===0)return;let r=document.activeElement,i=t.indexOf(r),a;a=i===-1?e.shiftKey?t.length-1:0:e.shiftKey?i<=0?t.length-1:i-1:i>=t.length-1?0:i+1,t[a]?.focus()}}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,S]),!e)return null;let A=e=>{let t=i.find(t=>t.id===e);t&&(v(e),b(te(t)))},j=()=>{v(null),b(``)},M=_===null,N=w!==``,P=e=>{e.preventDefault();let r=p.trim();if(!r)return;let i=y.trim();n(r,h.trim()||void 0,i||void 0,N?w:void 0),t()},F=[...i.map(e=>({id:e.id,label:e.label,isCustom:!1,agentType:e.agentType,command:e.command})),{id:`custom`,label:`Custom`,isCustom:!0,agentType:void 0,command:void 0}],I=[{id:``,label:`Local`,ok:!0,error:void 0},...c.map(e=>({id:e.host,label:e.host,ok:e.ok,error:e.error}))],L=p.trim()||`~`;return(0,W.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:[(0,W.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,W.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Host`,"data-testid":`host-select`,children:I.map((e,t)=>{let n=w===e.id,r=!e.ok&&!n;return(0,W.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e.label,title:e.ok?void 0:e.error||`Unreachable`,tabIndex:n?0:-1,onClick:()=>T(e.id),onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%I.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+I.length)%I.length;else return;let r=I[n];T(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``} ${r?`opacity-60`:``}`,children:e.label},e.id||`local`)})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Command preset`,"data-testid":`command-select`,children:F.map((e,t)=>{let n=e.isCustom?M:_===e.id;return(0,W.jsxs)(`button`,{ref:n?O:void 0,type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,onClick:()=>{e.isCustom?j():A(e.id)},onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%F.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+F.length)%F.length;else return;let r=F[n];r.isCustom?j():A(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``}`,children:[(0,W.jsx)(eh,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,W.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{ref:D,value:p,onChange:e=>m(e.target.value),placeholder:N?`/home/user/project`:s||o||r||`/Users/you/code/my-project`,className:`input flex-1 text-sm`}),!N&&(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,W.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,W.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,W.jsx)(RU,{initialPath:L,onSelect:e=>{m(e),C(!1)},onCancel:()=>C(!1)})]})}function BU({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=x.useRef(e!==void 0),[a,o]=x.useState(t);return[i?e:a,x.useCallback(e=>{i||o(e)},[])]}var VU={};function HU(e,t){let n=x.useRef(VU);return n.current===VU&&(n.current=e(t)),n}var UU=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],WU=UU&&UU!==x.useLayoutEffect?UU:e=>e();function GU(e){let t=HU(KU).current;return t.next=e,WU(t.effect),t.trampoline}function KU(){let e={next:void 0,callback:qU,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function qU(){}function JU(e,t,n,r){let i=HU(XU).current;return ZU(i,e,t,n,r)&&$U(i,[e,t,n,r]),i.callback}function YU(e){let t=HU(XU).current;return QU(t,e)&&$U(t,e),t.callback}function XU(){return{callback:null,cleanup:null,refs:[]}}function ZU(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function QU(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function $U(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var eW=typeof document<`u`?x.useLayoutEffect:()=>{},tW={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},nW={...tW,position:`fixed`,top:0,left:0},rW={...tW,position:`absolute`};function iW(){}Object.freeze([]);var aW=Object.freeze({});function oW(e,...t){let n=new URL(`https://base-ui.com/production-error`);return n.searchParams.set(`code`,e.toString()),t.forEach(e=>n.searchParams.append(`args[]`,e)),`Base UI error #${e}; visit ${n} for the full message.`}var sW=18;function cW(e){return sW>=e}function lW(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return(cW(19)?n?.ref:t.ref)??null}function uW(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function dW(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function fW(e,t){return typeof e==`function`?e(t):e}function pW(e,t){return typeof e==`function`?e(t):e}var mW={};function hW(e,t,n,r,i){let a={...xW(e,mW)};return t&&(a=_W(a,t)),n&&(a=_W(a,n)),r&&(a=_W(a,r)),i&&(a=_W(a,i)),a}function gW(e){if(e.length===0)return mW;if(e.length===1)return xW(e[0],mW);let t={...xW(e[0],mW)};for(let n=1;n<e.length;n+=1)t=_W(t,e[n]);return t}function _W(e,t){return bW(t)?t(e):vW(e,t)}function vW(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=uW(e.style,r);break;case`className`:e[n]=wW(e.className,r);break;default:yW(n,r)?e[n]=SW(e[n],r):e[n]=r}}return e}function yW(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function bW(e){return typeof e==`function`}function xW(e,t){return bW(e)?e(t):e??mW}function SW(e,t){return t?e?n=>{if(TW(n)){let r=n;CW(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function CW(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function wW(e,t){return t?e?t+` `+e:t:e}function TW(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function EW(e,t,n={}){let r=t.render,i=DW(t,n);return n.enabled===!1?null:kW(e,r,i,n.state??aW)}function DW(e,t={}){let{className:n,style:r,render:i}=e,{state:a=aW,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?fW(n,a):void 0,d=l?pW(r,a):void 0,f=l?dW(a,c):aW,p=l?uW(f,Array.isArray(s)?gW(s):s)??aW:aW;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=YU([p.ref,lW(i),...o]):p.ref=JU(p.ref,lW(i),o):JU(null,null)),l?(u!==void 0&&(p.className=wW(p.className,u)),d!==void 0&&(p.style=uW(p.style,d)),p):aW}var OW=Symbol.for(`react.lazy`);function kW(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=hW(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===OW&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return AW(e,n);throw Error(oW(8))}function AW(e,t){return e===`button`?(0,x.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,x.createElement)(`img`,{alt:``,...t,key:t.key}):x.createElement(e,t)}var jW={...x},MW=0;function NW(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(MW+=1,r(`${t}-${MW}`))},[n,t]),i}var PW=jW.useId;function FW(e,t){if(PW!==void 0){let n=PW();return e??(t?`${t}-${n}`:n)}return NW(e,t)}function IW(e){return FW(e,`base-ui`)}function LW(){return typeof window<`u`}function RW(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function zW(e){return LW()?e instanceof Element||e instanceof RW(e).Element:!1}function BW(e){return LW()?e instanceof HTMLElement||e instanceof RW(e).HTMLElement:!1}function VW(e){return!LW()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof RW(e).ShadowRoot}var HW=x.createContext(void 0);function UW(e=!1){let t=x.useContext(HW);if(t===void 0&&!e)throw Error(oW(16));return t}function WW(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:x.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function GW(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=UW(!0)!==void 0,s=GU(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=WW({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;KW(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return eW(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return hW({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(CW(e),o?.(e)),e.baseUIHandlerPrevented)return;let r=e.target===e.currentTarget&&!i&&!s()&&!t,a=e.key===`Enter`,c=e.key===` `;r&&((c||a)&&e.preventDefault(),a&&n?.(e))},onKeyUp(e){t||(CW(e),a?.(e)),!e.baseUIHandlerPrevented&&e.target===e.currentTarget&&!i&&!t&&e.key===` `&&n?.(e)},onPointerDown(e){if(t){e.preventDefault();return}l?.(e)}},i?void 0:{role:`button`},c,u)},[t,c,i,s]),buttonRef:GU(e=>{a.current=e,l()})}}function KW(e){return BW(e)&&e.tagName===`BUTTON`}var qW=x.createContext(void 0);function JW(){let e=x.useContext(qW);if(e===void 0)throw Error(oW(63));return e}var YW=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),XW={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},ZW={valid(e){return e===null?null:e?{[YW.valid]:``}:{[YW.invalid]:``}}},QW=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),$W={...ZW,checked(e){return e?{[QW.checked]:``}:{[QW.unchecked]:``}}};function eG(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var tG=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:iW,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function nG(){return x.useContext(tG)}var rG=x.createContext({invalid:void 0,name:void 0,validityData:{state:XW,errors:[],error:``,value:``,initialValue:null},setValidityData:iW,disabled:void 0,touched:!1,setTouched:iW,dirty:!1,setDirty:iW,filled:!1,setFilled:iW,focused:!1,setFocused:iW,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=aW)=>e,getInputValidationProps:(e=aW)=>e,inputRef:{current:null},commit:async()=>{}}});function iG(e=!0){let t=x.useContext(rG);if(t.setValidityData===iW&&!e)throw Error(oW(28));return t}function aG(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=nG(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=iG(),f=GU(e.getValue);eW(()=>{if(!t)return;let e=n;e===void 0&&(e=f()),u.initialValue===null&&e!==null&&d(t=>({...t,initialValue:e}))},[t,d,n,u.initialValue,f]),eW(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:eG(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?U.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),eW(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var oG=x.createContext({controlId:void 0,registerControlId:iW,labelId:void 0,setLabelId:iW,messageIds:[],setMessageIds:iW,getDescriptionProps:e=>e});function sG(){return x.useContext(oG)}function cG(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=sG(),o=IW(t),s=n?i:void 0,c=HU(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=GU(()=>{!l.current||a===iW||(l.current=!1,a(c.current,void 0))});return eW(()=>{if(a===iW)return;let e;if(n){let n=r?.current;e=zW(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),x.useEffect(()=>d,[d]),i??o}var lG=`none`;function uG(e,t,n,r){let i=!1,a=!1,o=r??aW;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function dG(e,t){let n=x.useRef(e),r=GU(t);eW(()=>{n.current!==e&&r(n.current)},[e,r]),eW(()=>{n.current=e},[e])}var fG=x.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,id:a,inputRef:o,name:s,nativeButton:c=!1,onCheckedChange:l,readOnly:u=!1,required:d=!1,disabled:f=!1,render:p,uncheckedValue:m,value:h,...g}=e,{clearErrors:_}=nG(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=iG(),{labelId:A}=sG(),j=D||f,M=O??s,N=GU(l),P=x.useRef(null),F=JU(P,o,k.inputRef),I=x.useRef(null),L=IW(),ee=cG({id:a,implicit:!1,controlRef:I}),R=c?void 0:ee,[z,B]=BU({controlled:n,default:!!i,name:`Switch`,state:`checked`});aG({id:L,commit:k.commit,value:z,controlRef:I,name:M,getValue:()=>z}),eW(()=>{P.current&&C(P.current.checked)},[P,C]),dG(z,()=>{_(M),b(z!==S.initialValue),C(z),T()?k.commit(z):k.commit(z,!0)});let{getButtonProps:te,buttonRef:V}=GW({disabled:j,native:c}),ne={id:c?ee:L,role:`switch`,"aria-checked":z,"aria-readonly":u||void 0,"aria-required":d||void 0,"aria-labelledby":A,onFocus(){j||w(!0)},onBlur(){let e=P.current;!e||j||(y(!0),w(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){u||j||(e.preventDefault(),P.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},H=x.useMemo(()=>hW({checked:z,disabled:j,id:R,name:M,required:d,style:M?rW:nW,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=uG(lG,e.nativeEvent);N?.(t,n),!n.isCanceled&&B(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?aW:{value:h}),[z,j,F,R,M,N,d,B,k,h]),re=x.useMemo(()=>({...v,checked:z,disabled:j,readOnly:u,required:d}),[v,z,j,u,d]),U=EW(`span`,e,{state:re,ref:[t,I,V],props:[ne,k.getValidationProps,g,te],stateAttributesMapping:$W});return(0,W.jsxs)(qW.Provider,{value:re,children:[U,!z&&M&&m!==void 0&&(0,W.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,W.jsx)(`input`,{...H})]})}),pG=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=iG(),o=JW();return EW(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:$W,props:i})});function mG(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=mG(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function hG(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=mG(e))&&(r&&(r+=` `),r+=t);return r}var gG=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},_G=(e,t)=>({classGroupId:e,validator:t}),vG=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),yG=`-`,bG=[],xG=`arbitrary..`,SG=e=>{let t=TG(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return wG(e);let n=e.split(yG);return CG(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?gG(i,t):t:i||bG}return n[e]||bG}}},CG=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=CG(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(yG):e.slice(t).join(yG),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},wG=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?xG+r:void 0})(),TG=e=>{let{theme:t,classGroups:n}=e;return EG(n,t)},EG=(e,t)=>{let n=vG();for(let r in e){let i=e[r];DG(i,n,r,t)}return n},DG=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];OG(i,t,n,r)}},OG=(e,t,n,r)=>{if(typeof e==`string`){kG(e,t,n);return}if(typeof e==`function`){AG(e,t,n,r);return}jG(e,t,n,r)},kG=(e,t,n)=>{let r=e===``?t:MG(t,e);r.classGroupId=n},AG=(e,t,n,r)=>{if(NG(e)){DG(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(_G(n,e))},jG=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];DG(o,MG(t,a),n,r)}},MG=(e,t)=>{let n=e,r=t.split(yG),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=vG(),n.nextPart.set(t,i)),n=i}return n},NG=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,PG=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},FG=`!`,IG=`:`,LG=[],RG=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),zG=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===IG){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(FG)?(c=s.slice(0,-1),l=!0):s.startsWith(FG)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return RG(t,l,c,u)};if(t){let e=t+IG,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):RG(LG,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},BG=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},VG=e=>({cache:PG(e.cacheSize),parseClassName:zG(e),sortModifiers:BG(e),...SG(e)}),HG=/\s+/,UG=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(HG),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+FG:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},WG=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=GG(n))&&(i&&(i+=` `),i+=r);return i},GG=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=GG(e[r]))&&(n&&(n+=` `),n+=t);return n},KG=(e,...t)=>{let n,r,i,a,o=o=>(n=VG(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=UG(e,n);return i(e,a),a};return a=o,(...e)=>a(WG(...e))},qG=[],JG=e=>{let t=t=>t[e]||qG;return t.isThemeGetter=!0,t},YG=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,XG=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ZG=/^\d+\/\d+$/,QG=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,$G=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,eK=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,tK=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,nK=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,rK=e=>ZG.test(e),iK=e=>!!e&&!Number.isNaN(Number(e)),aK=e=>!!e&&Number.isInteger(Number(e)),oK=e=>e.endsWith(`%`)&&iK(e.slice(0,-1)),sK=e=>QG.test(e),cK=()=>!0,lK=e=>$G.test(e)&&!eK.test(e),uK=()=>!1,dK=e=>tK.test(e),fK=e=>nK.test(e),pK=e=>!Q(e)&&!$(e),mK=e=>EK(e,AK,uK),Q=e=>YG.test(e),hK=e=>EK(e,jK,lK),gK=e=>EK(e,MK,iK),_K=e=>EK(e,OK,uK),vK=e=>EK(e,kK,fK),yK=e=>EK(e,PK,dK),$=e=>XG.test(e),bK=e=>DK(e,jK),xK=e=>DK(e,NK),SK=e=>DK(e,OK),CK=e=>DK(e,AK),wK=e=>DK(e,kK),TK=e=>DK(e,PK,!0),EK=(e,t,n)=>{let r=YG.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},DK=(e,t,n=!1)=>{let r=XG.exec(e);return r?r[1]?t(r[1]):n:!1},OK=e=>e===`position`||e===`percentage`,kK=e=>e===`image`||e===`url`,AK=e=>e===`length`||e===`size`||e===`bg-size`,jK=e=>e===`length`,MK=e=>e===`number`,NK=e=>e===`family-name`,PK=e=>e===`shadow`,FK=KG(()=>{let e=JG(`color`),t=JG(`font`),n=JG(`text`),r=JG(`font-weight`),i=JG(`tracking`),a=JG(`leading`),o=JG(`breakpoint`),s=JG(`container`),c=JG(`spacing`),l=JG(`radius`),u=JG(`shadow`),d=JG(`inset-shadow`),f=JG(`text-shadow`),p=JG(`drop-shadow`),m=JG(`blur`),h=JG(`perspective`),g=JG(`aspect`),_=JG(`ease`),v=JG(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],T=()=>[rK,`full`,`auto`,...w()],E=()=>[aK,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,aK,$,Q]},aK,$,Q],O=()=>[aK,`auto`,$,Q],k=()=>[`auto`,`min`,`max`,`fr`,$,Q],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[rK,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),SK,_K,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,CK,mK,{size:[$,Q]}],ee=()=>[oK,bK,hK],R=()=>[``,`none`,`full`,l,$,Q],z=()=>[``,iK,bK,hK],B=()=>[`solid`,`dashed`,`dotted`,`double`],te=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],V=()=>[iK,oK,SK,_K],ne=()=>[``,`none`,m,$,Q],H=()=>[`none`,iK,$,Q],re=()=>[`none`,iK,$,Q],U=()=>[iK,$,Q],ie=()=>[rK,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[sK],breakpoint:[sK],color:[cK],container:[sK],"drop-shadow":[sK],ease:[`in`,`out`,`in-out`],font:[pK],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[sK],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[sK],shadow:[sK],spacing:[`px`,iK],text:[sK],"text-shadow":[sK],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,rK,Q,$,g]}],container:[`container`],columns:[{columns:[iK,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{start:T()}],end:[{end:T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[aK,`auto`,$,Q]}],basis:[{basis:[rK,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[iK,rK,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,iK,$,Q]}],shrink:[{shrink:[``,iK,$,Q]}],order:[{order:[aK,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,bK,hK]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,$,gK]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,oK,Q]}],"font-family":[{font:[xK,Q,t]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[iK,`none`,$,gK]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...B(),`wavy`]}],"text-decoration-thickness":[{decoration:[iK,`from-font`,`auto`,$,hK]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[iK,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:L()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},aK,$,Q],radial:[``,$,Q],conic:[aK,$,Q]},wK,vK]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:R()}],"rounded-s":[{"rounded-s":R()}],"rounded-e":[{"rounded-e":R()}],"rounded-t":[{"rounded-t":R()}],"rounded-r":[{"rounded-r":R()}],"rounded-b":[{"rounded-b":R()}],"rounded-l":[{"rounded-l":R()}],"rounded-ss":[{"rounded-ss":R()}],"rounded-se":[{"rounded-se":R()}],"rounded-ee":[{"rounded-ee":R()}],"rounded-es":[{"rounded-es":R()}],"rounded-tl":[{"rounded-tl":R()}],"rounded-tr":[{"rounded-tr":R()}],"rounded-br":[{"rounded-br":R()}],"rounded-bl":[{"rounded-bl":R()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":z()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...B(),`hidden`,`none`]}],"divide-style":[{divide:[...B(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...B(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[iK,$,Q]}],"outline-w":[{outline:[``,iK,bK,hK]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,TK,yK]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,TK,yK]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:z()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[iK,hK]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,TK,yK]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[iK,$,Q]}],"mix-blend":[{"mix-blend":[...te(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":te()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[iK]}],"mask-image-linear-from-pos":[{"mask-linear-from":V()}],"mask-image-linear-to-pos":[{"mask-linear-to":V()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":V()}],"mask-image-t-to-pos":[{"mask-t-to":V()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":V()}],"mask-image-r-to-pos":[{"mask-r-to":V()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":V()}],"mask-image-b-to-pos":[{"mask-b-to":V()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":V()}],"mask-image-l-to-pos":[{"mask-l-to":V()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":V()}],"mask-image-x-to-pos":[{"mask-x-to":V()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":V()}],"mask-image-y-to-pos":[{"mask-y-to":V()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":V()}],"mask-image-radial-to-pos":[{"mask-radial-to":V()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[iK]}],"mask-image-conic-from-pos":[{"mask-conic-from":V()}],"mask-image-conic-to-pos":[{"mask-conic-to":V()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:ne()}],brightness:[{brightness:[iK,$,Q]}],contrast:[{contrast:[iK,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,TK,yK]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,iK,$,Q]}],"hue-rotate":[{"hue-rotate":[iK,$,Q]}],invert:[{invert:[``,iK,$,Q]}],saturate:[{saturate:[iK,$,Q]}],sepia:[{sepia:[``,iK,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[iK,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[iK,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,iK,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[iK,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,iK,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[iK,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[iK,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,iK,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[iK,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[iK,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:H()}],"rotate-x":[{"rotate-x":H()}],"rotate-y":[{"rotate-y":H()}],"rotate-z":[{"rotate-z":H()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":[`scale-3d`],skew:[{skew:U()}],"skew-x":[{"skew-x":U()}],"skew-y":[{"skew-y":U()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":[`translate-none`],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[iK,bK,hK,gK]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function IK(...e){return FK(hG(e))}function LK({checked:e,onCheckedChange:t,disabled:n,className:r,ariaLabel:i}){return(0,W.jsx)(fG,{checked:e,onCheckedChange:t,disabled:n,"aria-label":i,className:IK(`group relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center rounded-full transition-colors`,`bg-border data-[checked]:bg-accent`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg-base`,`disabled:cursor-not-allowed disabled:opacity-50`,r),children:(0,W.jsx)(pG,{className:IK(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var RK=null,zK=!1,BK={},VK=500;function HK(){if(typeof window>`u`)return null;if(RK?.state===`closed`&&(RK=null),!RK){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;RK=new e}return RK}function UK(){RK&&=(RK.close().catch(()=>{}),null),HK()}function WK(){return zK}function GK(){RK&&(UK(),zK=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&GK()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&GK()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&GK(),e=t},5e3)}async function KK(){let e=HK();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),zK=!1}async function qK(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function JK(e){let t=HK();if(!t||(await qK(t),t.state!==`running`))return;let{frequencies:n,durationMs:r,attackMs:i,peakGain:a,type:o=`sine`}=e,s=t.currentTime,c=r/1e3,l=i/1e3,u=t.createGain();u.connect(t.destination);let d=s+c*.7;u.gain.setValueAtTime(0,s),u.gain.linearRampToValueAtTime(a,s+l),u.gain.setValueAtTime(a,d),u.gain.linearRampToValueAtTime(0,s+c);let f=n.map(e=>{let n=t.createOscillator();return n.type=o,n.frequency.setValueAtTime(e,s),n.connect(u),n});for(let e of f)e.start(s),e.stop(s+c);let p=f[f.length-1];p.onended=()=>{for(let e of f)e.disconnect();u.disconnect()}}async function YK(){let e=Date.now();if(!(e-(BK.permission||0)<VK)){BK.permission=e;try{await JK({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function XK(){let e=Date.now();if(!(e-(BK.idle||0)<VK)){BK.idle=e;try{await JK({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function ZK({isOpen:e,onClose:t}){let n=H(e=>e.defaultProjectDir),r=H(e=>e.setDefaultProjectDir),i=H(e=>e.commandPresets),a=H(e=>e.setCommandPresets),o=H(e=>e.defaultPresetId),s=H(e=>e.setDefaultPresetId),c=H(e=>e.sessionSortMode),l=H(e=>e.setSessionSortMode),u=H(e=>e.sessionSortDirection),d=H(e=>e.setSessionSortDirection),f=H(e=>e.useWebGL),p=H(e=>e.setUseWebGL),m=H(e=>e.fontSize),h=H(e=>e.setFontSize),g=H(e=>e.lineHeight),_=H(e=>e.setLineHeight),v=H(e=>e.letterSpacing),y=H(e=>e.setLetterSpacing),b=H(e=>e.fontOption),S=H(e=>e.setFontOption),C=H(e=>e.customFontFamily),w=H(e=>e.setCustomFontFamily),T=H(e=>e.shortcutModifier),E=H(e=>e.setShortcutModifier),D=H(e=>e.showProjectName),O=H(e=>e.setShowProjectName),k=H(e=>e.showLastUserMessage),A=H(e=>e.setShowLastUserMessage),j=H(e=>e.showSessionIdPrefix),M=H(e=>e.setShowSessionIdPrefix),N=BH(e=>e.theme),F=BH(e=>e.setTheme),I=H(e=>e.soundOnPermission),ee=H(e=>e.setSoundOnPermission),R=H(e=>e.soundOnIdle),z=H(e=>e.setSoundOnIdle),[B,te]=(0,x.useState)(n),[V,ne]=(0,x.useState)(i),[re,U]=(0,x.useState)(o),[ie,ae]=(0,x.useState)(c),[oe,se]=(0,x.useState)(u),[ce,le]=(0,x.useState)(f),[ue,de]=(0,x.useState)(m),[fe,pe]=(0,x.useState)(g),[me,he]=(0,x.useState)(v),[ge,_e]=(0,x.useState)(b),[ve,ye]=(0,x.useState)(C),[be,xe]=(0,x.useState)(T),[Se,Ce]=(0,x.useState)(D),[we,Te]=(0,x.useState)(k),[Ee,De]=(0,x.useState)(j),[Oe,ke]=(0,x.useState)(N),[Ae,je]=(0,x.useState)(I),[Me,Ne]=(0,x.useState)(R),[Pe,Fe]=(0,x.useState)(!0),[Ie,Le]=(0,x.useState)(!1),[Re,ze]=(0,x.useState)(!0),[Be,Ve]=(0,x.useState)(!0),[He,Ue]=(0,x.useState)(!1),[We,Ge]=(0,x.useState)(!1),[Ke,Je]=(0,x.useState)(24),[Xe,Ze]=(0,x.useState)(!1),[Qe,$e]=(0,x.useState)(!1),[et,tt]=(0,x.useState)(``),[nt,rt]=(0,x.useState)(``),[it,at]=(0,x.useState)(``),ot=(0,x.useRef)(null),st=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let t=++st.current;if(ot.current&&=(clearTimeout(ot.current),null),e){if(te(n),ne(i),U(o),ae(c),se(u),le(f),de(m),pe(g),he(v),_e(b),ye(C),xe(T),Ce(D),Te(k),De(j),ke(N),je(I),Ne(R),$e(!1),tt(``),rt(``),at(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>Fe(e.enabled)).catch(()=>{}),Ve(!0),fetch(`/api/settings/terminal-colors`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{st.current===t&&ze(e.enabled)}).catch(()=>{}).finally(()=>{st.current===t&&Ve(!1)}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Je(e.hours)).catch(()=>{}),fetch(`/api/settings/prefer-window-name`).then(e=>e.json()).then(e=>Ue(e.enabled)).catch(()=>{}),typeof document<`u`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}}else typeof document<`u`&&(ot.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{ot.current&&=(clearTimeout(ot.current),null)}},[i,o,n,c,u,f,m,g,v,b,C,T,D,k,j,N,I,R,e]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=e=>{e.key===`Escape`&&(typeof e.stopPropagation==`function`&&e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let ct=e=>{e.preventDefault();let n=B.trim(),i=ce!==f;r(n||`~/Documents/GitHub`),a(V),s(re),l(ie),d(oe),p(ce),h(ue),_(fe),y(me),S(ge),w(ve),E(be),O(Se),A(we),M(Ee),F(Oe),ee(Ae),z(Me),t({webglChanged:i})},lt=(e,t)=>{ne(n=>n.map(n=>n.id===e?{...n,...t}:n))},ut=e=>{let t=V.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=V.filter(t=>t.id!==e);ne(n),e===re&&U(n[0]?.id||`claude`)},dt=()=>{if(!et.trim()||!nt.trim()||V.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:et.trim(),command:nt.trim(),isBuiltIn:!1,agentType:it||void 0};ne([...V,e]),$e(!1),tt(``),rt(``),at(``)},ft=V.length<50,pt=e=>{Le(!0),Fe(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Fe(!e)).finally(()=>Le(!1))},mt=e=>{Ge(!0),Ue(e),fetch(`/api/settings/prefer-window-name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Ue(!e)).finally(()=>Ge(!1))},ht=e=>{Ve(!0),ze(e),fetch(`/api/settings/terminal-colors`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>ze(!e)).finally(()=>Ve(!1))},gt=e=>{let t=Ke;Ze(!0),Je(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Je(t)).finally(()=>Ze(!1))};return(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`form`,{onSubmit:ct,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,W.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,W.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,W.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,W.jsx)(`input`,{value:B,onChange:e=>te(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,W.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,W.jsx)(`select`,{value:re,onChange:e=>U(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:V.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,W.jsx)(`div`,{className:`space-y-3`,children:V.map(e=>(0,W.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,W.jsx)(`input`,{value:e.label,onChange:t=>lt(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>ut(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,W.jsx)(`input`,{value:e.command,onChange:t=>lt(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,W.jsxs)(`select`,{value:e.agentType||``,onChange:t=>lt(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,W.jsx)(`option`,{value:``,children:`Terminal`}),(0,W.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,W.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),Qe?(0,W.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,W.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,W.jsx)(`input`,{value:et,onChange:e=>tt(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,W.jsx)(`input`,{value:nt,onChange:e=>rt(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`select`,{value:it,onChange:e=>at(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,W.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,W.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,W.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>$e(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:dt,disabled:!et.trim()||!nt.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,W.jsx)(`button`,{type:`button`,onClick:()=>$e(!0),disabled:!ft,className:`btn text-xs mt-3 w-full`,children:ft?`+ Add Preset`:`Max 50 presets`})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`created`?`btn-primary`:``}`,onClick:()=>ae(`created`),children:`Created`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`status`?`btn-primary`:``}`,onClick:()=>ae(`status`),children:`Status`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`manual`?`btn-primary`:``}`,onClick:()=>ae(`manual`),children:`Manual`})]}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ie===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:ie===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),ie===`created`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`desc`?`btn-primary`:``}`,onClick:()=>se(`desc`),children:`Newest First`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`asc`?`btn-primary`:``}`,onClick:()=>se(`asc`),children:`Oldest First`})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,W.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,W.jsx)(LK,{checked:Se,onCheckedChange:Ce})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,W.jsx)(LK,{checked:we,onCheckedChange:Te})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,W.jsx)(LK,{checked:Ee,onCheckedChange:De})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,W.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:1,max:168,value:Ke,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&>(t)},disabled:Xe,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,W.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>void YK(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,W.jsx)(LK,{checked:Ae,onCheckedChange:e=>{je(e),e&&KK()}})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>void XK(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,W.jsx)(LK,{checked:Me,onCheckedChange:e=>{Ne(e),e&&KK()}})]})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,W.jsx)(LK,{checked:ce,onCheckedChange:le})]}),ce!==f&&(0,W.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,W.jsx)(LK,{checked:Pe,onCheckedChange:pt,disabled:Ie})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Terminal Colors`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Preserve ANSI colors for terminal output. Hibernate then Wake running agents after changing this setting.`})]}),(0,W.jsx)(LK,{checked:Re,onCheckedChange:ht,disabled:Be,ariaLabel:`Enable terminal colors`})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Prefer Window Names`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Label discovered sessions with their tmux window name instead of the session name. Applies immediately.`})]}),(0,W.jsx)(LK,{checked:He,onCheckedChange:mt,disabled:We})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(Math.max(6,ue-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,W.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,W.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:ue}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(Math.min(24,ue+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,W.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:fe,onChange:e=>pe(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,W.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:fe.toFixed(1)})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:me,onChange:e=>he(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,W.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[me,`px`]})]})]}),(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,W.jsx)(`select`,{value:ge,onChange:e=>_e(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),ge===`custom`&&(0,W.jsx)(`input`,{value:ve,onChange:e=>ye(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,W.jsx)(LK,{checked:Oe===`dark`,onCheckedChange:e=>ke(e?`dark`:`light`)})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,W.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,W.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${be===e?`btn-primary`:``}`,onClick:()=>xe(e),children:e===`auto`?`Auto`:Ye(e)},e))}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:be===`auto`?`Shortcuts: ${Ye(qe(`auto`))}+[1-9/N/X/[/]]`:`Shortcuts: ${Ye(be)}+[1-9/N/X/[/]]`})]})]})}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var QK=[];function $K(e){x.useEffect(e,QK)}var eq=x.createContext(void 0);function tq(){let e=x.useContext(eq);if(!e)throw Error(oW(73));return e}var nq=Symbol(`NOT_FOUND`);function rq(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function iq(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function aq(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var oq=e=>Array.isArray(e)?e:[e];function sq(e){let t=Array.isArray(e[0])?e[0]:e;return aq(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function cq(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function lq(e){let t;return{get(n){return t&&e(t.key,n)?t.value:nq},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function uq(e,t){let n=[];function r(e){let r=n.findIndex(n=>t(e,n.key));if(r>-1){let e=n[r];return r>0&&(n.splice(r,1),n.unshift(e)),e.value}return nq}function i(t,i){r(t)===nq&&(n.unshift({key:t,value:i}),n.length>e&&n.pop())}function a(){return n}function o(){n=[]}return{get:r,put:i,getEntries:a,clear:o}}var dq=(e,t)=>e===t;function fq(e){return function(t,n){if(t===null||n===null||t.length!==n.length)return!1;let{length:r}=t;for(let i=0;i<r;i++)if(!e(t[i],n[i]))return!1;return!0}}function pq(e,t){let{equalityCheck:n=dq,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=fq(n),o=0,s=r<=1?lq(a):uq(r,a);function c(){let t=s.get(arguments);if(t===nq){if(t=e.apply(null,arguments),o++,i){let e=s.getEntries().find(e=>i(e.value,t));e&&(t=e.value,o!==0&&o--)}s.put(arguments,t)}return t}return c.clearCache=()=>{s.clear(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}var mq=class{constructor(e){this.value=e}deref(){return this.value}},hq=typeof WeakRef<`u`?WeakRef:mq,gq=0,_q=1;function vq(){return{s:gq,v:void 0,o:null,p:null}}function yq(e,t={}){let n=vq(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e<n;e++){let n=arguments[e];if(typeof n==`function`||typeof n==`object`&&n){let e=t.o;e===null&&(t.o=e=new WeakMap);let r=e.get(n);r===void 0?(t=vq(),e.set(n,t)):t=r}else{let e=t.p;e===null&&(t.p=e=new Map);let r=e.get(n);r===void 0?(t=vq(),e.set(n,t)):t=r}}let s=t,c;if(t.s===_q)c=t.v;else if(c=e.apply(null,arguments),a++,r){let e=i?.deref?.()??i;e!=null&&r(e,c)&&(c=e,a!==0&&a--),i=typeof c==`object`&&c||typeof c==`function`?new hq(c):c}return s.s=_q,s.v=c,c}return o.clearCache=()=>{n=vq(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function bq(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),rq(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=yq,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=oq(c),p=oq(u),m=sq(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=cq(m,arguments);return i=h.apply(null,e),i},...p);return Object.assign(g,{resultFunc:o,memoizedResultFunc:h,dependencies:m,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var xq=bq(yq),Sq=Object.assign((e,t=xq)=>{iq(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>Sq}),Cq=bq({memoize:pq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),wq=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(oW(1));let s;if(e&&t&&n&&r&&i&&a)s=(o,s,c,l)=>a(e(o,s,c,l),t(o,s,c,l),n(o,s,c,l),r(o,s,c,l),i(o,s,c,l),s,c,l);else if(e&&t&&n&&r&&i)s=(a,o,s,c)=>i(e(a,o,s,c),t(a,o,s,c),n(a,o,s,c),r(a,o,s,c),o,s,c);else if(e&&t&&n&&r)s=(i,a,o,s)=>r(e(i,a,o,s),t(i,a,o,s),n(i,a,o,s),a,o,s);else if(e&&t&&n)s=(r,i,a,o)=>n(e(r,i,a,o),t(r,i,a,o),i,a,o);else if(e&&t)s=(n,r,i,a)=>t(e(n,r,i,a),r,i,a);else if(e)s=e;else throw Error(`Missing arguments`);return s},Tq=(...e)=>{let t=new WeakMap,n=1,r=e[e.length-1],i=e.length-1||1,a=r.length-i;if(a>3)throw Error(oW(2));return(i,o,s,c)=>{let l=i.__cacheKey__;l||(l={id:n},i.__cacheKey__=l,n+=1);let u=t.get(l);if(!u){let n=e,i=[void 0,void 0,void 0];switch(a){case 0:break;case 1:n=[...e.slice(0,-1),()=>i[0],r];break;case 2:n=[...e.slice(0,-1),()=>i[0],()=>i[1],r];break;case 3:n=[...e.slice(0,-1),()=>i[0],()=>i[1],()=>i[2],r];break;default:throw Error(oW(2))}u=Cq(...n),u.selectorArgs=i,t.set(l,u)}switch(u.selectorArgs[0]=o,u.selectorArgs[1]=s,u.selectorArgs[2]=c,a){case 0:return u(i);case 1:return u(i,o);case 2:return u(i,o,s);case 3:return u(i,o,s,c);default:throw Error(`unreachable`)}}},Eq=s((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Dq=s(((e,t)=>{t.exports=Eq()})),Oq=s((e=>{var t=p(),n=Dq();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),kq=s(((e,t)=>{t.exports=Oq()})),Aq=[],jq=void 0;function Mq(){return jq}function Nq(e){Aq.push(e)}var Pq=Dq(),Fq=kq(),Iq=cW(19)?zq:Bq;function Lq(e,t,n,r,i){return Iq(e,t,n,r,i)}function Rq(e,t,n,r,i){let a=x.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,Pq.useSyncExternalStore)(e.subscribe,a,a)}Nq({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);(r.didChange||!Object.is(r.value,i))&&(t=!0,r.value=i,r.didChange=!1)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,Pq.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function zq(e,t,n,r,i){let a=Mq();if(!a)return Rq(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.didChange=!0)):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i),didChange:!1},a.syncHooks.push(s)),s.value}function Bq(e,t,n,r,i){return(0,Fq.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Vq=class{constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return Lq(this,e,t,n,r)}},Hq=class extends Vq{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),eW(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;eW(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;eW(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;eW(()=>{n&&!Object.is(this.state[e],t)&&super.setState({...this.state,[e]:t})},[e,t,n])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return x.useDebugValue(e),Lq(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=GU(t??iW);this.context[e]=n}useStateSetter(e){let t=x.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},Uq=null;globalThis.requestAnimationFrame;var Wq=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},Gq=class e{static create(){return new e}static request(e){return Wq.request(e)}static cancel(e){return Wq.cancel(e)}currentId=Uq;request(e){this.cancel(),this.currentId=Wq.request(()=>{this.currentId=Uq,e()})}cancel=()=>{this.currentId!==Uq&&(Wq.cancel(this.currentId),this.currentId=Uq)};disposeEffect=()=>this.cancel};function Kq(){let e=HU(Gq.create).current;return $K(e.disposeEffect),e}var qq=0,Jq=class e{static create(){return new e}currentId=qq;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=qq,t()},e)}isStarted(){return this.currentId!==qq}clear=()=>{this.currentId!==qq&&(clearTimeout(this.currentId),this.currentId=qq)};disposeEffect=()=>this.clear};function Yq(){let e=HU(Jq.create).current;return $K(e.disposeEffect),e}var Xq=0;function Zq(e){return Xq+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Xq}`}function Qq(e){return e?.ownerDocument||document}function $q(e,t){if(typeof e==`string`)return{description:e};if(typeof e==`function`){let n=e(t);return typeof n==`string`?{description:n}:n}return e}var eJ=typeof navigator<`u`,tJ=oJ(),nJ=cJ(),rJ=sJ();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),tJ.platform===`MacIntel`&&tJ.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(tJ.platform),eJ&&/firefox/i.test(rJ);var iJ=eJ&&/apple/i.test(navigator.vendor);eJ&&/Edg/i.test(rJ),eJ&&/android/i.test(nJ)||/android/i.test(rJ),eJ&&nJ.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var aJ=rJ.includes(`jsdom/`);function oJ(){if(!eJ)return{platform:``,maxTouchPoints:-1};let e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??-1}}function sJ(){if(!eJ)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function cJ(){if(!eJ)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function lJ(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function uJ(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&VW(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function dJ(e){return`composedPath`in e?e.composedPath()[0]:e.target}function fJ(e){if(!e||aJ)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var pJ=Tq(e=>e.toasts,e=>{let t=new Map,n=0,r=0;return e.forEach((e,i)=>{let a=e.transitionStatus===`ending`;t.set(e.id,{value:e,domIndex:i,visibleIndex:a?-1:n,offsetY:r}),r+=e.height||0,a||(n+=1)}),t}),mJ={toasts:wq(e=>e.toasts),isEmpty:wq(e=>e.toasts.length===0),toast:wq(pJ,(e,t)=>e.get(t)?.value),toastIndex:wq(pJ,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:wq(pJ,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:wq(pJ,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:wq(e=>e.hovering),focused:wq(e=>e.focused),expanded:wq(e=>e.hovering||e.focused),expandedOrOutOfFocus:wq(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:wq(e=>e.prevFocusElement)},hJ=class extends Hq{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},mJ)}setFocused(e){this.set(`focused`,e)}setHovering(e){this.set(`hovering`,e)}setIsWindowFocused(e){this.set(`isWindowFocused`,e)}setPrevFocusElement(e){this.set(`prevFocusElement`,e)}setViewport=e=>{this.set(`viewport`,e)};disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e){let t=mJ.toastIndex(this.state,e);if(t===-1)return;this.state.toasts[t]?.onRemove?.();let n=[...this.state.toasts];n.splice(t,1),this.setToasts(n)}addToast=e=>{let{toasts:t,timeout:n,limit:r}=this.state,i=e.id||Zq(`toast`),a={...e,id:i,transitionStatus:`starting`},o=[a,...t],s=o.filter(e=>e.transitionStatus!==`ending`);if(s.length>r){let e=s.length-r,t=s.slice(-e),n=new Set(t.map(e=>e.id));this.setToasts(o.map(e=>{let t=n.has(e.id);return e.limited===t?e:{...e,limited:t}}))}else this.setToasts(o.map(e=>e.limited?{...e,limited:!1}:e));let c=a.timeout??n;return a.type!==`loading`&&c>0&&this.scheduleTimer(i,c,()=>this.closeToast(i)),mJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=mJ.toast(this.state,e)??null;if(!i||i.transitionStatus===`ending`)return;let a={...i,...t};this.setToasts(r.map(n=>n.id===e?{...n,...t}:n));let o=a.timeout??n,s=i?.timeout??n,c=Object.hasOwn(t,`timeout`),l=a.transitionStatus!==`ending`&&a.type!==`loading`&&o>0,u=this.timers.has(e),d=s!==o,f=i?.type===`loading`;if(!l&&u){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e);return}if(l&&(!u||d||c||f)){let t=this.timers.get(e);t&&(t.timeout?.clear(),this.timers.delete(e)),this.scheduleTimer(e,o,()=>this.closeToast(e)),mJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{mJ.toast(this.state,e)?.onClose?.();let{limit:t,toasts:n}=this.state,r=0,i=n.map(n=>{if(n.id===e)return{...n,transitionStatus:`ending`,height:0};if(n.transitionStatus===`ending`)return n;let i=r>=t;return r+=1,n.limited===i?n:{...n,limited:i}}),a=this.timers.get(e);a&&a.timeout&&(a.timeout.clear(),this.timers.delete(e)),this.handleFocusManagement(e),this.setToasts(i)};promiseToast=(e,t)=>{let n=$q(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=$q(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=$q(t.error,e);return this.updateToast(r,{...n,type:`error`,timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,`setPromise`)&&t.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{if(e.timeout){e.timeout.clear();let t=Date.now()-e.start,n=e.delay-t;e.remaining=n>0?n:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=Jq.create(),e.timeout.start(e.remaining,()=>{this.timers.delete(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if(e.pointerType!==`touch`)return;let t=dJ(e);uJ(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!mJ.expandedOrOutOfFocus(this.state),a=i?Jq.create():void 0;a?.start(t,()=>{this.timers.delete(e),n()}),this.timers.set(e,{timeout:a,start:i?r:0,delay:t,remaining:t,callback:n})}setToasts(e){let t={toasts:e};e.length===0&&(t.hovering=!1,t.focused=!1),this.update(t)}handleFocusManagement(e){let t=lJ(Qq(this.state.viewport));if(!this.state.viewport||!uJ(this.state.viewport,t)||!fJ(t))return;let n=mJ.toasts(this.state),r=mJ.toastIndex(this.state,e),i=null,a=r+1;for(;a<n.length;){if(n[a].transitionStatus!==`ending`){i=n[a];break}a+=1}if(!i)for(a=r-1;a>=0;){if(n[a].transitionStatus!==`ending`){i=n[a];break}--a}i?i.ref?.current?.focus():this.restoreFocusToPrevElement()}},gJ=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=HU(()=>new hJ({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return $K(a.disposeEffect),x.useEffect(function(){if(i)return i[` subscribe`](({action:e,options:t})=>{let n=t.id;e===`promise`&&t.promise?a.promiseToast(t.promise,t):e===`update`&&n?a.updateToast(n,t):e===`close`&&n?a.closeToast(n):a.addToast(t)})},[a,n,i]),a.useSyncedValues({timeout:n,limit:r}),(0,W.jsx)(eq.Provider,{value:a,children:t})},_J=x.forwardRef(function(e,t){let[n,r]=x.useState();eW(()=>{iJ&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,W.jsx)(`span`,{...e,ref:t,style:nW,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),vJ=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),yJ=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=tq(),s=Yq(),c=x.useRef(!1),l=x.useRef(!1),u=o.useState(`isEmpty`),d=o.useState(`toasts`),f=o.useState(`focused`),p=o.useState(`expanded`),m=o.useState(`prevFocusElement`),h=d[0]?.height??0,g=x.useMemo(()=>d.some(e=>e.transitionStatus===`ending`),[d]);x.useEffect(()=>{let e=o.state.viewport;if(!e)return;function t(t){u||t.key===`F6`&&t.target!==e&&(t.preventDefault(),o.setPrevFocusElement(lJ(Qq(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=RW(e);return n.addEventListener(`keydown`,t),()=>{n.removeEventListener(`keydown`,t)}},[o,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=RW(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=dJ(n),i=lJ(Qq(e));(!uJ(e,r)||!fJ(i))&&o.resumeTimers(),s.start(0,()=>o.setIsWindowFocused(!0))}return t.addEventListener(`blur`,n,!0),t.addEventListener(`focus`,r,!0),()=>{t.removeEventListener(`blur`,n,!0),t.removeEventListener(`focus`,r,!0)}},[o,s,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=Qq(e);return t.addEventListener(`pointerdown`,o.handleDocumentPointerDown,!0),()=>{t.removeEventListener(`pointerdown`,o.handleDocumentPointerDown,!0)}},[u,o]);function _(e){let t=o.state.viewport;t&&(c.current=!0,e.relatedTarget===t?d[0]?.ref?.current?.focus():o.restoreFocusToPrevElement())}function v(e){e.key===`Tab`&&e.shiftKey&&e.target===o.state.viewport&&(e.preventDefault(),o.restoreFocusToPrevElement(),o.resumeTimers())}x.useEffect(()=>{!o.state.isWindowFocused||g||!l.current||(o.resumeTimers(),o.setHovering(!1),l.current=!1)},[g,o]);function y(){o.pauseTimers(),o.setHovering(!0),l.current=!1}function b(){g?l.current=!0:(o.resumeTimers(),o.setHovering(!1))}function S(){if(c.current){c.current=!1;return}f||fJ(Qq(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||uJ(o.state.viewport,e.relatedTarget)||(o.setFocused(!1),o.resumeTimers())}let w={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:y,onMouseMove:y,onMouseLeave:b,onFocus:S,onBlur:C,onKeyDown:v,onClick:S},T={expanded:p},E=EW(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[vJ.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,W.jsxs)(x.Fragment,{children:[!u&&m&&(0,W.jsx)(_J,{onFocus:_}),i,!u&&m&&(0,W.jsx)(_J,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,W.jsxs)(x.Fragment,{children:[!u&&m&&(0,W.jsx)(_J,{onFocus:_}),E,!f&&D.length>0&&(0,W.jsx)(`div`,{style:nW,children:D.map(e=>(0,W.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,W.jsx)(`div`,{children:e.title}),(0,W.jsx)(`div`,{children:e.description})]},e.id))})]})});function bJ(e){return cW(19)?e:e?`true`:void 0}var xJ=x.createContext(void 0);function SJ(){let e=x.useContext(xJ);if(!e)throw Error(oW(66));return e}var CJ=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),wJ={[CJ.startingStyle]:``},TJ={[CJ.endingStyle]:``},EJ={transitionStatus(e){return e===`starting`?wJ:e===`ending`?TJ:null}};function DJ(e){return e==null?e:`current`in e?e.current:e}function OJ(e,t=!1,n=!0){let r=Kq();return GU((i,a=null)=>{r.cancel();function o(){U.flushSync(i)}let s=DJ(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=CJ.startingStyle;if(!c.hasAttribute(e)){r.request(i);return}let t=new MutationObserver(()=>{c.hasAttribute(e)||(t.disconnect(),i())});t.observe(c,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}function i(){Promise.all(c.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||o()}).catch(()=>{let e=c.getAnimations();if(n){if(a?.aborted)return;o()}else e.length>0&&e.some(e=>e.pending||e.playState!==`finished`)&&i()})}if(t){e();return}r.request(i)}})}function kJ(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=GU(i),o=OJ(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var AJ=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}({}),jJ={...EJ,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},MJ=40,NJ=10,PJ=.5,FJ=1;function IJ(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function LJ(e){let t=window.getComputedStyle(e).transform,n=0,r=0,i=1;if(t&&t!==`none`){let e=t.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(n=t[4],r=t[5],i=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(n=t[12],r=t[13],i=t[0])}}return{x:n,y:r,scale:i}}var RJ=x.forwardRef(function(e,t){let{toast:n,render:r,className:i,swipeDirection:a=[`down`,`right`],...o}=e,s=n.positionerProps?.anchor!==void 0,c=[];s||(c=Array.isArray(a)?a:[a]);let l=c.length>0,u=tq(),[d,f]=x.useState(void 0),[p,m]=x.useState(!1),[h,g]=x.useState(!1),[_,v]=x.useState(!1),[y,b]=x.useState({x:0,y:0}),[S,C]=x.useState({x:0,y:0,scale:1}),[w,T]=x.useState(),[E,D]=x.useState(),[O,k]=x.useState(null),A=x.useRef(null),j=x.useRef({x:0,y:0}),M=x.useRef({x:0,y:0,scale:1}),N=x.useRef(void 0),P=x.useRef(0),F=x.useRef(!1),I=x.useRef({x:0,y:0}),L=x.useRef(!1),ee=u.useState(`toastIndex`,n.id),R=u.useState(`toastVisibleIndex`,n.id),z=u.useState(`toastOffsetY`,n.id),B=u.useState(`focused`),te=u.useState(`expanded`);kJ({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let V=GU((e=!1)=>{let t=A.current;if(!t)return;let r=t.style.height;t.style.height=`auto`;let i=t.offsetHeight;t.style.height=r;function a(){u.updateToastInternal(n.id,{ref:A,height:i,...n.transitionStatus===`starting`?{transitionStatus:void 0}:{}})}e?U.flushSync(a):a()});eW(V,[V]);function ne(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**PJ:-(Math.abs(e)**PJ):(!c.includes(`right`)&&e>0&&(n=e**PJ),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**PJ))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**PJ:-(Math.abs(t)**PJ):(!c.includes(`down`)&&t>0&&(r=t**PJ),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**PJ))),{x:n,y:r}}function H(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=dJ(e.nativeEvent);if(!(t&&t.closest(`button,a,input,textarea,[role="button"],[data-swipe-ignore]`))){if(F.current=!1,N.current=void 0,P.current=0,j.current={x:e.clientX,y:e.clientY},I.current=j.current,A.current){let e=LJ(A.current);M.current=e,C(e),b({x:e.x,y:e.y})}u.setHovering(!0),m(!0),g(!1),k(null),L.current=!0,A.current?.setPointerCapture(e.pointerId)}}function re(e){if(!p)return;e.preventDefault(),L.current&&=(j.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>I.current.y||i>0&&t<I.current.y)&&(I.current={x:I.current.x,y:t}),(r<0&&n>I.current.x||r>0&&n<I.current.x)&&(I.current={x:n,y:I.current.y});let a=n-j.current.x,o=t-j.current.y,s=t-I.current.y,l=n-I.current.x;if(!h&&Math.sqrt(a*a+o*o)>=FJ&&(g(!0),O===null)){let e=c.includes(`left`)||c.includes(`right`),t=c.includes(`up`)||c.includes(`down`);e&&t&&k(Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`)}let u;if(!N.current)O===`vertical`?o>0?u=`down`:o<0&&(u=`up`):O===`horizontal`?a>0?u=`right`:a<0&&(u=`left`):u=Math.abs(a)>=Math.abs(o)?a>0?`right`:`left`:o>0?`down`:`up`,u&&c.includes(u)&&(N.current=u,P.current=IJ(u,a,o),f(u));else{let e=N.current,t=IJ(e,l,s);t>MJ?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=NJ&&(F.current=!0)}let d=ne(a,o),m=M.current.x,_=M.current.y;O===`horizontal`?(c.includes(`left`)||c.includes(`right`))&&(m+=d.x):(O===`vertical`||(c.includes(`left`)||c.includes(`right`))&&(m+=d.x),(c.includes(`up`)||c.includes(`down`))&&(_+=d.y)),b({x:m,y:_})}function ie(e){if(!p)return;if(m(!1),g(!1),k(null),A.current?.releasePointerCapture(e.pointerId),F.current){b({x:S.x,y:S.y}),f(void 0);return}let t=!1,r=y.x-S.x,i=y.y-S.y,a;for(let e of c){switch(e){case`right`:r>MJ&&(t=!0,a=`right`);break;case`left`:r<-MJ&&(t=!0,a=`left`);break;case`down`:i>MJ&&(t=!0,a=`down`);break;case`up`:i<-MJ&&(t=!0,a=`up`);break;default:break}if(t)break}t?(f(a),v(!0),u.closeToast(n.id)):(b({x:S.x,y:S.y}),f(void 0))}function ae(e){if(e.key===`Escape`){if(!A.current||!uJ(A.current,lJ(Qq(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){uJ(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function oe(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[AJ.swipeMovementX]:`0px`,[AJ.swipeMovementY]:`0px`};let e=y.x-S.x,t=y.y-S.y;return{transition:p?`none`:void 0,transform:p?`translateX(${y.x}px) translateY(${y.y}px) scale(${S.scale})`:void 0,[AJ.swipeMovementX]:`${e}px`,[AJ.swipeMovementY]:`${t}px`}}let se=n.priority===`high`,ce={role:se?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":se&&!B?!0:void 0,onPointerDown:l?H:void 0,onPointerMove:l?re:void 0,onPointerUp:l?ie:void 0,onKeyDown:ae,inert:bJ(n.limited),style:{...oe(),[AJ.index]:n.transitionStatus===`ending`?ee:R,[AJ.offsetY]:`${z}px`,[AJ.height]:n.height?`${n.height}px`:void 0}},le=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:V,index:ee,visibleIndex:R,expanded:te}),[n,w,E,p,d,V,ee,R,te]),ue={transitionStatus:n.transitionStatus,expanded:te,limited:n.limited||!1,type:n.type,swiping:le.swiping,swipeDirection:le.swipeDirection},de=EW(`div`,e,{ref:[t,le.rootRef],state:ue,stateAttributesMapping:jJ,props:[ce,o]});return(0,W.jsx)(xJ.Provider,{value:le,children:de})}),zJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=SJ(),l=a??s.description,u=!!l,d=FW(i);eW(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=EW(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),BJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=SJ(),l=a??s.title,u=!!l,d=FW(i);eW(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=EW(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),VJ=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=tq(),{toast:c}=SJ(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=GW({disabled:i,native:a}),m={type:c.type};return EW(`button`,e,{ref:[t,p],state:m,props:[{"aria-hidden":!l&&!u,onClick(){s.closeToast(c.id)},onFocus(){d(!0)},onBlur(){d(!1)}},o,f]})});function HJ(){let e=x.useContext(eq);if(!e)throw Error(oW(73));let t=e.useState(`toasts`);return x.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function UJ(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||Zq(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{...n,id:e}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var WJ=5e3,GJ=UJ();function KJ({toast:e}){return(0,W.jsxs)(RJ,{toast:e,className:IK(`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:[(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(BJ,{className:IK(`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&&(0,W.jsx)(zJ,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,W.jsx)(VJ,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,W.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:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function qJ(){let{toasts:e}=HJ();return(0,W.jsx)(W.Fragment,{children:e.map(e=>(0,W.jsx)(KJ,{toast:e},e.id))})}function JJ(){return(0,W.jsxs)(gJ,{timeout:WJ,toastManager:GJ,children:[(0,W.jsx)(qJ,{}),(0,W.jsx)(yJ,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var YJ=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],XJ=3e3,ZJ=8e3,QJ=15e3,$J=5e3,eY=2e4,tY=1e4,nY=1500,rY=5e3,iY=750,aY=4,oY=5e3,sY=new class{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.lastConnectTs=0,this.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{if(QT(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,QT(`ws_resume`,{gapMs:t,...this.wsSnap()},`info`),this.ws?.readyState===WebSocket.OPEN?this.verifyConnection():this.forceReconnect(`visibilitychange`,!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null)},this.onPageShow=e=>{QT(`ws_pageshow`,{persisted:e.persisted,...this.wsSnap()},`info`),e.persisted&&(this.lastTick=Date.now(),this.forceReconnect(`pageshow`,!0))}}wsSnap(){return{status:this.status,ws:this.ws?YJ[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){let e=this.ws.readyState===WebSocket.OPEN;if(e&&this.status===`connected`){QT(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){QT(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}QT(`ws_connect_destroy_zombie`,{reason:e?`open_desynced`:`not_open`,...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus(`connecting`);let e=`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/ws`;QT(`ws_connect`,{url:e,resume:this.isResumeAttempt,...this.wsSnap()},`info`);let t=new WebSocket(e);this.ws=t,this.lastConnectTs=Date.now(),this.leakedSockets.add(t);let n=this.isResumeAttempt?ZJ:XJ;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(QT(`ws_connect_timeout`,{wsState:YJ[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){QT(`ws_onopen_stale`,this.wsSnap(),`info`);return}QT(`ws_onopen`,this.wsSnap(),`info`),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.connectionEpoch+=1,this.leakedSockets.delete(t),this.setStatus(`connected`),this.startHeartbeat()},t.onmessage=e=>{try{let t=e.data,n=performance.now(),r=JSON.parse(t),i=performance.now()-n,a=r;if(a._parseMs=Math.round(i),a._rawLength=t.length,r.type===`pong`){r.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),QT(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(rY)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(QT(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){QT(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}QT(`ws_onclose`,{code:e.code,reason:e.reason,clean:e.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),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(()=>{let e=Date.now(),t=e-this.lastTick;this.isHidden()||(t>QJ&&(QT(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},$J))}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(e){if(this.ws?.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return QT(`ws_send_error`,{messageType:e.type,error:t instanceof Error?t.message:String(t),...this.wsSnap()},`info`),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}subscribeStatus(e){return this.statusListeners.add(e),e(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(e)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;let e=this.pingSeq,t=this.ws;if(QT(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){QT(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(QT(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},nY)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){QT(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){QT(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){QT(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,QT(`ws_force_reconnect`,{trigger:e,force:t,...this.wsSnap()},`info`),this.reconnectAttempts=0,this.consecutiveFailures=0,this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),t?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},iY)):this.connect()}startHeartbeat(e){this.stopHeartbeat();let t=()=>{this.ws?.readyState===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:`ping`,seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,QT(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},tY)))};e!==void 0&&e<eY?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,eY)},e):this.heartbeatTimer=window.setInterval(t,eY)}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(e,t=null){this.status=e,this.error=t,this.statusListeners.forEach(n=>n(e,t,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){QT(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=aY){QT(`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()},oY);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);QT(`ws_schedule_reconnect`,{delay:e,...this.wsSnap()}),this.setStatus(`reconnecting`),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}isHidden(){return typeof document<`u`&&document.visibilityState===`hidden`}clearConnectTimer(){this.connectTimer&&=(window.clearTimeout(this.connectTimer),null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;let e=this.ws;this.ws=null,this.leakedSockets.add(e),e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){QT(`ws_purge_leaked`,{count:this.leakedSockets.size},`info`);for(let e of this.leakedSockets)try{e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,e.close()}catch{}this.leakedSockets.clear()}}};function cY(){let e=qm(e=>e.setConnectionState);return(0,x.useEffect)(()=>{sY.connect(),sY.startLifecycleListeners();let t=sY.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),sY.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{sY.send(e)},[]),subscribe:(0,x.useMemo)(()=>sY.subscribe.bind(sY),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>sY.getConnectionEpoch(),[])}}var lY=100;function uY({viewport:e,win:t,doc:n}){if(!e)return!1;let r=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+r),o=Math.max(0,a),s=Math.max(0,e.height||0),c=Math.max(0,e.width||0);return n.documentElement.style.setProperty(`--keyboard-inset`,`${o}px`),n.documentElement.style.setProperty(`--viewport-offset-top`,`${r}px`),n.documentElement.style.setProperty(`--viewport-offset-left`,`${i}px`),n.documentElement.style.setProperty(`--visual-viewport-height`,`${s}px`),n.documentElement.style.setProperty(`--visual-viewport-width`,`${c}px`),o>lY?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function dY(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 fY(){(0,x.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=null,n=null,r=()=>{let e=document.activeElement;if(!e)return!1;let t=e.tagName?.toLowerCase();return t===`input`||t===`textarea`?!0:!!e.isContentEditable},i=()=>{uY({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!=`function`){i();return}t!==null&&window.cancelAnimationFrame(t);let e=performance.now(),n=()=>{i(),t=performance.now()-e<1500?window.requestAnimationFrame(n):null};t=window.requestAnimationFrame(n)},o=()=>{if(!r()){c();return}i()},s=()=>{n!==null||typeof window.setInterval!=`function`||(n=window.setInterval(o,250),o())},c=()=>{n===null||typeof window.clearInterval!=`function`||(window.clearInterval(n),n=null)},l=()=>{r()?(a(),s(),i()):c()},u=()=>{l()},d=()=>{l()},f=()=>{a()};return i(),l(),e.addEventListener(`resize`,i),e.addEventListener(`scroll`,i),typeof window.addEventListener==`function`&&(window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,f)),typeof document.addEventListener==`function`&&(document.addEventListener(`focusin`,u),document.addEventListener(`focusout`,d),document.addEventListener(`focus`,u,!0),document.addEventListener(`blur`,d,!0)),()=>{e.removeEventListener(`resize`,i),e.removeEventListener(`scroll`,i),typeof window.removeEventListener==`function`&&(window.removeEventListener(`resize`,i),window.removeEventListener(`orientationchange`,f)),typeof document.removeEventListener==`function`&&(document.removeEventListener(`focusin`,u),document.removeEventListener(`focusout`,d),document.removeEventListener(`focus`,u,!0),document.removeEventListener(`blur`,d,!0)),t!==null&&typeof window.cancelAnimationFrame==`function`&&window.cancelAnimationFrame(t),c(),dY(document)}},[])}function pY(e,t,n){let r=e;return t.length>0&&(r=r.filter(e=>t.includes(e.projectPath))),n.length>0&&(r=r.filter(e=>n.includes(e.host??``))),r}function mY(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(void 0),[i,a]=(0,x.useState)(void 0),[o,s]=(0,x.useState)(void 0),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null),g=qm(e=>e.sessions),_=qm(e=>e.agentSessions),v=qm(e=>e.agentSessionsEpoch),y=qm(e=>e.selectedSessionId),b=qm(e=>e.selectedHibernatingSessionId),S=qm(e=>e.setSessions),C=qm(e=>e.setAgentSessions),w=qm(e=>e.setActiveAgentSessions),T=qm(e=>e.setHostStatuses),E=qm(e=>e.updateSession),D=qm(e=>e.setSelectedSessionId),O=qm(e=>e.setSelectedHibernatingSessionId),k=qm(e=>e.hasLoaded),A=qm(e=>e.connectionStatus),j=qm(e=>e.connectionError),M=qm(e=>e.clearExitingSession),N=qm(e=>e.markSessionExiting),P=qm(e=>e.setRemoteAllowControl),F=qm(e=>e.setRemoteAllowAttach),I=qm(e=>e.setHostLabel),L=qm(e=>e.setPreferWindowName),ee=qm(e=>e.hostStatuses),R=qm(e=>e.remoteAllowControl),z=qm(e=>e.hostLabel),B=BH(e=>e.theme),te=re(),V=H(e=>e.defaultProjectDir),ne=H(e=>e.commandPresets),ie=H(e=>e.defaultPresetId),ae=H(e=>e.lastProjectPath),oe=H(e=>e.setLastProjectPath),se=H(e=>e.addRecentPath),ce=H(e=>e.shortcutModifier),le=H(e=>e.sidebarWidth),ue=H(e=>e.setSidebarWidth),de=H(e=>e.projectFilters),fe=H(e=>e.hostFilters),pe=H(e=>e.soundOnPermission),me=H(e=>e.soundOnIdle),he=qm(e=>e.connectionEpoch),{sendMessage:ge,subscribe:_e,getConnectionEpoch:ve}=cY();fY(),(0,x.useEffect)(()=>{if(typeof document>`u`||!pe&&!me)return;let e=!1,t=()=>{e&&!WK()||(e=!0,KK())};return document.addEventListener(`click`,t,{passive:!0}),document.addEventListener(`keydown`,t,{passive:!0}),document.addEventListener(`touchstart`,t,{passive:!0}),()=>{document.removeEventListener(`click`,t),document.removeEventListener(`keydown`,t),document.removeEventListener(`touchstart`,t)}},[pe,me]);let ye=(0,x.useRef)(!1),be=(0,x.useCallback)(e=>{e.preventDefault(),ye.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]);(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=e=>{if(!ye.current)return;let t=e.clientX;ue(Math.max(180,Math.min(400,t)))},t=()=>{ye.current&&(ye.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[ue]),(0,x.useEffect)(()=>{let e=_e(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=qm.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=H.getState();if(n||r)for(let i of e.sessions){let e=t.find(e=>e.id===i.id);e&&e.status!==i.status&&(e.status!==`permission`&&i.status===`permission`&&n&&YK(),e.status===`working`&&i.status===`waiting`&&r&&XK())}if(Ie.current.size>0){let e=ve();for(let[t,n]of Ie.current)n.epoch!==e&&Ie.current.delete(t)}let i=Ie.current.size>0?e.sessions.filter(e=>!Ie.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=qm.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(Me.current=s),S(i);let c=Ne.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=qm.getState(),{projectFilters:d,hostFilters:f}=H.getState();if(c&&l===null&&u===null){let e=i.find(e=>!(e.agentSessionId?.trim()!==c||d.length>0&&!d.includes(e.projectPath)||f.length>0&&!f.includes(e.host??``)));e&&(Ne.current=null,D(e.id))}}if(e.type===`host-status`&&T(e.hosts),e.type===`server-config`&&(P(e.remoteAllowControl),F(e.remoteAllowAttach),I(e.hostLabel),L(e.preferWindowName),e.clientLogLevel&&ZT(e.clientLogLevel)),e.type===`session-update`){let t=qm.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=H.getState();t!==`permission`&&n===`permission`&&e&&YK(),t===`working`&&n===`waiting`&&r&&XK()}}if(e.type===`session-created`){let t=qm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),se(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=H.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){dH(e.sessionId);let t=qm.getState().sessions,n=t.filter(t=>t.id!==e.sessionId);n.length!==t.length&&S(n)}if(e.type===`agent-sessions`){let t=Array.isArray(e.active)?e.active:[],n=Array.isArray(e.hibernating)?e.hibernating:[],r=Array.isArray(e.history)?e.history:[],{selectedHibernatingSessionId:i}=qm.getState(),a=Me.current;i&&!n.some(e=>e.sessionId===i)&&(Ne.current=i),C(t,n,r),h(e=>e&&n.some(t=>t.sessionId===e.sessionId)?null:e),a&&n.some(e=>e.sessionId===a)?(Me.current=null,O(a)):a&&(Me.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=qm.getState().sessions,n=t.filter(t=>t.agentSessionId?.trim()!==e.session.sessionId);n.length!==t.length&&S(n)}if(e.type===`session-activated`){let t=qm.getState().sessions.find(t=>t.tmuxWindow===e.window);t&&E({...t,agentSessionId:e.session.sessionId,agentSessionName:e.session.displayName,logFilePath:e.session.logFilePath,isPinned:e.session.isPinned,lastUserMessage:e.session.lastUserMessage??t.lastUserMessage})}if(e.type===`session-wake-result`)if(e.ok&&e.session){h(t=>t?.sessionId===e.sessionId?null:t);let t=qm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id)}else e.ok||(d(`${e.error?.code}: ${e.error?.message}`),window.setTimeout(()=>d(null),6e3));if(e.type===`session-hibernate-result`&&(e.ok?(e.session&&h(e.session),O(e.sessionId)):(d(e.error??`Failed to hibernate session`),window.setTimeout(()=>d(null),6e3))),e.type===`terminal-error`&&(!e.sessionId||e.sessionId===y)&&(d(`${e.code}: ${e.message}`),window.setTimeout(()=>d(null),6e3)),e.type===`terminal-ready`&&e.sessionId===y&&d(null),e.type===`error`&&(d(e.message),window.setTimeout(()=>d(null),6e3)),e.type===`kill-failed`){let t=Ie.current.get(e.sessionId);if(t){let n=qm.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),Ie.current.delete(e.sessionId)}M(e.sessionId),d(e.message),window.setTimeout(()=>d(null),6e3)}e.type===`session-move-to-history-result`&&!e.ok&&e.error&&(d(e.error),window.setTimeout(()=>d(null),6e3))}});return()=>{e()}},[y,b,se,M,ge,D,O,h,S,C,w,T,P,F,I,L,_e,E]);let xe=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),Se=_.hibernating??[],Ce=_.history??[],we=(0,x.useMemo)(()=>pY(Se,de,fe),[Se,de,fe]),Te=(0,x.useMemo)(()=>we.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[we,m,b]);(0,x.useEffect)(()=>{xe?.projectPath&&!xe.remote&&oe(xe.projectPath)},[xe?.projectPath,xe?.remote,oe]);let Ee=H(e=>e.sessionSortMode),De=H(e=>e.sessionSortDirection),Oe=H(e=>e.manualSessionOrder),ke=(0,x.useMemo)(()=>Mm(g,{mode:Ee,direction:De,manualOrder:Oe}),[g,Ee,De,Oe]),Ae=(0,x.useMemo)(()=>{let e=ke;return de.length>0&&(e=e.filter(e=>de.includes(e.projectPath))),fe.length>0&&(e=e.filter(e=>fe.includes(e.host??``))),e},[ke,de,fe]),je=(0,x.useRef)(b),Me=(0,x.useRef)(null),Ne=(0,x.useRef)(null),Pe=(0,x.useRef)(he),Fe=(0,x.useCallback)(()=>Ae.length>0?(D(Ae[0].id),!0):we.length>0?(O(we[0].sessionId),!0):!1,[Ae,we,D,O]);(0,x.useEffect)(()=>{let e=je.current;e&&b===null&&!Se.some(t=>t.sessionId===e)?Ne.current=e:b!==null&&(Ne.current=null),je.current=b},[Se,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{Pe.current!==he&&(Pe.current=he,Me.current=null,Ne.current=null,h(null))},[he]),(0,x.useEffect)(()=>{k&&(b||y&&(Ae.some(e=>e.id===y)||Fe()||D(null)))},[k,y,b,Fe,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==he||we.some(e=>e.sessionId===b))return;let e=Ae.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Fe()||O(null)},[we,Ae,v,m,b,Fe,D,O,he]),(0,x.useEffect)(()=>{let e=Ne.current;if(!e)return;if(b!==null){Ne.current=null;return}let t=Ae.find(t=>t.agentSessionId?.trim()===e);if(t){Ne.current=null,D(t.id);return}if(y!==null){Ne.current=null;return}Fe()&&(Ne.current=null)},[Ae,y,b,Fe,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(Ae.length>0||we.length>0)&&Fe()},[we.length,Ae.length,k,Fe,y,b]);let Ie=(0,x.useRef)(new Map),Le=(0,x.useCallback)((e,t=`unknown`)=>{dH(e);let{sessions:n,selectedSessionId:r}=qm.getState(),i=n.find(t=>t.id===e);i&&Ie.current.set(e,{session:i,wasSelected:r===e,epoch:ve()}),(0,U.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),ge({type:`session-kill`,sessionId:e,source:t})},[N,S,ge]);(0,x.useEffect)(()=>{let n=qe(ce),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=Xe(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=Ae;if(t.length===0){let t=we;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){O(t[0].sessionId);return}O(t[(n+e+t.length)%t.length].sessionId);return}let n=t.findIndex(e=>e.id===y);if(n===-1){D(t[0].id);return}D(t[(n+e+t.length)%t.length].id);return}if(a&&/^Digit[1-9]$/.test(i)){let e=Number(i.slice(5))-1;if(Ae.length>0){let t=Ae[e];if(!t)return;r.preventDefault(),D(t.id);return}let t=we[e];if(!t)return;r.preventDefault(),O(t.sessionId);return}if(a&&i===`KeyN`){r.preventDefault(),!e&&te&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Le(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,Ae,we,Le,ce,te]);let Re=()=>te?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,ze=()=>l(!0),Be=(e,t,n,r)=>{ge({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||oe(e)},Ve=e=>{ge({type:`session-wake`,sessionId:e})},He=(0,x.useCallback)(e=>{ge({type:`session-hibernate`,sessionId:e})},[ge]),Ue=(e,t)=>{ge({type:`session-rename`,sessionId:e,newName:t})},We=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&ge({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,ge]),Ge=(0,x.useCallback)(e=>{ge({type:`session-move-to-history`,sessionId:e})},[ge]);(0,x.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,B)},[B]),(0,x.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ke=(0,x.useMemo)(()=>z?ee.filter(e=>e.host!==z):ee,[ee,z]);return(0,W.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:le},children:[(0,W.jsx)($e,{connectionStatus:A,onNewSession:Re,onOpenSettings:ze,tailscaleIp:f?.tailscaleIp??null}),(0,W.jsx)(KT,{sessions:g,hibernatingSessions:Se,historySessions:Ce,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:Ue,onResume:Ve,onHibernate:He,onKill:Le,onDuplicate:We,onMoveToHistory:Ge,onNewSession:Re,loading:!k,error:j||u})]}),(0,W.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:be}),(0,W.jsx)(LU,{session:xe,sessions:Ae,hibernatingSession:Te,hibernatingSessions:Se,connectionStatus:A,connectionEpoch:he,sendMessage:ge,subscribe:_e,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Re,onKillSession:Le,onRenameSession:Ue,onOpenSettings:ze,onResumeSession:Ve,onHibernateSession:He,onMoveToHistory:Ge,historySessions:Ce,loading:!k,error:j||u}),(0,W.jsx)(zU,{isOpen:e,onClose:()=>t(!1),onCreate:Be,defaultProjectDir:V,commandPresets:ne,defaultPresetId:ie,lastProjectPath:ae,activeProjectPath:xe&&!xe.remote?xe.projectPath:void 0,remoteHosts:Ke,remoteAllowControl:R,initialHost:n,initialPath:i,initialCommand:o}),(0,W.jsx)(ZK,{isOpen:c,onClose:()=>l(!1)}),(0,W.jsx)(JJ,{})]})}var hY=`modulepreload`,gY=function(e){return`/`+e},_Y={},vY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=gY(t,n),t in _Y)return;_Y[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:hY,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},yY=`true`,bY=`false`,xY=yY===`true`,SY=bY===`true`;function CY(e={}){let{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:a,onRegisterError:o}=e,s,c,l,u=async(e=!0)=>{await c,xY||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await vY(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bq4GJJid.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{o?.(e)}),!s)return;if(l=()=>{s?.messageSkipWaiting()},!SY)if(xY)s.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),s.addEventListener(`installed`,e=>{e.isUpdate||r?.()});else{let e=!1,t=()=>{e=!0,s?.addEventListener(`controlling`,e=>{e.isUpdate&&window.location.reload()}),n?.()};s.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&r?.():n.isExternal?t():!e&&r?.():n.isUpdate||r?.()}),s.addEventListener(`waiting`,t)}s.register({immediate:t}).then(e=>{a?a(`/sw.js`,e):i?.(e)}).catch(e=>{o?.(e)})}}return c=d(),u}We()&&document.documentElement.classList.add(`ios`),Ge()&&document.documentElement.classList.add(`ios-pwa`),CY({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var wY=document.getElementById(`root`);if(!wY)throw Error(`Root element not found`);(0,E.createRoot)(wY).render((0,W.jsx)(x.StrictMode,{children:(0,W.jsx)(mY,{})}));
|
|
304
|
+
${r?VU[t.status]:BU[t.status]}
|
|
305
|
+
`,onClick:()=>{HU(),u(t.id)},title:lt?t.name:void 0,children:i},t.id)})})]}),(0,W.jsxs)(`div`,{className:`relative flex-1`,children:[(0,W.jsx)(`div`,{ref:we,className:`absolute inset-0`,style:{backgroundColor:S.background}}),Me&&e&&(0,W.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`absolute top-2 left-2 z-50 flex items-center gap-1.5 rounded-lg bg-black/60 px-2.5 py-1.5 text-xs text-white/90 shadow-lg backdrop-blur-md`,children:[(0,W.jsxs)(`svg`,{className:`h-3 w-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,W.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,W.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),Fe&&e&&(0,W.jsxs)(`div`,{className:`absolute ${j&&!N?`bottom-20`:`bottom-8`} left-1/2 z-30 flex max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2 rounded-lg border border-border bg-elevated/95 px-2 py-2 shadow-lg backdrop-blur-sm md:left-auto md:right-4 md:translate-x-0`,children:[(0,W.jsx)(`span`,{className:`max-w-[12rem] truncate text-xs text-secondary md:max-w-[18rem]`,children:`Selection ready`}),(0,W.jsxs)(`button`,{type:`button`,onClick:Ie,className:`flex h-8 shrink-0 items-center justify-center gap-1.5 rounded bg-accent px-2.5 text-xs font-medium text-white hover:bg-accent/90 active:scale-95 transition-all`,title:`Copy selection`,"aria-label":`Copy selection`,children:[(0,W.jsx)(de,{width:14,height:14}),`Copy`]}),(0,W.jsx)(`button`,{type:`button`,onClick:Re,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all`,title:`Dismiss`,"aria-label":`Dismiss`,children:(0,W.jsx)(Ue,{width:14,height:14})})]}),!e&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted`,children:n?null:`Select a session to view terminal`}),e&&ve&&(0,W.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-center text-sm text-muted`,children:`Remote session (read-only). Use SSH to attach on the host.`}),n&&(0,W.jsx)(`div`,{className:`absolute inset-0 z-10 overflow-y-auto bg-base`,children:(0,W.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-5xl flex-col gap-4 p-4 md:p-6`,children:[(0,W.jsx)(`div`,{className:`border-b border-border pb-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(0,W.jsx)(`h2`,{className:`min-w-0 truncate text-lg font-semibold text-primary`,children:be}),(0,W.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-blue-400`,children:`Hibernating`}),xe&&(0,W.jsx)(`span`,{className:`text-muted`,children:xe}),(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Last active `,Se]})]}),n.lastResumeError&&(0,W.jsxs)(`div`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/15 px-2 py-1 text-xs text-amber-400`,title:`Last wake failed: ${n.lastResumeError}`,children:[(0,W.jsx)(ae,{width:12,height:12}),`Last wake failed`]}),n.lastUserMessage&&(0,W.jsx)(`p`,{className:`max-h-28 max-w-3xl overflow-y-auto whitespace-pre-wrap break-words pr-2 text-sm leading-6 text-secondary`,children:n.lastUserMessage})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary hidden md:inline-flex`,children:`Wake`}),_&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,W.jsx)(HT,{session:n})]})}),ke&&e&&!N?(0,W.jsxs)(`button`,{type:`button`,onClick:ze,className:`absolute bottom-14 left-1/2 z-20 flex h-10 items-center justify-center overflow-hidden rounded-full border border-amber-400/35 bg-amber-500/20 text-amber-100 shadow-lg backdrop-blur-sm transition-all hover:bg-amber-500/30 active:scale-95 md:bottom-8`,style:{transform:`translateX(-50%)`},title:`Exit tmux copy mode and return to live output`,"aria-label":`Exit copy mode`,children:[(0,W.jsx)(`span`,{className:`px-3 text-[11px] font-semibold uppercase tracking-wide`,children:`Copy mode`}),(0,W.jsx)(`span`,{className:`self-stretch border-l border-amber-400/25`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`px-3 text-sm font-medium`,children:`Exit`})]}):j&&e&&!N?(0,W.jsxs)(`button`,{type:`button`,onClick:ze,className:`absolute bottom-8 left-1/2 z-20 flex h-10 px-4 items-center justify-center gap-1.5 rounded-full bg-blue-600/90 text-white shadow-lg hover:bg-blue-600 active:scale-95 transition-all`,style:{transform:`translateX(-50%)`},title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:[(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,W.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]}):null]}),(0,W.jsx)(SU,{...ot}),e&&(0,W.jsx)(IU,{onSendKey:nt,onPasteText:rt,onPasteImage:it,disabled:a!==`connected`||ve||!Pe,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,agentType:e.agentType,fileUploadsAllowed:!fe,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:at,isKeyboardVisible:ct,onEnterTextMode:st}),(A||k)&&(0,W.jsx)(LU,{isOpen:z,onClose:()=>B(!1),sessions:t,hibernatingSessions:r,historySessions:i,selectedSessionId:e?.id??null,selectedHibernatingSessionId:n?.sessionId??null,onSelect:u,onSelectHibernating:d,onRename:m,onResume:h,onHibernate:g,onMoveToHistory:_,onNewSession:f,loading:y,error:b}),F&&e&&(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,W.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,W.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,W.jsxs)(`p`,{className:`text-sm text-secondary mb-4 text-pretty`,children:[`Kill "`,e.agentSessionName||e.name,`"? The process will be terminated. Conversation history is preserved in logs.`]}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,W.jsx)(`button`,{ref:ce,onClick:He,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function WU({onSelect:e,onCancel:t,initialPath:n}){let[r,i]=(0,x.useState)(n||`~`),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!0),[d,f]=(0,x.useState)(-1),p=(0,x.useRef)(null),m=H(e=>e.recentPaths),h=(0,x.useCallback)(async e=>{p.current?.abort();let t=new AbortController;p.current=t;let{signal:n}=t;u(!0),c(null),o(null),f(-1),i(e);try{let r=await fetch(`/api/directories?path=${encodeURIComponent(e)}`,{signal:n});if(!r.ok){let e=await r.json();throw Error(e.message||`Failed to load directory`)}let a=await r.json();if(p.current!==t)return;o(a),i(a.path)}catch(e){if(p.current!==t)return;let n=e;n?.name!==`AbortError`&&c(n?.message||`Failed to load directory`)}finally{p.current===t&&u(!1)}},[]);(0,x.useEffect)(()=>(h(n||`~`),()=>{p.current?.abort()}),[h,n]);let g=a?.directories??[],_=a?.path||r,v=a?.parent;return(0,x.useEffect)(()=>{let n=n=>{if(n.key===`Escape`){n.preventDefault(),t();return}if(!l){if(n.key===`ArrowDown`){n.preventDefault(),f(e=>g.length===0?-1:e<0?0:Math.min(e+1,g.length-1));return}if(n.key===`ArrowUp`){n.preventDefault(),f(e=>g.length===0?-1:e<0?g.length-1:Math.max(e-1,0));return}if(n.key===`Enter`){n.preventDefault();let t=g[d];t?h(t.path):_&&e(_);return}n.key===`Backspace`&&v&&(n.preventDefault(),h(v))}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[g,_,h,d,l,t,e,v]),(0,W.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Directory browser`,className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},"data-testid":`directory-browser`,children:(0,W.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,W.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,W.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,W.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,W.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,W.jsx)(`p`,{className:`text-danger`,children:s}),(0,W.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,W.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>h(e.path),onMouseEnter:()=>f(t),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs ${t===d?`bg-hover text-primary`:`text-secondary`}`,"data-testid":`directory-entry`,"data-entry-name":e.name,"data-entry-path":e.path,children:[(0,W.jsx)(xe,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,W.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,W.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,W.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,W.jsx)(`button`,{type:`button`,className:`block w-full truncate text-left text-xs text-secondary hover:text-primary`,onClick:()=>h(e),title:e,"data-testid":`directory-recent`,"data-recent-path":e,children:e},e))})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function GU({isOpen:e,onClose:t,onCreate:n,defaultProjectDir:r,commandPresets:i,defaultPresetId:a,lastProjectPath:o,activeProjectPath:s,remoteHosts:c=[],remoteAllowControl:l=!1,initialHost:u,initialPath:d,initialCommand:f}){let[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(``),[S,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=l&&c.length>0;if((0,x.useEffect)(()=>{if(!e){m(``),g(``),v(null),b(``),C(!1),T(u??``),setTimeout(()=>{if(typeof document>`u`||typeof document.querySelector!=`function`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300);return}if(typeof document<`u`&&typeof document.querySelector==`function`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}m(d?.trim()||s?.trim()||o||r||``),g(``),T(u??``);let t=f?.trim();if(t){let e=i.find(e=>te(e)===t);e?(v(e.id),b(te(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(te(e))):i.length>0?(v(i[0].id),b(te(i[0]))):(v(null),b(``))}setTimeout(()=>{if(O.current?.focus(),D.current){let e=D.current;e.scrollLeft=e.scrollWidth}},50)},[s,i,a,r,e,o,u,d,f]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=()=>E.current?Array.from(E.current.querySelectorAll(`input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]`)):[],r=e=>{if(!S){if(e.key===`Escape`){typeof e.stopPropagation==`function`&&e.stopPropagation(),t();return}if(e.key===`Enter`){let t=document.activeElement;if(!t||t.tagName===`INPUT`||t.closest(`[data-testid="host-select"]`)||!t.closest(`[data-testid="command-select"]`))return;e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation(),E.current?.requestSubmit();return}if(e.key===`Tab`){e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation();let t=n();if(t.length===0)return;let r=document.activeElement,i=t.indexOf(r),a;a=i===-1?e.shiftKey?t.length-1:0:e.shiftKey?i<=0?t.length-1:i-1:i>=t.length-1?0:i+1,t[a]?.focus()}}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,S]),!e)return null;let A=e=>{let t=i.find(t=>t.id===e);t&&(v(e),b(te(t)))},j=()=>{v(null),b(``)},M=_===null,N=w!==``,P=e=>{e.preventDefault();let r=p.trim();if(!r)return;let i=y.trim();n(r,h.trim()||void 0,i||void 0,N?w:void 0),t()},F=[...i.map(e=>({id:e.id,label:e.label,isCustom:!1,agentType:e.agentType,command:e.command})),{id:`custom`,label:`Custom`,isCustom:!0,agentType:void 0,command:void 0}],I=[{id:``,label:`Local`,ok:!0,error:void 0},...c.map(e=>({id:e.host,label:e.host,ok:e.ok,error:e.error}))],L=p.trim()||`~`;return(0,W.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:[(0,W.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,W.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,W.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Host`,"data-testid":`host-select`,children:I.map((e,t)=>{let n=w===e.id,r=!e.ok&&!n;return(0,W.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e.label,title:e.ok?void 0:e.error||`Unreachable`,tabIndex:n?0:-1,onClick:()=>T(e.id),onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%I.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+I.length)%I.length;else return;let r=I[n];T(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``} ${r?`opacity-60`:``}`,children:e.label},e.id||`local`)})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Command preset`,"data-testid":`command-select`,children:F.map((e,t)=>{let n=e.isCustom?M:_===e.id;return(0,W.jsxs)(`button`,{ref:n?O:void 0,type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,onClick:()=>{e.isCustom?j():A(e.id)},onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%F.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+F.length)%F.length;else return;let r=F[n];r.isCustom?j():A(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``}`,children:[(0,W.jsx)(eh,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,W.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`input`,{ref:D,value:p,onChange:e=>m(e.target.value),placeholder:N?`/home/user/project`:s||o||r||`/Users/you/code/my-project`,className:`input flex-1 text-sm`}),!N&&(0,W.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,W.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,W.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,W.jsx)(WU,{initialPath:L,onSelect:e=>{m(e),C(!1)},onCancel:()=>C(!1)})]})}function KU({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=x.useRef(e!==void 0),[a,o]=x.useState(t);return[i?e:a,x.useCallback(e=>{i||o(e)},[])]}var qU={};function JU(e,t){let n=x.useRef(qU);return n.current===qU&&(n.current=e(t)),n}var YU=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],XU=YU&&YU!==x.useLayoutEffect?YU:e=>e();function ZU(e){let t=JU(QU).current;return t.next=e,XU(t.effect),t.trampoline}function QU(){let e={next:void 0,callback:$U,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function $U(){}function eW(e,t,n,r){let i=JU(nW).current;return rW(i,e,t,n,r)&&aW(i,[e,t,n,r]),i.callback}function tW(e){let t=JU(nW).current;return iW(t,e)&&aW(t,e),t.callback}function nW(){return{callback:null,cleanup:null,refs:[]}}function rW(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function iW(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function aW(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var oW=typeof document<`u`?x.useLayoutEffect:()=>{},sW={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},cW={...sW,position:`fixed`,top:0,left:0},lW={...sW,position:`absolute`};function uW(){}Object.freeze([]);var dW=Object.freeze({});function fW(e,...t){let n=new URL(`https://base-ui.com/production-error`);return n.searchParams.set(`code`,e.toString()),t.forEach(e=>n.searchParams.append(`args[]`,e)),`Base UI error #${e}; visit ${n} for the full message.`}var pW=18;function mW(e){return pW>=e}function hW(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return(mW(19)?n?.ref:t.ref)??null}function gW(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function _W(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function vW(e,t){return typeof e==`function`?e(t):e}function yW(e,t){return typeof e==`function`?e(t):e}var bW={};function xW(e,t,n,r,i){let a={...DW(e,bW)};return t&&(a=CW(a,t)),n&&(a=CW(a,n)),r&&(a=CW(a,r)),i&&(a=CW(a,i)),a}function SW(e){if(e.length===0)return bW;if(e.length===1)return DW(e[0],bW);let t={...DW(e[0],bW)};for(let n=1;n<e.length;n+=1)t=CW(t,e[n]);return t}function CW(e,t){return EW(t)?t(e):wW(e,t)}function wW(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=gW(e.style,r);break;case`className`:e[n]=AW(e.className,r);break;default:TW(n,r)?e[n]=OW(e[n],r):e[n]=r}}return e}function TW(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function EW(e){return typeof e==`function`}function DW(e,t){return EW(e)?e(t):e??bW}function OW(e,t){return t?e?n=>{if(jW(n)){let r=n;kW(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function kW(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function AW(e,t){return t?e?t+` `+e:t:e}function jW(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function MW(e,t,n={}){let r=t.render,i=NW(t,n);return n.enabled===!1?null:FW(e,r,i,n.state??dW)}function NW(e,t={}){let{className:n,style:r,render:i}=e,{state:a=dW,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?vW(n,a):void 0,d=l?yW(r,a):void 0,f=l?_W(a,c):dW,p=l?gW(f,Array.isArray(s)?SW(s):s)??dW:dW;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=tW([p.ref,hW(i),...o]):p.ref=eW(p.ref,hW(i),o):eW(null,null)),l?(u!==void 0&&(p.className=AW(p.className,u)),d!==void 0&&(p.style=gW(p.style,d)),p):dW}var PW=Symbol.for(`react.lazy`);function FW(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=xW(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===PW&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return IW(e,n);throw Error(fW(8))}function IW(e,t){return e===`button`?(0,x.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,x.createElement)(`img`,{alt:``,...t,key:t.key}):x.createElement(e,t)}var LW={...x},RW=0;function zW(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(RW+=1,r(`${t}-${RW}`))},[n,t]),i}var BW=LW.useId;function VW(e,t){if(BW!==void 0){let n=BW();return e??(t?`${t}-${n}`:n)}return zW(e,t)}function HW(e){return VW(e,`base-ui`)}function UW(){return typeof window<`u`}function WW(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function GW(e){return UW()?e instanceof Element||e instanceof WW(e).Element:!1}function KW(e){return UW()?e instanceof HTMLElement||e instanceof WW(e).HTMLElement:!1}function qW(e){return!UW()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof WW(e).ShadowRoot}var JW=x.createContext(void 0);function YW(e=!1){let t=x.useContext(JW);if(t===void 0&&!e)throw Error(fW(16));return t}function XW(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:x.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function ZW(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=YW(!0)!==void 0,s=ZU(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=XW({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;QW(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return oW(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return xW({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(kW(e),o?.(e)),e.baseUIHandlerPrevented)return;let r=e.target===e.currentTarget&&!i&&!s()&&!t,a=e.key===`Enter`,c=e.key===` `;r&&((c||a)&&e.preventDefault(),a&&n?.(e))},onKeyUp(e){t||(kW(e),a?.(e)),!e.baseUIHandlerPrevented&&e.target===e.currentTarget&&!i&&!t&&e.key===` `&&n?.(e)},onPointerDown(e){if(t){e.preventDefault();return}l?.(e)}},i?void 0:{role:`button`},c,u)},[t,c,i,s]),buttonRef:ZU(e=>{a.current=e,l()})}}function QW(e){return KW(e)&&e.tagName===`BUTTON`}var $W=x.createContext(void 0);function eG(){let e=x.useContext($W);if(e===void 0)throw Error(fW(63));return e}var tG=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),nG={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},rG={valid(e){return e===null?null:e?{[tG.valid]:``}:{[tG.invalid]:``}}},iG=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),aG={...rG,checked(e){return e?{[iG.checked]:``}:{[iG.unchecked]:``}}};function oG(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var sG=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:uW,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function cG(){return x.useContext(sG)}var lG=x.createContext({invalid:void 0,name:void 0,validityData:{state:nG,errors:[],error:``,value:``,initialValue:null},setValidityData:uW,disabled:void 0,touched:!1,setTouched:uW,dirty:!1,setDirty:uW,filled:!1,setFilled:uW,focused:!1,setFocused:uW,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=dW)=>e,getInputValidationProps:(e=dW)=>e,inputRef:{current:null},commit:async()=>{}}});function uG(e=!0){let t=x.useContext(lG);if(t.setValidityData===uW&&!e)throw Error(fW(28));return t}function dG(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=cG(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=uG(),f=ZU(e.getValue);oW(()=>{if(!t)return;let e=n;e===void 0&&(e=f()),u.initialValue===null&&e!==null&&d(t=>({...t,initialValue:e}))},[t,d,n,u.initialValue,f]),oW(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:oG(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?U.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),oW(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var fG=x.createContext({controlId:void 0,registerControlId:uW,labelId:void 0,setLabelId:uW,messageIds:[],setMessageIds:uW,getDescriptionProps:e=>e});function pG(){return x.useContext(fG)}function mG(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=pG(),o=HW(t),s=n?i:void 0,c=JU(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=ZU(()=>{!l.current||a===uW||(l.current=!1,a(c.current,void 0))});return oW(()=>{if(a===uW)return;let e;if(n){let n=r?.current;e=GW(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),x.useEffect(()=>d,[d]),i??o}var hG=`none`;function gG(e,t,n,r){let i=!1,a=!1,o=r??dW;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function _G(e,t){let n=x.useRef(e),r=ZU(t);oW(()=>{n.current!==e&&r(n.current)},[e,r]),oW(()=>{n.current=e},[e])}var vG=x.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,id:a,inputRef:o,name:s,nativeButton:c=!1,onCheckedChange:l,readOnly:u=!1,required:d=!1,disabled:f=!1,render:p,uncheckedValue:m,value:h,...g}=e,{clearErrors:_}=cG(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=uG(),{labelId:A}=pG(),j=D||f,M=O??s,N=ZU(l),P=x.useRef(null),F=eW(P,o,k.inputRef),I=x.useRef(null),L=HW(),ee=mG({id:a,implicit:!1,controlRef:I}),R=c?void 0:ee,[z,B]=KU({controlled:n,default:!!i,name:`Switch`,state:`checked`});dG({id:L,commit:k.commit,value:z,controlRef:I,name:M,getValue:()=>z}),oW(()=>{P.current&&C(P.current.checked)},[P,C]),_G(z,()=>{_(M),b(z!==S.initialValue),C(z),T()?k.commit(z):k.commit(z,!0)});let{getButtonProps:te,buttonRef:V}=ZW({disabled:j,native:c}),ne={id:c?ee:L,role:`switch`,"aria-checked":z,"aria-readonly":u||void 0,"aria-required":d||void 0,"aria-labelledby":A,onFocus(){j||w(!0)},onBlur(){let e=P.current;!e||j||(y(!0),w(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){u||j||(e.preventDefault(),P.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},H=x.useMemo(()=>xW({checked:z,disabled:j,id:R,name:M,required:d,style:M?lW:cW,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=gG(hG,e.nativeEvent);N?.(t,n),!n.isCanceled&&B(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?dW:{value:h}),[z,j,F,R,M,N,d,B,k,h]),re=x.useMemo(()=>({...v,checked:z,disabled:j,readOnly:u,required:d}),[v,z,j,u,d]),U=MW(`span`,e,{state:re,ref:[t,I,V],props:[ne,k.getValidationProps,g,te],stateAttributesMapping:aG});return(0,W.jsxs)($W.Provider,{value:re,children:[U,!z&&M&&m!==void 0&&(0,W.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,W.jsx)(`input`,{...H})]})}),yG=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=uG(),o=eG();return MW(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:aG,props:i})});function bG(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=bG(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function xG(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=bG(e))&&(r&&(r+=` `),r+=t);return r}var SG=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},CG=(e,t)=>({classGroupId:e,validator:t}),wG=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),TG=`-`,EG=[],DG=`arbitrary..`,OG=e=>{let t=jG(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return AG(e);let n=e.split(TG);return kG(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?SG(i,t):t:i||EG}return n[e]||EG}}},kG=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=kG(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(TG):e.slice(t).join(TG),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},AG=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?DG+r:void 0})(),jG=e=>{let{theme:t,classGroups:n}=e;return MG(n,t)},MG=(e,t)=>{let n=wG();for(let r in e){let i=e[r];NG(i,n,r,t)}return n},NG=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];PG(i,t,n,r)}},PG=(e,t,n,r)=>{if(typeof e==`string`){FG(e,t,n);return}if(typeof e==`function`){IG(e,t,n,r);return}LG(e,t,n,r)},FG=(e,t,n)=>{let r=e===``?t:RG(t,e);r.classGroupId=n},IG=(e,t,n,r)=>{if(zG(e)){NG(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(CG(n,e))},LG=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];NG(o,RG(t,a),n,r)}},RG=(e,t)=>{let n=e,r=t.split(TG),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=wG(),n.nextPart.set(t,i)),n=i}return n},zG=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,BG=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},VG=`!`,HG=`:`,UG=[],WG=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),GG=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===HG){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(VG)?(c=s.slice(0,-1),l=!0):s.startsWith(VG)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return WG(t,l,c,u)};if(t){let e=t+HG,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):WG(UG,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},KG=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},qG=e=>({cache:BG(e.cacheSize),parseClassName:GG(e),sortModifiers:KG(e),...OG(e)}),JG=/\s+/,YG=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(JG),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+VG:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},XG=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=ZG(n))&&(i&&(i+=` `),i+=r);return i},ZG=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=ZG(e[r]))&&(n&&(n+=` `),n+=t);return n},QG=(e,...t)=>{let n,r,i,a,o=o=>(n=qG(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=YG(e,n);return i(e,a),a};return a=o,(...e)=>a(XG(...e))},$G=[],eK=e=>{let t=t=>t[e]||$G;return t.isThemeGetter=!0,t},tK=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,nK=/^\((?:(\w[\w-]*):)?(.+)\)$/i,rK=/^\d+\/\d+$/,iK=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,aK=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,oK=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sK=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,cK=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lK=e=>rK.test(e),uK=e=>!!e&&!Number.isNaN(Number(e)),dK=e=>!!e&&Number.isInteger(Number(e)),fK=e=>e.endsWith(`%`)&&uK(e.slice(0,-1)),pK=e=>iK.test(e),mK=()=>!0,hK=e=>aK.test(e)&&!oK.test(e),gK=()=>!1,_K=e=>sK.test(e),vK=e=>cK.test(e),yK=e=>!Q(e)&&!$(e),bK=e=>MK(e,IK,gK),Q=e=>tK.test(e),xK=e=>MK(e,LK,hK),SK=e=>MK(e,RK,uK),CK=e=>MK(e,PK,gK),wK=e=>MK(e,FK,vK),TK=e=>MK(e,BK,_K),$=e=>nK.test(e),EK=e=>NK(e,LK),DK=e=>NK(e,zK),OK=e=>NK(e,PK),kK=e=>NK(e,IK),AK=e=>NK(e,FK),jK=e=>NK(e,BK,!0),MK=(e,t,n)=>{let r=tK.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},NK=(e,t,n=!1)=>{let r=nK.exec(e);return r?r[1]?t(r[1]):n:!1},PK=e=>e===`position`||e===`percentage`,FK=e=>e===`image`||e===`url`,IK=e=>e===`length`||e===`size`||e===`bg-size`,LK=e=>e===`length`,RK=e=>e===`number`,zK=e=>e===`family-name`,BK=e=>e===`shadow`,VK=QG(()=>{let e=eK(`color`),t=eK(`font`),n=eK(`text`),r=eK(`font-weight`),i=eK(`tracking`),a=eK(`leading`),o=eK(`breakpoint`),s=eK(`container`),c=eK(`spacing`),l=eK(`radius`),u=eK(`shadow`),d=eK(`inset-shadow`),f=eK(`text-shadow`),p=eK(`drop-shadow`),m=eK(`blur`),h=eK(`perspective`),g=eK(`aspect`),_=eK(`ease`),v=eK(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],T=()=>[lK,`full`,`auto`,...w()],E=()=>[dK,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,dK,$,Q]},dK,$,Q],O=()=>[dK,`auto`,$,Q],k=()=>[`auto`,`min`,`max`,`fr`,$,Q],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[lK,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),OK,CK,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,kK,bK,{size:[$,Q]}],ee=()=>[fK,EK,xK],R=()=>[``,`none`,`full`,l,$,Q],z=()=>[``,uK,EK,xK],B=()=>[`solid`,`dashed`,`dotted`,`double`],te=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],V=()=>[uK,fK,OK,CK],ne=()=>[``,`none`,m,$,Q],H=()=>[`none`,uK,$,Q],re=()=>[`none`,uK,$,Q],U=()=>[uK,$,Q],ie=()=>[lK,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[pK],breakpoint:[pK],color:[mK],container:[pK],"drop-shadow":[pK],ease:[`in`,`out`,`in-out`],font:[yK],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[pK],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[pK],shadow:[pK],spacing:[`px`,uK],text:[pK],"text-shadow":[pK],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,lK,Q,$,g]}],container:[`container`],columns:[{columns:[uK,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{start:T()}],end:[{end:T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[dK,`auto`,$,Q]}],basis:[{basis:[lK,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[uK,lK,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,uK,$,Q]}],shrink:[{shrink:[``,uK,$,Q]}],order:[{order:[dK,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,EK,xK]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,$,SK]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,fK,Q]}],"font-family":[{font:[DK,Q,t]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[uK,`none`,$,SK]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...B(),`wavy`]}],"text-decoration-thickness":[{decoration:[uK,`from-font`,`auto`,$,xK]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[uK,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:L()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},dK,$,Q],radial:[``,$,Q],conic:[dK,$,Q]},AK,wK]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:ee()}],"gradient-via-pos":[{via:ee()}],"gradient-to-pos":[{to:ee()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:R()}],"rounded-s":[{"rounded-s":R()}],"rounded-e":[{"rounded-e":R()}],"rounded-t":[{"rounded-t":R()}],"rounded-r":[{"rounded-r":R()}],"rounded-b":[{"rounded-b":R()}],"rounded-l":[{"rounded-l":R()}],"rounded-ss":[{"rounded-ss":R()}],"rounded-se":[{"rounded-se":R()}],"rounded-ee":[{"rounded-ee":R()}],"rounded-es":[{"rounded-es":R()}],"rounded-tl":[{"rounded-tl":R()}],"rounded-tr":[{"rounded-tr":R()}],"rounded-br":[{"rounded-br":R()}],"rounded-bl":[{"rounded-bl":R()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":z()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...B(),`hidden`,`none`]}],"divide-style":[{divide:[...B(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...B(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[uK,$,Q]}],"outline-w":[{outline:[``,uK,EK,xK]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,jK,TK]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,jK,TK]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:z()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[uK,xK]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,jK,TK]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[uK,$,Q]}],"mix-blend":[{"mix-blend":[...te(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":te()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[uK]}],"mask-image-linear-from-pos":[{"mask-linear-from":V()}],"mask-image-linear-to-pos":[{"mask-linear-to":V()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":V()}],"mask-image-t-to-pos":[{"mask-t-to":V()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":V()}],"mask-image-r-to-pos":[{"mask-r-to":V()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":V()}],"mask-image-b-to-pos":[{"mask-b-to":V()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":V()}],"mask-image-l-to-pos":[{"mask-l-to":V()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":V()}],"mask-image-x-to-pos":[{"mask-x-to":V()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":V()}],"mask-image-y-to-pos":[{"mask-y-to":V()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":V()}],"mask-image-radial-to-pos":[{"mask-radial-to":V()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[uK]}],"mask-image-conic-from-pos":[{"mask-conic-from":V()}],"mask-image-conic-to-pos":[{"mask-conic-to":V()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:ne()}],brightness:[{brightness:[uK,$,Q]}],contrast:[{contrast:[uK,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,jK,TK]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,uK,$,Q]}],"hue-rotate":[{"hue-rotate":[uK,$,Q]}],invert:[{invert:[``,uK,$,Q]}],saturate:[{saturate:[uK,$,Q]}],sepia:[{sepia:[``,uK,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[uK,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[uK,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,uK,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[uK,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,uK,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[uK,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[uK,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,uK,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[uK,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[uK,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:H()}],"rotate-x":[{"rotate-x":H()}],"rotate-y":[{"rotate-y":H()}],"rotate-z":[{"rotate-z":H()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":[`scale-3d`],skew:[{skew:U()}],"skew-x":[{"skew-x":U()}],"skew-y":[{"skew-y":U()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":[`translate-none`],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[uK,EK,xK,SK]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function HK(...e){return VK(xG(e))}function UK({checked:e,onCheckedChange:t,disabled:n,className:r,ariaLabel:i}){return(0,W.jsx)(vG,{checked:e,onCheckedChange:t,disabled:n,"aria-label":i,className:HK(`group relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center rounded-full transition-colors`,`bg-border data-[checked]:bg-accent`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg-base`,`disabled:cursor-not-allowed disabled:opacity-50`,r),children:(0,W.jsx)(yG,{className:HK(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var WK=null,GK=!1,KK={},qK=500;function JK(){if(typeof window>`u`)return null;if(WK?.state===`closed`&&(WK=null),!WK){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;WK=new e}return WK}function YK(){WK&&=(WK.close().catch(()=>{}),null),JK()}function XK(){return GK}function ZK(){WK&&(YK(),GK=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&ZK()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&ZK()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&ZK(),e=t},5e3)}async function QK(){let e=JK();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),GK=!1}async function $K(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function eq(e){let t=JK();if(!t||(await $K(t),t.state!==`running`))return;let{frequencies:n,durationMs:r,attackMs:i,peakGain:a,type:o=`sine`}=e,s=t.currentTime,c=r/1e3,l=i/1e3,u=t.createGain();u.connect(t.destination);let d=s+c*.7;u.gain.setValueAtTime(0,s),u.gain.linearRampToValueAtTime(a,s+l),u.gain.setValueAtTime(a,d),u.gain.linearRampToValueAtTime(0,s+c);let f=n.map(e=>{let n=t.createOscillator();return n.type=o,n.frequency.setValueAtTime(e,s),n.connect(u),n});for(let e of f)e.start(s),e.stop(s+c);let p=f[f.length-1];p.onended=()=>{for(let e of f)e.disconnect();u.disconnect()}}async function tq(){let e=Date.now();if(!(e-(KK.permission||0)<qK)){KK.permission=e;try{await eq({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function nq(){let e=Date.now();if(!(e-(KK.idle||0)<qK)){KK.idle=e;try{await eq({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function rq({isOpen:e,onClose:t}){let n=H(e=>e.defaultProjectDir),r=H(e=>e.setDefaultProjectDir),i=H(e=>e.commandPresets),a=H(e=>e.setCommandPresets),o=H(e=>e.defaultPresetId),s=H(e=>e.setDefaultPresetId),c=H(e=>e.sessionSortMode),l=H(e=>e.setSessionSortMode),u=H(e=>e.sessionSortDirection),d=H(e=>e.setSessionSortDirection),f=H(e=>e.useWebGL),p=H(e=>e.setUseWebGL),m=H(e=>e.fontSize),h=H(e=>e.setFontSize),g=H(e=>e.lineHeight),_=H(e=>e.setLineHeight),v=H(e=>e.letterSpacing),y=H(e=>e.setLetterSpacing),b=H(e=>e.fontOption),S=H(e=>e.setFontOption),C=H(e=>e.customFontFamily),w=H(e=>e.setCustomFontFamily),T=H(e=>e.shortcutModifier),E=H(e=>e.setShortcutModifier),D=H(e=>e.showProjectName),O=H(e=>e.setShowProjectName),k=H(e=>e.showLastUserMessage),A=H(e=>e.setShowLastUserMessage),j=H(e=>e.showSessionIdPrefix),M=H(e=>e.setShowSessionIdPrefix),N=BH(e=>e.theme),F=BH(e=>e.setTheme),I=H(e=>e.soundOnPermission),ee=H(e=>e.setSoundOnPermission),R=H(e=>e.soundOnIdle),z=H(e=>e.setSoundOnIdle),[B,te]=(0,x.useState)(n),[V,ne]=(0,x.useState)(i),[re,U]=(0,x.useState)(o),[ie,ae]=(0,x.useState)(c),[oe,se]=(0,x.useState)(u),[ce,le]=(0,x.useState)(f),[ue,de]=(0,x.useState)(m),[fe,pe]=(0,x.useState)(g),[me,he]=(0,x.useState)(v),[ge,_e]=(0,x.useState)(b),[ve,ye]=(0,x.useState)(C),[be,xe]=(0,x.useState)(T),[Se,Ce]=(0,x.useState)(D),[we,Te]=(0,x.useState)(k),[Ee,De]=(0,x.useState)(j),[Oe,ke]=(0,x.useState)(N),[Ae,je]=(0,x.useState)(I),[Me,Ne]=(0,x.useState)(R),[Pe,Fe]=(0,x.useState)(!0),[Ie,Le]=(0,x.useState)(!1),[Re,ze]=(0,x.useState)(!0),[Be,Ve]=(0,x.useState)(!0),[He,Ue]=(0,x.useState)(!1),[We,Ge]=(0,x.useState)(!1),[Ke,Je]=(0,x.useState)(24),[Xe,Ze]=(0,x.useState)(!1),[Qe,$e]=(0,x.useState)(!1),[et,tt]=(0,x.useState)(``),[nt,rt]=(0,x.useState)(``),[it,at]=(0,x.useState)(``),ot=(0,x.useRef)(null),st=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let t=++st.current;if(ot.current&&=(clearTimeout(ot.current),null),e){if(te(n),ne(i),U(o),ae(c),se(u),le(f),de(m),pe(g),he(v),_e(b),ye(C),xe(T),Ce(D),Te(k),De(j),ke(N),je(I),Ne(R),$e(!1),tt(``),rt(``),at(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>Fe(e.enabled)).catch(()=>{}),Ve(!0),fetch(`/api/settings/terminal-colors`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{st.current===t&&ze(e.enabled)}).catch(()=>{}).finally(()=>{st.current===t&&Ve(!1)}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Je(e.hours)).catch(()=>{}),fetch(`/api/settings/prefer-window-name`).then(e=>e.json()).then(e=>Ue(e.enabled)).catch(()=>{}),typeof document<`u`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}}else typeof document<`u`&&(ot.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{ot.current&&=(clearTimeout(ot.current),null)}},[i,o,n,c,u,f,m,g,v,b,C,T,D,k,j,N,I,R,e]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=e=>{e.key===`Escape`&&(typeof e.stopPropagation==`function`&&e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let ct=e=>{e.preventDefault();let n=B.trim(),i=ce!==f;r(n||`~/Documents/GitHub`),a(V),s(re),l(ie),d(oe),p(ce),h(ue),_(fe),y(me),S(ge),w(ve),E(be),O(Se),A(we),M(Ee),F(Oe),ee(Ae),z(Me),t({webglChanged:i})},lt=(e,t)=>{ne(n=>n.map(n=>n.id===e?{...n,...t}:n))},ut=e=>{let t=V.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=V.filter(t=>t.id!==e);ne(n),e===re&&U(n[0]?.id||`claude`)},dt=()=>{if(!et.trim()||!nt.trim()||V.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:et.trim(),command:nt.trim(),isBuiltIn:!1,agentType:it||void 0};ne([...V,e]),$e(!1),tt(``),rt(``),at(``)},ft=V.length<50,pt=e=>{Le(!0),Fe(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Fe(!e)).finally(()=>Le(!1))},mt=e=>{Ge(!0),Ue(e),fetch(`/api/settings/prefer-window-name`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Ue(!e)).finally(()=>Ge(!1))},ht=e=>{Ve(!0),ze(e),fetch(`/api/settings/terminal-colors`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>ze(!e)).finally(()=>Ve(!1))},gt=e=>{let t=Ke;Ze(!0),Je(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`)}).catch(()=>Je(t)).finally(()=>Ze(!1))};return(0,W.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`form`,{onSubmit:ct,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,W.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,W.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,W.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,W.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,W.jsx)(`input`,{value:B,onChange:e=>te(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,W.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,W.jsx)(`select`,{value:re,onChange:e=>U(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:V.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,W.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,W.jsx)(`div`,{className:`space-y-3`,children:V.map(e=>(0,W.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,W.jsx)(`input`,{value:e.label,onChange:t=>lt(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>ut(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,W.jsx)(`input`,{value:e.command,onChange:t=>lt(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,W.jsxs)(`select`,{value:e.agentType||``,onChange:t=>lt(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,W.jsx)(`option`,{value:``,children:`Terminal`}),(0,W.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,W.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),Qe?(0,W.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,W.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,W.jsx)(`input`,{value:et,onChange:e=>tt(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,W.jsx)(`input`,{value:nt,onChange:e=>rt(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`select`,{value:it,onChange:e=>at(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,W.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,W.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,W.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,W.jsx)(`div`,{className:`flex-1`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>$e(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,onClick:dt,disabled:!et.trim()||!nt.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,W.jsx)(`button`,{type:`button`,onClick:()=>$e(!0),disabled:!ft,className:`btn text-xs mt-3 w-full`,children:ft?`+ Add Preset`:`Max 50 presets`})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`created`?`btn-primary`:``}`,onClick:()=>ae(`created`),children:`Created`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`status`?`btn-primary`:``}`,onClick:()=>ae(`status`),children:`Status`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ie===`manual`?`btn-primary`:``}`,onClick:()=>ae(`manual`),children:`Manual`})]}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ie===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:ie===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),ie===`created`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`desc`?`btn-primary`:``}`,onClick:()=>se(`desc`),children:`Newest First`}),(0,W.jsx)(`button`,{type:`button`,className:`btn flex-1 ${oe===`asc`?`btn-primary`:``}`,onClick:()=>se(`asc`),children:`Oldest First`})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,W.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,W.jsx)(UK,{checked:Se,onCheckedChange:Ce})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,W.jsx)(UK,{checked:we,onCheckedChange:Te})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,W.jsx)(UK,{checked:Ee,onCheckedChange:De})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,W.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:1,max:168,value:Ke,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&>(t)},disabled:Xe,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,W.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>void tq(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,W.jsx)(UK,{checked:Ae,onCheckedChange:e=>{je(e),e&&QK()}})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex-1`,children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>void nq(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,W.jsx)(UK,{checked:Me,onCheckedChange:e=>{Ne(e),e&&QK()}})]})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,W.jsx)(UK,{checked:ce,onCheckedChange:le})]}),ce!==f&&(0,W.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,W.jsx)(UK,{checked:Pe,onCheckedChange:pt,disabled:Ie})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Terminal Colors`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Preserve ANSI colors for terminal output. Hibernate then Wake running agents after changing this setting.`})]}),(0,W.jsx)(UK,{checked:Re,onCheckedChange:ht,disabled:Be,ariaLabel:`Enable terminal colors`})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Prefer Window Names`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Label discovered sessions with their tmux window name instead of the session name. Applies immediately.`})]}),(0,W.jsx)(UK,{checked:He,onCheckedChange:mt,disabled:We})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(Math.max(6,ue-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,W.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,W.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:ue}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>de(Math.min(24,ue+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,W.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:fe,onChange:e=>pe(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,W.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:fe.toFixed(1)})]})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:me,onChange:e=>he(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,W.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[me,`px`]})]})]}),(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,W.jsx)(`select`,{value:ge,onChange:e=>_e(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),ge===`custom`&&(0,W.jsx)(`input`,{value:ve,onChange:e=>ye(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,W.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,W.jsx)(UK,{checked:Oe===`dark`,onCheckedChange:e=>ke(e?`dark`:`light`)})]})]}),(0,W.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,W.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,W.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,W.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${be===e?`btn-primary`:``}`,onClick:()=>xe(e),children:e===`auto`?`Auto`:Ye(e)},e))}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:be===`auto`?`Shortcuts: ${Ye(qe(`auto`))}+[1-9/N/X/[/]]`:`Shortcuts: ${Ye(be)}+[1-9/N/X/[/]]`})]})]})}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var iq=[];function aq(e){x.useEffect(e,iq)}var oq=x.createContext(void 0);function sq(){let e=x.useContext(oq);if(!e)throw Error(fW(73));return e}var cq=Symbol(`NOT_FOUND`);function lq(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function uq(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function dq(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var fq=e=>Array.isArray(e)?e:[e];function pq(e){let t=Array.isArray(e[0])?e[0]:e;return dq(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function mq(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function hq(e){let t;return{get(n){return t&&e(t.key,n)?t.value:cq},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function gq(e,t){let n=[];function r(e){let r=n.findIndex(n=>t(e,n.key));if(r>-1){let e=n[r];return r>0&&(n.splice(r,1),n.unshift(e)),e.value}return cq}function i(t,i){r(t)===cq&&(n.unshift({key:t,value:i}),n.length>e&&n.pop())}function a(){return n}function o(){n=[]}return{get:r,put:i,getEntries:a,clear:o}}var _q=(e,t)=>e===t;function vq(e){return function(t,n){if(t===null||n===null||t.length!==n.length)return!1;let{length:r}=t;for(let i=0;i<r;i++)if(!e(t[i],n[i]))return!1;return!0}}function yq(e,t){let{equalityCheck:n=_q,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=vq(n),o=0,s=r<=1?hq(a):gq(r,a);function c(){let t=s.get(arguments);if(t===cq){if(t=e.apply(null,arguments),o++,i){let e=s.getEntries().find(e=>i(e.value,t));e&&(t=e.value,o!==0&&o--)}s.put(arguments,t)}return t}return c.clearCache=()=>{s.clear(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}var bq=class{constructor(e){this.value=e}deref(){return this.value}},xq=typeof WeakRef<`u`?WeakRef:bq,Sq=0,Cq=1;function wq(){return{s:Sq,v:void 0,o:null,p:null}}function Tq(e,t={}){let n=wq(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e<n;e++){let n=arguments[e];if(typeof n==`function`||typeof n==`object`&&n){let e=t.o;e===null&&(t.o=e=new WeakMap);let r=e.get(n);r===void 0?(t=wq(),e.set(n,t)):t=r}else{let e=t.p;e===null&&(t.p=e=new Map);let r=e.get(n);r===void 0?(t=wq(),e.set(n,t)):t=r}}let s=t,c;if(t.s===Cq)c=t.v;else if(c=e.apply(null,arguments),a++,r){let e=i?.deref?.()??i;e!=null&&r(e,c)&&(c=e,a!==0&&a--),i=typeof c==`object`&&c||typeof c==`function`?new xq(c):c}return s.s=Cq,s.v=c,c}return o.clearCache=()=>{n=wq(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Eq(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),lq(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=Tq,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=fq(c),p=fq(u),m=pq(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=mq(m,arguments);return i=h.apply(null,e),i},...p);return Object.assign(g,{resultFunc:o,memoizedResultFunc:h,dependencies:m,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var Dq=Eq(Tq),Oq=Object.assign((e,t=Dq)=>{uq(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>Oq}),kq=Eq({memoize:yq,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),Aq=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(fW(1));let s;if(e&&t&&n&&r&&i&&a)s=(o,s,c,l)=>a(e(o,s,c,l),t(o,s,c,l),n(o,s,c,l),r(o,s,c,l),i(o,s,c,l),s,c,l);else if(e&&t&&n&&r&&i)s=(a,o,s,c)=>i(e(a,o,s,c),t(a,o,s,c),n(a,o,s,c),r(a,o,s,c),o,s,c);else if(e&&t&&n&&r)s=(i,a,o,s)=>r(e(i,a,o,s),t(i,a,o,s),n(i,a,o,s),a,o,s);else if(e&&t&&n)s=(r,i,a,o)=>n(e(r,i,a,o),t(r,i,a,o),i,a,o);else if(e&&t)s=(n,r,i,a)=>t(e(n,r,i,a),r,i,a);else if(e)s=e;else throw Error(`Missing arguments`);return s},jq=(...e)=>{let t=new WeakMap,n=1,r=e[e.length-1],i=e.length-1||1,a=r.length-i;if(a>3)throw Error(fW(2));return(i,o,s,c)=>{let l=i.__cacheKey__;l||(l={id:n},i.__cacheKey__=l,n+=1);let u=t.get(l);if(!u){let n=e,i=[void 0,void 0,void 0];switch(a){case 0:break;case 1:n=[...e.slice(0,-1),()=>i[0],r];break;case 2:n=[...e.slice(0,-1),()=>i[0],()=>i[1],r];break;case 3:n=[...e.slice(0,-1),()=>i[0],()=>i[1],()=>i[2],r];break;default:throw Error(fW(2))}u=kq(...n),u.selectorArgs=i,t.set(l,u)}switch(u.selectorArgs[0]=o,u.selectorArgs[1]=s,u.selectorArgs[2]=c,a){case 0:return u(i);case 1:return u(i,o);case 2:return u(i,o,s);case 3:return u(i,o,s,c);default:throw Error(`unreachable`)}}},Mq=s((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Nq=s(((e,t)=>{t.exports=Mq()})),Pq=s((e=>{var t=p(),n=Nq();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Fq=s(((e,t)=>{t.exports=Pq()})),Iq=[],Lq=void 0;function Rq(){return Lq}function zq(e){Iq.push(e)}var Bq=Nq(),Vq=Fq(),Hq=mW(19)?Gq:Kq;function Uq(e,t,n,r,i){return Hq(e,t,n,r,i)}function Wq(e,t,n,r,i){let a=x.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,Bq.useSyncExternalStore)(e.subscribe,a,a)}zq({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);(r.didChange||!Object.is(r.value,i))&&(t=!0,r.value=i,r.didChange=!1)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,Bq.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Gq(e,t,n,r,i){let a=Rq();if(!a)return Wq(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.didChange=!0)):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i),didChange:!1},a.syncHooks.push(s)),s.value}function Kq(e,t,n,r,i){return(0,Vq.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var qq=class{constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return Uq(this,e,t,n,r)}},Jq=class extends qq{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),oW(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;oW(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;oW(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;oW(()=>{n&&!Object.is(this.state[e],t)&&super.setState({...this.state,[e]:t})},[e,t,n])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return x.useDebugValue(e),Uq(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=ZU(t??uW);this.context[e]=n}useStateSetter(e){let t=x.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},Yq=null;globalThis.requestAnimationFrame;var Xq=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},Zq=class e{static create(){return new e}static request(e){return Xq.request(e)}static cancel(e){return Xq.cancel(e)}currentId=Yq;request(e){this.cancel(),this.currentId=Xq.request(()=>{this.currentId=Yq,e()})}cancel=()=>{this.currentId!==Yq&&(Xq.cancel(this.currentId),this.currentId=Yq)};disposeEffect=()=>this.cancel};function Qq(){let e=JU(Zq.create).current;return aq(e.disposeEffect),e}var $q=0,eJ=class e{static create(){return new e}currentId=$q;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=$q,t()},e)}isStarted(){return this.currentId!==$q}clear=()=>{this.currentId!==$q&&(clearTimeout(this.currentId),this.currentId=$q)};disposeEffect=()=>this.clear};function tJ(){let e=JU(eJ.create).current;return aq(e.disposeEffect),e}var nJ=0;function rJ(e){return nJ+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${nJ}`}function iJ(e){return e?.ownerDocument||document}function aJ(e,t){if(typeof e==`string`)return{description:e};if(typeof e==`function`){let n=e(t);return typeof n==`string`?{description:n}:n}return e}var oJ=typeof navigator<`u`,sJ=fJ(),cJ=mJ(),lJ=pJ();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),sJ.platform===`MacIntel`&&sJ.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(sJ.platform),oJ&&/firefox/i.test(lJ);var uJ=oJ&&/apple/i.test(navigator.vendor);oJ&&/Edg/i.test(lJ),oJ&&/android/i.test(cJ)||/android/i.test(lJ),oJ&&cJ.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var dJ=lJ.includes(`jsdom/`);function fJ(){if(!oJ)return{platform:``,maxTouchPoints:-1};let e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??-1}}function pJ(){if(!oJ)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function mJ(){if(!oJ)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function hJ(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function gJ(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&qW(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function _J(e){return`composedPath`in e?e.composedPath()[0]:e.target}function vJ(e){if(!e||dJ)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var yJ=jq(e=>e.toasts,e=>{let t=new Map,n=0,r=0;return e.forEach((e,i)=>{let a=e.transitionStatus===`ending`;t.set(e.id,{value:e,domIndex:i,visibleIndex:a?-1:n,offsetY:r}),r+=e.height||0,a||(n+=1)}),t}),bJ={toasts:Aq(e=>e.toasts),isEmpty:Aq(e=>e.toasts.length===0),toast:Aq(yJ,(e,t)=>e.get(t)?.value),toastIndex:Aq(yJ,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:Aq(yJ,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:Aq(yJ,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:Aq(e=>e.hovering),focused:Aq(e=>e.focused),expanded:Aq(e=>e.hovering||e.focused),expandedOrOutOfFocus:Aq(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Aq(e=>e.prevFocusElement)},xJ=class extends Jq{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},bJ)}setFocused(e){this.set(`focused`,e)}setHovering(e){this.set(`hovering`,e)}setIsWindowFocused(e){this.set(`isWindowFocused`,e)}setPrevFocusElement(e){this.set(`prevFocusElement`,e)}setViewport=e=>{this.set(`viewport`,e)};disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e){let t=bJ.toastIndex(this.state,e);if(t===-1)return;this.state.toasts[t]?.onRemove?.();let n=[...this.state.toasts];n.splice(t,1),this.setToasts(n)}addToast=e=>{let{toasts:t,timeout:n,limit:r}=this.state,i=e.id||rJ(`toast`),a={...e,id:i,transitionStatus:`starting`},o=[a,...t],s=o.filter(e=>e.transitionStatus!==`ending`);if(s.length>r){let e=s.length-r,t=s.slice(-e),n=new Set(t.map(e=>e.id));this.setToasts(o.map(e=>{let t=n.has(e.id);return e.limited===t?e:{...e,limited:t}}))}else this.setToasts(o.map(e=>e.limited?{...e,limited:!1}:e));let c=a.timeout??n;return a.type!==`loading`&&c>0&&this.scheduleTimer(i,c,()=>this.closeToast(i)),bJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=bJ.toast(this.state,e)??null;if(!i||i.transitionStatus===`ending`)return;let a={...i,...t};this.setToasts(r.map(n=>n.id===e?{...n,...t}:n));let o=a.timeout??n,s=i?.timeout??n,c=Object.hasOwn(t,`timeout`),l=a.transitionStatus!==`ending`&&a.type!==`loading`&&o>0,u=this.timers.has(e),d=s!==o,f=i?.type===`loading`;if(!l&&u){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e);return}if(l&&(!u||d||c||f)){let t=this.timers.get(e);t&&(t.timeout?.clear(),this.timers.delete(e)),this.scheduleTimer(e,o,()=>this.closeToast(e)),bJ.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{bJ.toast(this.state,e)?.onClose?.();let{limit:t,toasts:n}=this.state,r=0,i=n.map(n=>{if(n.id===e)return{...n,transitionStatus:`ending`,height:0};if(n.transitionStatus===`ending`)return n;let i=r>=t;return r+=1,n.limited===i?n:{...n,limited:i}}),a=this.timers.get(e);a&&a.timeout&&(a.timeout.clear(),this.timers.delete(e)),this.handleFocusManagement(e),this.setToasts(i)};promiseToast=(e,t)=>{let n=aJ(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=aJ(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=aJ(t.error,e);return this.updateToast(r,{...n,type:`error`,timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,`setPromise`)&&t.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{if(e.timeout){e.timeout.clear();let t=Date.now()-e.start,n=e.delay-t;e.remaining=n>0?n:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=eJ.create(),e.timeout.start(e.remaining,()=>{this.timers.delete(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if(e.pointerType!==`touch`)return;let t=_J(e);gJ(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!bJ.expandedOrOutOfFocus(this.state),a=i?eJ.create():void 0;a?.start(t,()=>{this.timers.delete(e),n()}),this.timers.set(e,{timeout:a,start:i?r:0,delay:t,remaining:t,callback:n})}setToasts(e){let t={toasts:e};e.length===0&&(t.hovering=!1,t.focused=!1),this.update(t)}handleFocusManagement(e){let t=hJ(iJ(this.state.viewport));if(!this.state.viewport||!gJ(this.state.viewport,t)||!vJ(t))return;let n=bJ.toasts(this.state),r=bJ.toastIndex(this.state,e),i=null,a=r+1;for(;a<n.length;){if(n[a].transitionStatus!==`ending`){i=n[a];break}a+=1}if(!i)for(a=r-1;a>=0;){if(n[a].transitionStatus!==`ending`){i=n[a];break}--a}i?i.ref?.current?.focus():this.restoreFocusToPrevElement()}},SJ=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=JU(()=>new xJ({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return aq(a.disposeEffect),x.useEffect(function(){if(i)return i[` subscribe`](({action:e,options:t})=>{let n=t.id;e===`promise`&&t.promise?a.promiseToast(t.promise,t):e===`update`&&n?a.updateToast(n,t):e===`close`&&n?a.closeToast(n):a.addToast(t)})},[a,n,i]),a.useSyncedValues({timeout:n,limit:r}),(0,W.jsx)(oq.Provider,{value:a,children:t})},CJ=x.forwardRef(function(e,t){let[n,r]=x.useState();oW(()=>{uJ&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,W.jsx)(`span`,{...e,ref:t,style:cW,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),wJ=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),TJ=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=sq(),s=tJ(),c=x.useRef(!1),l=x.useRef(!1),u=o.useState(`isEmpty`),d=o.useState(`toasts`),f=o.useState(`focused`),p=o.useState(`expanded`),m=o.useState(`prevFocusElement`),h=d[0]?.height??0,g=x.useMemo(()=>d.some(e=>e.transitionStatus===`ending`),[d]);x.useEffect(()=>{let e=o.state.viewport;if(!e)return;function t(t){u||t.key===`F6`&&t.target!==e&&(t.preventDefault(),o.setPrevFocusElement(hJ(iJ(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=WW(e);return n.addEventListener(`keydown`,t),()=>{n.removeEventListener(`keydown`,t)}},[o,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=WW(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=_J(n),i=hJ(iJ(e));(!gJ(e,r)||!vJ(i))&&o.resumeTimers(),s.start(0,()=>o.setIsWindowFocused(!0))}return t.addEventListener(`blur`,n,!0),t.addEventListener(`focus`,r,!0),()=>{t.removeEventListener(`blur`,n,!0),t.removeEventListener(`focus`,r,!0)}},[o,s,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=iJ(e);return t.addEventListener(`pointerdown`,o.handleDocumentPointerDown,!0),()=>{t.removeEventListener(`pointerdown`,o.handleDocumentPointerDown,!0)}},[u,o]);function _(e){let t=o.state.viewport;t&&(c.current=!0,e.relatedTarget===t?d[0]?.ref?.current?.focus():o.restoreFocusToPrevElement())}function v(e){e.key===`Tab`&&e.shiftKey&&e.target===o.state.viewport&&(e.preventDefault(),o.restoreFocusToPrevElement(),o.resumeTimers())}x.useEffect(()=>{!o.state.isWindowFocused||g||!l.current||(o.resumeTimers(),o.setHovering(!1),l.current=!1)},[g,o]);function y(){o.pauseTimers(),o.setHovering(!0),l.current=!1}function b(){g?l.current=!0:(o.resumeTimers(),o.setHovering(!1))}function S(){if(c.current){c.current=!1;return}f||vJ(iJ(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||gJ(o.state.viewport,e.relatedTarget)||(o.setFocused(!1),o.resumeTimers())}let w={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:y,onMouseMove:y,onMouseLeave:b,onFocus:S,onBlur:C,onKeyDown:v,onClick:S},T={expanded:p},E=MW(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[wJ.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,W.jsxs)(x.Fragment,{children:[!u&&m&&(0,W.jsx)(CJ,{onFocus:_}),i,!u&&m&&(0,W.jsx)(CJ,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,W.jsxs)(x.Fragment,{children:[!u&&m&&(0,W.jsx)(CJ,{onFocus:_}),E,!f&&D.length>0&&(0,W.jsx)(`div`,{style:cW,children:D.map(e=>(0,W.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,W.jsx)(`div`,{children:e.title}),(0,W.jsx)(`div`,{children:e.description})]},e.id))})]})});function EJ(e){return mW(19)?e:e?`true`:void 0}var DJ=x.createContext(void 0);function OJ(){let e=x.useContext(DJ);if(!e)throw Error(fW(66));return e}var kJ=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),AJ={[kJ.startingStyle]:``},jJ={[kJ.endingStyle]:``},MJ={transitionStatus(e){return e===`starting`?AJ:e===`ending`?jJ:null}};function NJ(e){return e==null?e:`current`in e?e.current:e}function PJ(e,t=!1,n=!0){let r=Qq();return ZU((i,a=null)=>{r.cancel();function o(){U.flushSync(i)}let s=NJ(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=kJ.startingStyle;if(!c.hasAttribute(e)){r.request(i);return}let t=new MutationObserver(()=>{c.hasAttribute(e)||(t.disconnect(),i())});t.observe(c,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}function i(){Promise.all(c.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||o()}).catch(()=>{let e=c.getAnimations();if(n){if(a?.aborted)return;o()}else e.length>0&&e.some(e=>e.pending||e.playState!==`finished`)&&i()})}if(t){e();return}r.request(i)}})}function FJ(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=ZU(i),o=PJ(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var IJ=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}({}),LJ={...MJ,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},RJ=40,zJ=10,BJ=.5,VJ=1;function HJ(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function UJ(e){let t=window.getComputedStyle(e).transform,n=0,r=0,i=1;if(t&&t!==`none`){let e=t.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(n=t[4],r=t[5],i=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(n=t[12],r=t[13],i=t[0])}}return{x:n,y:r,scale:i}}var WJ=x.forwardRef(function(e,t){let{toast:n,render:r,className:i,swipeDirection:a=[`down`,`right`],...o}=e,s=n.positionerProps?.anchor!==void 0,c=[];s||(c=Array.isArray(a)?a:[a]);let l=c.length>0,u=sq(),[d,f]=x.useState(void 0),[p,m]=x.useState(!1),[h,g]=x.useState(!1),[_,v]=x.useState(!1),[y,b]=x.useState({x:0,y:0}),[S,C]=x.useState({x:0,y:0,scale:1}),[w,T]=x.useState(),[E,D]=x.useState(),[O,k]=x.useState(null),A=x.useRef(null),j=x.useRef({x:0,y:0}),M=x.useRef({x:0,y:0,scale:1}),N=x.useRef(void 0),P=x.useRef(0),F=x.useRef(!1),I=x.useRef({x:0,y:0}),L=x.useRef(!1),ee=u.useState(`toastIndex`,n.id),R=u.useState(`toastVisibleIndex`,n.id),z=u.useState(`toastOffsetY`,n.id),B=u.useState(`focused`),te=u.useState(`expanded`);FJ({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let V=ZU((e=!1)=>{let t=A.current;if(!t)return;let r=t.style.height;t.style.height=`auto`;let i=t.offsetHeight;t.style.height=r;function a(){u.updateToastInternal(n.id,{ref:A,height:i,...n.transitionStatus===`starting`?{transitionStatus:void 0}:{}})}e?U.flushSync(a):a()});oW(V,[V]);function ne(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**BJ:-(Math.abs(e)**BJ):(!c.includes(`right`)&&e>0&&(n=e**BJ),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**BJ))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**BJ:-(Math.abs(t)**BJ):(!c.includes(`down`)&&t>0&&(r=t**BJ),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**BJ))),{x:n,y:r}}function H(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=_J(e.nativeEvent);if(!(t&&t.closest(`button,a,input,textarea,[role="button"],[data-swipe-ignore]`))){if(F.current=!1,N.current=void 0,P.current=0,j.current={x:e.clientX,y:e.clientY},I.current=j.current,A.current){let e=UJ(A.current);M.current=e,C(e),b({x:e.x,y:e.y})}u.setHovering(!0),m(!0),g(!1),k(null),L.current=!0,A.current?.setPointerCapture(e.pointerId)}}function re(e){if(!p)return;e.preventDefault(),L.current&&=(j.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>I.current.y||i>0&&t<I.current.y)&&(I.current={x:I.current.x,y:t}),(r<0&&n>I.current.x||r>0&&n<I.current.x)&&(I.current={x:n,y:I.current.y});let a=n-j.current.x,o=t-j.current.y,s=t-I.current.y,l=n-I.current.x;if(!h&&Math.sqrt(a*a+o*o)>=VJ&&(g(!0),O===null)){let e=c.includes(`left`)||c.includes(`right`),t=c.includes(`up`)||c.includes(`down`);e&&t&&k(Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`)}let u;if(!N.current)O===`vertical`?o>0?u=`down`:o<0&&(u=`up`):O===`horizontal`?a>0?u=`right`:a<0&&(u=`left`):u=Math.abs(a)>=Math.abs(o)?a>0?`right`:`left`:o>0?`down`:`up`,u&&c.includes(u)&&(N.current=u,P.current=HJ(u,a,o),f(u));else{let e=N.current,t=HJ(e,l,s);t>RJ?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=zJ&&(F.current=!0)}let d=ne(a,o),m=M.current.x,_=M.current.y;O===`horizontal`?(c.includes(`left`)||c.includes(`right`))&&(m+=d.x):(O===`vertical`||(c.includes(`left`)||c.includes(`right`))&&(m+=d.x),(c.includes(`up`)||c.includes(`down`))&&(_+=d.y)),b({x:m,y:_})}function ie(e){if(!p)return;if(m(!1),g(!1),k(null),A.current?.releasePointerCapture(e.pointerId),F.current){b({x:S.x,y:S.y}),f(void 0);return}let t=!1,r=y.x-S.x,i=y.y-S.y,a;for(let e of c){switch(e){case`right`:r>RJ&&(t=!0,a=`right`);break;case`left`:r<-RJ&&(t=!0,a=`left`);break;case`down`:i>RJ&&(t=!0,a=`down`);break;case`up`:i<-RJ&&(t=!0,a=`up`);break;default:break}if(t)break}t?(f(a),v(!0),u.closeToast(n.id)):(b({x:S.x,y:S.y}),f(void 0))}function ae(e){if(e.key===`Escape`){if(!A.current||!gJ(A.current,hJ(iJ(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){gJ(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function oe(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[IJ.swipeMovementX]:`0px`,[IJ.swipeMovementY]:`0px`};let e=y.x-S.x,t=y.y-S.y;return{transition:p?`none`:void 0,transform:p?`translateX(${y.x}px) translateY(${y.y}px) scale(${S.scale})`:void 0,[IJ.swipeMovementX]:`${e}px`,[IJ.swipeMovementY]:`${t}px`}}let se=n.priority===`high`,ce={role:se?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":se&&!B?!0:void 0,onPointerDown:l?H:void 0,onPointerMove:l?re:void 0,onPointerUp:l?ie:void 0,onKeyDown:ae,inert:EJ(n.limited),style:{...oe(),[IJ.index]:n.transitionStatus===`ending`?ee:R,[IJ.offsetY]:`${z}px`,[IJ.height]:n.height?`${n.height}px`:void 0}},le=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:V,index:ee,visibleIndex:R,expanded:te}),[n,w,E,p,d,V,ee,R,te]),ue={transitionStatus:n.transitionStatus,expanded:te,limited:n.limited||!1,type:n.type,swiping:le.swiping,swipeDirection:le.swipeDirection},de=MW(`div`,e,{ref:[t,le.rootRef],state:ue,stateAttributesMapping:LJ,props:[ce,o]});return(0,W.jsx)(DJ.Provider,{value:le,children:de})}),GJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=OJ(),l=a??s.description,u=!!l,d=VW(i);oW(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=MW(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),KJ=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=OJ(),l=a??s.title,u=!!l,d=VW(i);oW(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=MW(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),qJ=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=sq(),{toast:c}=OJ(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=ZW({disabled:i,native:a}),m={type:c.type};return MW(`button`,e,{ref:[t,p],state:m,props:[{"aria-hidden":!l&&!u,onClick(){s.closeToast(c.id)},onFocus(){d(!0)},onBlur(){d(!1)}},o,f]})});function JJ(){let e=x.useContext(oq);if(!e)throw Error(fW(73));let t=e.useState(`toasts`);return x.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function YJ(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||rJ(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{...n,id:e}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var XJ=5e3,ZJ=YJ();function QJ({toast:e}){return(0,W.jsxs)(WJ,{toast:e,className:HK(`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:[(0,W.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,W.jsx)(KJ,{className:HK(`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&&(0,W.jsx)(GJ,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,W.jsx)(qJ,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,W.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:[(0,W.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,W.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function $J(){let{toasts:e}=JJ();return(0,W.jsx)(W.Fragment,{children:e.map(e=>(0,W.jsx)(QJ,{toast:e},e.id))})}function eY(){return(0,W.jsxs)(SJ,{timeout:XJ,toastManager:ZJ,children:[(0,W.jsx)($J,{}),(0,W.jsx)(TJ,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var tY=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],nY=3e3,rY=8e3,iY=15e3,aY=5e3,oY=2e4,sY=1e4,cY=1500,lY=5e3,uY=750,dY=4,fY=5e3,pY=new class{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.lastConnectTs=0,this.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{if(J(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,J(`ws_resume`,{gapMs:t,...this.wsSnap()},`info`),this.ws?.readyState===WebSocket.OPEN?this.verifyConnection():this.forceReconnect(`visibilitychange`,!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null)},this.onPageShow=e=>{J(`ws_pageshow`,{persisted:e.persisted,...this.wsSnap()},`info`),e.persisted&&(this.lastTick=Date.now(),this.forceReconnect(`pageshow`,!0))}}wsSnap(){return{status:this.status,ws:this.ws?tY[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){let e=this.ws.readyState===WebSocket.OPEN;if(e&&this.status===`connected`){J(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){J(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}J(`ws_connect_destroy_zombie`,{reason:e?`open_desynced`:`not_open`,...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus(`connecting`);let e=`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/ws`;J(`ws_connect`,{url:e,resume:this.isResumeAttempt,...this.wsSnap()},`info`);let t=new WebSocket(e);this.ws=t,this.lastConnectTs=Date.now(),this.leakedSockets.add(t);let n=this.isResumeAttempt?rY:nY;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(J(`ws_connect_timeout`,{wsState:tY[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){J(`ws_onopen_stale`,this.wsSnap(),`info`);return}J(`ws_onopen`,this.wsSnap(),`info`),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.connectionEpoch+=1,this.leakedSockets.delete(t),this.setStatus(`connected`),this.startHeartbeat()},t.onmessage=e=>{try{let t=e.data,n=performance.now(),r=JSON.parse(t),i=performance.now()-n,a=r;if(a._parseMs=Math.round(i),a._rawLength=t.length,r.type===`pong`){r.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),J(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(lY)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(J(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){J(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}J(`ws_onclose`,{code:e.code,reason:e.reason,clean:e.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),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(()=>{let e=Date.now(),t=e-this.lastTick;this.isHidden()||(t>iY&&(J(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},aY))}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(e){if(this.ws?.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return J(`ws_send_error`,{messageType:e.type,error:t instanceof Error?t.message:String(t),...this.wsSnap()},`info`),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}subscribeStatus(e){return this.statusListeners.add(e),e(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(e)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;let e=this.pingSeq,t=this.ws;if(J(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){J(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(J(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},cY)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){J(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){J(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){J(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,J(`ws_force_reconnect`,{trigger:e,force:t,...this.wsSnap()},`info`),this.reconnectAttempts=0,this.consecutiveFailures=0,this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),t?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},uY)):this.connect()}startHeartbeat(e){this.stopHeartbeat();let t=()=>{this.ws?.readyState===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:`ping`,seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,J(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},sY)))};e!==void 0&&e<oY?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,oY)},e):this.heartbeatTimer=window.setInterval(t,oY)}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(e,t=null){this.status=e,this.error=t,this.statusListeners.forEach(n=>n(e,t,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){J(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=dY){J(`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()},fY);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);J(`ws_schedule_reconnect`,{delay:e,...this.wsSnap()}),this.setStatus(`reconnecting`),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}isHidden(){return typeof document<`u`&&document.visibilityState===`hidden`}clearConnectTimer(){this.connectTimer&&=(window.clearTimeout(this.connectTimer),null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;let e=this.ws;this.ws=null,this.leakedSockets.add(e),e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){J(`ws_purge_leaked`,{count:this.leakedSockets.size},`info`);for(let e of this.leakedSockets)try{e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,e.close()}catch{}this.leakedSockets.clear()}}};function mY(){let e=qm(e=>e.setConnectionState);return(0,x.useEffect)(()=>{pY.connect(),pY.startLifecycleListeners();let t=pY.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),pY.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{pY.send(e)},[]),subscribe:(0,x.useMemo)(()=>pY.subscribe.bind(pY),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>pY.getConnectionEpoch(),[])}}var hY=100;function gY({viewport:e,win:t,doc:n}){if(!e)return!1;let r=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+r),o=Math.max(0,a),s=Math.max(0,e.height||0),c=Math.max(0,e.width||0);return n.documentElement.style.setProperty(`--keyboard-inset`,`${o}px`),n.documentElement.style.setProperty(`--viewport-offset-top`,`${r}px`),n.documentElement.style.setProperty(`--viewport-offset-left`,`${i}px`),n.documentElement.style.setProperty(`--visual-viewport-height`,`${s}px`),n.documentElement.style.setProperty(`--visual-viewport-width`,`${c}px`),o>hY?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function _Y(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 vY(){(0,x.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=null,n=null,r=()=>{let e=document.activeElement;if(!e)return!1;let t=e.tagName?.toLowerCase();return t===`input`||t===`textarea`?!0:!!e.isContentEditable},i=()=>{gY({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!=`function`){i();return}t!==null&&window.cancelAnimationFrame(t);let e=performance.now(),n=()=>{i(),t=performance.now()-e<1500?window.requestAnimationFrame(n):null};t=window.requestAnimationFrame(n)},o=()=>{if(!r()){c();return}i()},s=()=>{n!==null||typeof window.setInterval!=`function`||(n=window.setInterval(o,250),o())},c=()=>{n===null||typeof window.clearInterval!=`function`||(window.clearInterval(n),n=null)},l=()=>{r()?(a(),s(),i()):c()},u=()=>{l()},d=()=>{l()},f=()=>{a()};return i(),l(),e.addEventListener(`resize`,i),e.addEventListener(`scroll`,i),typeof window.addEventListener==`function`&&(window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,f)),typeof document.addEventListener==`function`&&(document.addEventListener(`focusin`,u),document.addEventListener(`focusout`,d),document.addEventListener(`focus`,u,!0),document.addEventListener(`blur`,d,!0)),()=>{e.removeEventListener(`resize`,i),e.removeEventListener(`scroll`,i),typeof window.removeEventListener==`function`&&(window.removeEventListener(`resize`,i),window.removeEventListener(`orientationchange`,f)),typeof document.removeEventListener==`function`&&(document.removeEventListener(`focusin`,u),document.removeEventListener(`focusout`,d),document.removeEventListener(`focus`,u,!0),document.removeEventListener(`blur`,d,!0)),t!==null&&typeof window.cancelAnimationFrame==`function`&&window.cancelAnimationFrame(t),c(),_Y(document)}},[])}function yY(e,t,n){let r=e;return t.length>0&&(r=r.filter(e=>t.includes(e.projectPath))),n.length>0&&(r=r.filter(e=>n.includes(e.host??``))),r}function bY(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(void 0),[i,a]=(0,x.useState)(void 0),[o,s]=(0,x.useState)(void 0),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null),g=qm(e=>e.sessions),_=qm(e=>e.agentSessions),v=qm(e=>e.agentSessionsEpoch),y=qm(e=>e.selectedSessionId),b=qm(e=>e.selectedHibernatingSessionId),S=qm(e=>e.setSessions),C=qm(e=>e.setAgentSessions),w=qm(e=>e.setActiveAgentSessions),T=qm(e=>e.setHostStatuses),E=qm(e=>e.updateSession),D=qm(e=>e.setSelectedSessionId),O=qm(e=>e.setSelectedHibernatingSessionId),k=qm(e=>e.hasLoaded),A=qm(e=>e.connectionStatus),j=qm(e=>e.connectionError),M=qm(e=>e.clearExitingSession),N=qm(e=>e.markSessionExiting),P=qm(e=>e.setRemoteAllowControl),F=qm(e=>e.setRemoteAllowAttach),I=qm(e=>e.setHostLabel),L=qm(e=>e.setPreferWindowName),ee=qm(e=>e.hostStatuses),R=qm(e=>e.remoteAllowControl),z=qm(e=>e.hostLabel),B=BH(e=>e.theme),te=re(),V=H(e=>e.defaultProjectDir),ne=H(e=>e.commandPresets),ie=H(e=>e.defaultPresetId),ae=H(e=>e.lastProjectPath),oe=H(e=>e.setLastProjectPath),se=H(e=>e.addRecentPath),ce=H(e=>e.shortcutModifier),le=H(e=>e.sidebarWidth),ue=H(e=>e.setSidebarWidth),de=H(e=>e.projectFilters),fe=H(e=>e.hostFilters),pe=H(e=>e.soundOnPermission),me=H(e=>e.soundOnIdle),he=qm(e=>e.connectionEpoch),{sendMessage:ge,subscribe:_e,getConnectionEpoch:ve}=mY();vY(),(0,x.useEffect)(()=>{if(typeof document>`u`||!pe&&!me)return;let e=!1,t=()=>{e&&!XK()||(e=!0,QK())};return document.addEventListener(`click`,t,{passive:!0}),document.addEventListener(`keydown`,t,{passive:!0}),document.addEventListener(`touchstart`,t,{passive:!0}),()=>{document.removeEventListener(`click`,t),document.removeEventListener(`keydown`,t),document.removeEventListener(`touchstart`,t)}},[pe,me]);let ye=(0,x.useRef)(!1),be=(0,x.useCallback)(e=>{e.preventDefault(),ye.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]);(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=e=>{if(!ye.current)return;let t=e.clientX;ue(Math.max(180,Math.min(400,t)))},t=()=>{ye.current&&(ye.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[ue]),(0,x.useEffect)(()=>{let e=_e(e=>{if(e.type!==`terminal-output`){if(e.type===`sessions`){let t=qm.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=H.getState();if(n||r)for(let i of e.sessions){let e=t.find(e=>e.id===i.id);e&&e.status!==i.status&&(e.status!==`permission`&&i.status===`permission`&&n&&tq(),e.status===`working`&&i.status===`waiting`&&r&&nq())}if(Ie.current.size>0){let e=ve();for(let[t,n]of Ie.current)n.epoch!==e&&Ie.current.delete(t)}let i=Ie.current.size>0?e.sessions.filter(e=>!Ie.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=qm.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(Me.current=s),S(i);let c=Ne.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=qm.getState(),{projectFilters:d,hostFilters:f}=H.getState();if(c&&l===null&&u===null){let e=i.find(e=>!(e.agentSessionId?.trim()!==c||d.length>0&&!d.includes(e.projectPath)||f.length>0&&!f.includes(e.host??``)));e&&(Ne.current=null,D(e.id))}}if(e.type===`host-status`&&T(e.hosts),e.type===`server-config`&&(P(e.remoteAllowControl),F(e.remoteAllowAttach),I(e.hostLabel),L(e.preferWindowName),e.clientLogLevel&&QT(e.clientLogLevel)),e.type===`session-update`){let t=qm.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=H.getState();t!==`permission`&&n===`permission`&&e&&tq(),t===`working`&&n===`waiting`&&r&&nq()}}if(e.type===`session-created`){let t=qm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),se(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=H.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){dH(e.sessionId);let t=qm.getState().sessions,n=t.filter(t=>t.id!==e.sessionId);n.length!==t.length&&S(n)}if(e.type===`agent-sessions`){let t=Array.isArray(e.active)?e.active:[],n=Array.isArray(e.hibernating)?e.hibernating:[],r=Array.isArray(e.history)?e.history:[],{selectedHibernatingSessionId:i}=qm.getState(),a=Me.current;i&&!n.some(e=>e.sessionId===i)&&(Ne.current=i),C(t,n,r),h(e=>e&&n.some(t=>t.sessionId===e.sessionId)?null:e),a&&n.some(e=>e.sessionId===a)?(Me.current=null,O(a)):a&&(Me.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=qm.getState().sessions,n=t.filter(t=>t.agentSessionId?.trim()!==e.session.sessionId);n.length!==t.length&&S(n)}if(e.type===`session-activated`){let t=qm.getState().sessions.find(t=>t.tmuxWindow===e.window);t&&E({...t,agentSessionId:e.session.sessionId,agentSessionName:e.session.displayName,logFilePath:e.session.logFilePath,isPinned:e.session.isPinned,lastUserMessage:e.session.lastUserMessage??t.lastUserMessage})}if(e.type===`session-wake-result`)if(e.ok&&e.session){h(t=>t?.sessionId===e.sessionId?null:t);let t=qm.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id)}else e.ok||(d(`${e.error?.code}: ${e.error?.message}`),window.setTimeout(()=>d(null),6e3));if(e.type===`session-hibernate-result`&&(e.ok?(e.session&&h(e.session),O(e.sessionId)):(d(e.error??`Failed to hibernate session`),window.setTimeout(()=>d(null),6e3))),e.type===`terminal-error`&&(!e.sessionId||e.sessionId===y)&&(d(`${e.code}: ${e.message}`),window.setTimeout(()=>d(null),6e3)),e.type===`terminal-ready`&&e.sessionId===y&&d(null),e.type===`error`&&(d(e.message),window.setTimeout(()=>d(null),6e3)),e.type===`kill-failed`){let t=Ie.current.get(e.sessionId);if(t){let n=qm.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),Ie.current.delete(e.sessionId)}M(e.sessionId),d(e.message),window.setTimeout(()=>d(null),6e3)}e.type===`session-move-to-history-result`&&!e.ok&&e.error&&(d(e.error),window.setTimeout(()=>d(null),6e3))}});return()=>{e()}},[y,b,se,M,ge,D,O,h,S,C,w,T,P,F,I,L,_e,E]);let xe=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),Se=_.hibernating??[],Ce=_.history??[],we=(0,x.useMemo)(()=>yY(Se,de,fe),[Se,de,fe]),Te=(0,x.useMemo)(()=>we.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[we,m,b]);(0,x.useEffect)(()=>{xe?.projectPath&&!xe.remote&&oe(xe.projectPath)},[xe?.projectPath,xe?.remote,oe]);let Ee=H(e=>e.sessionSortMode),De=H(e=>e.sessionSortDirection),Oe=H(e=>e.manualSessionOrder),ke=(0,x.useMemo)(()=>Mm(g,{mode:Ee,direction:De,manualOrder:Oe}),[g,Ee,De,Oe]),Ae=(0,x.useMemo)(()=>{let e=ke;return de.length>0&&(e=e.filter(e=>de.includes(e.projectPath))),fe.length>0&&(e=e.filter(e=>fe.includes(e.host??``))),e},[ke,de,fe]),je=(0,x.useRef)(b),Me=(0,x.useRef)(null),Ne=(0,x.useRef)(null),Pe=(0,x.useRef)(he),Fe=(0,x.useCallback)(()=>Ae.length>0?(D(Ae[0].id),!0):we.length>0?(O(we[0].sessionId),!0):!1,[Ae,we,D,O]);(0,x.useEffect)(()=>{let e=je.current;e&&b===null&&!Se.some(t=>t.sessionId===e)?Ne.current=e:b!==null&&(Ne.current=null),je.current=b},[Se,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{Pe.current!==he&&(Pe.current=he,Me.current=null,Ne.current=null,h(null))},[he]),(0,x.useEffect)(()=>{k&&(b||y&&(Ae.some(e=>e.id===y)||Fe()||D(null)))},[k,y,b,Fe,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==he||we.some(e=>e.sessionId===b))return;let e=Ae.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Fe()||O(null)},[we,Ae,v,m,b,Fe,D,O,he]),(0,x.useEffect)(()=>{let e=Ne.current;if(!e)return;if(b!==null){Ne.current=null;return}let t=Ae.find(t=>t.agentSessionId?.trim()===e);if(t){Ne.current=null,D(t.id);return}if(y!==null){Ne.current=null;return}Fe()&&(Ne.current=null)},[Ae,y,b,Fe,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(Ae.length>0||we.length>0)&&Fe()},[we.length,Ae.length,k,Fe,y,b]);let Ie=(0,x.useRef)(new Map),Le=(0,x.useCallback)((e,t=`unknown`)=>{dH(e);let{sessions:n,selectedSessionId:r}=qm.getState(),i=n.find(t=>t.id===e);i&&Ie.current.set(e,{session:i,wasSelected:r===e,epoch:ve()}),(0,U.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),ge({type:`session-kill`,sessionId:e,source:t})},[N,S,ge]);(0,x.useEffect)(()=>{let n=qe(ce),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=Xe(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=Ae;if(t.length===0){let t=we;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){O(t[0].sessionId);return}O(t[(n+e+t.length)%t.length].sessionId);return}let n=t.findIndex(e=>e.id===y);if(n===-1){D(t[0].id);return}D(t[(n+e+t.length)%t.length].id);return}if(a&&/^Digit[1-9]$/.test(i)){let e=Number(i.slice(5))-1;if(Ae.length>0){let t=Ae[e];if(!t)return;r.preventDefault(),D(t.id);return}let t=we[e];if(!t)return;r.preventDefault(),O(t.sessionId);return}if(a&&i===`KeyN`){r.preventDefault(),!e&&te&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Le(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,Ae,we,Le,ce,te]);let Re=()=>te?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,ze=()=>l(!0),Be=(e,t,n,r)=>{ge({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||oe(e)},Ve=e=>{ge({type:`session-wake`,sessionId:e})},He=(0,x.useCallback)(e=>{ge({type:`session-hibernate`,sessionId:e})},[ge]),Ue=(e,t)=>{ge({type:`session-rename`,sessionId:e,newName:t})},We=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&ge({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,ge]),Ge=(0,x.useCallback)(e=>{ge({type:`session-move-to-history`,sessionId:e})},[ge]);(0,x.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,B)},[B]),(0,x.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ke=(0,x.useMemo)(()=>z?ee.filter(e=>e.host!==z):ee,[ee,z]);return(0,W.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,W.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:le},children:[(0,W.jsx)($e,{connectionStatus:A,onNewSession:Re,onOpenSettings:ze,tailscaleIp:f?.tailscaleIp??null}),(0,W.jsx)(qT,{sessions:g,hibernatingSessions:Se,historySessions:Ce,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:Ue,onResume:Ve,onHibernate:He,onKill:Le,onDuplicate:We,onMoveToHistory:Ge,onNewSession:Re,loading:!k,error:j||u})]}),(0,W.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:be}),(0,W.jsx)(UU,{session:xe,sessions:Ae,hibernatingSession:Te,hibernatingSessions:Se,connectionStatus:A,connectionEpoch:he,sendMessage:ge,subscribe:_e,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Re,onKillSession:Le,onRenameSession:Ue,onOpenSettings:ze,onResumeSession:Ve,onHibernateSession:He,onMoveToHistory:Ge,historySessions:Ce,loading:!k,error:j||u}),(0,W.jsx)(GU,{isOpen:e,onClose:()=>t(!1),onCreate:Be,defaultProjectDir:V,commandPresets:ne,defaultPresetId:ie,lastProjectPath:ae,activeProjectPath:xe&&!xe.remote?xe.projectPath:void 0,remoteHosts:Ke,remoteAllowControl:R,initialHost:n,initialPath:i,initialCommand:o}),(0,W.jsx)(rq,{isOpen:c,onClose:()=>l(!1)}),(0,W.jsx)(eY,{})]})}var xY=`modulepreload`,SY=function(e){return`/`+e},CY={},wY=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=SY(t,n),t in CY)return;CY[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:xY,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},TY=`true`,EY=`false`,DY=TY===`true`,OY=EY===`true`;function kY(e={}){let{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:a,onRegisterError:o}=e,s,c,l,u=async(e=!0)=>{await c,DY||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await wY(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bq4GJJid.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{o?.(e)}),!s)return;if(l=()=>{s?.messageSkipWaiting()},!OY)if(DY)s.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),s.addEventListener(`installed`,e=>{e.isUpdate||r?.()});else{let e=!1,t=()=>{e=!0,s?.addEventListener(`controlling`,e=>{e.isUpdate&&window.location.reload()}),n?.()};s.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&r?.():n.isExternal?t():!e&&r?.():n.isUpdate||r?.()}),s.addEventListener(`waiting`,t)}s.register({immediate:t}).then(e=>{a?a(`/sw.js`,e):i?.(e)}).catch(e=>{o?.(e)})}}return c=d(),u}We()&&document.documentElement.classList.add(`ios`),Ge()&&document.documentElement.classList.add(`ios-pwa`),kY({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var AY=document.getElementById(`root`);if(!AY)throw Error(`Root element not found`);(0,E.createRoot)(AY).render((0,W.jsx)(x.StrictMode,{children:(0,W.jsx)(bY,{})}));
|