opencode-webui 1.0.2 → 1.0.3

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.
@@ -47,76 +47,76 @@ Error generating stack: `+e.message+`
47
47
  .block-interactivity-${e} {pointer-events: none;}
48
48
  .allow-interactivity-${e} {pointer-events: all;}
49
49
  `},Mo=0,No=[];function Po(e){var t=E.useRef([]),n=E.useRef([0,0]),r=E.useRef(),i=E.useState(Mo++)[0],a=E.useState(to)[0],o=E.useRef(e);E.useEffect(function(){o.current=e},[e]),E.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Aa([e.lockRef.current],(e.shards||[]).map(ko),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=E.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Do(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=bo(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=bo(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Eo(h,t,e,h===`h`?s:c,!0)},[]),c=E.useCallback(function(e){var n=e;if(!(!No.length||No[No.length-1]!==a)){var r=`deltaY`in n?Oo(n):Do(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Ao(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(ko).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=E.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Fo(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=E.useCallback(function(e){n.current=Do(e),r.current=void 0},[]),d=E.useCallback(function(t){l(t.type,Oo(t),t.target,s(t,e.lockRef.current))},[]),f=E.useCallback(function(t){l(t.type,Do(t),t.target,s(t,e.lockRef.current))},[]);E.useEffect(function(){return No.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,ho),document.addEventListener(`touchmove`,c,ho),document.addEventListener(`touchstart`,u,ho),function(){No=No.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,ho),document.removeEventListener(`touchmove`,c,ho),document.removeEventListener(`touchstart`,u,ho)}},[]);var p=e.removeScrollBar,m=e.inert;return E.createElement(E.Fragment,null,m?E.createElement(a,{styles:jo(i)}):null,p?E.createElement(fo,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Fo(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Io=Wa(Ga,Po),Lo=E.forwardRef(function(e,t){return E.createElement(qa,Oa({},e,{ref:t,sideCar:Io}))});Lo.classNames=qa.classNames;var Ro=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},zo=new WeakMap,Bo=new WeakMap,Vo={},Ho=0,Uo=function(e){return e&&(e.host||Uo(e.parentNode))},Wo=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Uo(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Go=function(e,t,n,r){var i=Wo(t,Array.isArray(e)?e:[e]);Vo[n]||(Vo[n]=new WeakMap);var a=Vo[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(zo.get(e)||0)+1,l=(a.get(e)||0)+1;zo.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Bo.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Ho++,function(){o.forEach(function(e){var t=zo.get(e)-1,i=a.get(e)-1;zo.set(e,t),a.set(e,i),t||(Bo.has(e)||e.removeAttribute(r),Bo.delete(e)),i||e.removeAttribute(n)}),Ho--,Ho||(zo=new WeakMap,zo=new WeakMap,Bo=new WeakMap,Vo={})}},Ko=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Ro(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Go(r,i,n,`aria-hidden`)):function(){return null}},qo=Object.defineProperty,Jo=(e,t)=>qo(e,`name`,{value:t,configurable:!0}),Yo=`Dialog`,[Xo,Zo]=zr(Yo),[Qo,$o]=Xo(Yo),es=Jo(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=E.useRef(null),c=E.useRef(null),[l,u]=gi({prop:r,defaultProp:i??!1,onChange:a,caller:Yo}),[d,f]=E.useState(0),[p,m]=E.useState(0);return(0,R.jsx)(Qo,{scope:t,triggerRef:s,contentRef:c,contentId:Pi(),titleId:Pi(),descriptionId:Pi(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:E.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),ts=`DialogTrigger`,ns=E.forwardRef(Jo(function(e,t){let{__scopeDialog:n,...r}=e,i=$o(ts,n),a=mr(t,i.triggerRef);return(0,R.jsx)(Pr.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Ss(i.open),...r,ref:a,onClick:H(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),rs=`DialogPortal`,[is,as]=Xo(rs,{forceMount:void 0}),os=Jo(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=$o(rs,t);return(0,R.jsx)(is,{scope:t,forceMount:n,children:E.Children.map(r,e=>(0,R.jsx)(wi,{present:n||a.open,children:(0,R.jsx)(ba,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),ss=`DialogOverlay`,cs=E.forwardRef(Jo(function(e,t){let n=as(ss,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=$o(ss,e.__scopeDialog);return a.modal?(0,R.jsx)(wi,{present:r||a.open,children:(0,R.jsx)(us,{...i,ref:t})}):null},`DialogOverlay`)),ls=_r(`DialogOverlay.RemoveScroll`),us=E.forwardRef(Jo(function(e,t){let{__scopeDialog:n,...r}=e,i=$o(ss,n),a=mr(t,Xi());return(0,R.jsx)(Lo,{as:ls,allowPinchZoom:!0,shards:[i.contentRef],children:(0,R.jsx)(Pr.div,{"data-state":Ss(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),ds=`DialogContent`,fs=E.forwardRef(Jo(function(e,t){let n=as(ds,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=$o(ds,e.__scopeDialog);return(0,R.jsx)(wi,{present:r||a.open,children:a.modal?(0,R.jsx)(ps,{...i,ref:t}):(0,R.jsx)(ms,{...i,ref:t})})},`DialogContent`)),ps=E.forwardRef(Jo(function(e,t){let n=$o(ds,e.__scopeDialog),r=E.useRef(null),i=mr(t,n.contentRef,r);return E.useEffect(()=>{let e=r.current;if(e)return Ko(e)},[]),(0,R.jsx)(hs,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:H(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:H(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:H(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),ms=E.forwardRef(Jo(function(e,t){let n=$o(ds,e.__scopeDialog),r=E.useRef(!1),i=E.useRef(!1);return(0,R.jsx)(hs,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),hs=E.forwardRef(Jo(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=$o(ds,n);return Ea(),(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(sa,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(Yi,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Ss(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),gs=`DialogTitle`,_s=E.forwardRef(Jo(function(e,t){let{__scopeDialog:n,...r}=e,i=$o(gs,n),{setTitleCount:a}=i;return si(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(Pr.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),vs=`DialogDescription`,ys=E.forwardRef(Jo(function(e,t){let{__scopeDialog:n,...r}=e,i=$o(vs,n),{setDescriptionCount:a}=i;return si(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(Pr.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),bs=`DialogClose`,xs=E.forwardRef(Jo(function(e,t){let{__scopeDialog:n,...r}=e,i=$o(bs,n);return(0,R.jsx)(Pr.button,{type:`button`,...r,ref:t,onClick:H(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Ss(e){return e?`open`:`closed`}Jo(Ss,`getState`);var Cs=Object.defineProperty,ws=(e,t)=>Cs(e,`name`,{value:t,configurable:!0});function Ts(e){let[t,n]=E.useState(void 0);return si(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}ws(Ts,`useSize`);var Es=[`top`,`right`,`bottom`,`left`],Ds=Math.min,Os=Math.max,ks=Math.round,As=Math.floor,js=e=>({x:e,y:e}),Ms={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Ns(e,t,n){return Os(e,Ds(t,n))}function Ps(e,t){return typeof e==`function`?e(t):e}function Fs(e){return e.split(`-`)[0]}function Is(e){return e.split(`-`)[1]}function Ls(e){return e===`x`?`y`:`x`}function Rs(e){return e===`y`?`height`:`width`}function zs(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Bs(e){return Ls(zs(e))}function Vs(e,t,n){n===void 0&&(n=!1);let r=Is(e),i=Bs(e),a=Rs(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Xs(o)),[o,Xs(o)]}function Hs(e){let t=Xs(e);return[Us(e),t,Us(t)]}function Us(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Ws=[`left`,`right`],Gs=[`right`,`left`],Ks=[`top`,`bottom`],qs=[`bottom`,`top`];function Js(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Gs:Ws:t?Ws:Gs;case`left`:case`right`:return t?Ks:qs;default:return[]}}function Ys(e,t,n,r){let i=Is(e),a=Js(Fs(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Us)))),a}function Xs(e){let t=Fs(e);return Ms[t]+e.slice(t.length)}function Zs(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Qs(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Zs(e)}function $s(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ec(e,t,n){let{reference:r,floating:i}=e,a=zs(t),o=Bs(t),s=Rs(o),c=Fs(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Is(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function tc(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Ps(t,e),p=Qs(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=$s(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=$s(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var nc=50,rc=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:tc},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ec(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<nc&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ec(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ic=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Ps(e,t)||{};if(l==null)return{};let d=Qs(u),f={x:n,y:r},p=Bs(i),m=Rs(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Ds(d[_],T),D=Ds(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=Ns(E,k,O),j=!c.arrow&&Is(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),ac=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Ps(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Fs(r),_=zs(o),v=Fs(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Xs(o)]:Hs(o)),x=p!==`none`;!d&&x&&b.push(...Ys(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Vs(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===zs(t)||T.every(e=>zs(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=zs(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function oc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function sc(e){return Es.some(t=>e[t]>=0)}var cc=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Ps(e,t);switch(i){case`referenceHidden`:{let e=oc(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:sc(e)}}}case`escaped`:{let e=oc(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:sc(e)}}}default:return{}}}}},lc=new Set([`left`,`top`]);async function uc(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Fs(n),s=Is(n),c=zs(n)===`y`,l=lc.has(o)?-1:1,u=a&&c?-1:1,d=Ps(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var dc=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await uc(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},fc=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Ps(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=zs(i),p=Ls(f),m=u[p],h=u[f],g=(e,t)=>Ns(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},pc=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Ps(e,t),u={x:n,y:r},d=zs(i),f=Ls(d),p=u[f],m=u[d],h=Ps(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=lc.has(Fs(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},mc=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Ps(e,t),c=await i.detectOverflow(t,s),l=Fs(n),u=Is(n),d=zs(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Ds(p-c[m],g),y=Ds(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Os(c.left,c.right):S=p-2*Os(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function hc(){return typeof window<`u`}function gc(e){return yc(e)?(e.nodeName||``).toLowerCase():`#document`}function _c(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vc(e){return((yc(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function yc(e){return hc()?e instanceof Node||e instanceof _c(e).Node:!1}function bc(e){return hc()?e instanceof Element||e instanceof _c(e).Element:!1}function xc(e){return hc()?e instanceof HTMLElement||e instanceof _c(e).HTMLElement:!1}function Sc(e){return!hc()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof _c(e).ShadowRoot}function Cc(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Pc(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function wc(e){return/^(table|td|th)$/.test(gc(e))}function Tc(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ec=/transform|translate|scale|rotate|perspective|filter/,Dc=/paint|layout|strict|content/,Oc=e=>!!e&&e!==`none`,kc;function Ac(e){let t=bc(e)?Pc(e):e;return Oc(t.transform)||Oc(t.translate)||Oc(t.scale)||Oc(t.rotate)||Oc(t.perspective)||!Mc()&&(Oc(t.backdropFilter)||Oc(t.filter))||Ec.test(t.willChange||``)||Dc.test(t.contain||``)}function jc(e){let t=Ic(e);for(;xc(t)&&!Nc(t);){if(Ac(t))return t;if(Tc(t))return null;t=Ic(t)}return null}function Mc(){return kc??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),kc}function Nc(e){return/^(html|body|#document)$/.test(gc(e))}function Pc(e){return _c(e).getComputedStyle(e)}function Fc(e){return bc(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ic(e){if(gc(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Sc(e)&&e.host||vc(e);return Sc(t)?t.host:t}function Lc(e){let t=Ic(e);return Nc(t)?(e.ownerDocument||e).body:xc(t)&&Cc(t)?t:Lc(t)}function Rc(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Lc(e),i=r===e.ownerDocument?.body,a=_c(r);if(i){let e=zc(a);return t.concat(a,a.visualViewport||[],Cc(r)?r:[],e&&n?Rc(e):[])}return t.concat(r,Rc(r,[],n))}function zc(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Bc(e){let t=Pc(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=xc(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ks(n)!==a||ks(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Vc(e){return bc(e)?e:e.contextElement}function Hc(e){let t=Vc(e);if(!xc(t))return js(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Bc(t),o=(a?ks(n.width):n.width)/r,s=(a?ks(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Uc=js(0);function Wc(e){let t=_c(e);return!Mc()||!t.visualViewport?Uc:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Gc(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===_c(e)}function Kc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Vc(e),o=js(1);t&&(r?bc(r)&&(o=Hc(r)):o=Hc(e));let s=Gc(a,n,r)?Wc(a):js(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=_c(a),t=bc(r)?_c(r):r,n=e,i=zc(n);for(;i&&t!==n;){let e=Hc(i),t=i.getBoundingClientRect(),r=Pc(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=_c(i),i=zc(n)}}return $s({width:u,height:d,x:c,y:l})}function qc(e,t){let n=Fc(e).scrollLeft;return t?t.left+n:Kc(vc(e)).left+n}function Jc(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-qc(e,n),y:n.top+t.scrollTop}}function Yc(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=vc(r),s=t?Tc(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=js(1),u=js(0),d=xc(r);if((d||!a)&&((gc(r)!==`body`||Cc(o))&&(c=Fc(r)),d)){let e=Kc(r);l=Hc(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Jc(o,c):js(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Xc(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Zc(e){let t=Fc(e),n=e.ownerDocument.body,r=Os(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Os(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+qc(e),o=-t.scrollTop;return Pc(n).direction===`rtl`&&(a+=Os(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Qc=25;function $c(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=_c(e),a=vc(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Mc()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(qc(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Qc&&(s-=o)}return{width:s,height:c,x:l,y:u}}function el(e,t){let n=Kc(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Hc(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function tl(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=$c(e,n,t);else if(t===`document`)r=Zc(vc(e));else if(bc(t))r=el(t,n);else{let n=Wc(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return $s(r)}function nl(e,t){let n=t.get(e);if(n)return n;let r=Rc(e,[],!1).filter(e=>bc(e)&&gc(e)!==`body`),i=null,a=Pc(e).position===`fixed`,o=a?Ic(e):e;for(;bc(o)&&!Nc(o);){let e=Pc(o),t=Ac(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ic(o)}return t.set(e,r),r}function rl(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Tc(t)?[]:nl(t,this._c):[].concat(n),r],o=tl(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=tl(t,a[e],i);s=Os(n.top,s),c=Ds(n.right,c),l=Ds(n.bottom,l),u=Os(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function il(e){let{width:t,height:n}=Bc(e);return{width:t,height:n}}function al(e,t,n){let r=xc(t),i=vc(t),a=n===`fixed`,o=Kc(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=js(0);if((r||!a)&&((gc(t)!==`body`||Cc(i))&&(s=Fc(t)),r)){let e=Kc(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=qc(i));let l=i&&!r&&!a?Jc(i,s):js(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function ol(e){return Pc(e).position===`static`}function sl(e,t){if(!xc(e)||Pc(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return vc(e)===n&&(n=n.ownerDocument.body),n}function cl(e,t){let n=_c(e);if(Tc(e))return n;if(!xc(e)){let t=Ic(e);for(;t&&!Nc(t);){if(bc(t)&&!ol(t))return t;t=Ic(t)}return n}let r=sl(e,t);for(;r&&wc(r)&&ol(r);)r=sl(r,t);return r&&Nc(r)&&ol(r)&&!Ac(r)?n:r||jc(e)||n}var ll=async function(e){let t=this.getOffsetParent||cl,n=this.getDimensions,r=await n(e.floating);return{reference:al(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ul(e){return Pc(e).direction===`rtl`}var dl={convertOffsetParentRelativeRectToViewportRelativeRect:Yc,getDocumentElement:vc,getClippingRect:rl,getOffsetParent:cl,getElementRects:ll,getClientRects:Xc,getDimensions:il,getScale:Hc,isElement:bc,isRTL:ul};function fl(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function pl(e,t,n){let r=null,i,a=vc(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=As(d),h=As(a.clientWidth-(u+f)),g=As(a.clientHeight-(d+p)),_=As(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Os(0,Ds(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!fl(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=_c(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function ml(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Vc(e),u=i||a?[...l?Rc(l):[],...t?Rc(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?pl(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Kc(e):null;c&&g();function g(){let t=Kc(e);h&&!fl(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var hl=dc,gl=fc,_l=ac,vl=mc,yl=cc,bl=ic,xl=pc,Sl=(e,t,n)=>{let r=new Map,i=n??{},a={...dl,...i.platform,_c:r};return rc(e,t,{...i,platform:a})},Cl=typeof document<`u`?E.useLayoutEffect:function(){};function wl(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!wl(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!wl(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Tl(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function El(e,t){let n=Tl(e);return Math.round(t*n)/n}function Dl(e){let t=E.useRef(e);return Cl(()=>{t.current=e}),t}function Ol(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=E.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=E.useState(r);wl(f,r)||p(r);let[m,h]=E.useState(null),[g,_]=E.useState(null),v=E.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=E.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=E.useRef(null),C=E.useRef(null),w=E.useRef(u),T=c!=null,D=Dl(c),O=Dl(i),k=Dl(l),A=E.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Sl(S.current,C.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!wl(w.current,t)&&(w.current=t,jr.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);Cl(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=E.useRef(!1);Cl(()=>(j.current=!0,()=>{j.current=!1}),[]),Cl(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(D.current)return D.current(b,x,A);A()}},[b,x,A,D,T]);let M=E.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=E.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=E.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=El(N.floating,u.x),r=El(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Tl(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return E.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:ee}),[u,A,M,N,ee])}var kl=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:bl({element:r.current,padding:i}).fn(n):r?bl({element:r,padding:i}).fn(n):{}}}},Al=(e,t)=>{let n=hl(e);return{name:n.name,fn:n.fn,options:[e,t]}},jl=(e,t)=>{let n=gl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ml=(e,t)=>({fn:xl(e).fn,options:[e,t]}),Nl=(e,t)=>{let n=_l(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pl=(e,t)=>{let n=vl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Fl=(e,t)=>{let n=yl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Il=(e,t)=>{let n=kl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ll=Object.defineProperty,Rl=(e,t)=>Ll(e,`name`,{value:t,configurable:!0}),zl=`Popper`,[Bl,Vl]=zr(zl),[Hl,Ul]=Bl(zl),Wl=Rl(e=>{let{__scopePopper:t,children:n}=e,[r,i]=E.useState(null),[a,o]=E.useState(void 0);return(0,R.jsx)(Hl,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Gl=`PopperAnchor`,Kl=E.forwardRef(Rl(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Ul(Gl,n),o=E.useRef(null),s=a.onAnchorChange,c=mr(t,E.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=E.useRef(null);E.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&$l(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,R.jsx)(Pr.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),ql=`PopperContent`,[Jl,Yl]=Bl(ql),Xl=E.forwardRef(Rl(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=Ul(ql,n),[_,v]=E.useState(null),y=mr(t,v),[b,x]=E.useState(null),S=Ts(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),D=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(Zl),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:ee,middlewareData:te}=Ol({strategy:`fixed`,placement:T,whileElementsMounted:Rl((...e)=>ml(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Al({mainAxis:i+w,alignmentAxis:o}),c&&jl({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Ml():void 0,...A}),c&&Nl({...A}),Pl({...A,apply:Rl(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&Il({element:b,padding:s}),Ql({arrowWidth:C,arrowHeight:w}),f&&Fl({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),P=g.setPlacementState;si(()=>(P(N),()=>{P(void 0)}),[N,P]);let[F,ne]=$l(N),re=Vi(m);si(()=>{ee&&re?.()},[ee,re]);let ie=te.arrow?.x,ae=te.arrow?.y,I=te.arrow?.centerOffset!==0,[L,oe]=E.useState();return si(()=>{_&&oe(window.getComputedStyle(_).zIndex)},[_]),(0,R.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:ee?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:L,"--radix-popper-transform-origin":[te.transformOrigin?.x,te.transformOrigin?.y].join(` `),...te.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,R.jsx)(Jl,{scope:n,placedSide:F,placedAlign:ne,onArrowChange:x,arrowX:ie,arrowY:ae,shouldHideArrow:I,children:(0,R.jsx)(Pr.div,{"data-side":F,"data-align":ne,...h,ref:y,style:{...h.style,animation:ee?h.style?.animation:`none`}})})})},`PopperContent`));function Zl(e){return e!==null}Rl(Zl,`isNotNull`);var Ql=Rl(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=$l(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function $l(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Rl($l,`getSideAndAlignFromPlacement`);var eu=Wl,tu=Kl,nu=Xl,ru=Object.defineProperty,iu=(e,t)=>ru(e,`name`,{value:t,configurable:!0}),au=!1;function ou(){let[e,t]=E.useState(au);return E.useEffect(()=>{au||(au=!0,t(!0))},[]),e}iu(ou,`useIsHydrated`);var su=E.useSyncExternalStore;function cu(){return()=>{}}iu(cu,`subscribe`);function lu(){return su(cu,()=>!0,()=>!1)}iu(lu,`useIsHydratedModern`);var uu=typeof su==`function`?lu:ou,du=Object.defineProperty,fu=(e,t)=>du(e,`name`,{value:t,configurable:!0}),pu=`rovingFocusGroup.onEntryFocus`,mu={bubbles:!1,cancelable:!0},hu=`RovingFocusGroup`,[gu,_u,vu]=Ur(hu),[yu,bu]=zr(hu,[vu]),[xu,Su]=yu(hu),Cu=E.forwardRef(fu(function(e,t){return(0,R.jsx)(gu.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(gu.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(wu,{...e,ref:t})})})},`RovingFocusGroup`)),wu=E.forwardRef(fu(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=E.useRef(null),p=mr(t,f),m=Ri(a),[h,g]=gi({prop:o,defaultProp:s??null,onChange:c,caller:hu}),[_,v]=E.useState(!1),y=Vi(l),b=_u(n),x=E.useRef(!1),[S,C]=E.useState(0);return E.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(pu,y),()=>e.removeEventListener(pu,y)},[y]),(0,R.jsx)(xu,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:E.useCallback(e=>g(e),[g]),onItemShiftTab:E.useCallback(()=>v(!0),[]),onFocusableItemAdd:E.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:E.useCallback(()=>C(e=>e-1),[]),children:(0,R.jsx)(Pr.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:H(e.onMouseDown,()=>{x.current=!0}),onFocus:H(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(pu,mu);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Au([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:H(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),Tu=`RovingFocusGroupItem`,Eu=E.forwardRef(fu(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Pi(),l=a||c,u=Su(Tu,n),d=u.currentTabStopId===l,f=_u(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=uu();return si(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),E.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,R.jsx)(gu.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(Pr.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:H(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:H(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:H(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=ku(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?ju(n,r+1):n.slice(r+1)}setTimeout(()=>Au(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),Du={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ou(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}fu(Ou,`getDirectionAwareKey`);function ku(e,t,n){let r=Ou(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Du[r]}fu(ku,`getFocusIntent`);function Au(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}fu(Au,`focusFirst`);function ju(e,t){return e.map((n,r)=>e[(t+r)%e.length])}fu(ju,`wrapArray`);var Mu=Cu,Nu=Eu,Pu=Object.defineProperty,Fu=(e,t)=>Pu(e,`name`,{value:t,configurable:!0}),Iu=[`Enter`,` `],Lu=[`ArrowDown`,`PageUp`,`Home`],Ru=[`ArrowUp`,`PageDown`,`End`],zu=[...Lu,...Ru];[...Iu],[...Iu];var Bu=`Menu`,[Vu,Hu,Uu]=Ur(Bu),[Wu,Gu]=zr(Bu,[Uu,Vl,bu]),Ku=Vl(),qu=bu(),[Ju,Yu]=Wu(Bu),[Xu,Zu]=Wu(Bu),Qu=Fu(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Ku(t),[c,l]=E.useState(null),u=E.useRef(!1),d=Vi(a),f=Ri(i);return E.useEffect(()=>{let e=Fu(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=Fu(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),E.useEffect(()=>{if(!n)return;let e=Fu(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,R.jsx)(eu,{...s,children:(0,R.jsx)(Ju,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(Xu,{scope:t,onClose:E.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),$u=E.forwardRef(Fu(function(e,t){let{__scopeMenu:n,...r}=e,i=Ku(n);return(0,R.jsx)(tu,{...i,...r,ref:t})},`MenuAnchor`)),ed=`MenuPortal`,[td,nd]=Wu(ed,{forceMount:void 0}),rd=Fu(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Yu(ed,t);return(0,R.jsx)(td,{scope:t,forceMount:n,children:(0,R.jsx)(wi,{present:n||a.open,children:(0,R.jsx)(ba,{asChild:!0,container:i,children:r})})})},`MenuPortal`),id=`MenuContent`,[ad,od]=Wu(id),sd=E.forwardRef(Fu(function(e,t){let n=nd(id,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Yu(id,e.__scopeMenu),o=Zu(id,e.__scopeMenu);return(0,R.jsx)(Vu.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(wi,{present:r||a.open,children:(0,R.jsx)(Vu.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(cd,{...i,ref:t}):(0,R.jsx)(ld,{...i,ref:t})})})})},`MenuContent`)),cd=E.forwardRef(Fu(function(e,t){let n=Yu(id,e.__scopeMenu),r=E.useRef(null),i=mr(t,r);return E.useEffect(()=>{let e=r.current;if(e)return Ko(e)},[]),(0,R.jsx)(dd,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:H(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),ld=E.forwardRef(Fu(function(e,t){let n=Yu(id,e.__scopeMenu);return(0,R.jsx)(dd,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),ud=_r(`MenuContent.ScrollLock`),dd=E.forwardRef(Fu(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=Yu(id,n),_=Zu(id,n),v=Ku(n),y=qu(n),b=Hu(n),[x,S]=E.useState(null),C=E.useRef(null),w=mr(t,C,g.onContentChange),T=E.useRef(0),D=E.useRef(``),O=E.useRef(0),k=E.useRef(null),A=E.useRef(`right`),j=E.useRef(0),M=m?Lo:E.Fragment,N=m?{as:ud,allowPinchZoom:!0}:void 0,ee=Fu(e=>{let t=D.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=kd(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;Fu((function e(t){D.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);E.useEffect(()=>()=>window.clearTimeout(T.current),[]),Ea();let te=E.useCallback(e=>A.current===k.current?.side&&jd(e,k.current?.area),[]);return(0,R.jsx)(ad,{scope:n,searchRef:D,onItemEnter:E.useCallback(e=>{te(e)&&e.preventDefault()},[te]),onItemLeave:E.useCallback(e=>{te(e)||(C.current?.focus(),S(null))},[te]),onTriggerLeave:E.useCallback(e=>{te(e)&&e.preventDefault()},[te]),pointerGraceTimerRef:O,onPointerGraceIntentChange:E.useCallback(e=>{k.current=e},[]),children:(0,R.jsx)(M,{...N,children:(0,R.jsx)(sa,{asChild:!0,trapped:i,onMountAutoFocus:H(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(Yi,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(Mu,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:H(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(nu,{role:`menu`,"aria-orientation":`vertical`,"data-state":wd(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:H(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ee(e.key));let i=C.current;if(e.target!==i||!zu.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);Ru.includes(e.key)&&a.reverse(),Dd(a)}),onBlur:H(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),D.current=``)}),onPointerMove:H(e.onPointerMove,Md(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),fd=E.forwardRef(Fu(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(Pr.div,{...r,ref:t})},`MenuLabel`)),pd=`MenuItem`,md=`menu.itemSelect`,hd=E.forwardRef(Fu(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=E.useRef(null),o=Zu(pd,e.__scopeMenu),s=od(pd,e.__scopeMenu),c=mr(t,a),l=E.useRef(!1),u=Fu(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(md,{bubbles:!0,cancelable:!0});e.addEventListener(md,e=>r?.(e),{once:!0}),Fr(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,R.jsx)(gd,{...i,ref:c,disabled:n,onClick:H(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:H(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:H(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&Iu.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),gd=E.forwardRef(Fu(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=od(pd,n),s=qu(n),c=E.useRef(null),l=mr(t,c),[u,d]=E.useState(!1),[f,p]=E.useState(``);return E.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(Vu.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(Nu,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(Pr.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:H(e.onPointerMove,Md(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:H(e.onPointerLeave,Md(e=>o.onItemLeave(e))),onFocus:H(e.onFocus,()=>d(!0)),onBlur:H(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[_d,vd]=Wu(`MenuRadioGroup`,{value:void 0,onValueChange:Fu(()=>{},`onValueChange`)}),[yd,bd]=Wu(`MenuItemIndicator`,{checked:!1}),xd=E.forwardRef(Fu(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(Pr.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[Sd,Cd]=Wu(`MenuSub`);function wd(e){return e?`open`:`closed`}Fu(wd,`getOpenState`);function Td(e){return e===`indeterminate`}Fu(Td,`isIndeterminate`);function Ed(e){return Td(e)?`indeterminate`:e?`checked`:`unchecked`}Fu(Ed,`getCheckedState`);function Dd(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Fu(Dd,`focusFirst`);function Od(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Fu(Od,`wrapArray`);function kd(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Od(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}Fu(kd,`getNextMatch`);function Ad(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Fu(Ad,`isPointInPolygon`);function jd(e,t){return t?Ad({x:e.clientX,y:e.clientY},t):!1}Fu(jd,`isPointerInGraceArea`);function Md(e){return t=>t.pointerType===`mouse`?e(t):void 0}Fu(Md,`whenMouse`);var Nd=Qu,Pd=$u,Fd=rd,Id=sd,Ld=fd,Rd=hd,zd=xd,Bd=Object.defineProperty,Vd=(e,t)=>Bd(e,`name`,{value:t,configurable:!0}),Hd=`ContextMenu`,[Ud,Wd]=zr(Hd,[Gu]),Gd=Gu(),[Kd,qd]=Ud(Hd),Jd=Vd(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,dir:a,modal:o=!0}=e,s=E.useRef(!1),[c,l]=gi({prop:i,defaultProp:!1,onChange:r,caller:Hd}),u=Gd(t);return(0,R.jsx)(Kd,{scope:t,open:c,onOpenChange:l,modal:o,hasInteractedRef:s,children:(0,R.jsx)(Nd,{...u,dir:a,open:c,onOpenChange:l,modal:o,children:n})})},`ContextMenu`),Yd=`ContextMenuTrigger`,Xd=E.forwardRef(Vd(function(e,t){let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=qd(Yd,n),o=Gd(n),[s,c]=E.useState({x:0,y:0}),l=E.useMemo(()=>({current:{getBoundingClientRect:Vd(()=>DOMRect.fromRect({width:0,height:0,...s}),`getBoundingClientRect`)}}),[s]),u=E.useRef(0),d=E.useCallback(()=>window.clearTimeout(u.current),[]),f=Vd(e=>{a.hasInteractedRef.current=!0,c({x:e.clientX,y:e.clientY}),a.onOpenChange(!0)},`handleOpen`);return E.useEffect(()=>d,[d]),E.useEffect(()=>void(r&&d()),[r,d]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Pd,{...o,virtualRef:l}),(0,R.jsx)(Pr.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:H(e.onContextMenu,e=>{d(),f(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:H(e.onPointerDown,nf(e=>{d(),a.open&&a.onOpenChange(!1),u.current=window.setTimeout(()=>f(e),700)})),onPointerMove:r?e.onPointerMove:H(e.onPointerMove,nf(d)),onPointerCancel:r?e.onPointerCancel:H(e.onPointerCancel,nf(d)),onPointerUp:r?e.onPointerUp:H(e.onPointerUp,nf(d))})]})},`ContextMenuTrigger`)),Zd=Vd(e=>{let{__scopeContextMenu:t,...n}=e,r=Gd(t);return(0,R.jsx)(Fd,{...r,...n})},`ContextMenuPortal`),Qd=`ContextMenuContent`,$d=E.forwardRef(Vd(function(e,t){let{__scopeContextMenu:n,...r}=e,i=qd(Qd,n),a=Gd(n),o=E.useRef(!1);return(0,R.jsx)(Id,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`ContextMenuContent`)),ef=E.forwardRef(Vd(function(e,t){let{__scopeContextMenu:n,...r}=e,i=Gd(n);return(0,R.jsx)(Rd,{...i,...r,ref:t})},`ContextMenuItem`)),tf=E.forwardRef(Vd(function(e,t){let{__scopeContextMenu:n,...r}=e,i=Gd(n);return(0,R.jsx)(zd,{...i,...r,ref:t})},`ContextMenuSeparator`));function nf(e){return t=>t.pointerType===`mouse`?void 0:e(t)}Vd(nf,`whenTouchOrPen`);var rf=Jd,af=Xd,of=Zd,sf=$d,cf=ef,lf=tf,uf=Object.defineProperty,df=(e,t)=>uf(e,`name`,{value:t,configurable:!0}),ff=`DropdownMenu`,[pf,mf]=zr(ff,[Gu]),hf=Gu(),[gf,_f]=pf(ff),vf=df(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=hf(t),l=E.useRef(null),[u,d]=gi({prop:i,defaultProp:a??!1,onChange:o,caller:ff});return(0,R.jsx)(gf,{scope:t,triggerId:Pi(),triggerRef:l,contentId:Pi(),open:u,onOpenChange:d,onOpenToggle:E.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(Nd,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),yf=`DropdownMenuTrigger`,bf=E.forwardRef(df(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=_f(yf,n),o=hf(n),s=mr(t,a.triggerRef);return(0,R.jsx)(Pd,{asChild:!0,...o,children:(0,R.jsx)(Pr.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:H(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:H(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),xf=df(e=>{let{__scopeDropdownMenu:t,...n}=e,r=hf(t);return(0,R.jsx)(Fd,{...r,...n})},`DropdownMenuPortal`),Sf=`DropdownMenuContent`,Cf=E.forwardRef(df(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=_f(Sf,n),a=hf(n),o=E.useRef(!1);return(0,R.jsx)(Id,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:H(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:H(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),wf=E.forwardRef(df(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=hf(n);return(0,R.jsx)(Ld,{...i,...r,ref:t})},`DropdownMenuLabel`)),Tf=E.forwardRef(df(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=hf(n);return(0,R.jsx)(Rd,{...i,...r,ref:t})},`DropdownMenuItem`)),Ef=E.forwardRef(df(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=hf(n);return(0,R.jsx)(zd,{...i,...r,ref:t})},`DropdownMenuSeparator`)),Df=vf,Of=bf,kf=xf,Af=Cf,jf=wf,Mf=Tf,Nf=Ef,Pf=Object.defineProperty,Ff=(e,t)=>Pf(e,`name`,{value:t,configurable:!0});function If(e,[t,n]){return Math.min(n,Math.max(t,e))}Ff(If,`clamp`);var Lf=Object.defineProperty,Rf=(e,t)=>Lf(e,`name`,{value:t,configurable:!0}),zf=`Popover`,[Bf,Vf]=zr(zf,[Vl]),Hf=Vl(),[Uf,Wf]=Bf(zf),Gf=Rf(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Hf(t),c=E.useRef(null),[l,u]=E.useState(!1),[d,f]=gi({prop:r,defaultProp:i??!1,onChange:a,caller:zf});return(0,R.jsx)(eu,{...s,children:(0,R.jsx)(Uf,{scope:t,contentId:Pi(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:E.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:E.useCallback(()=>u(!0),[]),onCustomAnchorRemove:E.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),Kf=`PopoverAnchor`,qf=E.forwardRef(Rf(function(e,t){let{__scopePopover:n,...r}=e,i=Wf(Kf,n),a=Hf(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return E.useEffect(()=>(o(),()=>s()),[o,s]),(0,R.jsx)(tu,{...a,...r,ref:t})},`PopoverAnchor`)),Jf=`PopoverPortal`,[Yf,Xf]=Bf(Jf,{forceMount:void 0}),Zf=Rf(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Wf(Jf,t);return(0,R.jsx)(Yf,{scope:t,forceMount:n,children:(0,R.jsx)(wi,{present:n||a.open,children:(0,R.jsx)(ba,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),Qf=`PopoverContent`,$f=E.forwardRef(Rf(function(e,t){let n=Xf(Qf,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Wf(Qf,e.__scopePopover);return(0,R.jsx)(wi,{present:r||a.open,children:a.modal?(0,R.jsx)(tp,{...i,ref:t}):(0,R.jsx)(np,{...i,ref:t})})},`PopoverContent`)),ep=_r(`PopoverContent.RemoveScroll`),tp=E.forwardRef(Rf(function(e,t){let n=Wf(Qf,e.__scopePopover),r=E.useRef(null),i=mr(t,r),a=E.useRef(!1);return E.useEffect(()=>{let e=r.current;if(e)return Ko(e)},[]),(0,R.jsx)(Lo,{as:ep,allowPinchZoom:!0,children:(0,R.jsx)(rp,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:H(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:H(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:H(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),np=E.forwardRef(Rf(function(e,t){let n=Wf(Qf,e.__scopePopover),r=E.useRef(!1),i=E.useRef(!1);return(0,R.jsx)(rp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),rp=E.forwardRef(Rf(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Wf(Qf,n),p=Hf(n);return Ea(),(0,R.jsx)(sa,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(Yi,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,R.jsx)(nu,{"data-state":ip(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function ip(e){return e?`open`:`closed`}Rf(ip,`getState`);var ap=Gf,op=qf,sp=Zf,cp=$f,lp=Object.defineProperty,up=(e,t)=>lp(e,`name`,{value:t,configurable:!0});function dp(e,t){return E.useReducer((e,n)=>t[e][n]??e,e)}up(dp,`useStateMachine`);var fp=`ScrollArea`,[pp,mp]=zr(fp),[hp,gp]=pp(fp),_p=E.forwardRef(up(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=E.useState(null),[l,u]=E.useState(null),[d,f]=E.useState(null),[p,m]=E.useState(null),[h,g]=E.useState(null),[_,v]=E.useState(0),[y,b]=E.useState(0),[x,S]=E.useState(!1),[C,w]=E.useState(!1),T=mr(t,c),D=Ri(i);return(0,R.jsx)(hp,{scope:n,type:r,dir:D,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:S,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:C,onScrollbarYEnabledChange:w,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,R.jsx)(Pr.div,{dir:D,...o,ref:T,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})},`ScrollArea`)),vp=`ScrollAreaViewport`,yp=E.forwardRef(up(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=gp(vp,n),s=mr(t,E.useRef(null),o.onViewportChange);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(bp,{nonce:i}),(0,R.jsx)(Pr.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,R.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),bp=E.memo(up(function({nonce:e}){return(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),xp=`ScrollAreaScrollbar`,Sp=E.forwardRef(up(function(e,t){let{forceMount:n,...r}=e,i=gp(xp,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return E.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,R.jsx)(Cp,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,R.jsx)(wp,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,R.jsx)(Tp,{...r,ref:t,forceMount:n}):i.type===`always`?(0,R.jsx)(Ep,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),Cp=E.forwardRef(up(function(e,t){let{forceMount:n,...r}=e,i=gp(xp,e.__scopeScrollArea),[a,o]=E.useState(!1);return E.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=up(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=up(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,R.jsx)(wi,{present:n||a,children:(0,R.jsx)(Tp,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),wp=E.forwardRef(up(function(e,t){let{forceMount:n,...r}=e,i=gp(xp,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Kp(()=>c(`SCROLL_END`),100),[s,c]=dp(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return E.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),E.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=up(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,R.jsx)(wi,{present:n||s!==`hidden`,children:(0,R.jsx)(Ep,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:H(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:H(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),Tp=E.forwardRef(up(function(e,t){let n=gp(xp,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=E.useState(!1),s=e.orientation===`horizontal`,c=Kp(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return qp(n.viewport,c),qp(n.content,c),(0,R.jsx)(wi,{present:r||a,children:(0,R.jsx)(Ep,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),Ep=E.forwardRef(up(function(e,t){let{orientation:n=`vertical`,...r}=e,i=gp(xp,e.__scopeScrollArea),a=E.useRef(null),o=E.useRef(0),[s,c]=E.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=zp(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:up(e=>a.current=e,`onThumbChange`),onThumbPointerUp:up(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:up(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return Vp(e,o.current,s,t)}return up(d,`getScrollPosition`),n===`horizontal`?(0,R.jsx)(Dp,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=Hp(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,R.jsx)(Op,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=Hp(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),Dp=E.forwardRef(up(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=gp(xp,e.__scopeScrollArea),[o,s]=E.useState(),c=E.useRef(null),l=mr(t,c,a.onScrollbarXChange);return E.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,R.jsx)(jp,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":Bp(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Wp(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Rp(o.paddingLeft),paddingEnd:Rp(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),Op=E.forwardRef(up(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=gp(xp,e.__scopeScrollArea),[o,s]=E.useState(),c=E.useRef(null),l=mr(t,c,a.onScrollbarYChange);return E.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,R.jsx)(jp,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":Bp(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Wp(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Rp(o.paddingTop),paddingEnd:Rp(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[kp,Ap]=pp(xp),jp=E.forwardRef(up(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=gp(xp,n),[m,h]=E.useState(null),g=mr(t,h),_=E.useRef(null),v=E.useRef(``),y=p.viewport,b=r.content-r.viewport,x=Vi(u),S=Vi(c),C=Kp(d,10);function w(e){if(_.current){let t=e.clientX-_.current.left,n=e.clientY-_.current.top;l({x:t,y:n})}}return up(w,`handleDragScroll`),E.useEffect(()=>{let e=up(e=>{let t=e.target;m?.contains(t)&&x(e,b)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),E.useEffect(S,[r,S]),qp(m,C),qp(p.content,C),(0,R.jsx)(kp,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:Vi(a),onThumbPointerUp:Vi(o),onThumbPositionChange:S,onThumbPointerDown:Vi(s),children:(0,R.jsx)(Pr.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:H(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),w(e))}),onPointerMove:H(e.onPointerMove,w),onPointerUp:H(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})},`ScrollAreaScrollbarImpl`)),Mp=`ScrollAreaThumb`,Np=E.forwardRef(up(function(e,t){let{forceMount:n,...r}=e,i=Ap(Mp,e.__scopeScrollArea);return(0,R.jsx)(wi,{present:n||i.hasThumb,children:(0,R.jsx)(Pp,{ref:t,...r})})},`ScrollAreaThumb`)),Pp=E.forwardRef(up(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=gp(Mp,n),o=Ap(Mp,n),{onThumbPositionChange:s}=o,c=mr(t,o.onThumbChange),l=E.useRef(void 0),u=Kp(()=>{l.current&&=(l.current(),void 0)},100);return E.useEffect(()=>{let e=a.viewport;if(e){let t=up(()=>{if(u(),!l.current){let t=Gp(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,R.jsx)(Pr.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:H(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:H(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),Fp=`ScrollAreaCorner`,Ip=E.forwardRef(up(function(e,t){let n=gp(Fp,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,R.jsx)(Lp,{...e,ref:t}):null},`ScrollAreaCorner`)),Lp=E.forwardRef(up(function(e,t){let{__scopeScrollArea:n,...r}=e,i=gp(Fp,n),[a,o]=E.useState(0),[s,c]=E.useState(0),l=!!(a&&s),{onCornerWidthChange:u,onCornerHeightChange:d}=i;return qp(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),qp(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),E.useEffect(()=>()=>{u(0),d(0)},[u,d]),l?(0,R.jsx)(Pr.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function Rp(e){return e?parseInt(e,10):0}up(Rp,`toInt`);function zp(e,t){let n=e/t;return isNaN(n)?0:n}up(zp,`getThumbRatio`);function Bp(e){let t=zp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}up(Bp,`getThumbSize`);function Vp(e,t,n,r=`ltr`){let i=Bp(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Up([c,l],d)(e)}up(Vp,`getScrollPositionFromPointer`);function Hp(e,t,n=`ltr`){let r=Bp(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=If(e,n===`ltr`?[0,o]:[o*-1,0]);return Up([0,o],[0,s])(c)}up(Hp,`getThumbOffsetFromScroll`);function Up(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}up(Up,`linearScale`);function Wp(e,t){return e>0&&e<t}up(Wp,`isScrollingWithinScrollbarBounds`);var Gp=up((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return up((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function Kp(e,t){let n=Vi(e),r=E.useRef(0);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),E.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}up(Kp,`useDebounceCallback`);function qp(e,t){let n=Vi(t);si(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}up(qp,`useResizeObserver`);var Jp=_p,Yp=yp,Xp=Ip,Zp=Object.defineProperty,Qp=(e,t)=>Zp(e,`name`,{value:t,configurable:!0}),$p=`horizontal`,em=[`horizontal`,`vertical`],tm=E.forwardRef(Qp(function(e,t){let{decorative:n,orientation:r=$p,...i}=e,a=nm(r)?r:$p,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,R.jsx)(Pr.div,{"data-orientation":a,...o,...i,ref:t})},`Separator`));function nm(e){return em.includes(e)}Qp(nm,`isValidOrientation`);var rm=tm,im=Object.defineProperty,am=(e,t)=>im(e,`name`,{value:t,configurable:!0}),om=`Switch`,[sm,cm]=zr(om),[lm,um]=sm(om);function dm(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=gi({prop:n,defaultProp:i??!1,onChange:c,caller:om}),[m,h]=E.useState(null),[g,_]=E.useState(null),v=E.useRef(!1),[y,b]=E.useReducer(e=>e+1,0),x={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:b,required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,R.jsx)(lm,{scope:t,...x,children:ym(d)?d(x):r})}am(dm,`SwitchProvider`);var fm=`SwitchTrigger`,pm=E.forwardRef(am(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=um(fm,e),g=mr(r,u),_=E.useRef(c);return E.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=am(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,R.jsx)(Pr.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":bm(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:g,onClick:H(t,e=>{p(),d(e=>!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`SwitchTrigger`)),mm=E.forwardRef(am(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,R.jsx)(dm,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(pm,{...d,ref:t,__scopeSwitch:n}),e&&(0,R.jsx)(vm,{__scopeSwitch:n})]})})},`Switch`)),hm=`SwitchThumb`,gm=E.forwardRef(am(function(e,t){let{__scopeSwitch:n,...r}=e,i=um(hm,n);return(0,R.jsx)(Pr.span,{"data-state":bm(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),_m=`SwitchBubbleInput`,vm=E.forwardRef(am(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=um(_m,e),g=mr(r,h),_=Ts(i),v=E.useRef(!1),y=E.useRef(s),b=E.useRef(o);E.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});n.call(e,s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=E.useRef(s);return(0,R.jsx)(Pr.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:H(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function ym(e){return typeof e==`function`}am(ym,`isFunction`);function bm(e){return e?`checked`:`unchecked`}am(bm,`getState`);var xm=Object.defineProperty,Sm=(e,t)=>xm(e,`name`,{value:t,configurable:!0}),Cm=`Tabs`,[wm,Tm]=zr(Cm,[bu]),Em=bu(),[Dm,Om]=wm(Cm),km=E.forwardRef(Sm(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Ri(s),[d,f]=gi({prop:r,onChange:i,defaultProp:a??``,caller:Cm});return(0,R.jsx)(Dm,{scope:n,baseId:Pi(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,R.jsx)(Pr.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),Am=`TabsList`,jm=E.forwardRef(Sm(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=Om(Am,n),o=Em(n);return(0,R.jsx)(Mu,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,R.jsx)(Pr.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),Mm=`TabsTrigger`,Nm=E.forwardRef(Sm(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Om(Mm,n),s=Em(n),c=Im(o.baseId,r),l=Lm(o.baseId,r),u=r===o.value;return(0,R.jsx)(Nu,{asChild:!0,...s,focusable:!i,active:u,children:(0,R.jsx)(Pr.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:H(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:H(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:H(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),Pm=`TabsContent`,Fm=E.forwardRef(Sm(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Om(Pm,n),c=Im(s.baseId,r),l=Lm(s.baseId,r),u=r===s.value,d=E.useRef(u);return E.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,R.jsx)(wi,{present:i||u,children:({present:n})=>(0,R.jsx)(Pr.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function Im(e,t){return`${e}-trigger-${t}`}Sm(Im,`makeTriggerId`);function Lm(e,t){return`${e}-content-${t}`}Sm(Lm,`makeContentId`);var Rm=km,zm=jm,Bm=Nm,Vm=Fm,Hm=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Um=It,Wm=(e,t)=>n=>{if(t?.variants==null)return Um(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Hm(t)||Hm(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Um(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},Gm=Wm(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function U({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?vr:`button`;return(0,R.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:V(Gm({variant:t,size:n,className:e})),...i})}function Km({...e}){return(0,R.jsx)(es,{"data-slot":`dialog`,...e})}function qm({...e}){return(0,R.jsx)(ns,{"data-slot":`dialog-trigger`,...e})}function Jm({...e}){return(0,R.jsx)(os,{"data-slot":`dialog-portal`,...e})}function Ym({...e}){return(0,R.jsx)(xs,{"data-slot":`dialog-close`,...e})}function Xm({className:e,...t}){return(0,R.jsx)(cs,{"data-slot":`dialog-overlay`,className:V(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Zm({className:e,children:t,showCloseButton:n=!0,...r}){return(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:V(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,R.jsx)(xs,{"data-slot":`dialog-close`,asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function Qm({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`dialog-header`,className:V(`flex flex-col gap-2`,e),...t})}function $m({className:e,showCloseButton:t=!1,children:n,...r}){return(0,R.jsxs)(`div`,{"data-slot":`dialog-footer`,className:V(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,R.jsx)(xs,{asChild:!0,children:(0,R.jsx)(U,{variant:`outline`,children:`Close`})})]})}function eh({className:e,...t}){return(0,R.jsx)(_s,{"data-slot":`dialog-title`,className:V(`font-heading text-base leading-none font-medium`,e),...t})}function th({className:e,...t}){return(0,R.jsx)(ys,{"data-slot":`dialog-description`,className:V(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function nh({className:e,type:t,...n}){return(0,R.jsx)(`input`,{type:t,"data-slot":`input`,className:V(`h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function rh({className:e,...t}){return(0,R.jsx)(`textarea`,{"data-slot":`textarea`,className:V(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function ih({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:V(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,e),...t})}var ah=Wm(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function oh({className:e,align:t=`inline-start`,...n}){return(0,R.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":t,className:V(ah({align:t}),e),onClick:e=>{e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()},...n})}var sh=E.createContext(null);function ch(){let e=E.useContext(sh);if(!e)throw Error(`Command components must be used inside <Command>`);return e}var lh=null;function uh(e){lh?.move(e)}function dh(){lh?.selectActive()}function fh(e){return e?Array.from(e.querySelectorAll(`[data-slot="command-item"]`)).filter(e=>e.dataset.disabled!==`true`):[]}function ph({className:e,children:t,...n}){let[r,i]=E.useState(``),[a,o]=E.useState(-1),s=E.useRef(null),c=E.useCallback(()=>{let e=fh(s.current);e.length!==0&&(a>=0&&a<e.length?e[a]:e[0])?.click()},[a]),l=E.useMemo(()=>({query:r,setQuery:i,rootRef:s,activeIndex:a,setActiveIndex:o,selectActive:c}),[r,a,c]),u=E.useRef({activeIndex:a,setActiveIndex:o,selectActive:c});u.current={activeIndex:a,setActiveIndex:o,selectActive:c};let d=E.useMemo(()=>({move(e){let t=u.current,n=fh(s.current);if(n.length===0)return;let r=n.length,i=t.activeIndex>=0&&t.activeIndex<r?t.activeIndex:-1;t.setActiveIndex(e===1?(i+1)%r:i<=0?r-1:i-1)},selectActive(){u.current.selectActive()}}),[]);return E.useEffect(()=>(lh=d,()=>{lh===d&&(lh=null)}),[d]),E.useEffect(()=>{fh(s.current)[a]?.scrollIntoView({block:`nearest`})},[a]),(0,R.jsx)(sh.Provider,{value:l,children:(0,R.jsx)(`div`,{ref:s,"data-slot":`command`,className:V(`flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground`,e),...n,children:t})})}function mh({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!1,...a}){return(0,R.jsxs)(Km,{...a,children:[(0,R.jsxs)(Qm,{className:`sr-only`,children:[(0,R.jsx)(eh,{children:e}),(0,R.jsx)(th,{children:t})]}),(0,R.jsx)(Zm,{className:V(`top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0`,r),showCloseButton:i,children:(0,R.jsx)(ph,{className:`[&_[data-slot=command-group-heading]]:px-2 [&_[data-slot=command-group-heading]]:font-medium [&_[data-slot=command-group-heading]]:text-muted-foreground [&_[data-slot=command-group]]:px-2 [&_[data-slot=command-input-wrapper]_svg]:size-5 [&_[data-slot=command-input]]:h-12 [&_[data-slot=command-item]]:px-2 [&_[data-slot=command-item]]:py-3 [&_[data-slot=command-item]_svg]:size-5`,children:n})})]})}function hh({className:e,value:t,onValueChange:n,...r}){let i=ch(),a=t!==void 0,o=a?t:i.query;return(0,R.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,R.jsx)(oh,{className:`[&_svg]:size-4 shrink-0 [&_svg]:text-muted-foreground`,children:(0,R.jsx)(qe,{})}),(0,R.jsx)(ih,{children:(0,R.jsx)(`input`,{"data-slot":`command-input`,className:V(`flex h-9 w-full bg-transparent text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),value:o,onChange:e=>{let t=e.target.value;a||i.setQuery(t),n?.(t)},...r})})]})}function gh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`command-list`,className:V(`max-h-[300px] overflow-y-auto overflow-x-hidden p-1`,e),...t})}function _h({className:e,...t}){let n=ch(),[r,i]=E.useState(0);E.useEffect(()=>i(e=>e+1),[n.query]);let a=n.query.trim().toLowerCase();return E.useMemo(()=>{let e=document.querySelector(`[data-slot=command]`);return!e||[...e.querySelectorAll(`[data-slot=command-item]`)].some(e=>!a||(e.dataset.value??``).toLowerCase().includes(a))},[n.query,r])?null:(0,R.jsx)(`div`,{"data-slot":`command-empty`,className:V(`py-6 text-center text-sm text-muted-foreground`,e),...t})}function vh({className:e,heading:t,children:n,...r}){let i=ch(),a=E.useRef(null);return E.useMemo(()=>{let e=i.query.trim().toLowerCase();return!a.current||[...a.current.querySelectorAll(`[data-slot=command-item]`)].some(t=>!e||(t.dataset.value??``).toLowerCase().includes(e))},[i.query])?(0,R.jsxs)(`div`,{ref:a,"data-slot":`command-group`,className:V(`overflow-hidden p-1 text-foreground **:[[data-slot=command-group-heading]]:px-2 **:[[data-slot=command-group-heading]]:py-1.5 **:[[data-slot=command-group-heading]]:text-xs **:[[data-slot=command-group-heading]]:font-medium **:[[data-slot=command-group-heading]]:text-muted-foreground`,e),...r,children:[t!==void 0&&(0,R.jsx)(`div`,{"data-slot":`command-group-heading`,className:`px-2 py-1.5 text-xs font-medium text-muted-foreground`,children:t}),n]}):null}function yh({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`command-separator`,className:V(`h-px bg-border`,e),...t})}function bh({className:e,value:t,disabled:n,onSelect:r,children:i,...a}){let o=ch(),s=E.useRef(null),[c,l]=E.useState(-1);E.useLayoutEffect(()=>{let e=s.current;if(!e||!o.rootRef.current){l(-1);return}let t=o.rootRef.current.querySelectorAll(`[data-slot="command-item"]:not([data-disabled="true"])`);l(Array.prototype.indexOf.call(t,e))});let u=!n&&c>=0&&c===o.activeIndex,d=t??s.current?.textContent??``;E.useEffect(()=>{let e=s.current;e&&(u?(e.dataset.selected=`true`,e.dataset.state=`active`,e.setAttribute(`aria-selected`,`true`)):(delete e.dataset.selected,e.dataset.state=``,e.setAttribute(`aria-selected`,`false`)))},[u]);let f=o.query.trim().toLowerCase();return f&&!d.toLowerCase().includes(f)?null:(0,R.jsx)(`div`,{ref:s,"data-slot":`command-item`,"data-value":d,role:`option`,"aria-selected":u,"data-disabled":n||void 0,"data-state":u?`active`:void 0,onClick:()=>{n||r?.()},className:V(`relative flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-[color:var(--surface-raised-base-active)] data-[selected=true]:text-[color:var(--text-strong)] data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...a,children:i})}function xh({className:e,...t}){return(0,R.jsx)(`span`,{"data-slot":`command-shortcut`,className:V(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}var Sh={showReasoning:!0,showToolDetails:!0,showTimestamps:!1},Ch=`webui.prefs`;function wh(){try{let e=localStorage.getItem(Ch);if(!e)return{...Sh};let t=JSON.parse(e);return{...Sh,...t}}catch{return{...Sh}}}var Th=wh(),Eh=new Set;function Dh(){return{...Th}}function Oh(e,t){Th={...Th,[e]:t};try{localStorage.setItem(Ch,JSON.stringify(Th))}catch{}for(let e of Eh)e()}function kh(e){return Eh.add(e),()=>Eh.delete(e)}function Ah(e,t){let n=new URLSearchParams;if(e&&(e.directory!=null&&n.set(`location[directory]`,e.directory),e.workspace!=null&&n.set(`location[workspace]`,e.workspace)),t)for(let[e,r]of Object.entries(t))r!=null&&n.set(e,String(r));return n.toString()}async function W(e,t){let n=await fetch(e,t);if(!n.ok){let e=`${n.status} ${n.statusText}`;try{let t=await n.json();t.message&&(e=t.message)}catch{}throw Error(e)}if(n.status!==204)return await n.json()}function jh(e,t){return W(e,{method:`POST`,headers:{"content-type":`application/json`},body:t==null?void 0:JSON.stringify(t)})}function Mh(e,t){return W(e,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}var G={health:()=>W(`/api/webui/status`),webuiReplay:(e,t)=>W(`/api/webui/replay?sessionID=${encodeURIComponent(e)}${t?`&since=${encodeURIComponent(t)}`:``}`),listSessions:(e={})=>{let t=new URLSearchParams;return t.set(`limit`,String(e.limit??50)),e.cursor?t.set(`cursor`,e.cursor):(t.set(`order`,`desc`),e.search&&t.set(`search`,e.search)),W(`/api/session?${t.toString()}`)},activeSessions:()=>W(`/api/session/active`),sessionWait:(e,t)=>fetch(`/api/session/${encodeURIComponent(e)}/wait`,{method:`POST`,signal:t}).then(e=>e.status,()=>-1),sessionLogHead:async e=>{try{let t=await fetch(`/api/experimental/session/${encodeURIComponent(e)}/log?follow=false`);if(!t.ok)return null;let n=await t.text();for(let e of n.split(`
50
- `))if(e.startsWith(`data:`))try{let t=JSON.parse(e.slice(5).trim());if(t.type===`log.synced`&&typeof t.seq==`number`)return t.seq}catch{}return null}catch{return null}},createSession:e=>W(`/api/session`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),getSession:e=>W(`/api/session/${e}`),renameSession:(e,t)=>W(`/api/session/${e}/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:t})}),forkSession:(e,t)=>W(`/api/session/${e}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({boundary:t})}),exportSession:(e,t=!1)=>W(`/api/session/${e}/export?sanitize=${t}`),compactSession:(e,t=`steer`)=>W(`/api/session/${e}/compact`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:null,delivery:t})}),deleteSession:e=>W(`/api/session/${e}`,{method:`DELETE`}),switchAgent:(e,t)=>W(`/api/session/${e}/agent`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({agent:t})}),switchModel:(e,t)=>W(`/api/session/${e}/model`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({model:t})}),interrupt:(e,t)=>W(`/api/session/${e}/interrupt${t===void 0?``:`?continue=${t}`}`,{method:`POST`}),moveSession:(e,t)=>W(`/api/session/${e}/move`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({directory:t})}),revertStage:(e,t)=>W(`/api/session/${e}/revert/stage`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({messageID:t})}),revertClear:e=>W(`/api/session/${e}/revert/clear`,{method:`POST`}),revertCommit:e=>W(`/api/session/${e}/revert/commit`,{method:`POST`}),sessionBackground:e=>W(`/api/session/${e}/background`,{method:`POST`}),sessionShell:(e,t)=>W(`/api/session/${e}/shell`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:crypto.randomUUID(),command:t})}),messages:(e,t=100)=>W(`/api/session/${e}/message?limit=${t}&order=desc`),messagesWithCursor:(e,t=100,n)=>{let r=new URLSearchParams({limit:String(t)});return n?r.set(`cursor`,n):r.set(`order`,`desc`),W(`/api/session/${e}/message?${r.toString()}`)},prompt:(e,t,n)=>W(`/api/session/${e}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n?{text:t,delivery:n}:{text:t})}).then(e=>e.data),promptWithFiles:(e,t,n,r)=>W(`/api/session/${e}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r?{text:t,files:n,delivery:r}:{text:t,files:n})}).then(e=>e.data),runCommand:(e,t,n)=>W(`/api/session/${e}/command`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({command:t,arguments:n??null})}),activateSkill:(e,t)=>W(`/api/session/${e}/skill`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({skill:t})}),pendingPermissions:()=>W(`/api/permission/request`),replyPermission:(e,t,n)=>W(`/api/session/${e}/permission/${t}/reply`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({reply:n,message:null})}),pendingForms:()=>W(`/api/form/request`),sessionForms:e=>W(`/api/session/${e}/form`),formState:(e,t)=>W(`/api/session/${e}/form/${t}/state`),replyForm:(e,t,n)=>W(`/api/session/${e}/form/${t}/reply`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answer:n})}),cancelForm:(e,t)=>W(`/api/session/${e}/form/${t}/cancel`,{method:`POST`}),questionRequestGet:()=>W(`/api/question/request`),sessionQuestionList:e=>W(`/api/session/${e}/question`),sessionQuestionReply:(e,t,n)=>W(`/api/session/${e}/question/${t}/reply`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answers:n})}),sessionQuestionReject:(e,t)=>W(`/api/session/${e}/question/${t}/reject`,{method:`POST`}),inboxList:e=>W(`/api/session/${e}/inbox`),inboxQueue:(e,t)=>W(`/api/session/${e}/inbox/${t}/queue`,{method:`POST`}),inboxSteer:(e,t)=>W(`/api/session/${e}/inbox/${t}/steer`,{method:`POST`}),inboxDelete:(e,t)=>W(`/api/session/${e}/inbox/${t}`,{method:`DELETE`}),inboxPrompt:(e,t)=>G.prompt(e,t,`queue`),location:()=>W(`/api/location`),locationInfo:()=>W(`/api/location`),projectCurrent:()=>W(`/api/project/current`),projectList:()=>W(`/api/project`),fsFind:(e,t)=>{let n=new URLSearchParams({query:e});return t?.location&&n.set(`location[directory]`,t.location),t?.type&&n.set(`type`,t.type),t?.limit!==void 0&&n.set(`limit`,String(t.limit)),W(`/api/fs/find?${n.toString()}`)},fsList:e=>{let t=new URLSearchParams;return e?.location&&t.set(`location[directory]`,e.location),e?.path&&t.set(`path`,e.path),W(`/api/fs/list?${t.toString()}`)},fsRead:async(e,t)=>{let n=e.split(`/`).map(encodeURIComponent).join(`/`),r=new URLSearchParams;t&&r.set(`location[directory]`,t);let i=r.toString(),a=await fetch(`/api/fs/read/${n}${i?`?${i}`:``}`);if(!a.ok){let e=`${a.status} ${a.statusText}`;try{let t=await a.json();t.message&&(e=t.message)}catch{}throw Error(e)}return a.text()},fsReadBytes:async(e,t)=>{let n=e.split(`/`).map(encodeURIComponent).join(`/`),r=new URLSearchParams;t&&r.set(`location[directory]`,t);let i=r.toString(),a=await fetch(`/api/fs/read/${n}${i?`?${i}`:``}`);if(!a.ok)throw Error(`${a.status} ${a.statusText}`);return a.arrayBuffer()},models:async()=>(await W(`/api/model`)).data,agents:async()=>(await W(`/api/agent`)).data,commands:async()=>(await W(`/api/command`)).data,skills:async()=>(await W(`/api/skill`)).data,vcsStatus:e=>W(`/api/vcs/status?${Ah(e)}`),vcsDiff:(e,t,n)=>W(`/api/vcs/diff?${Ah(t,{mode:e,context:n})}`),shellList:e=>W(`/api/shell?${Ah(e)}`),shellCreate:(e,t)=>W(`/api/shell?${Ah(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),shellGet:(e,t)=>W(`/api/shell/${e}?${Ah(t)}`),shellDelete:(e,t)=>W(`/api/shell/${e}?${Ah(t)}`,{method:`DELETE`}),shellOutput:(e,t,n)=>W(`/api/shell/${e}/output?${Ah(n,{cursor:t?.cursor,limit:t?.limit})}`),shellTimeout:(e,t,n)=>W(`/api/shell/${e}/timeout?${Ah(n)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({timeout:t})}),ptyList:e=>W(`/api/pty?${Ah(e)}`),ptyCreate:(e,t)=>W(`/api/pty?${Ah(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),ptyDelete:(e,t)=>W(`/api/pty/${e}?${Ah(t)}`,{method:`DELETE`}),ptyConnectToken:(e,t)=>W(`/api/pty/${e}/connect-token?${Ah(t)}`,{method:`POST`,headers:{"x-opencode-ticket":`1`}}),ptyUpdate:(e,t,n)=>W(`/api/pty/${e}?${Ah(n)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),providerList:()=>W(`/api/provider`),providerGet:e=>W(`/api/provider/${e}`),integrationList:()=>W(`/api/integration`),integrationConnectKey:(e,t)=>jh(`/api/integration/${e}/connect/key`,{key:t.key,answer:t.answer??null,label:t.label??null}),integrationConnectOauth:(e,t)=>jh(`/api/integration/${e}/connect/oauth`,{methodID:t.methodID,answer:t.answer??null,label:t.label??null}),integrationConnectCommand:(e,t)=>jh(`/api/integration/${e}/connect/command`,{methodID:t.methodID,label:t.label??null}),integrationOauthAttempt:(e,t)=>W(`/api/integration/${e}/connect/oauth/${t}`),integrationCommandAttempt:(e,t)=>W(`/api/integration/${e}/connect/command/${t}`),mcpList:()=>W(`/api/mcp`),mcpResource:()=>W(`/api/mcp/resource`),mcpPut:(e,t)=>Mh(`/api/mcp/${e}`,{config:t}),mcpDelete:e=>W(`/api/mcp/${e}`,{method:`DELETE`}),mcpConnect:e=>jh(`/api/mcp/${e}/connect`,null),mcpDisconnect:e=>jh(`/api/mcp/${e}/disconnect`,null),pluginList:()=>W(`/api/plugin`),websearchProviders:()=>W(`/api/websearch/provider`),websearch:(e,t)=>jh(`/api/websearch`,{query:e,providerID:t}),configGet:()=>W(`/api/config`),credentialPatch:(e,t)=>Mh(`/api/credential/${e}`,{label:t}),credentialDelete:e=>W(`/api/credential/${e}`,{method:`DELETE`}),serverInfo:()=>W(`/api/server`),serviceStop:e=>jh(`/api/service/stop`,{instanceID:e??``}),generate:(e,t)=>jh(`/api/generate`,{prompt:e,model:t??null}),referenceList:()=>W(`/api/reference`)},Nh=[],Ph=null,Fh=new Map,Ih=new Map;function Lh(e){return e.length===0?``:` `+e.map(e=>typeof e==`string`?e:Rh(e)).join(` `)}function Rh(e){if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}function zh(e){Nh.push(e),Ph||=setTimeout(()=>{Ph=null,Bh()},400)}async function Bh(){if(Nh.length===0)return;let e=Nh.splice(0);try{await fetch(`/api/debug`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}catch{}}var Vh=1e3;function Hh(e,t,...n){let r=e+`|`+t,i=Date.now(),a=(Fh.get(r)??0)+1;Fh.set(r,a);let o=Ih.get(r)??0;if(a===1||i-o>=Vh){Ih.set(r,i);let o=`[${new Date().toISOString().slice(11,23)}] [${e}] ${t}${a>1?` (x${a})`:``}${Lh(n)}`;typeof window<`u`&&window.__WEBUI_DEBUG_CONSOLE__&&console.debug(o),zh(o)}}var Uh=2e4,Wh=3e4,Gh=0;function Kh(){return Gh===0?1/0:Date.now()-Gh}function qh(){return Kh()>Wh}async function Jh(e,t={}){for(;!t.signal?.aborted;){let n=!1,r=0;try{let i=await fetch(`/api/event`,{signal:t.signal});if(!i.ok||!i.body)throw Error(`event stream: ${i.status}`);Hh(`sse`,`connected`,i.status),Gh=Date.now(),t.onOpen?.();let a=i.body.getReader(),o=new TextDecoder,s=``,c=()=>setTimeout(()=>{n=!0,Hh(`sse`,`STALLED - no data for ${Uh/1e3}s (rx=${r}B total); forcing reconnect`),console.warn(`[events] no data for ${Uh/1e3}s; forcing reconnect`),a.cancel()},Uh),l=c(),u=null,d=t=>{let n;try{n=JSON.parse(t)}catch{return!1}let r=typeof n.type==`string`?n.type:null;if(!r)return!1;let i={id:typeof n.id==`string`?n.id:``,created:typeof n.created==`number`?n.created:Date.now(),type:r,data:n.data??{}};return e({id:i.id,event:r,data:i}),!0};for(;;){let{done:e,value:t}=await a.read();if(e)break;clearTimeout(l),Gh=Date.now(),r+=t.byteLength,s+=o.decode(t,{stream:!0});let n=s.split(`
51
- `);s=n.pop()??``;for(let e of n){let t=e.trim();if(!t){u=null;continue}if(!t.startsWith(`data:`))continue;let n=t.slice(5).trim();u=d(u?u+n:n)?null:u?u+n:n}l=c()}if(clearTimeout(l),a.releaseLock(),n)throw Error(`event stream stalled`);Hh(`sse`,`stream ended cleanly; reconnecting (rx=${r}B)`)}catch(e){if(t.signal?.aborted)return;Hh(`sse`,`reconnect`,String(e)),console.warn(`[events] stream ended, reconnecting:`,e)}n?await new Promise(e=>setTimeout(e,500)):await new Promise(e=>setTimeout(e,1500))}}var Yh=new Map,Xh=1,Zh=null,Qh=null,$h=1e3;function eg(){return typeof document<`u`&&document.hidden?`hidden`:Qh?Qh.isBusy()||Qh.isSseStale()?`live`:`idle`:`live`}function tg(e,t){return Math.max(e.minInterval,e.intervals[t]??e.minInterval)}function ng(e,t){e.lastRun=t,e.inFlight=!0;let n;try{n=e.run()}catch(t){e.inFlight=!1,Hh(`poll`,`${e.name} failed: ${t instanceof Error?t.message:String(t)}`);return}n instanceof Promise?n.catch(t=>{Hh(`poll`,`${e.name} failed: ${t instanceof Error?t.message:String(t)}`)}).finally(()=>{e.inFlight=!1}):e.inFlight=!1}function rg(){let e=eg(),t=Date.now();for(let n of Yh.values())e===`hidden`&&!n.whenHidden||n.inFlight||t-n.lastRun<tg(n,e)||ng(n,t)}function ig(e){Qh=e,!Zh&&(Zh=setInterval(rg,$h),typeof document<`u`&&document.addEventListener(`visibilitychange`,ag))}function ag(){document.hidden||rg()}function og(e){let t=Xh++,n={name:e.name,minInterval:e.minInterval,intervals:e.intervals??{},whenHidden:e.whenHidden??!1,run:e.run,lastRun:Date.now()-Math.random()*e.minInterval,inFlight:!1};return Yh.set(t,n),()=>{Yh.delete(t)}}var sg=`modulepreload`,cg=function(e){return`/`+e},lg={},ug=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}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=cg(t,n),t=s(t),t in lg)return;lg[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:sg,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.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)})},dg=s({DRAFT_SESSION_ID:()=>Tg,MAIN_PANE:()=>wg,MAX_SPLITS:()=>3,NEW_SESSION_HREF:()=>Pg,activateSkill:()=>jy,addSplitPane:()=>Gv,applyRevertView:()=>Av,backgroundSubagents:()=>Ly,cancelForm:()=>By,cancelPendingRequest:()=>Uy,childSessionsOf:()=>Ov,clearPendingEdit:()=>ob,clearSendError:()=>vy,closeRunsPanel:()=>wv,closeSplitPicker:()=>Wv,commitPendingEdit:()=>sb,compactSession:()=>nb,consumeRevertPrompt:()=>Dv,createRealSession:()=>Jy,dismissRunNotice:()=>G_,editAtMessage:()=>cb,ensureSessionWait:()=>ov,exportSession:()=>tb,fetchReplay:()=>tv,flushSteersNow:()=>Sy,focusPane:()=>Hv,focusedPaneKey:()=>Yv,forkAtMessage:()=>lb,forkSession:()=>eb,getState:()=>Ng,handleEvent:()=>$_,interrupt:()=>My,isDraftSession:()=>Eg,lastLiveSignalAt:()=>Jg,liveToolPart:()=>A_,loadMessages:()=>Qg,loadMoreSessions:()=>Xg,loadSessionDetail:()=>M_,materializeDraft:()=>Yy,navigateFocused:()=>Jv,newSession:()=>Xy,openRunsPanel:()=>Cv,openSplitPicker:()=>Uv,pendingDelete:()=>yy,pendingRequests:()=>Sg,pendingSendNow:()=>xy,pendingSetDelivery:()=>by,prefetchSession:()=>Xv,reconcileInbox:()=>dy,redoSession:()=>ib,refreshSessions:()=>Yg,rejectQuestion:()=>Hy,removeSplitPane:()=>Kv,renameSession:()=>$y,replyForm:()=>zy,replyPermission:()=>Ry,replyQuestion:()=>Vy,requestInterrupt:()=>Iy,requestShellPanel:()=>xv,resolveDefaultModel:()=>P_,revealSubagentComposer:()=>Ev,revertMarkerFor:()=>jv,selectSession:()=>Pv,sendCommand:()=>hy,sendPromptTo:()=>ey,sendPromptWithFiles:()=>_y,sendShell:()=>gy,sessionHref:()=>Fg,sessionLabel:()=>Cg,sessionOrSubagentsLive:()=>kv,setHighlightMessage:()=>Ky,setPaneSession:()=>qv,setPendingWorkspace:()=>Gy,setRunsSelection:()=>Tv,signalUI:()=>Sv,startDraftSession:()=>Wy,startEditAtMessage:()=>ab,startStore:()=>mv,switchAgent:()=>Zy,switchModel:()=>Qy,undoSession:()=>rb,useStore:()=>J}),fg=0,pg=()=>++fg,mg=new Map,hg=6e4;function gg(e){let t=Date.now();for(let n of e)mg.has(n)||mg.set(n,t);if(mg.size>500)for(let[e,n]of mg)t-n>10*hg&&mg.delete(e)}var _g=new Map;function vg(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>n.get(e.id)||{...e,seq:pg()})}function yg(e){return e.metadata?.kind===`question`}function bg(e){let t=e.metadata;return{id:e.id,sessionID:e.sessionID,seq:e.seq,channel:`form`,tool:t?.tool,questions:e.fields.map(e=>{let t=e;return{header:(`title`in e?e.title:void 0)??e.key,question:(`description`in e?e.description:void 0)??``,options:(`options`in e?e.options??[]:[]).map(e=>({label:e.label,value:e.value,description:e.description??``})),multiple:`type`in e&&e.type===`multiselect`,custom:t.custom===!0}})}}var xg=null;function Sg(e){if(xg&&xg.permissions===e.permissions&&xg.forms===e.forms&&xg.questions===e.questions)return xg.out;let t=[];for(let n of e.permissions)t.push({kind:`permission`,req:n});for(let n of e.questions)t.push({kind:`question`,req:n});for(let n of e.forms)yg(n)?t.push({kind:`question`,req:bg(n)}):t.push({kind:`form`,req:n});let n=t.sort((e,t)=>e.req.seq-t.req.seq);return xg={permissions:e.permissions,forms:e.forms,questions:e.questions,out:n},n}function Cg(e,t){return Eg(t)?`New session`:e.sessions.find(e=>e.id===t)?.title??e.sessionDetails[t]?.title??`session ${t.slice(0,8)}…`}var wg=`main`,Tg=`__draft__`;function Eg(e){return e===Tg}var K={connected:!1,serviceOK:!1,sessions:[],sessionsCursor:null,activeIDs:[],messages:{},sessionDetails:{},live:[],running:{},queued:{},permissions:[],forms:[],questions:[],currentSessionID:null,panes:[{id:wg,sessionID:null}],focusedPane:wg,splitPickerOpen:!1,shellPanelTick:0,uiSignals:{models:0,agents:0,themes:0,explorer:0,runsDialog:0,help:0,variants:0},revertPrompt:null,runsPanelOpen:!1,runsSelection:null,subagentComposerOpen:!1,draftWorkspace:null,pendingAgent:null,pendingModel:null,sendErrors:{},pending:{},runNotices:{},pendingWorkspace:null,interruptArmed:!1,highlightMessageID:null,highlightSessionID:null,pendingEdit:null,revertMarkers:{}},Dg=new Set,Og=0,kg=!1;function q(e){if(K={...K,...e},Og>0){kg=!0;return}Ag()}function Ag(){for(let e of Dg)e()}function jg(e){Og+=1;try{e()}finally{--Og,Og===0&&kg&&(kg=!1,Ag())}}function Mg(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.is(e[r],t[r]))return!1;return!0}function J(e){let t=(0,E.useRef)(null);return(0,E.useSyncExternalStore)(e=>(Dg.add(e),()=>Dg.delete(e)),()=>{let n=e(K);return t.current&&Mg(t.current.value,n)?t.current.value:(t.current={value:n},n)})}function Ng(){return K}var Pg=`/new-session`;function Fg(e){return`/session/${encodeURIComponent(e)}`}function Ig(){if(typeof window>`u`)return null;let e=window.location.pathname.match(/^\/session\/([^/]+)\/?$/);if(!e)return null;let t=e[1];if(!t)return null;try{return decodeURIComponent(t)}catch{return null}}function Lg(){return typeof window<`u`&&window.location.pathname===`/new-session`}function Rg(e,t){if(typeof window>`u`)return;let n=e===`__draft__`?Pg:e?Fg(e):`/`;window.location.pathname===n&&!window.location.search&&!window.location.hash||window.history[t===`replace`?`replaceState`:`pushState`]({},``,n)}var zg=null;function Bg(){zg&&clearTimeout(zg),zg=setTimeout(()=>void Yg(),400)}var Vg=100,Hg=3e4,Ug=15e3,Wg=45e3,Gg=new Map,Kg=new Map;function qg(e){e&&Gg.set(e,Date.now())}function Jg(e){return Kg.get(e)??0}async function Yg(){try{let e=await G.listSessions({limit:Math.max(Vg,K.sessions.length+1)}),t=await G.activeSessions(),n=new Set(Object.keys(t.data)),r=Date.now(),i={...K.running},a=[];for(let e of n)i[e]||r-(Gg.get(e)??0)<Hg||(i[e]=!0,a.push(e));for(let e of a)ov(e);for(let[e,t]of Object.entries(i))!t||n.has(e)||r-Jg(e)<Ug||delete i[e];let o={...K.queued};for(let[e,t]of Object.entries(o))!t||n.has(e)||i[e]||r-Jg(e)<Wg||delete o[e];let s=[...e.data].sort((e,t)=>t.time.updated-e.time.updated),c=K.sessions.length!==s.length||K.sessions.some((e,t)=>{let n=s[t];return!n||n.id!==e.id||n.time.updated!==e.time.updated||n.title!==e.title}),l=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]),r=Object.keys(t).filter(e=>t[e]);return n.length===r.length&&n.every(e=>t[e])},u=[...n],d=K.activeIDs.length!==u.length||K.activeIDs.some((e,t)=>e!==u[t]);if(!c&&!d&&l(K.running,i)&&l(K.queued,o))return;q({...c?{sessions:s,sessionsCursor:e.cursor.next}:{},...d?{activeIDs:u}:{},...l(K.running,i)?{}:{running:i},...l(K.queued,o)?{}:{queued:o}})}catch(e){console.warn(`refreshSessions failed:`,e)}}async function Xg(){try{let e=await G.listSessions({limit:Vg,cursor:K.sessionsCursor}),t=new Map;for(let e of K.sessions)t.set(e.id,e);for(let n of e.data)t.set(n.id,n);q({sessions:[...t.values()].sort((e,t)=>t.time.updated-e.time.updated),sessionsCursor:e.cursor.next})}catch(e){console.warn(`loadMoreSessions failed:`,e)}}async function Zg(){let e=new Set(K.panes.map(e=>e.sessionID).filter(e=>!!e)),[t,n,...r]=await Promise.allSettled([G.pendingPermissions(),G.pendingForms(),...[...e].map(e=>G.sessionForms(e))]);function i(e,t){let n=new Map(vg(e,t).map(e=>[e.id,e]));for(let t of e)n.has(t.id)||n.set(t.id,t);return[...n.values()]}if(t.status===`fulfilled`){let e=t.value.data;q({permissions:i(K.permissions,e)})}else console.warn(`refreshQueues permissions failed:`,t.reason);if(n.status===`fulfilled`){let e=new Map,t=t=>{e.has(t.id)||e.set(t.id,t)};n.value.data.forEach(t);for(let e of r)e.status===`fulfilled`?e.value.data.forEach(t):console.warn(`refreshQueues session forms failed:`,e.reason);let a=[...e.values()],o=K.forms;gg([...o.map(e=>e.id),...a.map(e=>e.id)]);let s=new Set(o.map(e=>e.id)),c=new Set;await Promise.all([...s].map(async t=>{let n=K.forms.find(e=>e.id===t)??e.get(t);if(n)try{((await G.formState(n.sessionID,t)).data?.status??`pending`)!==`pending`&&c.add(t)}catch(e){let n=e instanceof Error?e.message:String(e),r=mg.get(t)??Date.now();n.includes(`404`)&&Date.now()-r>hg&&c.add(t)}}));let l=Date.now();for(let e of c)_g.set(e,l);if(_g.size>500)for(let[e,t]of _g)l-t>hg&&_g.delete(e);let u=a.filter(e=>{let t=_g.get(e.id);return t===void 0||Date.now()-t>hg});Hh(`queue`,`refresh forms=${o.length} listed=${a.length} settled=${c.size}`),q({forms:i(K.forms,u).filter(e=>!c.has(e.id))})}else console.warn(`refreshQueues forms failed:`,n.reason)}async function Qg(e){if(Eg(e))return;let t=e_(e),n=[],r,i=0;try{do{let a=r?await G.messagesWithCursor(e,200,r):await G.messages(e,200);if($g.get(e)!==t)return;let o=a.data;if(n.push(...o),r=a.cursor?.next,i++,o.length<200)break}while(r&&i<5)}catch(e){if(n.length===0){console.warn(`loadMessages failed:`,e);return}console.warn(`loadMessages partial failure, using`,n.length,`messages:`,e)}if($g.get(e)!==t)return;let a=[...n].reverse();Hh(`load`,`messages ${e}: ${a.length} (${i} pages)`),S_(e,a)}var $g=new Map;function e_(e){let t=($g.get(e)??0)+1;return $g.set(e,t),t}function t_(e){return e?.type===`assistant`&&e.time.completed===void 0}function n_(e){return K.panes.some(t=>t.sessionID===e)}function r_(e){return K.live.filter(t=>t.sessionID===e)}function i_(e){return e?!!(n_(e)||e===K.currentSessionID||r_(e).length>0||K.running[e]||K.queued[e]||K.activeIDs.includes(e)):!1}function a_(e){let t=new Set(e.map(e=>e.sessionID));return K.live.filter(e=>t.has(e.sessionID)||!!K.running[e.sessionID]||!!K.queued[e.sessionID]||K.activeIDs.includes(e.sessionID))}var o_=`webui.live.`;function s_(e){return`${o_}${e}`}function c_(e){if(!(!e||Eg(e)))try{if(typeof localStorage>`u`)return;let t=r_(e);if(t.length===0){localStorage.removeItem(s_(e));return}let n=t.map(e=>({id:e.id,sessionID:e.sessionID,agent:e.agent,model:e.model,started:e.started,completed:e.completed,finish:e.finish,cost:e.cost,error:e.error,content:e.content.map(e=>e.type===`tool`?{type:`tool`,tool:{id:e.tool.id,name:e.tool.name,inputText:e.tool.inputText,input:e.tool.input,status:e.tool.status,content:e.tool.content,metadata:e.tool.metadata,error:e.tool.error,executed:e.tool.executed,created:e.tool.created,ran:e.tool.ran,completed:e.tool.completed}}:{type:e.type,ordinal:e.ordinal,text:e.text})}));localStorage.setItem(s_(e),JSON.stringify(n))}catch{}}function l_(e){try{if(typeof localStorage>`u`)return;localStorage.removeItem(s_(e))}catch{}}function u_(e){if(!e||Eg(e)||r_(e).length>0)return!1;try{if(typeof localStorage>`u`)return!1;let t=localStorage.getItem(s_(e));if(!t)return!1;let n=JSON.parse(t);if(!Array.isArray(n)||n.length===0)return!1;let r=[];for(let t of n){if(!t||typeof t.id!=`string`||typeof t.sessionID!=`string`||t.sessionID!==e)continue;let n=Array.isArray(t.content)?t.content:[],i=[],a=new Map;for(let e of n)if(!(!e||typeof e.type!=`string`)){if(e.type===`tool`&&e.tool&&typeof e.tool.id==`string`){let t=e.tool,n={id:t.id,name:t.name??`tool`,inputText:t.inputText??``,input:t.input,status:t.status??`streaming`,content:t.content,metadata:t.metadata,error:t.error,executed:t.executed,created:t.created,ran:t.ran,completed:t.completed};a.set(n.id,n),i.push({type:`tool`,tool:n})}else(e.type===`text`||e.type===`reasoning`)&&typeof e.ordinal==`number`&&typeof e.text==`string`&&i.push({type:e.type,ordinal:e.ordinal,text:e.text})}let o={sessionID:t.sessionID,id:t.id,agent:t.agent,model:t.model,content:i,text:``,reasoning:``,tools:a,finish:t.finish,cost:t.cost,error:t.error,started:typeof t.started==`number`?t.started:Date.now(),completed:t.completed};r.push(f_(o,i))}return r.length!==0&&(q({live:[...K.live,...r]}),Hh(`load`,`restored ${r.length} live assistant(s) for ${e} from localStorage`),!0)}catch{return!1}}function d_(e){return{text:e.filter(e=>e.type===`text`).map(e=>e.text).join(``),reasoning:e.filter(e=>e.type===`reasoning`).map(e=>e.text).join(``),tools:new Map(e.filter(e=>e.type===`tool`).map(e=>[e.tool.id,e.tool]))}}function f_(e,t){return{...e,content:t,...d_(t)}}function p_(e){let t=e.state,n=t.status===`streaming`?t.input:JSON.stringify(t.input);return{id:e.id,name:e.name,inputText:n,input:t.status===`streaming`?void 0:t.input,status:t.status,content:`content`in t?t.content:void 0,metadata:`metadata`in t?t.metadata:void 0,error:t.status===`error`?t.error:void 0,executed:e.executed,created:e.time.created,ran:e.time.ran,completed:e.time.completed}}function m_(e,t){let n={text:0,reasoning:0},r=t.content.map(e=>{if(e.type===`tool`)return{type:`tool`,tool:p_(e)};let t=n[e.type]++;return{type:e.type,ordinal:t,text:e.text}});return f_({sessionID:e,id:t.id,agent:t.agent,model:t.model,content:[],text:``,reasoning:``,tools:new Map,finish:t.finish,cost:t.cost,error:t.error,started:t.time.created,completed:t.time.completed},r)}function h_(e,t){return e?t?t.startsWith(e)||e.endsWith(t)?t.length>=e.length?t:e:e.startsWith(t)?e:`${e}${t}`:e:t}function g_(e,t){if(!t)return e;if(!e)return t;if(e.endsWith(t))return e;let n=Math.min(e.length,t.length-1);for(let r=n;r>0;r--)if(e.endsWith(t.slice(0,r)))return e+t.slice(r);return e+t}function __(e){return e.type===`tool`?`tool:${e.tool.id}`:`${e.type}:${e.ordinal}`}function v_(e,t){let n=m_(e.sessionID,t);if(e.content.length===0)return{...n,id:e.id,started:e.started,sessionID:e.sessionID};let r=new Map(e.content.map(e=>[__(e),e])),i=n.content.map(e=>{let t=r.get(__(e));if(!t)return e;if(e.type===`tool`&&t.type===`tool`){let n=e.tool,r=t.tool;return{type:`tool`,tool:{...n,...r,inputText:h_(n.inputText,r.inputText),input:r.input??n.input,status:r.status===`streaming`&&n.status!==`streaming`?n.status:r.status,content:r.content??n.content,metadata:r.metadata??n.metadata,error:r.error??n.error,executed:r.executed??n.executed,created:n.created??r.created,ran:r.ran??n.ran,completed:r.completed??n.completed}}}return e.type!==`tool`&&t.type!==`tool`?{...e,text:h_(e.text,t.text)}:e}),a=new Set(i.map(__));return i.push(...e.content.filter(e=>!a.has(__(e)))),f_({...e,agent:e.agent??n.agent,model:e.model??n.model,finish:e.finish??n.finish,cost:e.cost??n.cost,error:e.error??n.error,completed:e.completed??n.completed},i)}function y_(e,t){if(r_(e).length===0&&u_(e),!i_(e)&&!n_(e))return;let n=r_(e).length>0,r=e===K.currentSessionID;if(!(K.running[e]||K.queued[e]||K.activeIDs.includes(e)||n)&&!(r&&n))return;let i=new Map(t.filter(e=>e.type===`assistant`&&t_(e)).map(e=>[e.id,e])),a=new Set(r_(e).map(e=>e.id)),o=[];for(let n of t)n.type!==`assistant`||!t_(n)||a.has(n.id)||(a.add(n.id),o.push(m_(e,n)));let s=!1,c=K.live.map(t=>{if(t.sessionID!==e)return t;let n=i.get(t.id);if(!n)return t;let r=v_(t,n);return s||=r!==t,r});o.length>0&&(Hh(`load`,`seeded ${o.length} in-flight assistant(s) for ${e}`),c=[...c,...o],s=!0),s&&q({live:c})}function b_(e,t){let n=new Map(t.map(e=>[e.id,e]));return new Set(r_(e).filter(e=>{let t=n.get(e.id);return e.id!==`pending`&&(!t||t_(t))}).map(e=>e.id))}function x_(e,t){let n=K.messages[e]??[],r=b_(e,t),i=new Map,a=new Map;for(let e of n)e.type===`user`&&!e.id.startsWith(`msg_local_`)&&i.set(e.text,(i.get(e.text)??0)+1);for(let e of t)e.type===`user`&&a.set(e.text,(a.get(e.text)??0)+1);let o=new Map;for(let[e,t]of a){let n=t-(i.get(e)??0);n>0&&o.set(e,n)}let s=new Map;for(let e of n)if(!r.has(e.id)){if(e.id.startsWith(`msg_local_`)&&e.type===`user`){let t=o.get(e.text)??0;if(t>0){o.set(e.text,t-1);continue}}s.set(e.id,e)}for(let e of t)r.has(e.id)||s.set(e.id,e);return[...s.values()].sort((e,t)=>e.time.created-t.time.created||e.id.localeCompare(t.id))}function S_(e,t){y_(e,t);let n=x_(e,t);if(!n_(e)){let r=new Map(t.map(e=>[e.id,e])),i=!K.running[e]&&!K.queued[e],a=r_(e),o=new Set(a.filter(e=>{if(e.id===`pending`)return!1;if(i&&!r.has(e.id)&&Date.now()-e.started>3e4)return!0;let t=r.get(e.id);return t?.type===`assistant`&&t.time.completed!==void 0}).map(e=>e.id)),s=o.size>0?K.live.filter(t=>!(t.sessionID===e&&o.has(t.id))):K.live;q({messages:{...K.messages,[e]:n},...s===K.live?{}:{live:s}}),a.length>0&&o.size===a.length&&l_(e);return}let r=new Map(t.map(e=>[e.id,e])),i=r_(e),a=i.find(e=>e.id===`pending`),o=!!a&&t.some(e=>e.type===`assistant`&&e.time.completed!==void 0&&e.time.created>=a.started-5e3),s=new Set(i.filter(e=>{let t=r.get(e.id);return t?.type===`assistant`&&t.time.completed!==void 0}).map(e=>e.id)),c=!K.running[e]&&!K.queued[e],l=new Set(c?i.filter(e=>e.id!==`pending`&&!r.has(e.id)&&Date.now()-e.started>3e4).map(e=>e.id):[]),u={...K.running};o&&(delete u[e],K_.delete(e));let d=K.live.filter(t=>t.sessionID!==e||(t.id===`pending`?!o:!(s.has(t.id)||l.has(t.id)))),f=K.live.some(t=>t.sessionID===e),p=d.some(t=>t.sessionID===e);q({messages:{...K.messages,[e]:n},live:d,running:u}),(f&&!p&&(s.size>0||l.size>0||o)||f&&!p&&t.some(e=>e.type===`assistant`&&e.time.completed!==void 0))&&l_(e)}function C_(e,t,n=Date.now()){let r=K.live.find(n=>n.sessionID===e&&n.id===t);if(r)return r;let i=K.messages[e],a=i?.find(e=>e.id===t&&e.type===`assistant`&&t_(e)),o=a?m_(e,a):{sessionID:e,id:t,content:[],text:``,reasoning:``,tools:new Map,started:n};return q({live:[...K.live,o],...a?{messages:{...K.messages,[e]:i.filter(e=>e.id!==t)}}:{}}),o.id!==`pending`&&c_(e),o}function w_(e,t){let n=K.messages[e];n?.some(e=>e.id===t&&t_(e))&&q({messages:{...K.messages,[e]:n.filter(e=>e.id!==t)}})}function T_(e,t){let n=K.live.find(t=>t.id===e)?.sessionID;q({live:K.live.map(n=>{if(n.id!==e)return n;let r={...n,...t,tools:new Map(n.tools)};return t.content?f_(r,t.content):r})}),n&&c_(n)}function E_(e,t,n,r){let i=C_(e,t),a=i.content.find(e=>e.type===n&&e.ordinal===r);if(a)return a;let o={type:n,ordinal:r,text:``};return T_(t,{content:[...i.content,o]}),o}function D_(e,t,n,r,i){let a=K.live.find(t=>t.id===e);a&&T_(e,{content:a.content.map(e=>e.type!==t||e.ordinal!==n?e:{...e,text:i===`append`?g_(e.text,r):r})})}function O_(e,t,n,r){let i=C_(e,t),a=i.tools.get(n);if(a)return a;let o={id:n,name:r??`tool`,inputText:``,status:`streaming`,created:Date.now()};return T_(t,{content:[...i.content,{type:`tool`,tool:o}]}),o}function k_(e,t,n){let r=K.live.find(t=>t.id===e);if(!r)return;let i=r.tools.get(t);if(!i)return;let a=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0)),o={...i,...a};T_(e,{content:r.content.map(e=>e.type===`tool`&&e.tool.id===t?{type:`tool`,tool:o}:e)})}function A_(e){let t=e.status===`streaming`?e.inputText:e.input===void 0?{}:e.input,n=e.status===`error`?{status:`error`,input:t,error:e.error??{type:`error`,message:`tool failed`},content:e.content}:e.status===`completed`?{status:`completed`,input:t,content:e.content??[],metadata:e.metadata}:e.status===`running`?{status:`running`,input:t,metadata:e.metadata}:{status:`streaming`,input:e.inputText};return{type:`tool`,id:e.id,name:e.name,executed:e.executed,state:n,time:{created:e.created??Date.now(),ran:e.ran,completed:e.completed}}}function j_(e,t,n){let r=K.live.find(t=>t.sessionID===e&&t.id===`pending`&&t.text===``&&t.reasoning===``&&t.tools.size===0);if(!r){C_(e,t),T_(t,n);return}let i=K.live.find(n=>n.sessionID===e&&n.id===t);if(i&&(i.content.length>0||i.tools.size>0)){q({live:K.live.filter(e=>e!==r).map(e=>e===i?{...e,...n,tools:new Map(e.tools)}:e)}),c_(e);return}q({live:K.live.map(i=>i===r?{...i,...n,id:t}:i.sessionID===e&&i.id===t?null:i).filter(e=>e!==null)}),t!==`pending`&&c_(e)}async function M_(e){if(!Eg(e))try{let t=(await G.getSession(e)).data,n=K.revertMarkers;if(n[e]===void 0){let r=t.revert?.messageID;r&&(n={...n,[e]:r})}q({sessionDetails:{...K.sessionDetails,[e]:t},...n===K.revertMarkers?{}:{revertMarkers:n}})}catch(e){console.warn(`loadSessionDetail failed:`,e)}}var N_=null;function P_(){return N_??=(async()=>{try{let e=(await G.agents()).find(e=>e.mode===`primary`&&!e.hidden);if(e?.model)return e.model}catch{}try{let e=(await G.models()).filter(e=>e.enabled);if(e.length>0)return{id:e[0].modelID,providerID:e[0].providerID}}catch{}})(),N_}async function F_(e){if(K.pendingAgent&&!Eg(e)){let t=K.pendingAgent;try{await G.switchAgent(e,t),Hh(`model`,`committed agent ${t} on send`)}catch(e){console.warn(`switchAgent on send failed:`,e)}q({pendingAgent:null})}if(K.pendingModel&&!Eg(e)){let t=K.pendingModel;try{await G.switchModel(e,t),Hh(`model`,`committed model ${t.providerID}/${t.id} on send`)}catch(e){console.warn(`switchModel on send failed:`,e)}q({pendingModel:null})}}async function I_(e){if(Eg(e))return;if(K.sessions.find(t=>t.id===e)?.model||K.pendingModel){await F_(e);return}let t=await P_();if(t)try{await G.switchModel(e,t),Hh(`model`,`pinned ${e} -> ${t.providerID}/${t.id}`)}catch(e){console.warn(`ensureSessionModel failed:`,e)}}async function L_(e){await Qg(e);let t=r_(e).filter(e=>e.id!==`pending`).map(e=>e.id);if(t.length===0)return;let n=K.messages[e]??[];t.filter(e=>!n.some(t=>t.id===e)).length>0&&setTimeout(()=>void Qg(e),1500)}var R_=15e3,z_=0;function B_(e,t){let n={...K.runNotices};t&&t.length>0?n[e]=t:delete n[e],q({runNotices:n})}function V_(e){K.runNotices[e]&&B_(e,null)}function H_(e){let t=K.runNotices[e];t?.some(e=>e.kind===`retry`)&&B_(e,t.filter(e=>e.kind!==`retry`))}function U_(e){if(!e||typeof e!=`object`)return!1;let t=e,n=(t.type??``).toLowerCase(),r=(t.message??``).toLowerCase();return n===`aborted`||n===`abort`||r.includes(`aborted`)||r.includes(`step interrupted`)||r.includes(`run interrupted`)||r.includes(`interrupted`)}function W_(e,t,n,r=Date.now()){if(!e||Eg(e)||t===`interrupted`||t===`failed`&&/aborted|step interrupted|run interrupted/i.test(n))return;let i=K.runNotices[e]??[],a=i[i.length-1];if(a&&a.kind===t&&a.text===n&&r-a.at<R_)return;let o={id:`rn_${++z_}`,kind:t,text:n,at:r};B_(e,[...i,o].slice(-3))}function G_(e,t){let n=K.runNotices[e];n?.some(e=>e.id===t)&&B_(e,n.filter(e=>e.id!==t))}var K_=new Set,q_=new Set,J_=new Set([`session.execution.started`,`session.execution.succeeded`,`session.execution.failed`,`session.execution.interrupted`,`session.step.started`,`session.step.ended`,`session.step.failed`,`session.text.started`,`session.text.delta`,`session.text.ended`,`session.reasoning.started`,`session.reasoning.delta`,`session.reasoning.ended`,`session.tool.called`,`session.tool.input.started`,`session.tool.input.delta`,`session.tool.input.ended`,`session.tool.progress`,`session.tool.success`,`session.tool.failed`,`session.retry.scheduled`]);function Y_(e){return[...K.live].reverse().find(t=>t.sessionID===e&&t.id!==`pending`)}function X_(e){!e||K.running[e]||(Hh(`run`,`live via stream delta ${e}`),q({running:{...K.running,[e]:!0},queued:{...K.queued,[e]:!1}}))}function Z_(e){H_(e);let t={...K.running};delete t[e],K_.delete(e),qg(e),q({running:t,queued:{...K.queued,[e]:!1}}),K.live.some(t=>t.sessionID===e&&t.id===`pending`)&&q({live:K.live.filter(t=>t.sessionID!==e||t.id!==`pending`)}),L_(e),Ty(e),Bg()}function Q_(e,t,n){let r={...K.running};delete r[e],K_.delete(e),qg(e),q({running:r,queued:{...K.queued,[e]:!1}}),K.live.some(t=>t.sessionID===e&&t.id===`pending`)&&q({live:K.live.filter(t=>t.sessionID!==e||t.id!==`pending`)});let i=Y_(e);i&&T_(i.id,{finish:t===`session.execution.succeeded`?`stop`:t===`session.execution.failed`?`error`:`interrupted`,error:n??(t===`session.execution.succeeded`?void 0:i.error)}),L_(e),Ty(e),Bg()}function $_(e){let{type:t,data:n}=e,r=n.sessionID;r&&(J_.has(t)||t===`session.status`)&&Kg.set(r,Date.now());let i=r?i_(r)||n_(r):!1;if(e.id&&r&&i&&q_.has(e.id))return;e.id&&r&&i&&(q_.size>2e4&&q_.clear(),q_.add(e.id));let a=e=>!!e&&n_(e),o=e=>!!e&&i_(e);switch(Hh(`evt`,t,`sid=${n.sessionID??`-`}`,`current=${K.currentSessionID??`-`}`,`mid=${n.assistantMessageID??`-`}`),r&&J_.has(t)&&!n_(r)&&!i_(r)?Hh(`gate`,`${t} for non-pane session ${r} — skipped`):r&&J_.has(t)&&!n_(r)&&Hh(`gate`,`${t} for non-pane session ${r} — tracked via shouldTrackLive`),t){case`session.created`:case`session.renamed`:case`session.deleted`:case`session.moved`:case`session.forked`:case`session.usage.updated`:Bg(),r&&(K.messages[r]?.length??0)>0&&Qg(r),t!==`session.usage.updated`&&M_(n.sessionID);break;case`session.revert.staged`:{let e=n.revert?.messageID;r&&e&&Mv(r,e),Bg(),r&&(K.messages[r]?.length??0)>0&&Qg(r),r&&M_(n.sessionID);break}case`session.revert.committed`:{let e=n.to;if(r&&e){let t=K.messages[r]??[],n=t.findIndex(t=>t.id===e);if(n!==-1){let e=[...t.slice(0,n),...t.slice(n).filter(e=>e.id.startsWith(`msg_local_`))];q({messages:{...K.messages,[r]:e},revertMarkers:{...K.revertMarkers,[r]:null}})}else Mv(r,null)}Bg(),r&&(Qg(r),M_(r));break}case`session.revert.cleared`:r&&Mv(r,null),Bg(),r&&(K.messages[r]?.length??0)>0&&Qg(r),r&&M_(n.sessionID);break;case`session.agent.selected`:case`session.model.selected`:Bg(),M_(n.sessionID);break;case`session.inbox.enqueued`:{let e=n,t=typeof e.id==`string`&&e.id?e.id:typeof e.inboxID==`string`&&e.inboxID?e.inboxID:void 0;e.sessionID&&!Eg(e.sessionID)&&t&&typeof e.payload?.text==`string`&&fy(e.sessionID,{id:t,text:e.payload.text,delivery:e.delivery}),a(n.sessionID)&&(Hh(`run`,`queued ${n.sessionID}`),q({queued:{...K.queued,[n.sessionID]:!0}}));break}case`session.inbox.delivered`:{let e=n,t=typeof e.id==`string`&&e.id?e.id:typeof e.inboxID==`string`&&e.inboxID?e.inboxID:void 0;t&&py(t);break}case`session.error`:if(n.sessionID){let t=n.error;t&&!U_(t)?(q({sendErrors:{...K.sendErrors,[n.sessionID]:{type:t.type??`error`,message:t.message,status:t.status}}}),W_(n.sessionID,`error`,`${t.type}: ${t.message}`,e.created)):t&&U_(t),ky(n.sessionID)}break;case`session.execution.started`:K_.add(n.sessionID),Hh(`run`,`started ${n.sessionID}`),q({running:{...K.running,[n.sessionID]:!0},queued:{...K.queued,[n.sessionID]:!1}}),ov(n.sessionID),o(n.sessionID)&&C_(n.sessionID,n.assistantMessageID??`pending`,e.created);break;case`session.retry.scheduled`:if(n.sessionID&&n.error){let t=n.attempt;W_(n.sessionID,`retry`,`Retry attempt ${t??`?`} scheduled — ${n.error.message}`,e.created)}o(n.sessionID)&&n.assistantMessageID&&n.error&&T_(n.assistantMessageID,{error:{type:n.error.type,message:`Retrying${n.at?` at ${new Date(n.at).toLocaleTimeString()}`:``} — ${n.error.message}`,status:n.error.status}});break;case`session.execution.succeeded`:case`session.execution.failed`:case`session.execution.interrupted`:if(Hh(`run`,`finished ${n.sessionID} (${t})`),t===`session.execution.succeeded`)V_(n.sessionID);else if(H_(n.sessionID),t===`session.execution.failed`){let t=n.error;t&&!U_(t)?W_(n.sessionID,`failed`,`${t.type}: ${t.message}`,e.created):t||W_(n.sessionID,`failed`,`Run failed`,e.created)}Q_(n.sessionID,t,n.error);break;case`session.step.started`:o(n.sessionID)&&n.assistantMessageID&&(j_(n.sessionID,n.assistantMessageID,{agent:n.agent,model:n.model}),C_(n.sessionID,n.assistantMessageID,e.created),w_(n.sessionID,n.assistantMessageID),T_(n.assistantMessageID,{agent:n.agent,model:n.model,finish:void 0,error:void 0,completed:void 0}),K.running[n.sessionID]||(Hh(`run`,`live via step.started ${n.sessionID}`),q({running:{...K.running,[n.sessionID]:!0},queued:{...K.queued,[n.sessionID]:!1}}),ov(n.sessionID)));break;case`session.step.ended`:if(o(n.sessionID)&&n.assistantMessageID&&(T_(n.assistantMessageID,{finish:n.finish,cost:n.cost,completed:e.created}),!K_.has(n.sessionID)&&n.finish===`stop`)){let e={...K.running};delete e[n.sessionID],q({running:e})}break;case`session.step.failed`:if(n.sessionID&&n.error&&!U_(n.error)&&W_(n.sessionID,`failed`,`${n.error.type}: ${n.error.message}`,e.created),o(n.sessionID)&&n.assistantMessageID&&(T_(n.assistantMessageID,{finish:`error`,error:n.error,cost:n.cost,completed:e.created}),!K_.has(n.sessionID))){let e={...K.running};delete e[n.sessionID],q({running:e})}break;case`session.text.started`:o(n.sessionID)&&n.assistantMessageID&&(X_(n.sessionID),E_(n.sessionID,n.assistantMessageID,`text`,n.ordinal??0),K.queued[n.sessionID]&&q({queued:{...K.queued,[n.sessionID]:!1}}));break;case`session.text.delta`:o(n.sessionID)&&n.assistantMessageID&&(E_(n.sessionID,n.assistantMessageID,`text`,n.ordinal??0),D_(n.assistantMessageID,`text`,n.ordinal??0,n.delta??``,`append`));break;case`session.text.ended`:o(n.sessionID)&&n.assistantMessageID&&(E_(n.sessionID,n.assistantMessageID,`text`,n.ordinal??0),D_(n.assistantMessageID,`text`,n.ordinal??0,n.text??``,`replace`));break;case`session.reasoning.started`:o(n.sessionID)&&n.assistantMessageID&&(X_(n.sessionID),E_(n.sessionID,n.assistantMessageID,`reasoning`,n.ordinal??0));break;case`session.reasoning.delta`:o(n.sessionID)&&n.assistantMessageID&&(E_(n.sessionID,n.assistantMessageID,`reasoning`,n.ordinal??0),D_(n.assistantMessageID,`reasoning`,n.ordinal??0,n.delta??``,`append`));break;case`session.reasoning.ended`:o(n.sessionID)&&n.assistantMessageID&&(E_(n.sessionID,n.assistantMessageID,`reasoning`,n.ordinal??0),D_(n.assistantMessageID,`reasoning`,n.ordinal??0,n.text??``,`replace`));break;case`session.tool.input.started`:o(n.sessionID)&&n.assistantMessageID&&n.id&&(X_(n.sessionID),O_(n.sessionID,n.assistantMessageID,n.id,n.name));break;case`session.tool.input.delta`:if(o(n.sessionID)&&n.assistantMessageID&&n.id){O_(n.sessionID,n.assistantMessageID,n.id);let e=K.live.find(e=>e.id===n.assistantMessageID)?.tools.get(n.id);k_(n.assistantMessageID,n.id,{inputText:g_(e?.inputText??``,n.delta??``)})}break;case`session.tool.input.ended`:if(o(n.sessionID)&&n.assistantMessageID&&n.id){let e=O_(n.sessionID,n.assistantMessageID,n.id),t;try{t=JSON.parse(n.text??``)}catch{t=n.text}k_(n.assistantMessageID,n.id,{input:t,inputText:n.text??``,status:e.status===`streaming`?`running`:e.status})}break;case`session.tool.called`:if(o(n.sessionID)&&n.assistantMessageID&&n.id){let t=O_(n.sessionID,n.assistantMessageID,n.id);k_(n.assistantMessageID,n.id,{input:n.input,inputText:n.input===void 0?t.inputText:JSON.stringify(n.input),status:t.status===`streaming`?`running`:t.status,executed:n.executed,ran:e.created})}break;case`session.tool.progress`:o(n.sessionID)&&n.assistantMessageID&&n.id&&(O_(n.sessionID,n.assistantMessageID,n.id),k_(n.assistantMessageID,n.id,{metadata:n.metadata}));break;case`session.tool.success`:o(n.sessionID)&&n.assistantMessageID&&n.id&&(X_(n.sessionID),k_(n.assistantMessageID,n.id,{...typeof n.name==`string`?{name:n.name}:{},status:`completed`,content:n.content??void 0,metadata:n.metadata,executed:n.executed,completed:e.created}));break;case`session.tool.failed`:o(n.sessionID)&&n.assistantMessageID&&n.id&&k_(n.assistantMessageID,n.id,{...typeof n.name==`string`?{name:n.name}:{},status:`error`,error:n.error,content:n.content??void 0,metadata:n.metadata,executed:n.executed,completed:e.created});break;case`session.status`:{let e=n.status?.type;e===`busy`?q({running:{...K.running,[n.sessionID]:!0},queued:{...K.queued,[n.sessionID]:!1}}):e===`idle`&&Z_(n.sessionID);break}case`session.idle`:Z_(n.sessionID);break;case`permission.asked`:K.permissions.some(e=>e.id===n.id)||q({permissions:[...K.permissions,{id:n.id,sessionID:n.sessionID,action:n.action??``,resources:n.resources??[],seq:pg()}]});break;case`form.created`:{let e=n.form;e?.id&&!K.forms.some(t=>t.id===e.id)&&q({forms:[...K.forms,{...e,seq:pg()}]});break}case`form.replied`:case`form.cancelled`:case`form.deleted`:q({forms:K.forms.filter(e=>e.id!==n.id)});break;case`permission.replied`:q({permissions:K.permissions.filter(e=>e.id!==n.id)});break;case`question.asked`:if(!K.questions.some(e=>e.id===n.id)){let e=n;q({questions:[...K.questions,{id:n.id,sessionID:n.sessionID,questions:e.questions??[],tool:e.tool,seq:pg()}]})}break;case`question.replied`:case`question.rejected`:q({questions:K.questions.filter(e=>e.id!==n.requestID)});break;case`session.shell.started`:case`session.shell.ended`:r&&Qg(r);break;case`session.compaction.started`:case`session.compaction.ended`:case`session.compaction.failed`:r&&(Qg(r),M_(r));break;default:(t.startsWith(`form.`)||t.startsWith(`question.`)||t===`session.skill.activated`)&&Zg()}}var ev=new Map;async function tv(e){if(!(!e||Eg(e))){lv(e);try{let t=(await G.webuiReplay(e,ev.get(e))).data??[];for(let n of t)n.id&&ev.set(e,n.id),pv({id:n.id,created:n.created,type:n.type,data:n.data});t.length>0&&Hh(`sse`,`replay ${e}: ${t.length} event(s)`)}catch{}}}function nv(){let e=new Set;for(let t of K.panes)t.sessionID&&e.add(t.sessionID);K.currentSessionID&&e.add(K.currentSessionID);for(let[t,n]of Object.entries(K.running))n&&e.add(t);return[...e].filter(e=>!!e&&!Eg(e))}var rv=new Set,iv=1e3,av=3e5;function ov(e){!e||Eg(e)||rv.has(e)||(rv.add(e),sv(e).finally(()=>rv.delete(e)))}async function sv(e){for(;;){if(!K.running[e]&&!K.queued[e])return;let t=await G.sessionWait(e,AbortSignal.timeout(av)).catch(()=>-1);if(t===204){if(K.running[e]){Hh(`run`,`wait: engine idle ${e}`),qg(e);let t={...K.running};delete t[e],K_.delete(e),q({running:t}),L_(e),Ty(e)}if(!K.running[e]&&!K.queued[e])return;await new Promise(e=>setTimeout(e,iv));continue}if(t===404){bv(e,`wait 404`);return}if(!K.running[e]&&!K.queued[e])return;await new Promise(e=>setTimeout(e,iv))}}var cv=new Map;function lv(e){!e||Eg(e)||G.sessionLogHead(e).then(t=>{t!==null&&cv.get(e)!==t&&(cv.set(e,t),Hh(`sse`,`log head ${e}: ${t}`))}).catch(()=>void 0)}var uv=!1,dv=[],fv=null;function pv(e){dv.push(e),!fv&&(fv=setTimeout(()=>{fv=null;let e=dv.splice(0,dv.length);jg(()=>{for(let t of e)try{$_(t)}catch(e){console.warn(`event handler failed:`,t.type,e)}})},16))}function mv(){if(!uv){if(uv=!0,Hh(`boot`,`start`),Hh(`boot`,`build pending-panel-v6`),typeof window<`u`){let e=()=>{let e=Ig();e?Pv(e,{history:`none`}):Lg()?(Wy(null),$v().catch(()=>void 0)):(Pv(null,{history:`none`}),$v())};window.addEventListener(`popstate`,e);let t=zv();t.length>0&&q({panes:[{id:wg,sessionID:null},...t]}),e()}Yg().then(Bv).catch(()=>void 0),Zg(),G.health().then(e=>q({serviceOK:e.ok})).catch(()=>q({serviceOK:!1})),Jh(e=>pv(e.data),{onOpen:()=>{q({connected:!0}),Yg(),Zg();for(let e of nv())tv(e)}}).then(()=>q({connected:!1})),hv()}}function hv(){ig({isBusy:()=>{let e=K;for(let t of Object.values(e.running))if(t)return!0;for(let t of Object.values(e.queued))if(t)return!0;for(let t of Object.values(e.pending))if(t.length>0)return!0;return e.live.length>0},isSseStale:qh}),og({name:`messages`,minInterval:2e3,intervals:{live:2e3,idle:12e3,hidden:6e4},run:()=>vv()}),og({name:`queues`,minInterval:1e4,intervals:{live:1e4,idle:12e3,hidden:6e4},run:()=>Zg()}),og({name:`sessions`,minInterval:1e4,intervals:{live:1e4,idle:2e4,hidden:6e4},run:()=>Yg()})}async function gv(e,t){K.panes.some(t=>t.sessionID===e)&&S_(e,t)}var _v=!1;async function vv(){if(_v)return;let e=new Set;for(let[t,n]of Object.entries(K.running))n&&e.add(t);for(let t of Object.keys(K.pending))(K.pending[t]?.length??0)>0&&!Eg(t)&&e.add(t);for(let t of K.panes){let n=t.sessionID;n&&!Eg(n)&&(r_(n).length>0||K.queued[n])&&e.add(n)}for(let t of K.live)Eg(t.sessionID)||e.add(t.sessionID);if(e.size!==0){_v=!0;try{for(let t of e){let e=e_(t);try{let n=await G.messages(t,50);if($g.get(t)!==e)continue;yv.delete(t);let r=K.messages[t]?.length??0,i=[...n.data].reverse();await gv(t,i);let a=K.messages[t]?.length??0;a!==r&&Hh(`poll`,`reconcile ${t}: ${r} -> ${a} messages`),((K.pending[t]?.length??0)>0||K.queued[t])&&await dy(t,i)}catch(e){let n=e instanceof Error?e.message:String(e),r=yv.get(t)??{count:0};r.count+=1,yv.set(t,r),(n.includes(`404`)||r.count>=3)&&(bv(t,n),yv.delete(t))}}}finally{_v=!1}}}var yv=new Map;function bv(e,t){Hh(`poll`,`retiring vanished session ${e} (${t})`);let n={...K.running};delete n[e];let r={...K.queued};delete r[e];let i={...K.pending};delete i[e],K_.delete(e),Gg.delete(e),Kg.delete(e),ev.delete(e);let a=wy.get(e);a&&(clearTimeout(a),wy.delete(e)),q({running:n,queued:r,pending:i,live:K.live.filter(t=>t.sessionID!==e)}),l_(e),yv.delete(e)}function xv(){q({shellPanelTick:K.shellPanelTick+1})}function Sv(e){if(e===`runsDialog`){q({runsPanelOpen:!0,uiSignals:{...K.uiSignals,[e]:K.uiSignals[e]+1}});return}q({uiSignals:{...K.uiSignals,[e]:K.uiSignals[e]+1}})}function Cv(){q({runsPanelOpen:!0,uiSignals:{...K.uiSignals,runsDialog:K.uiSignals.runsDialog+1}})}function wv(){K.runsPanelOpen&&q({runsPanelOpen:!1})}function Tv(e){q({runsSelection:e})}function Ev(){K.subagentComposerOpen||q({subagentComposerOpen:!0})}function Dv(){let e=K.revertPrompt;return K.revertPrompt!==null&&q({revertPrompt:null}),e}function Ov(e,t){return e.filter(e=>e.parentID===t).sort((e,t)=>t.time.updated-e.time.updated)}function kv(e,t){if(!t)return!1;if(e.running[t]||e.queued[t])return!0;for(let n of e.sessions)if(n.parentID===t&&(e.running[n.id]||e.queued[n.id]))return!0;return!1}function Av(e,t){if(!t)return e;let n=e.findIndex(e=>e.id===t);return n===-1?e:e.slice(0,n)}function jv(e,t,n){let r=e.revertMarkers[t];return r===void 0?(n??e.sessionDetails[t])?.revert?.messageID:r??void 0}function Mv(e,t){K.revertMarkers[e]!==t&&q({revertMarkers:{...K.revertMarkers,[e]:t}})}function Nv(e){let t=jv(K,e);if(!t)return;let n=Av(K.messages[e]??[],t);q({messages:{...K.messages,[e]:n}})}async function Pv(e,t={}){if(Hh(`session`,`select`,e??`null`),t.history!==`none`&&Rg(e,t.history??`push`),q_.clear(),e===`__draft__`){let e=Lv(Tg);q({currentSessionID:Tg,live:a_(e),subagentComposerOpen:!1,panes:e,focusedPane:wg});return}let n=Lv(e);q({currentSessionID:e,live:a_(n),subagentComposerOpen:!1,panes:n,focusedPane:wg,queued:e?{...K.queued,[e]:!1}:K.queued}),e?(Qv(e),u_(e),tv(e),K.draftWorkspace!==null&&q({draftWorkspace:null}),!K.sessions.some(t=>t.id===e)&&!K.sessionDetails[e]&&M_(e),await Qg(e),dy(e).catch(()=>void 0)):K.draftWorkspace!==null&&q({draftWorkspace:null})}var Fv=`webui.splits`,Iv=0;function Lv(e){let t=K.panes.length>0?K.panes.slice():[{id:wg,sessionID:null}];return t[0]={id:wg,sessionID:e},t}function Rv(){try{localStorage.setItem(Fv,JSON.stringify(K.panes.slice(1)))}catch{}}function zv(){try{let e=localStorage.getItem(Fv);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>!!e&&typeof e.id==`string`&&typeof e.sessionID==`string`&&e.id!==`main`):[]}catch{return[]}}function Bv(){let e=e=>K.sessions.some(t=>t.id===e)||!!K.sessionDetails[e],t=K.panes.filter((t,n)=>n===0||e(t.sessionID));t.length!==K.panes.length&&q({panes:t,...t.some(e=>e.id===K.focusedPane)?{}:{focusedPane:wg}})}async function Vv(e){K.currentSessionID!==e&&(q({currentSessionID:e,live:a_(K.panes),subagentComposerOpen:!1,pendingAgent:null,pendingModel:null,...e?{queued:{...K.queued,[e]:!1}}:{}}),e&&!Eg(e)&&(u_(e),tv(e),await Qg(e),dy(e).catch(()=>void 0)))}async function Hv(e){let t=K.panes.find(t=>t.id===e);t&&K.focusedPane!==e&&(Hh(`pane`,`focus ${e}`),q({focusedPane:e}),await Vv(t.sessionID))}function Uv(){q({splitPickerOpen:!0})}function Wv(){K.splitPickerOpen&&q({splitPickerOpen:!1})}async function Gv(e){if(!e||Eg(e)||K.panes.length-1>=3||K.panes.some(t=>t.sessionID===e))return!1;let t={id:`${wg}-${Date.now().toString(36)}-${++Iv}`,sessionID:e};return Hh(`pane`,`split open ${e} (${t.id})`),q({panes:[...K.panes,t],focusedPane:t.id,splitPickerOpen:!1}),Rv(),!K.sessions.some(t=>t.id===e)&&!K.sessionDetails[e]&&M_(e),await Vv(e),!0}async function Kv(e){if(e===`main`)return;let t=K.panes.filter(t=>t.id!==e);if(t.length===K.panes.length)return;Hh(`pane`,`close ${e}`);let n=K.focusedPane===e;q({panes:t,...n?{focusedPane:wg}:{}}),Rv(),n&&await Vv(K.panes[0].sessionID)}async function qv(e,t){let n=K.panes.findIndex(t=>t.id===e);if(n<=0||!t||Eg(t))return;let r=K.panes.slice();r[n]={...r[n],sessionID:t},q({panes:r}),Rv(),K.focusedPane===e?await Vv(t):Qg(t)}async function Jv(e){if(K.focusedPane===`main`||K.panes.length<=1){await Pv(e);return}await qv(K.focusedPane,e)}function Yv(e=Ng()){return e.focusedPane}function Xv(e){Eg(e)||(K.messages[e]?.length??0)>0||Qg(e)}var Zv=`webui.last-session`;function Qv(e){try{localStorage.setItem(Zv,e)}catch{}}async function $v(){if(/^\/ext\//.test(window.location.pathname))return;let e=null;try{e=localStorage.getItem(Zv)}catch{return}!e||K.currentSessionID||(await Yg(),!(K.currentSessionID||!e)&&K.sessions.some(t=>t.id===e)&&(Hh(`session`,`reopen last session ${e}`),await Pv(e,{history:`replace`})))}async function ey(e,t,n){if(Hh(`send`,`prompt ${e}: ${t.slice(0,80)}${n?.delivery?` (${n.delivery})`:``}`),await I_(e),!Eg(e)&&ty(e)){Nv(e),await oy(e,t,n?.delivery);return}Nv(e),Dy(e,t),Oy(e);try{if(await G.prompt(e,t),ov(e),e===`__draft__`||(K.messages.__draft__?.length??0)===0)try{let{clearDraft:e}=await ug(async()=>{let{clearDraft:e}=await Promise.resolve().then(()=>zx);return{clearDraft:e}},void 0);e(Tg)}catch{}}catch(t){throw ky(e),Ay(e,t),t}}function ty(e){return K.running[e]||K.queued[e]||K.activeIDs.includes(e)?!0:n_(e)&&r_(e).length>0}var ny=0;function ry(e,t){let n={...K.pending};t&&t.length>0?n[e]=t:delete n[e],q({pending:n})}function iy(e,t){ry(e,[...K.pending[e]??[],t])}function ay(e,t,n){let r=K.pending[e];if(!r?.some(e=>e.key===t))return;let i=!1,a=r.map(e=>{if(e.key!==t)return e;let r=n(e);return r!==e&&(i=!0),r});i&&ry(e,a)}async function oy(e,t,n){let r=`pend_${Date.now().toString(36)}_${++ny}`;iy(e,{key:r,text:t,state:`sending`,admittedAt:Date.now(),...n?{delivery:n}:{}});try{let i=await G.prompt(e,t,n);ov(e);let a=i?.data??i;a?.id&&ay(e,r,e=>({...e,state:`tracked`,inboxID:a.id,delivery:a.delivery??n}))}catch(t){throw sy(e,r),Ay(e,t),t}}function sy(e,t){let n=K.pending[e];n?.some(e=>e.key===t)&&ry(e,n.filter(e=>e.key!==t))}function cy(e){let t=e.payload;return typeof t?.text==`string`?t.text:``}function ly(e,t){return t===``||ty(e)?!1:(K.messages[e]??[]).some(e=>e.type===`user`&&e.id.startsWith(`msg_local_`)&&e.text===t)}function uy(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.key===r.key&&e.text===r.text&&e.state===r.state&&e.inboxID===r.inboxID&&e.delivery===r.delivery})}async function dy(e,t){let n=(await G.inboxList(e)).data.filter(e=>e.type===`user`),r=new Set(n.map(e=>e.id)),i=K.pending[e]??[],a=[...i],o=null,s=new Set;if(t){o=new Set(t.filter(e=>e.type===`user`&&!e.id.startsWith(`msg_local_`)).map(e=>e.id));for(let e of i)(e.inboxID&&o.has(e.inboxID)||!e.inboxID&&e.admittedAt!==void 0&&t.some(t=>t.type===`user`&&!t.id.startsWith(`msg_local_`)&&t.text===e.text&&t.time.created>=e.admittedAt-6e4))&&s.add(e.key)}let c=new Set(a.filter(e=>e.inboxID).map(e=>e.inboxID));a=a.map(e=>{if(e.state!==`sending`)return e;let t=n.filter(t=>!c.has(t.id)&&cy(t)===e.text);if(t.length===0)return e;let r=t.reduce((e,t)=>t.timeCreated>=e.timeCreated?t:e);return c.add(r.id),{...e,state:`tracked`,inboxID:r.id,delivery:r.delivery}}),a=a.filter(e=>!s.has(e.key)&&!(e.state===`tracked`&&e.inboxID&&!r.has(e.inboxID)));for(let t of[...n].sort((e,t)=>e.timeCreated-t.timeCreated)){if(a.some(e=>e.inboxID===t.id)||o?.has(t.id))continue;let n=cy(t);ly(e,n)||a.push({key:`inbox_${t.id}`,text:n,state:`tracked`,inboxID:t.id,delivery:t.delivery,admittedAt:Date.now()})}let l=new Set(s);for(let e of i)e.state===`tracked`&&e.inboxID&&!r.has(e.inboxID)&&l.add(e.key);let u=new Set(a.map(e=>e.key));for(let t of K.pending[e]??[])!u.has(t.key)&&!l.has(t.key)&&a.push(t);uy(i,a)||ry(e,a)}function fy(e,t){let n=K.pending[e];n?.some(e=>e.inboxID===t.id)||n?.some(e=>e.state===`sending`&&e.text===t.text)||ly(e,t.text)||iy(e,{key:`inbox_${t.id}`,text:t.text,state:`tracked`,inboxID:t.id,delivery:t.delivery??`steer`,admittedAt:Date.now()})}function py(e){let t=!1,n={...K.pending};for(let[r,i]of Object.entries(n)){if(!i.some(t=>t.inboxID===e))continue;let a=i.filter(t=>t.inboxID!==e);t=!0,a.length>0?n[r]=a:delete n[r]}t&&q({pending:n})}function my(e){if(!e||Eg(e))throw Error(`send before materialize`);return!0}async function hy(e,t){let n=K.currentSessionID;if(n){my(n),Hh(`send`,`command ${n}: /${e} ${t??``}`.trim()),await I_(n),Nv(n),Dy(n,t?`/${e} ${t}`:`/${e}`),Oy(n);try{await G.runCommand(n,e,t)}catch(e){throw ky(n),Ay(n,e),e}}}async function gy(e){let t=K.currentSessionID;if(t){my(t),Hh(`send`,`shell ${t}: !${e.slice(0,60)}`),await I_(t),Nv(t),Dy(t,`!${e}`),Oy(t);try{await G.sessionShell(t,e)}catch(e){throw ky(t),Ay(t,e),e}}}async function _y(e,t){let n=K.currentSessionID;if(n){my(n),Hh(`send`,`prompt+files ${n}: ${e.slice(0,80)}`),await I_(n),Nv(n),Dy(n,e),Oy(n);try{await G.promptWithFiles(n,e,t);try{let{clearDraft:e}=await ug(async()=>{let{clearDraft:e}=await Promise.resolve().then(()=>zx);return{clearDraft:e}},void 0);e(Tg)}catch{}}catch(e){throw ky(n),Ay(n,e),e}}}function vy(e){if(!K.sendErrors[e])return;let t={...K.sendErrors};delete t[e],q({sendErrors:t})}function yy(e,t){let n=K.pending[e]?.find(e=>e.key===t);n&&(sy(e,t),n.state===`tracked`&&n.inboxID&&G.inboxDelete(e,n.inboxID).catch(t=>{Ay(e,t),iy(e,n)}))}function by(e,t,n){let r=K.pending[e]?.find(e=>e.key===t);if(!r||(r.delivery??`steer`)===n)return;let i=r.delivery??`steer`;ay(e,t,e=>({...e,delivery:n})),(r.state===`tracked`&&r.inboxID?n===`steer`?G.inboxSteer(e,r.inboxID):G.inboxQueue(e,r.inboxID):Promise.resolve()).catch(n=>{ay(e,t,e=>({...e,delivery:i})),Ay(e,n)})}function xy(e,t){let n=K.pending[e]?.find(e=>e.key===t);!n||n.state!==`tracked`||(n.delivery??`steer`)===`queue`&&by(e,t,`steer`)}async function Sy(e){!e||Eg(e)||(Fy(),await G.interrupt(e,!0),qg(e),q({running:{...K.running,[e]:!1},queued:{...K.queued,[e]:!1}}))}var Cy=1800,wy=new Map;function Ty(e){if(Eg(e))return;let t=wy.get(e);t&&clearTimeout(t);let n=setTimeout(()=>{wy.delete(e),Ey(e)},Cy);wy.set(e,n)}async function Ey(e){let t=(K.pending[e]??[]).find(e=>e.delivery===`queue`&&e.state===`tracked`&&!!e.inboxID);if(t?.inboxID&&!(K.running[e]||K.queued[e]))try{if(!(await G.inboxList(e)).data.some(e=>e.id===t.inboxID)||K.running[e]||K.queued[e])return;Hh(`run`,`drain ${e}: steering parked queue item ${t.inboxID}`),ay(e,t.key,e=>({...e,delivery:`steer`})),await G.inboxSteer(e,t.inboxID)}catch(e){console.warn(`queue drain failed:`,e)}}function Dy(e,t){let n={id:`msg_local_${Date.now()}`,type:`user`,text:t,time:{created:Date.now()}};q({messages:{...K.messages,[e]:[...K.messages[e]??[],n]}})}function Oy(e){Hh(`run`,`pending ${e} (awaiting run start)`),V_(e),q({queued:{...K.queued,[e]:!0}})}function ky(e){q({queued:{...K.queued,[e]:!1}})}function Ay(e,t){let n=t instanceof Error?t.message:String(t),r;t&&typeof t==`object`&&`payload`in t&&(r=t.payload);let i=r&&typeof r==`object`&&`message`in r?{type:String(r.name??`error`),message:String(r.message??n)}:{type:`request-failed`,message:n};console.warn(`send failed:`,i.type,i.message),q({sendErrors:{...K.sendErrors,[e]:i}})}async function jy(e){let t=K.currentSessionID;!t||Eg(t)||(await G.activateSkill(t,e),Zg())}async function My(e){let t=e??K.currentSessionID;!t||Eg(t)||(Fy(),await G.interrupt(t),qg(t),q({running:{...K.running,[t]:!1},queued:{...K.queued,[t]:!1}}))}var Ny=2500,Py=null;function Fy(){Py&&=(clearTimeout(Py),null),K.interruptArmed&&q({interruptArmed:!1})}function Iy(){let e=K.currentSessionID;if(!(!e||!K.running[e])){if(!K.interruptArmed){Py&&clearTimeout(Py),q({interruptArmed:!0}),Py=setTimeout(()=>{Py=null,q({interruptArmed:!1})},Ny);return}My()}}async function Ly(e){try{await G.sessionBackground(e),Bg()}catch(e){console.warn(`backgroundSubagents failed:`,e)}}async function Ry(e,t){let n=K.permissions.find(t=>t.id===e);if(n)try{await G.replyPermission(n.sessionID,e,t)}finally{q({permissions:K.permissions.filter(t=>t.id!==e)})}}async function zy(e,t){let n=K.forms.find(t=>t.id===e);if(n)try{await G.replyForm(n.sessionID,e,t)}finally{q({forms:K.forms.filter(t=>t.id!==e)})}}async function By(e){let t=K.forms.find(t=>t.id===e);if(t)try{await G.cancelForm(t.sessionID,e)}finally{q({forms:K.forms.filter(t=>t.id!==e)})}}async function Vy(e,t){let n=K.questions.find(t=>t.id===e);if(n){try{await G.sessionQuestionReply(n.sessionID,e,t)}catch(t){return Hh(`panel`,`question reply FAILED ${e}:`,t instanceof Error?t.message:String(t)),!1}return q({questions:K.questions.filter(t=>t.id!==e)}),!0}let r=K.forms.find(t=>t.id===e&&yg(t));if(!r)return!1;let i={};r.fields.forEach((e,n)=>{let r=t[n]??[],a=e.type===`multiselect`;i[e.key]=a?r:r[0]??``});try{await G.replyForm(r.sessionID,r.id,i)}catch(e){return Hh(`panel`,`question reply FAILED ${r.id}:`,e instanceof Error?e.message:String(e)),!1}return q({forms:K.forms.filter(e=>e.id!==r.id)}),!0}async function Hy(e){let t=K.questions.find(t=>t.id===e);if(t){try{await G.sessionQuestionReject(t.sessionID,e)}finally{q({questions:K.questions.filter(t=>t.id!==e)})}return}let n=K.forms.find(t=>t.id===e&&yg(t));n&&await By(n.id)}function Uy(e){e.kind===`permission`?Ry(e.req.id,`reject`):e.kind===`question`?Hy(e.req.id):By(e.req.id)}function Wy(e){let t=e=>{if(!(!e||Eg(e)))return(K.sessions.find(t=>t.id===e)??K.sessionDetails[e])?.location?.directory},n=K.currentSessionID&&!Eg(K.currentSessionID)?K.sessions.find(e=>e.id===K.currentSessionID)??K.sessionDetails[K.currentSessionID]:void 0,r=t(K.currentSessionID)??(n?.parentID?t(n.parentID):void 0),i=e??K.pendingWorkspace??K.draftWorkspace??r??null,a=Eg(K.currentSessionID);Hh(`session`,`draft ${a?`retarget`:`open`} (workspace=${i??`default`})`);let o=Lv(Tg);q({currentSessionID:Tg,panes:o,focusedPane:wg,draftWorkspace:i,pendingWorkspace:null,live:a_(o),...a?{}:{pendingAgent:null,pendingModel:null}}),typeof window<`u`&&Rg(Tg,`push`)}function Gy(e){q({pendingWorkspace:e})}function Ky(e,t){q({highlightSessionID:e,highlightMessageID:t})}var qy=!1;async function Jy(e){let t=await P_(),n=(await G.createSession({title:null,agent:null,model:t??null,location:e?{directory:e}:null})).data.id;return t&&Hh(`model`,`new session ${n} -> ${t.providerID}/${t.id}`),await Yg(),await M_(n),n}async function Yy(e){if(!Eg(K.currentSessionID)&&K.draftWorkspace===null)throw Error(`no draft session`);if(qy)throw Error(`draft already materializing`);qy=!0;try{let e=K.draftWorkspace;Hh(`session`,`draft -> create (workspace=${e??`default`})`);let t=await Jy(e),n=K.messages.__draft__??[];q_.clear();let r=Lv(t);return q({currentSessionID:t,panes:r,focusedPane:wg,draftWorkspace:null,live:a_(r),messages:{...K.messages,[t]:n,[Tg]:[]}}),Qv(t),typeof window<`u`&&Rg(t,`replace`),t}finally{qy=!1}}async function Xy(e={}){Wy(null)}async function Zy(e,t){q({pendingAgent:t})}async function Qy(e,t){q({pendingModel:t})}async function $y(e,t){await G.renameSession(e,t),await Yg()}async function eb(e,t){let n=await G.forkSession(e,t);return await Yg(),n.data.id}async function tb(e){return(await G.exportSession(e)).data}async function nb(e,t=`steer`){await G.compactSession(e,t),await Yg()}async function rb(e){K.running[e]&&await My(e);let t=K.sessionDetails[e]??await G.getSession(e).then(e=>e.data).catch(()=>void 0),n=jv(K,e,t??void 0),r=[...Av(K.messages[e]??[],n)].reverse().find(e=>e.type===`user`);if(!(!r||r.id.startsWith(`msg_local_`))){try{await G.revertStage(e,r.id),Mv(e,r.id)}finally{M_(e),Qg(e),Bg()}q({revertPrompt:r.text??null})}}async function ib(e){let t=K.sessionDetails[e]??await G.getSession(e).then(e=>e.data).catch(()=>void 0),n=jv(K,e,t??void 0);if(n)try{let t=(K.messages[e]??[]).find(e=>e.type===`user`&&e.id>n);t?(await G.revertStage(e,t.id),Mv(e,t.id)):(await G.revertClear(e),Mv(e,null))}finally{M_(e),Qg(e),Bg()}}function ab(e,t,n){q({pendingEdit:{sessionID:e,messageID:t,originalText:n??``},revertPrompt:n??null})}function ob(){q({pendingEdit:null})}async function sb(e){let t=K.pendingEdit;if(!t||t.sessionID!==e)return;K.running[e]&&await My(e);try{await G.revertStage(e,t.messageID)}finally{M_(e),Qg(e),Bg()}let n=K.messages[e]??[],r=n.findIndex(e=>e.id===t.messageID),i=r===-1?n:n.slice(0,r);q({messages:{...K.messages,[e]:i},revertMarkers:{...K.revertMarkers,[e]:t.messageID},pendingEdit:null})}async function cb(e,t,n){ab(e,t,n)}async function lb(e,t){let n=(await G.forkSession(e,{type:`before`,messageID:t})).data.id;return n&&await Pv(n),n}var ub=[`ctrl`,`shift`,`meta`,`alt`],db={control:`ctrl`,cmd:`meta`,command:`meta`,super:`meta`,esc:`escape`,return:`enter`,up:`arrowup`,down:`arrowdown`,left:`arrowleft`,right:`arrowright`};function fb(e){let t=e.trim().toLowerCase();return db[t]??t}function pb(e){let t=new Set,n=``;for(let r of e.split(`+`).map(fb))ub.includes(r)?t.add(r):n=r;return{mods:t,key:n}}function mb(e,t){let{mods:n,key:r}=pb(e);return!(!r||r!==fb(t.key)||n.has(`ctrl`)!==t.ctrlKey||n.has(`shift`)!==t.shiftKey||n.has(`meta`)!==t.metaKey||n.has(`alt`)!==t.altKey)}function hb(e){let t=(0,E.useRef)(e);t.current=e,(0,E.useEffect)(()=>{let e=e=>{if(e.repeat)return;let n=Object.keys(t.current).find(t=>mb(t,e));if(!n)return;let r=t.current[n];if(!r)return;let{mods:i}=pb(n);i.size===0&&gb(e.target)||(e.preventDefault(),r(e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function gb(e){let t=e;return t?t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable:!1}function _b(){let[e,t]=(0,E.useState)(Dh);return(0,E.useEffect)(()=>kh(()=>t(Dh())),[]),e}var vb=`../theme/themes`;function yb(){let[e,t]=(0,E.useState)(!1),n=J(e=>e.sessions),r=J(e=>e.currentSessionID),i=_b(),[a,o]=(0,E.useState)(null);hb({"ctrl+p":()=>t(e=>!e),escape:()=>t(!1)}),(0,E.useEffect)(()=>{let e=!1;return ug(()=>import(vb).then(t=>{if(e)return;let n=t;if(typeof n.applyTheme!=`function`)return;let r=n.listThemes?n.listThemes():(n.THEMES??[]).map(e=>({id:e.id,label:e.label}));r.length&&o({list:r,apply:n.applyTheme,current:n.getTheme?.()??null})}),[]).catch(()=>{}),()=>{e=!0}},[]);let s=[...n].filter(e=>!e.parentID).sort((e,t)=>t.time.updated-e.time.updated),c=typeof St==`function`?St():[];return(0,R.jsxs)(mh,{open:e,onOpenChange:t,children:[(0,R.jsx)(hh,{placeholder:`Type a command or search…`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),uh(1)):e.key===`ArrowUp`?(e.preventDefault(),uh(-1)):e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),dh())}}),(0,R.jsxs)(gh,{children:[(0,R.jsx)(_h,{children:`No results found.`}),(0,R.jsxs)(vh,{heading:`Actions`,children:[(0,R.jsxs)(bh,{onSelect:()=>{t(!1),Xy()},children:[(0,R.jsx)(xe,{}),(0,R.jsx)(`span`,{children:`New session`}),(0,R.jsx)(xh,{children:`Ctrl N`})]}),(0,R.jsxs)(bh,{onSelect:()=>Oh(`showReasoning`,!i.showReasoning),children:[i.showReasoning?(0,R.jsx)(me,{}):(0,R.jsx)(he,{}),(0,R.jsxs)(`span`,{children:[i.showReasoning?`Hide`:`Show`,` thinking`]})]}),(0,R.jsxs)(bh,{onSelect:()=>Oh(`showToolDetails`,!i.showToolDetails),children:[i.showToolDetails?(0,R.jsx)(me,{}):(0,R.jsx)(he,{}),(0,R.jsxs)(`span`,{children:[i.showToolDetails?`Hide`:`Show`,` tool details`]})]})]}),(0,R.jsx)(yh,{}),(0,R.jsxs)(vh,{heading:`Sessions`,children:[s.length===0&&(0,R.jsxs)(bh,{disabled:!0,children:[(0,R.jsx)(we,{}),(0,R.jsx)(`span`,{children:`No sessions yet`})]}),s.map(e=>(0,R.jsxs)(bh,{value:`${e.title??`Untitled session`} ${e.id}`,onSelect:()=>{t(!1),Pv(e.id)},children:[(0,R.jsx)(we,{}),(0,R.jsx)(`span`,{className:`truncate`,children:e.title??`Untitled session`})]},e.id))]}),c.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(yh,{}),(0,R.jsx)(vh,{heading:`Extension commands`,children:c.map(e=>{let n=e.keybind;return(0,R.jsxs)(bh,{value:`${e.title} ${e.id} ${n??``}`,onSelect:()=>{t(!1);try{e.run({sessionID:r??void 0})}catch(e){console.error(`[extensions] command failed:`,e)}},children:[(0,R.jsx)(We,{}),(0,R.jsx)(`span`,{className:`truncate`,children:e.title}),n?(0,R.jsx)(xh,{children:n}):null]},e.id)})})]}),a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(yh,{}),(0,R.jsx)(vh,{heading:`Themes`,children:a.list.map(e=>(0,R.jsxs)(bh,{onSelect:()=>a.apply(e.id),children:[(0,R.jsx)(Pe,{}),(0,R.jsx)(`span`,{children:e.label}),a.current===e.id&&(0,R.jsx)(ae,{className:`ml-auto size-4 opacity-100`})]},e.id))})]})]})]})}function bb({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:i}){let a=xb(Sb(r,i),t);if(!n)return E.createElement(e,a);if(typeof n==`function`)return n(a,r);if(!E.isValidElement(n))return null;let o=n.props,s={...xb(a,o),ref:Tb(a.ref,o.ref)};return E.cloneElement(n,s)}function xb(...e){let t={};for(let n of e){if(!n)continue;let e=n;for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let i=t[n];t[n]=n===`className`?[i,r].filter(Boolean).join(` `):n===`style`?{...i,...r}:n===`ref`?Tb(i,r):wb(n)&&typeof i==`function`&&typeof r==`function`?Cb(r,i):r}}return t}function Sb(e,t){let n={};for(let r of Object.keys(e)){let i=e[r],a=t?.[r]?.(i);if(a){Object.assign(n,a);continue}if(r===`slot`){n[`data-slot`]=i;continue}let o=`data-${String(r).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`;typeof i==`boolean`?n[o]=i?``:void 0:i!=null&&(n[o]=String(i))}return n}function Cb(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function wb(e){return/^on[A-Z]/.test(e)}function Tb(...e){let t=e.filter(Boolean);if(t.length!==0)return e=>{for(let n of t)typeof n==`function`?n(e):n&&(n.current=e)}}var Eb=8,Db=64,Ob=0,kb=.5,Ab=180,jb=new Set([`ArrowDown`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`,` `]),Mb={start:!1,end:!1},Nb={currentAnchorId:null,visibleMessageIds:[]};function Pb({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return Mb;let i=Kb({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:i-r.scrollTop-r.clientHeight>t}}function Fb({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:i,visibleMessageIds:a}){if(!e||!i)return Nb;let o=i.getBoundingClientRect(),s=o.top+t+n,c=typeof IntersectionObserver>`u`,l=[],u=null;for(let t of Ib(e,r)){let e=t.dataset.messageId;if(!e)continue;let n=t.dataset.scrollAnchor===`true`,r=n||c?t.getBoundingClientRect():null;(c&&r?r.bottom>s&&r.top<o.bottom:a.has(e))&&l.push(e),n&&r&&r.top<=s+kb&&(u=e)}return l.length===0&&u===null?Nb:{currentAnchorId:u,visibleMessageIds:l}}function Ib(e,t){return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e!==t)}function Lb(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t?.dataset.scrollAnchor===`true`)return t}return null}function Rb(e,t){for(let n of e)if(n.dataset.scrollAnchor===`true`&&!t.has(n))return n;return null}function zb(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor===`true`&&(n+=1,n>1))return!0;return!1}function Bb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor===`true`)return n}return null}function Vb({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let n of Ib(e,t)){if(!n.dataset.messageId)continue;let e=n.getBoundingClientRect();if(e.bottom>r.top&&e.top<r.bottom)return n}return null}function Hb({align:e,element:t,scrollMargin:n,spacer:r,viewport:i}){let a=Ub(t,i),o=t.getBoundingClientRect().height,s=Yb(r);if(e===`center`){let e=Math.max(0,i.clientHeight-s.start-s.end);return a-s.start-(e-o)/2-n}if(e===`end`)return a-i.clientHeight+o+s.end+n;if(e===`nearest`){let e=a+o,t=i.scrollTop+s.start,r=i.scrollTop+i.clientHeight-s.end;return a>=t&&e<=r?i.scrollTop:a<t?a-s.start-n:e-i.clientHeight+s.end+n}return a-s.start-n}function Ub(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Wb(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Gb({content:e,scrollTop:t,spacer:n,viewport:r}){let i=Kb({content:e,spacer:n,viewport:r});return t+r.clientHeight-i}function Kb({content:e,spacer:t,viewport:n}){let r=Ib(e,t),i=Jb(e),a=n.getBoundingClientRect(),o=n.scrollTop,s=i.start+i.end;for(let e of r){let t=e.getBoundingClientRect();s=Math.max(s,t.bottom-a.top+o+i.end)}return s}function qb(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Jb(e){let t=window.getComputedStyle(e);return{end:Zb(t.paddingBlockEnd||t.paddingBottom),start:Zb(t.paddingBlockStart||t.paddingTop)}}function Yb(e){let t=e?.parentElement;return t?Jb(t):{end:0,start:0}}function Xb(e){if(!e)return 0;let t=window.getComputedStyle(e);return Zb(t.rowGap===`normal`?t.gap:t.rowGap)}function Zb(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Qb({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:i,autoScrollRef:a,autoscrollingRef:o,autoscrollingTimeoutRef:s,contentRef:c,defaultScrollPositionAppliedRef:l,itemCountRef:u,messageElementsRef:d,modeRef:f,pendingScrollToMessageRef:p,prependRestoreRef:m,scrollMarginRef:h,scrollPreviousItemPeekRef:g,spacerGapRef:_,spacerHeightRef:v,spacerRef:y,viewportRef:b}=e,x=E.useCallback(e=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),o.current!==e&&(o.current=e,t()),e&&(s.current=window.setTimeout(()=>{s.current=null,o.current=!1,t()},Ab))},[t]),S=E.useCallback(e=>{let t=y.current;if(!t)return;let n=Math.max(0,Math.ceil(e));v.current!==n&&(v.current=n,t.hidden=n===0,t.style.height=`${n}px`,t.style.marginTop=n>0?`${-_.current}px`:``)},[]),C=E.useCallback((e,{behavior:r=`auto`,autoscrolling:i=!1}={})=>{let a=b.current;if(!a)return;let o=Math.max(0,e);if(Math.abs(a.scrollTop-o)<=kb){a.scrollTop=o,t();return}i&&x(!0),a.scrollTo({top:o,behavior:r}),n()},[t,n,x]),w=E.useCallback(({behavior:e=`auto`}={})=>b.current?(S(0),i.current=null,f.current=`free-scrolling`,C(0,{behavior:e}),r(),!0):!1,[r,C,S]),T=E.useCallback(({behavior:e=`auto`}={})=>{let t=b.current;return t?(S(0),i.current=null,f.current=a.current?`following-bottom`:`free-scrolling`,C(qb(t),{autoscrolling:!0,behavior:e}),r(),!0):!1},[r,C,S]),D=E.useCallback((e,{align:t=`start`,behavior:n=`auto`,scrollMargin:a=h.current}={},{keepPreviousPeek:o=!1}={})=>{let s=c.current,l=b.current;if(!s||!l||!s.contains(e))return!1;let u=Hb({align:t,element:e,scrollMargin:o?a+g.current:a,spacer:y.current,viewport:l}),d=Gb({content:s,scrollTop:u,spacer:y.current,viewport:l});return S(d),m.current={element:e,viewportTop:Wb(e,l)},f.current=o?`anchored-to-message`:`settling-jump`,i.current=o?e:null,C(u,{behavior:n}),r(),!0},[r,C,S]),O=E.useCallback(()=>{let e=i.current;return!e||!e.isConnected||f.current!==`anchored-to-message`?!1:D(e,{align:`start`},{keepPreviousPeek:!0})},[D]),k=E.useCallback((e,t)=>{let n=d.current.get(e);return n?(l.current=!0,D(n,t)?(p.current=null,!0):(p.current={messageId:e,options:t},!0)):u.current===0&&(p.current={messageId:e,options:t},l.current=!0,!0)},[D]);return{flushPendingScrollToMessage:E.useCallback(()=>{let e=p.current;if(!e)return!1;let t=d.current.get(e.messageId);return!t||!D(t,e.options)?!1:(p.current=null,l.current=!0,!0)},[D]),reanchorToAnchoredMessage:O,scrollToElement:D,scrollToEnd:T,scrollToMessage:k,scrollToStart:w}}function $b(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:e=>{t(n,e)||(n=e,r.forEach(e=>e()))},subscribe:(e,t,n)=>{let i=r.size===0;return r.add(e),i&&t?.(),()=>{r.delete(e),r.size===0&&n?.()}}}}function ex(e,t){return $b(e,t)}function tx(){return $b(Nb,rx)}function nx(e,t){return e.start===t.start&&e.end===t.end}function rx(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((e,n)=>e===t.visibleMessageIds[n])}function ix({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let i=E.useRef(e),a=E.useRef(!1),o=E.useRef(null),s=E.useRef(!1),c=E.useRef(t),l=E.useRef(0),u=E.useRef(null),d=E.useRef(0),f=E.useRef(e?`following-bottom`:`free-scrolling`),p=E.useRef(new Map),m=E.useRef(null),h=E.useRef(null),g=E.useRef(null),_=E.useRef(r),v=E.useRef(!0),y=E.useRef(null),b=E.useRef(n),x=E.useRef(null),S=E.useRef(0),C=E.useRef(0),w=E.useRef(null),T=E.useRef(null),D=E.useRef(null),O=E.useRef(null),k=E.useRef(null),A=E.useRef(null),j=E.useRef(null),M=E.useRef(null),N=E.useRef(new Set),ee=E.useRef(new WeakSet);return D.current===null&&(D.current=ex(Mb,nx)),M.current===null&&(M.current=tx()),i.current=e,c.current=t,b.current=n,_.current=r,{autoScrollRef:i,autoscrollingRef:a,autoscrollingTimeoutRef:O,streamingTurnRef:g,contentRef:o,defaultScrollPositionAppliedRef:s,firstItemRef:u,itemCountRef:l,lastScrollTopRef:d,messageElementsRef:p,modeRef:f,pendingScrollFrameRef:x,pendingScrollToMessageRef:m,prependRestoreRef:h,preserveScrollOnPrependRef:v,rootRef:y,scrollEdgeThresholdRef:c,scrollMarginRef:b,scrollPreviousItemPeekRef:_,spacerGapRef:S,spacerHeightRef:C,spacerRef:w,stateFrameRef:T,stateStore:D.current,viewportRef:k,visibilityFrameRef:A,visibilityObserverRef:j,visibilityStore:M.current,visibleMessageIdsRef:N,handledScrollAnchorsRef:ee}}function ax(e,t){return E.useCallback(n=>{e.current=n,n&&t()},[e,t])}function ox({autoScroll:e=!1,defaultScrollPosition:t=`end`,scrollEdgeThreshold:n=Eb,scrollPreviousItemPeek:r=Db,scrollMargin:i=Ob}){let a=ix({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:i,scrollPreviousItemPeek:r}),{streamingTurnRef:o,autoScrollRef:s,autoscrollingRef:c,autoscrollingTimeoutRef:l,contentRef:u,defaultScrollPositionAppliedRef:d,firstItemRef:f,itemCountRef:p,lastScrollTopRef:m,messageElementsRef:h,modeRef:g,pendingScrollFrameRef:_,pendingScrollToMessageRef:v,prependRestoreRef:y,preserveScrollOnPrependRef:b,rootRef:x,scrollEdgeThresholdRef:S,scrollMarginRef:C,scrollPreviousItemPeekRef:w,spacerGapRef:T,spacerHeightRef:D,spacerRef:O,stateFrameRef:k,stateStore:A,viewportRef:j,visibilityFrameRef:M,visibilityObserverRef:N,visibilityStore:ee,visibleMessageIdsRef:te,handledScrollAnchorsRef:P}=a,F=E.useRef(t);F.current!==t&&(F.current=t,d.current=!1);let ne=E.useCallback(e=>{let t=x.current,n=j.current,r=[e.start&&`start`,e.end&&`end`].filter(Boolean).join(` `),i=c.current;for(let e of[t,n])e&&(r?e.setAttribute(`data-scrollable`,r):e.removeAttribute(`data-scrollable`),e.toggleAttribute(`data-autoscrolling`,i))},[]),re=E.useCallback(e=>{let t=j.current?.scrollTop??0,n=t<m.current-kb;m.current=t,s.current&&!e.end&&g.current!==`settling-jump`&&g.current!==`anchored-to-message`?g.current=`following-bottom`:g.current===`following-bottom`&&e.end&&n&&!c.current&&(g.current=`free-scrolling`)},[]),ie=E.useCallback(()=>{let e=Pb({content:u.current,scrollEdgeThreshold:S.current,spacer:O.current,viewport:j.current});re(e);let t=g.current===`following-bottom`?{...e,end:!1}:e;ne(t),A.setSnapshot(t)},[re,A,ne]),ae=E.useCallback(()=>{k.current===null&&(k.current=window.requestAnimationFrame(()=>{k.current=null,ie()}))},[ie]),I=E.useCallback(()=>{ee.hasListeners()&&M.current===null&&(M.current=window.requestAnimationFrame(()=>{M.current=null,ee.hasListeners()&&ee.setSnapshot(Fb({content:u.current,scrollMargin:C.current,scrollPreviousItemPeek:w.current,spacer:O.current,viewport:j.current,visibleMessageIds:te.current}))}))},[ee]),{flushPendingScrollToMessage:L,reanchorToAnchoredMessage:oe,scrollToElement:se,scrollToEnd:ce,scrollToMessage:le,scrollToStart:ue}=Qb({refs:a,commitScrollState:ie,scheduleStateCommit:ae,scheduleVisibilitySync:I}),de=E.useCallback(()=>{let e=y.current,t=j.current;if(!e||!t||!e.element.isConnected)return!1;let n=Wb(e.element,t)-e.viewportTop;return Math.abs(n)<=kb?!1:(t.scrollTop+=n,e.viewportTop=Wb(e.element,t),ae(),I(),!0)},[ae,I]),fe=E.useCallback(()=>{let e=u.current,t=j.current;if(!e||!t){y.current=null;return}let n=Vb({content:e,spacer:O.current,viewport:t});y.current=n?{element:n,viewportTop:Wb(n,t)}:null},[]),pe=E.useCallback(()=>{_.current===null&&(_.current=window.requestAnimationFrame(()=>{_.current=null,L()&&fe()}))},[fe,L]),me=E.useCallback(()=>{if(!t||d.current||p.current===0)return!1;let e=!1;if(t===`last-anchor`){let t=u.current,n=j.current,r=t&&n?Bb(Ib(t,O.current)):null;if(!t||!n||!r)e=ce({behavior:`auto`});else{let i=Ub(r,n);e=Kb({content:t,spacer:O.current,viewport:n})-i<=n.clientHeight?ce({behavior:`auto`}):se(r,{align:`start`},{keepPreviousPeek:!0})}}else e=t===`end`?ce({behavior:`auto`}):ue({behavior:`auto`});return e?(d.current=!0,!0):!1},[t,se,ce,ue]),he=E.useCallback(()=>{let e=u.current;if(!e)return;let t=Ib(e,O.current),n=p.current,r=f.current;p.current=t.length,f.current=t[0]??null,(()=>{if(L())return;if(n===0){if(me()||t.length>0&&s.current&&ce({behavior:`auto`}))return;ie(),I();return}let e=r?t.indexOf(r):-1;if(b.current&&e>0){de();return}if(t.length>n){let e=Lb(t,n);if(e){if(s.current&&g.current===`following-bottom`&&zb(t,n)){ce({behavior:`auto`});return}se(e,{align:`start`},{keepPreviousPeek:!0}),P.current.add(e);return}}if(t.length===n){let e=Rb(t,P.current);if(e){se(e,{align:`start`},{keepPreviousPeek:!0}),P.current.add(e);return}}g.current===`following-bottom`&&s.current?ce({behavior:`auto`}):(ie(),I())})(),fe()},[me,fe,ie,L,de,I,se,ce]),ge=E.useCallback(()=>{if(g.current===`following-bottom`&&s.current){ce({behavior:`auto`});return}let e=D.current;if(oe()){s.current&&e>0&&D.current===0&&ce({behavior:`auto`});return}ae(),I()},[oe,ae,I,ce]),_e=E.useCallback(()=>{let e=j.current;if(!(!e||!ee.hasListeners())){if(typeof IntersectionObserver>`u`){I();return}N.current||=new IntersectionObserver(e=>{for(let t of e){let e=t.target.dataset.messageId;e&&(t.isIntersecting?te.current.add(e):te.current.delete(e))}I()},{root:e,rootMargin:`${-(C.current+w.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]}),h.current.forEach(e=>{N.current?.observe(e)}),I()}},[I,ee]),ve=E.useCallback(()=>{M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),N.current?.disconnect(),N.current=null,te.current.clear(),ee.setSnapshot(Nb)},[ee]),ye=E.useCallback((e,t,n)=>{if(t){h.current.set(e,t),N.current?.observe(t),I(),v.current?.messageId===e&&pe();return}n&&h.current.get(e)===n&&(h.current.delete(e),te.current.delete(e),N.current?.unobserve(n),I())},[pe,I]),be=E.useCallback(()=>{(g.current===`following-bottom`||g.current===`anchored-to-message`||g.current===`settling-jump`)&&(o.current=null,g.current=`free-scrolling`)},[]),xe=E.useCallback(()=>ne(A.getSnapshot()),[A,ne]),Se=ax(x,xe),Ce=ax(j,xe),we=E.useCallback(e=>{u.current=e},[]),Te=E.useCallback(e=>{O.current=e,T.current=Xb(e?.parentElement??null)},[]),Ee=E.useCallback(()=>{ie(),I(),fe()},[fe,ie,I]),De=E.useMemo(()=>({handleContentChange:he,handleResize:ge,observeVisibility:_e,preserveScrollOnPrependRef:b,scrollToEnd:ce,scrollToMessage:le,scrollToStart:ue,setContentElement:we,setRootElement:Se,setSpacerElement:Te,setViewportElement:Ce,stateStore:A,syncAfterScroll:Ee,unobserveVisibility:ve,userScrollIntent:be,viewportRef:j,visibilityStore:ee}),[he,ge,_e,ce,le,ue,we,Se,Te,Ce,A,Ee,ve,be,ee]);return E.useLayoutEffect(()=>{me()},[me]),E.useEffect(()=>()=>{k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),N.current?.disconnect(),N.current=null},[]),E.useLayoutEffect(()=>{if(e&&g.current===`following-bottom`&&p.current>0){ce({behavior:`auto`});return}ie()},[e,ie,ce]),{context:De,registerMessage:ye}}function sx(e){let t=E.useRef(e);return t.current=e,t}var cx=E.createContext(null),lx=E.createContext(null);function ux(){let e=E.useContext(cx);if(!e)throw Error(`useMessageScroller must be used within a MessageScroller.`);return e}function dx(){let e=E.useContext(lx);if(!e)throw Error(`MessageScrollerItem must be used within a MessageScroller.`);return e}function fx(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=ux();return E.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function px({autoScroll:e=!1,children:t,defaultScrollPosition:n=`end`,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a}){let{context:o,registerMessage:s}=ox({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a});return(0,R.jsx)(cx.Provider,{value:o,children:(0,R.jsx)(lx.Provider,{value:s,children:t})})}function mx({children:e,...t}){let{setRootElement:n}=ux();return(0,R.jsx)(`div`,{ref:n,...t,children:e})}function hx({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:i,onWheel:a,preserveScrollOnPrepend:o=!0,ref:s,role:c,tabIndex:l,...u}){let{handleResize:d,preserveScrollOnPrependRef:f,setViewportElement:p,syncAfterScroll:m,userScrollIntent:h,viewportRef:g}=ux();f.current=o;let _=E.useCallback(e=>{p(e),Tb(s)?.(e)},[s,p]);function v(e){m(),r?.(e)}function y(e){h(),a?.(e)}function b(e){h(),i?.(e)}function x(e){jb.has(e.key)&&h(),n?.(e)}return E.useEffect(()=>{let e=g.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(d)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[d,g]),(0,R.jsx)(`div`,{ref:_,role:c??`region`,"aria-label":e??`Messages`,tabIndex:l??0,onKeyDown:x,onScroll:v,onTouchMove:b,onWheel:y,...u,children:t})}function gx({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:i,...a}){let{handleContentChange:o,handleResize:s,setContentElement:c,setSpacerElement:l}=ux(),u=E.useRef(null),d=E.useCallback(e=>{u.current=e,c(e),Tb(n)?.(e)},[n,c]);return E.useLayoutEffect(()=>{let e=u.current;if(!e||(o(),typeof MutationObserver>`u`))return;let t=new MutationObserver(()=>{o()});return t.observe(e,{childList:!0}),()=>t.disconnect()},[o]),E.useEffect(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(s)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[s]),(0,R.jsxs)(`div`,{ref:d,role:r??`log`,"aria-relevant":e??`additions`,...a,children:[t,(0,R.jsx)(`div`,{ref:l,"aria-hidden":`true`,"data-message-scroller-spacer":``,hidden:!0,className:i})]})}function _x({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let i=dx(),a=E.useRef(null),o=E.useCallback(n=>{let r=a.current;a.current=n,e&&i(e,n,r),Tb(t)?.(n)},[e,t,i]);return(0,R.jsx)(`div`,{ref:o,"data-message-id":e,"data-scroll-anchor":n?`true`:`false`,...r})}function vx({behavior:e=`smooth`,children:t,direction:n=`end`,onClick:r,render:i,tabIndex:a,type:o=`button`,...s}){let{scrollToEnd:c,scrollToStart:l,stateStore:u}=ux(),d=sx(r),f=E.useCallback(e=>u.subscribe(e),[u]),p=E.useCallback(()=>{let e=u.getSnapshot();return n===`start`?e.start:e.end},[n,u]),m=E.useSyncExternalStore(f,p,p),h=E.useCallback(t=>{m&&(d.current?.(t),t.defaultPrevented||(t.currentTarget.blur(),n===`start`?l({behavior:e}):c({behavior:e})))},[e,n,m,d,c,l]);return bb({defaultTagName:`button`,props:xb({type:o,inert:!m,tabIndex:m?a:-1,children:t??(0,R.jsxs)(`span`,{children:[`Scroll to `,n]}),onClick:h},s),render:i,state:{active:m,direction:n},stateAttributesMapping:{active:e=>({"data-active":e?`true`:`false`})}})}var yx={Provider:px,Root:mx,Viewport:hx,Content:gx,Item:_x,Button:vx};function bx(e){return(0,R.jsx)(yx.Provider,{...e})}function xx({className:e,...t}){return(0,R.jsx)(yx.Root,{"data-slot":`message-scroller`,className:V(`group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden`,e),...t})}function Sx({className:e,...t}){return(0,R.jsx)(yx.Viewport,{"data-slot":`message-scroller-viewport`,className:V(`size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content [overflow-anchor:none]`,e),...t})}function Cx({className:e,...t}){return(0,R.jsx)(yx.Content,{"data-slot":`message-scroller-content`,className:V(`flex h-max min-h-full flex-col gap-6`,e),...t})}function wx({className:e,scrollAnchor:t=!1,...n}){return(0,R.jsx)(yx.Item,{"data-slot":`message-scroller-item`,scrollAnchor:t,className:V(`min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]`,e),...n})}function Tx({direction:e=`end`,className:t,children:n,render:r,variant:i=`secondary`,size:a=`icon-sm`,...o}){return(0,R.jsx)(yx.Button,{"data-slot":`message-scroller-button`,"data-direction":e,"data-variant":i,"data-size":a,direction:e,className:V(`absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180`,t),render:r??(0,R.jsx)(U,{variant:i,size:a}),...o,children:n??(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:e===`end`?`Scroll to end`:`Scroll to start`})]})})}var Ex=Wm(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function Dx({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?vr:`span`;return(0,R.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:V(Ex({variant:t}),e),...r})}var Ox=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i;function kx(e){return!!e&&e.startsWith(`image/`)}function Ax(e){return e?Ox.test(e.split(`?`)[0]??``):!1}function jx(e){return kx(e.type)||Ax(e.name)}function Mx(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`could not read ${e.name}`)),r.onload=()=>{let i=String(r.result??``);if(!i.startsWith(`data:`)){n(Error(`unexpected read result for ${e.name}`));return}t({id:`att_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,name:e.name||`image`,mime:e.type||Fx(e.name)||`application/octet-stream`,uri:i})},r.readAsDataURL(e)})}async function Nx(e){let t=[];for(let n of Array.from(e))if(jx(n))try{t.push(await Mx(n))}catch{}return t}function Px(e){return{uri:e.uri,name:e.name}}function Fx(e){switch((e.split(`.`).pop()??``).toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;case`avif`:return`image/avif`;case`bmp`:return`image/bmp`;case`svg`:return`image/svg+xml`;default:return}}function Ix(e){if(!kx(e.mime)&&!Ax(e.name))return null;if(e.data)return`data:${e.mime};base64,${e.data}`;if(e.source?.type===`uri`){let t=e.source.uri;if(/^(https?:|blob:|data:image\/)/i.test(t))return t}return null}function Lx(e){if(!kx(e.mime)&&!Ax(e.name)||e.data)return null;if(e.source?.type===`uri`){let t=e.source.uri;if(/^file:\/\//i.test(t))try{return decodeURIComponent(new URL(t).pathname)}catch{return null}if(/^\//.test(t)||Ax(t))return t}return null}function Rx(e){let t=new Uint8Array(e),n=32768,r=``;for(let e=0;e<t.length;e+=n)r+=String.fromCharCode(...t.subarray(e,e+n));return btoa(r)}var zx=s({clearDraft:()=>Kx,loadDraft:()=>Wx,saveDraft:()=>Gx}),Bx=`webui.drafts`,Vx=50;function Hx(){try{let e=localStorage.getItem(Bx);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}function Ux(e){try{let t=Object.entries(e).sort((e,t)=>t[1].at-e[1].at).slice(0,Vx);localStorage.setItem(Bx,JSON.stringify(Object.fromEntries(t)))}catch{}}function Wx(e){return Hx()[e]?.text??``}function Gx(e,t){let n=Hx();if(t)n[e]={text:t,at:Date.now()};else{if(!(e in n))return;delete n[e]}Ux(n)}function Kx(e){let t=Hx();e in t&&(delete t[e],Ux(t))}function qx({className:e,children:t,...n}){return(0,R.jsxs)(Jp,{"data-slot":`scroll-area`,className:V(`relative`,e),...n,children:[(0,R.jsx)(Yp,{"data-slot":`scroll-area-viewport`,className:`size-full min-w-0 max-w-full overflow-x-hidden rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,R.jsx)(Jx,{}),(0,R.jsx)(Xp,{})]})}function Jx({className:e,orientation:t=`vertical`,...n}){return(0,R.jsx)(Sp,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:V(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,R.jsx)(Np,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Yx({className:e,size:t=`default`,...n}){return(0,R.jsx)(mm,{"data-slot":`switch`,"data-size":t,className:V(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,R.jsx)(gm,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function Xx({className:e,orientation:t=`horizontal`,...n}){return(0,R.jsx)(Rm,{"data-slot":`tabs`,"data-orientation":t,className:V(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Zx=Wm(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Qx({className:e,variant:t=`default`,...n}){return(0,R.jsx)(zm,{"data-slot":`tabs-list`,"data-variant":t,className:V(Zx({variant:t}),e),...n})}function $x({className:e,...t}){return(0,R.jsx)(Bm,{"data-slot":`tabs-trigger`,className:V(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function eS({className:e,...t}){return(0,R.jsx)(Vm,{"data-slot":`tabs-content`,className:V(`flex-1 text-sm outline-none`,e),...t})}var tS=`webui.ext.disabled`,nS=null,rS=new Set;function iS(){if(nS)return nS;try{let e=JSON.parse(localStorage.getItem(tS)??`[]`);nS=Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{nS=[]}return nS}function aS(e){return iS().includes(e)}function oS(e,t){let n=new Set(iS());t?n.add(e):n.delete(e),nS=[...n];try{localStorage.setItem(tS,JSON.stringify(nS))}catch{}for(let e of rS)e()}function sS(e){return rS.add(e),()=>rS.delete(e)}var cS={primary:`default`,secondary:`secondary`,ghost:`ghost`,outline:`outline`,danger:`destructive`};function lS({children:e,onClick:t,variant:n=`ghost`,disabled:r,className:i=``,title:a,type:o=`button`}){return(0,R.jsx)(U,{type:o,title:a,variant:cS[n],className:i,onClick:t,disabled:r,children:e})}function uS({className:e=`size-4`}){return(0,R.jsx)(`span`,{className:`inline-block animate-spin rounded-full border-2 border-[color-mix(in_oklch,var(--border-selected)_30%,transparent)] border-t-[var(--border-selected)] ${e}`})}var dS={neutral:`bg-[var(--surface-raised-base)] text-[var(--text-weak)]`,green:`bg-[color-mix(in_oklch,var(--surface-success-strong)_12%,transparent)] text-[var(--surface-success-strong)]`,red:`bg-[color-mix(in_oklch,var(--surface-critical-strong)_12%,transparent)] text-[var(--surface-critical-strong)]`,blue:`bg-[color-mix(in_oklch,var(--border-selected)_12%,transparent)] text-[var(--text-interactive-base)]`,amber:`bg-[color-mix(in_oklch,var(--surface-warning-strong)_12%,transparent)] text-[var(--surface-warning-strong)]`};function fS({children:e,tone:t=`neutral`}){return(0,R.jsx)(Dx,{variant:`secondary`,className:V(dS[t]),children:e})}function pS(e){let t=Math.max(1,Math.floor((Date.now()-e)/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function mS(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}var hS=`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--input-base)] px-2.5 py-1.5 text-sm text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)] focus:ring-1 focus:ring-[var(--border-selected)]`;function gS({title:e,note:t,onRefresh:n,loading:r}){return(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`h3`,{className:`shrink-0 text-[13px] font-medium text-[var(--text-strong)]`,children:e}),t&&(0,R.jsx)(`span`,{className:`truncate text-[11px] text-[var(--text-weaker)]`,children:t})]}),n&&(0,R.jsx)(U,{variant:`ghost`,size:`icon-sm`,title:`Refresh`,disabled:r,onClick:n,children:(0,R.jsx)(Ge,{className:r?`animate-spin`:``})})]})}function _S({children:e}){return(0,R.jsx)(`p`,{className:`py-3 text-center text-xs text-[var(--text-weaker)]`,children:e})}function vS(e){let[t,n]=(0,E.useState)(null),[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!0),[s,c]=(0,E.useState)(0);return(0,E.useEffect)(()=>{let t=!1;return o(!0),i(null),e().then(e=>{t||n(e)}).catch(e=>{t||i(e instanceof Error?e.message:String(e))}).finally(()=>{t||o(!1)}),()=>{t=!0}},[s]),{data:t,error:r,loading:a,refresh:(0,E.useCallback)(()=>c(e=>e+1),[])}}function yS({message:e}){return(0,R.jsx)(`p`,{className:`rounded-md border border-[var(--surface-critical-base)] bg-[var(--surface-critical-weak)] px-2.5 py-1.5 text-xs text-[var(--surface-critical-strong)]`,children:e})}function bS({text:e}){let[t,n]=(0,E.useState)(!1);return(0,R.jsx)(U,{variant:`ghost`,size:`xs`,title:`Copy`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1200)})},children:t?`copied`:`copy`})}function xS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.configGet());return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Configuration`,note:`Read-only — edit server-side in opencode.jsonc`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No configuration found.`}),(0,R.jsx)(`div`,{className:`space-y-2`,children:e?.map((e,t)=>(0,R.jsx)(SS,{entry:e},t))})]})}function SS({entry:e}){return(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] p-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(fS,{tone:e.type===`document`?`blue`:`neutral`,children:e.type}),e.path&&(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-[var(--text-weak)]`,children:e.path})]}),e.type===`document`&&(0,R.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-[var(--text-base)] mt-2 max-h-72`,children:JSON.stringify(e.info,null,2)})]})}var CS=`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-3 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`;function wS(e,t,n,r){let[i,a]=(0,E.useState)({kind:`idle`}),o=i.kind===`active`?i.attemptID:null,s=i.kind===`active`?i.status:null;return(0,E.useEffect)(()=>{if(!e){a({kind:`idle`});return}let n=!1;return a({kind:`starting`}),t(e).then(e=>{n||a({kind:`active`,attemptID:e.attemptID,url:e.url,instructions:e.instructions,status:`pending`})}).catch(e=>a({kind:`starting`,error:e instanceof Error?e.message:String(e)})),()=>{n=!0}},[e?.integrationID,e?.methodID]),(0,E.useEffect)(()=>{if(!e||!o||s!==`pending`)return;let t=async()=>{try{let t=await n(e,o);a(e=>e.kind===`active`?{...e,status:t.status,message:t.message}:e),t.status===`complete`&&r()}catch{}};return og({name:`integration-attempt`,minInterval:2e3,run:()=>t()})},[e?.integrationID,e?.methodID,o,s]),i}function TS({state:e,onCancel:t,label:n}){return e.kind===`idle`?null:e.kind===`starting`?(0,R.jsxs)(`div`,{className:`space-y-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[e.error?(0,R.jsx)(yS,{message:e.error}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--text-base)]`,children:[(0,R.jsx)(Me,{className:`size-3.5 animate-spin`}),` starting `,n,`…`]}),(0,R.jsx)(U,{variant:`ghost`,size:`xs`,onClick:t,children:`cancel`})]}):(0,R.jsxs)(`div`,{className:`space-y-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-xs text-[var(--text-base)]`,children:[n,` attempt`]}),(0,R.jsx)(fS,{tone:e.status===`complete`?`green`:e.status===`pending`?`amber`:`red`,children:e.status})]}),e.url&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`a`,{className:`min-w-0 truncate text-xs text-[var(--text-interactive-base)] underline underline-offset-2`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),(0,R.jsx)(pe,{className:`size-3 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(bS,{text:e.url})]}),e.instructions&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weak)]`,children:e.instructions}),e.message&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weak)]`,children:e.message}),e.status===`pending`&&(0,R.jsx)(U,{variant:`ghost`,size:`xs`,onClick:t,children:`cancel`})]})}function ES({integration:e,method:t,open:n,onClose:r,onDone:i}){let[a,o]=(0,E.useState)(``),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(!1),[d,f]=(0,E.useState)(null);return(0,R.jsx)(Km,{open:n,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/60`}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:CS,children:[(0,R.jsxs)(Qm,{children:[(0,R.jsxs)(eh,{children:[e.name,` · API key`]}),(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:t.label??`Connect with an API key for ${e.id}`})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`input`,{className:hS,placeholder:`API key`,type:`password`,autoComplete:`off`,value:a,onChange:e=>o(e.target.value)}),(0,R.jsx)(`input`,{className:hS,placeholder:`Label (optional)`,value:s,onChange:e=>c(e.target.value)}),d&&(0,R.jsx)(yS,{message:d})]}),(0,R.jsxs)($m,{className:`rounded-b-lg`,children:[(0,R.jsx)(U,{variant:`ghost`,onClick:r,disabled:l,children:`Cancel`}),(0,R.jsx)(U,{disabled:a.trim().length===0||l,onClick:()=>{u(!0),f(null),G.integrationConnectKey(e.id,{key:a.trim(),label:s.trim()||null}).then(()=>{r(),i()}).catch(e=>f(e instanceof Error?e.message:String(e))).finally(()=>u(!1))},children:l?`Connecting…`:`Connect`})]}),(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})})}function DS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.integrationList().then(e=>e.data)),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)(``),c=vS(()=>G.models()),l=vS(()=>G.providerList().then(e=>e.data)),[u,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(null),[m,h]=(0,E.useState)(null),g=wS(f,e=>G.integrationConnectOauth(e.integrationID,{methodID:e.methodID}).then(e=>({attemptID:e.data.attemptID,url:e.data.url,instructions:e.data.instructions})),(e,t)=>G.integrationOauthAttempt(e.integrationID,t).then(e=>e.data),r),_=wS(m,e=>G.integrationConnectCommand(e.integrationID,{methodID:e.methodID}).then(e=>({attemptID:e.data.attemptID})),(e,t)=>G.integrationCommandAttempt(e.integrationID,t).then(e=>e.data),r),v=(0,E.useMemo)(()=>{let e=new Map;if(!c.data||!l.data)return e;let t=new Map;for(let e of l.data){if(!e.integrationID)continue;let n=t.get(e.integrationID)??new Set;n.add(e.id),t.set(e.integrationID,n)}for(let n of c.data)for(let[r,i]of t)i.has(n.providerID)&&e.set(r,(e.get(r)??0)+1);return e},[c.data,l.data]),y=(0,E.useMemo)(()=>e?[...e].sort((e,t)=>{let n=+(e.connections.length>0),r=+(t.connections.length>0);return n===r?(e.name||e.id).localeCompare(t.name||t.id):r-n}):[],[e]),b=o.trim().toLowerCase(),x=(0,E.useMemo)(()=>b?y.filter(e=>e.name.toLowerCase().includes(b)||e.id.toLowerCase().includes(b)):y,[y,b]);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Integrations`,note:`Connect providers — API keys, OAuth, CLI commands`,onRefresh:r,loading:n}),(0,R.jsx)(`p`,{className:`-mt-1 mb-2 text-xs text-[var(--text-weaker)]`,children:`An integration is how the engine authenticates to a model provider. Connect one to enable its models.`}),(0,R.jsxs)(`div`,{className:`relative mb-2`,children:[(0,R.jsx)(qe,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(`input`,{className:`${hS} h-7 pl-7`,placeholder:`Search integrations`,value:o,onChange:e=>s(e.target.value)})]}),b&&(0,R.jsxs)(`p`,{className:`mb-1 px-1 text-[11px] text-[var(--text-weaker)]`,"aria-live":`polite`,children:[x.length,` of `,y.length]}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No integrations available.`}),!t&&e&&e.length>0&&x.length===0&&(0,R.jsxs)(_S,{children:[`No integrations match “`,o.trim(),`”.`]}),(0,R.jsx)(`div`,{className:`space-y-1`,children:x.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-raised-base-hover)]`,onClick:()=>a(i===e.id?null:e.id),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(L,{className:`size-3.5 shrink-0 text-[var(--text-weaker)] transition-transform ${i===e.id?`rotate-90`:``}`}),(0,R.jsx)(`span`,{className:`truncate text-[13px] text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-[var(--text-weaker)]`,children:e.id})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(v.get(e.id)??0)>0&&(0,R.jsxs)(`span`,{className:`text-[11px] text-[var(--text-weaker)]`,children:[`· `,v.get(e.id),` models`]}),e.connections.length>0?(0,R.jsxs)(fS,{tone:`green`,children:[`connected`,e.connections.length>1?` · ${e.connections.length}`:``]}):(0,R.jsx)(fS,{children:`not connected`}),e.connections.map((e,t)=>(0,R.jsx)(fS,{tone:`blue`,children:e.type===`credential`?e.label:e.name},t))]})]}),i===e.id&&(0,R.jsxs)(`div`,{className:`mt-1 ml-4 space-y-1.5 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[e.connections.length===0&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:`No connections yet.`}),e.connections.length>0&&(0,R.jsx)(`div`,{className:`space-y-1`,children:e.connections.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,R.jsx)(fS,{tone:e.type===`credential`?`blue`:`neutral`,children:e.type===`credential`?`credential`:`env`}),(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:e.type===`credential`?e.label:e.name}),e.type===`credential`&&(0,R.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--text-weaker)]`,children:e.id})]},t))}),(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:e.methods.map((t,n)=>(0,R.jsx)(OS,{method:t,onKey:()=>d({integration:e,method:t}),onOauth:()=>p({integrationID:e.id,methodID:t.id}),onCommand:()=>h({integrationID:e.id,methodID:t.id})},n))}),f?.integrationID===e.id&&(0,R.jsx)(TS,{state:g,onCancel:()=>p(null),label:`OAuth`}),m?.integrationID===e.id&&(0,R.jsx)(TS,{state:_,onCancel:()=>h(null),label:`Command`})]})]},e.id))}),u&&(0,R.jsx)(ES,{integration:u.integration,method:u.method,open:!0,onClose:()=>d(null),onDone:r})]})}function OS({method:e,onKey:t,onOauth:n,onCommand:r}){let i=e.type===`env`?`env: ${e.names.join(`, `)}`:e.label??e.type;return e.type===`env`?(0,R.jsx)(U,{size:`xs`,variant:`outline`,disabled:!0,title:`Configured via environment variables`,children:i}):(0,R.jsx)(U,{size:`xs`,variant:`outline`,onClick:e.type===`key`?t:e.type===`oauth`?n:r,children:i})}var kS=`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-3 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`;function AS(e){switch(e.status){case`connected`:return`green`;case`pending`:case`needs_auth`:return`amber`;case`failed`:return`red`;default:return`neutral`}}function jS(e){return e.status===`needs_auth`?`needs auth`:e.status}function MS(){let e=vS(()=>G.mcpList().then(e=>e.data)),t=vS(()=>G.mcpResource().then(e=>e.data)),[n,r]=(0,E.useState)(null),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)(null),c=()=>{e.refresh(),t.refresh()},l=(e,t)=>{r(e),a(null),t().catch(e=>a(e instanceof Error?e.message:String(e))).finally(()=>{r(null),c()})};return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`MCP servers`,note:`Model Context Protocol endpoints`,onRefresh:c,loading:e.loading}),e.error&&(0,R.jsx)(yS,{message:e.error}),i&&(0,R.jsx)(yS,{message:i}),!e.error&&e.data&&e.data.length===0&&(0,R.jsx)(_S,{children:`No MCP servers configured.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e.data?.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-[13px] text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(fS,{tone:AS(e.status),children:jS(e.status)}),e.status.status===`failed`&&(0,R.jsx)(`span`,{className:`max-w-40 truncate text-[10px] text-[var(--text-on-critical-base)]`,children:e.status.error})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.status.status!==`connected`&&(0,R.jsx)(U,{size:`xs`,variant:`outline`,disabled:n!==null,onClick:()=>l(`connect:${e.name}`,()=>G.mcpConnect(e.name)),children:n===`connect:${e.name}`?`Connecting…`:`Connect`}),e.status.status===`connected`&&(0,R.jsx)(U,{size:`xs`,variant:`outline`,disabled:n!==null,onClick:()=>l(`disconnect:${e.name}`,()=>G.mcpDisconnect(e.name)),children:n===`disconnect:${e.name}`?`Disconnecting…`:`Disconnect`}),(0,R.jsx)(U,{size:`xs`,variant:`ghost`,disabled:n!==null,className:`text-[var(--surface-critical-strong)]`,onClick:()=>s(e),children:`Remove`})]})]},e.name))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Resources`,note:`Read-only catalog`,onRefresh:t.refresh,loading:t.loading}),t.error&&(0,R.jsx)(yS,{message:t.error}),!t.error&&t.data&&t.data.resources.length===0&&(0,R.jsx)(_S,{children:`No resources exposed.`}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[t.data?.resources.map(e=>(0,R.jsx)(NS,{resource:e},`${e.server}:${e.name}`)),t.data?.templates.map(e=>(0,R.jsx)(PS,{template:e},`${e.server}:${e.name}`))]})]}),o&&(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&s(null),children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/60`}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:kS,children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Remove MCP server`}),(0,R.jsxs)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:[`Remove`,` `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:o.name}),` `,`from the config? This affects the server-side configuration.`]})]}),(0,R.jsxs)($m,{className:`rounded-b-lg`,children:[(0,R.jsx)(U,{variant:`ghost`,onClick:()=>s(null),children:`Cancel`}),(0,R.jsx)(U,{variant:`destructive`,onClick:()=>{l(`remove:${o.name}`,()=>G.mcpDelete(o.name)),s(null)},children:`Remove`})]}),(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})})]})}function NS({resource:e}){return(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`truncate text-xs text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:e.server})]}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[(0,R.jsx)(Ae,{className:`size-3 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-weak)]`,children:e.uri})]}),e.description&&(0,R.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-[var(--text-weaker)]`,children:e.description})]})}function PS({template:e}){return(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`truncate text-xs text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:e.server})]}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[(0,R.jsx)(Ae,{className:`size-3 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-weak)]`,children:e.uriTemplate})]})]})}function FS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.pluginList().then(e=>e.data));return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Plugins`,note:`Read-only — installed plugins`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No plugins installed.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e?.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-1.5`,children:[(0,R.jsx)(We,{className:`size-3.5 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-[var(--text-strong)]`,children:e.id})]},e.id))})]})}function IS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.providerList().then(e=>e.data)),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)(null),[c,l]=(0,E.useState)(null);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Providers`,note:`Registered model providers`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No providers registered.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e?.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-raised-base-hover)]`,onClick:()=>{if(i===e.id){a(null),s(null);return}a(e.id),s(null),l(null),G.providerGet(e.id).then(e=>s(e.data)).catch(e=>l(e instanceof Error?e.message:String(e)))},children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(L,{className:`size-3.5 shrink-0 text-[var(--text-weaker)] transition-transform ${i===e.id?`rotate-90`:``}`}),(0,R.jsx)(`span`,{className:`truncate text-[13px] text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-[var(--text-weaker)]`,children:e.id})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.disabled&&(0,R.jsx)(`span`,{className:`rounded border border-[var(--border-weak-base)] px-1.5 py-0.5 text-[10px] text-[var(--text-weaker)]`,children:`disabled`}),(0,R.jsx)(`span`,{className:`max-w-48 truncate font-mono text-[10px] text-[var(--text-weak)]`,children:e.package})]})]}),i===e.id&&(0,R.jsxs)(`div`,{className:`mt-1 ml-4 space-y-1.5 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[c&&(0,R.jsx)(yS,{message:c}),!o&&!c&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(Me,{className:`size-3.5 animate-spin`}),` loading…`]}),o&&(0,R.jsxs)(R.Fragment,{children:[o.integrationID&&(0,R.jsxs)(`p`,{className:`text-[11px] text-[var(--text-weak)]`,children:[`integration:`,` `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:o.integrationID})]}),o.settings&&Object.keys(o.settings).length>0&&(0,R.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-[var(--text-base)]`,children:JSON.stringify(o.settings,null,2)}),o.headers&&Object.keys(o.headers).length>0&&(0,R.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-[var(--text-base)]`,children:JSON.stringify(o.headers,null,2)}),o.body&&Object.keys(o.body).length>0&&(0,R.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-[var(--text-base)]`,children:JSON.stringify(o.body,null,2)}),(!o.settings||Object.keys(o.settings).length===0)&&(!o.headers||Object.keys(o.headers).length===0)&&(!o.body||Object.keys(o.body).length===0)&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:`No settings.`})]})]})]},e.id))})]})}var LS=`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-3 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`;function RS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.serverInfo()),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)(null),[u,d]=(0,E.useState)(null);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Server`,note:`Backend service`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.urls.length===0&&(0,R.jsx)(_S,{children:`No server endpoints.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e?.urls.map(e=>(0,R.jsx)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-1.5`,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-[var(--text-strong)]`,children:e})},e))})]}),(0,R.jsxs)(`div`,{className:`space-y-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-[13px] font-medium text-[var(--text-strong)]`,children:`Stop service`}),(0,R.jsx)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`Request the managed opencode service to shut down. The web UI itself keeps running.`})]}),(0,R.jsxs)(U,{variant:`destructive`,onClick:()=>a(!0),disabled:o,children:[(0,R.jsx)(Ue,{}),o?`Stopping…`:`Stop`]})]}),c&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-base)]`,children:c}),u&&(0,R.jsx)(yS,{message:u})]}),i&&(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&a(!1),children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/60`}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:LS,children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Stop the service?`}),(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:`This stops the background opencode service. Running sessions will be interrupted.`})]}),(0,R.jsxs)($m,{className:`rounded-b-lg`,children:[(0,R.jsx)(U,{variant:`ghost`,onClick:()=>a(!1),disabled:o,children:`Cancel`}),(0,R.jsx)(U,{variant:`destructive`,disabled:o,onClick:()=>{s(!0),l(null),d(null),G.serviceStop().then(e=>{l(e.accepted?`Stop accepted — the service is shutting down.`:`Stop not accepted — this instance is not the service owner.`)}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>{s(!1),a(!1)})},children:`Stop service`})]}),(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})})]})}function zS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.websearchProviders().then(e=>e.data)),[i,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(null),[u,d]=(0,E.useState)(!1),[f,p]=(0,E.useState)(null),m=i||e?.[0]?.id||``;return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Websearch`,note:`Test search providers`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No websearch providers available.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e?.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`truncate text-xs text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-[var(--text-weaker)]`,children:e.id})]}),(0,R.jsx)(U,{size:`xs`,variant:i===e.id?`default`:`outline`,onClick:()=>a(i===e.id?``:e.id),children:i===e.id?`selected`:`select`})]},e.id))})]}),e&&e.length>0&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{className:`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--input-base)] px-2.5 py-1.5 text-sm text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)] focus:ring-1 focus:ring-[var(--border-selected)] h-8 flex-1`,placeholder:`Search query…`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()&&!u&&h()}}),(0,R.jsxs)(U,{variant:`default`,disabled:!o.trim()||u||!m,onClick:h,children:[(0,R.jsx)(qe,{}),u?`Searching…`:`Search`]})]}),!m&&(0,R.jsx)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`Select a provider to search.`}),f&&(0,R.jsx)(yS,{message:f}),c&&(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsxs)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:[c.results.length,` results · provider `,c.providerID]}),c.results.length===0&&(0,R.jsx)(_S,{children:`No results.`}),c.results.map((e,t)=>(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-2`,children:[(0,R.jsx)(`a`,{className:`block truncate text-xs text-[var(--text-interactive-base)] underline underline-offset-2`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.title??e.url}),(0,R.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-[var(--text-weak)]`,children:e.content}),(0,R.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-[var(--text-weaker)]`,children:e.url})]},`${e.url}:${t}`))]})]}),(0,R.jsx)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-2`,children:(0,R.jsxs)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:[`Searching with`,` `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:e?.find(e=>e.id===m)?.name??m})]})})]});function h(){!o.trim()||u||(d(!0),p(null),G.websearch(o.trim(),m).then(e=>l(e.data)).catch(e=>p(e instanceof Error?e.message:String(e))).finally(()=>d(!1)))}}var BS=null;function VS(e){BS?.(e)}var HS=`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 grid-rows-[auto_minmax(0,1fr)] gap-3 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-3xl h-[min(84vh,660px)] data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,US=[{id:`providers`,label:`Providers`,icon:ue},{id:`integrations`,label:`Integrations`,icon:Ve},{id:`mcp`,label:`MCP`,icon:ne},{id:`plugins`,label:`Plugins`,icon:We},{id:`extensions`,label:`Extensions`,icon:F},{id:`config`,label:`Config`,icon:ve},{id:`websearch`,label:`Websearch`,icon:ke},{id:`server`,label:`Server`,icon:Ye}];function WS(){let[e,t]=(0,E.useState)(!1),[n,r]=(0,E.useState)(`providers`);return(0,E.useEffect)(()=>(BS=e=>{e&&r(e),t(!0)},()=>{BS=null}),[]),(0,R.jsx)(Km,{open:e,onOpenChange:e=>{t(e),e||r(`providers`)},children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/60`}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:HS,children:[(0,R.jsxs)(Qm,{className:`pr-8`,children:[(0,R.jsx)(eh,{children:`Settings`}),(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:`Providers · integrations · MCP · plugins · extensions · config`})]}),(0,R.jsxs)(Xx,{value:n,onValueChange:r,className:`flex min-h-0 flex-col`,children:[(0,R.jsx)(Qx,{className:`mb-2 flex w-full flex-wrap justify-start gap-1 rounded-md bg-[var(--surface-base)] p-1`,children:US.map(e=>(0,R.jsxs)($x,{value:e.id,title:e.id===`integrations`?`Connect providers`:void 0,className:`h-7 gap-1.5 rounded px-2 text-xs`,children:[(0,R.jsx)(e.icon,{className:`size-3.5`}),e.label]},e.id))}),(0,R.jsxs)(qx,{className:`min-h-0 flex-1 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-3`,children:[(0,R.jsx)(eS,{value:`providers`,children:(0,R.jsx)(IS,{})}),(0,R.jsx)(eS,{value:`integrations`,children:(0,R.jsx)(DS,{})}),(0,R.jsx)(eS,{value:`mcp`,children:(0,R.jsx)(MS,{})}),(0,R.jsx)(eS,{value:`plugins`,children:(0,R.jsx)(FS,{})}),(0,R.jsx)(eS,{value:`extensions`,children:(0,R.jsx)(qS,{})}),(0,R.jsx)(eS,{value:`config`,children:(0,R.jsx)(xS,{})}),(0,R.jsx)(eS,{value:`websearch`,children:(0,R.jsx)(zS,{})}),(0,R.jsx)(eS,{value:`server`,children:(0,R.jsx)(RS,{})})]})]}),(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})})}function GS(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),e}function KS(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>sS(()=>t(e=>e+1)),[]),e}function qS(){KS();let e=GS(),[t,n]=(0,E.useState)(null);(0,E.useEffect)(()=>{let e=async()=>{if(!document.hidden)try{let e=await fetch(`/api/webui/extensions`);if(!e.ok)throw Error(String(e.status));let t=await e.json();n(t.data??[])}catch{n([])}};return e(),og({name:`extensions-runtime-list`,minInterval:1e4,run:()=>e()})},[]);let r=(0,E.useMemo)(()=>Et(),[e]);return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Extensions`,note:`plugin-shipped UI — toggle off to disable`}),t===null?null:t.length===0?(0,R.jsx)(_S,{children:`No plugin extensions installed.`}):(0,R.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate font-mono text-xs text-[var(--text-strong)]`,children:e.id}),(0,R.jsx)(`p`,{className:`truncate text-[11px] text-[var(--text-weaker)]`,children:e.source})]}),(0,R.jsx)(Yx,{size:`sm`,checked:!aS(e.id),onCheckedChange:t=>oS(e.id,t),"aria-label":`Toggle ${e.id}`,title:aS(e.id)?`Disabled`:`Enabled`})]},e.id))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Built-in extensions`}),st.length>0&&(0,R.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-1`,children:st.map(e=>(0,R.jsx)(`span`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2 py-1 font-mono text-xs text-[var(--text-strong)]`,children:e},e))}),(0,R.jsx)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`built-in — manage in ui-extensions/config.ts`})]}),r.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Extension settings`,note:`contributed by enabled extensions`}),(0,R.jsx)(`div`,{className:`space-y-2`,children:r.map(t=>(0,R.jsx)(JS,{id:t.id,children:(0,R.jsxs)(`section`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] p-2.5`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-medium text-[var(--text-strong)]`,children:t.title}),t.description&&(0,R.jsx)(`p`,{className:`mt-0.5 text-[11px] text-[var(--text-weaker)]`,children:t.description}),(0,R.jsx)(`div`,{className:`mt-2`,children:t.render()})]})},`${e}:${t.id}`))})]})]})}var JS=class extends E.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[extensions] settings section "${this.props.id}" crashed:`,e)}render(){return this.state.failed?(0,R.jsx)(`p`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-2 text-xs text-[var(--text-weaker)]`,children:`This extension's settings crashed.`}):this.props.children}};function YS(e){let t=e.variant&&e.variant!=="default"?e.variant:`default`;return`${e.providerID}/${e.id}@${t}`}function XS(e){let t=(0,E.useRef)(null);return(0,E.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}function ZS({open:e,onClose:t,count:n,onSelect:r,listId:i,query:a,onQueryChange:o}){let[s,c]=(0,E.useState)(0),l=(0,E.useRef)(0);l.current=s;let u=(0,E.useRef)({prefix:``,at:0});(0,E.useEffect)(()=>{e&&c(0)},[e,a]),(0,E.useEffect)(()=>{e&&document.getElementById(`${i}-item-${s}`)?.scrollIntoView({block:`nearest`})},[e,s,i]);function d(e){let t=e.currentTarget,n=Array.from(t.querySelectorAll(`[role="option"]`));for(let t of n){let r=t.getBoundingClientRect();if(e.clientY>=r.top&&e.clientY<r.bottom){c(n.indexOf(t));return}}}return(0,E.useEffect)(()=>{if(!e)return;let s=null,d=e=>{if(e.key===`Escape`||e.key===`Tab`){if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`&&o&&a){o(``);return}t();return}if(n===0)return;if(e.key===`ArrowDown`){e.preventDefault(),e.stopPropagation(),c(e=>(e+1)%n);return}if(e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation(),c(e=>e<=0?n-1:e-1);return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),c(0);return}if(e.key===`End`){e.preventDefault(),e.stopPropagation(),c(n-1);return}if(e.key===`Enter`){e.preventDefault(),e.stopPropagation(),r(l.current<n?l.current:0);return}if(o)return;let d=e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey?e.key.toLowerCase():null;if(!d)return;let f=Date.now(),p=u.current,m=f-p.at<1e3?p.prefix+d:d;p.prefix=m,p.at=f,s??=Array.from(document.querySelectorAll(`#${i} > button`)).map(e=>(e.textContent??``).trim().toLowerCase()),c(e=>{for(let t=1;t<=n;t++){let r=(e+t)%n;if((s?.[r]??``).startsWith(m))return r}return e})};return window.addEventListener(`keydown`,d,!0),()=>window.removeEventListener(`keydown`,d,!0)},[e,n,t,r,i,a,o]),[s,c,d]}async function QS(){try{let e=await G.agents();return e.find(e=>e.mode===`primary`&&!e.hidden)??e[0]}catch{return}}function $S(e){let t=J(t=>t.sessions.find(t=>t.id===e)),n=J(t=>t.sessionDetails[e]);return(0,E.useEffect)(()=>{M_(e)},[e]),{session:t,detail:n}}var eC=`flex w-full cursor-pointer items-center justify-between px-3 py-2 text-left transition-colors hover:bg-[color:var(--surface-base-hover)] data-[hl=true]:bg-[color:var(--surface-raised-base-active)]`;function tC({sessionID:e,openUp:t=!1,align:n=`right`}){let{session:r,detail:i}=$S(e),a=J(e=>e.pendingModel),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)([]),[u,d]=(0,E.useState)(null),f=XS(()=>s(!1)),p=J(e=>e.uiSignals.models);(0,E.useEffect)(()=>{p&&s(!0)},[p]);let m=(0,E.useMemo)(()=>c.filter(e=>e.enabled),[c]),h=`menu-models`;function g(e,t){if(t.includes(e)){let n=t.indexOf(e),r=1e3-n*2;return(n===0||t[n-1]===` `||t[n-1]===`/`||t[n-1]===`-`)&&(r+=20),r}let n=0,r=-2,i=0,a=0,o=0,s=0,c=0;for(let l=0;l<t.length&&n<e.length;l++)t[l]===e[n]&&((l===0||t[l-1]===` `||t[l-1]===`/`||t[l-1]===`-`)&&c++,r+1===l?(a++,s++,o=Math.max(o,s)):(i+=l-r-1,s=1),r=l,n++);return n===e.length?500-r*.5-i*2+a*10+c*2+o*3:null}let[_,v]=(0,E.useState)(``),y=_.trim().toLowerCase(),b=(0,E.useMemo)(()=>{if(!y)return m;let e=[];for(let t=0;t<m.length;t++){let n=m[t],r=`${n.name} ${n.modelID} ${n.providerID} ${n.id}`.toLowerCase(),i=g(y,r);i!==null&&e.push({m:n,s:i,i:t})}return e.sort((e,t)=>t.s-e.s||e.i-t.i),e.map(e=>e.m)},[m,y]),x=(0,E.useRef)(null);(0,E.useEffect)(()=>{o&&(v(``),x.current?.focus())},[o]);let S=a??i?.model??r?.model??u??void 0;(0,E.useEffect)(()=>{o&&c.length===0&&G.models().then(l)},[o,c.length]),(0,E.useEffect)(()=>{!r?.model&&u===null&&P_().then(e=>{e&&d(e)})},[r?.model,u]);let C=t=>{let n=b[t];n&&(Qy(e,{id:n.modelID,providerID:n.providerID}).then(Yg),s(!1))},[w,,T]=ZS({open:o,onClose:()=>s(!1),count:b.length,onSelect:C,listId:h,query:_,onQueryChange:v}),D=`${t?`bottom-full mb-1`:`mt-1`} ${n===`right`?`right-0`:`left-0`}`;return(0,R.jsxs)(`div`,{ref:f,className:`relative`,children:[(0,R.jsx)(lS,{variant:`outline`,onClick:()=>s(!o),"aria-expanded":o,"aria-haspopup":`listbox`,title:`Switch model`,className:`h-7 max-w-48 gap-1 px-2 font-mono text-[11px]`,children:(0,R.jsx)(`span`,{className:`truncate`,children:S?YS(S):`model`})}),o&&(0,R.jsxs)(`div`,{className:`absolute z-40 w-72 overflow-hidden rounded-lg border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] shadow-xl ${D}`,children:[(0,R.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-[color:var(--border-weak-base)] px-2.5`,children:[(0,R.jsx)(qe,{className:`size-3.5 shrink-0 text-[color:var(--text-weaker)]`}),(0,R.jsx)(`input`,{ref:x,value:_,onChange:e=>v(e.target.value),placeholder:`Filter models…`,"aria-label":`Filter models`,autoComplete:`off`,spellCheck:!1,className:`h-full w-full bg-transparent font-mono text-[11px] text-[color:var(--text-strong)] outline-none placeholder:text-[color:var(--text-weaker)]`})]}),(0,R.jsx)(`div`,{id:h,role:`listbox`,"aria-label":`Switch model`,"aria-activedescendant":b.length>0?`${h}-item-${w}`:void 0,className:`max-h-72 overflow-y-auto`,onMouseMove:T,children:b.length===0?(0,R.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-[color:var(--text-weaker)]`,children:`No matching models`}):b.map((e,t)=>(0,R.jsxs)(`button`,{id:`${h}-item-${t}`,type:`button`,role:`option`,"aria-selected":S?.id===e.modelID&&S?.providerID===e.providerID,"data-hl":t===w||void 0,className:eC,onClick:()=>C(t),children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`font-mono text-[color:var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`ml-2 font-mono text-[color:var(--text-weaker)]`,children:e.providerID})]}),S?.id===e.modelID&&S?.providerID===e.providerID&&(0,R.jsx)(`span`,{className:`text-emerald-500`,children:`✓`})]},`${e.providerID}/${e.modelID}`))})]})]})}function nC({sessionID:e,openUp:t=!1,align:n=`right`}){let{session:r,detail:i}=$S(e),a=J(e=>e.pendingModel),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)([]),u=XS(()=>s(!1)),d=J(e=>e.uiSignals.variants);(0,E.useEffect)(()=>{d&&s(!0)},[d]),(0,E.useEffect)(()=>{o&&c.length===0&&G.models().then(l)},[o,c.length]);let f=a??i?.model??r?.model,p=c.find(e=>e.enabled&&e.modelID===f?.id&&e.providerID===f?.providerID)?.variants??[],m=f?.variant&&f.variant!=="default"?f.variant:void 0;function h(t){Qy(e,{id:f.id,providerID:f.providerID,...t?{variant:t}:{}}),s(!1)}let g=`menu-variants`,[_,,v]=ZS({open:o,onClose:()=>s(!1),count:p.length+1,onSelect:e=>{e===0?h():h(p[e-1]?.id)},listId:g});if(!f||p.length===0)return null;let y=`${t?`bottom-full mb-1`:`mt-1`} ${n===`right`?`right-0`:`left-0`}`;return(0,R.jsxs)(`div`,{ref:u,className:`relative`,children:[(0,R.jsx)(lS,{variant:`outline`,onClick:()=>s(!o),"aria-expanded":o,"aria-haspopup":`listbox`,title:`Switch model variant`,className:`h-7 max-w-20 px-2 font-mono text-[11px]`,children:(0,R.jsx)(`span`,{className:`truncate`,children:m?`@${m}`:`@default`})}),o&&(0,R.jsxs)(`div`,{id:g,role:`listbox`,"aria-label":`Switch model variant`,"aria-activedescendant":`${g}-item-${_}`,className:`absolute z-40 max-h-80 w-48 overflow-y-auto rounded-lg border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] shadow-xl ${y}`,onMouseMove:v,children:[(0,R.jsxs)(`button`,{id:`${g}-item-0`,type:`button`,role:`option`,"aria-selected":!m,"data-hl":_===0||void 0,className:eC,onClick:()=>h(),children:[(0,R.jsx)(`span`,{className:`text-[color:var(--text-strong)]`,children:`Default`}),!m&&(0,R.jsx)(`span`,{className:`text-emerald-500`,children:`✓`})]}),p.map((e,t)=>(0,R.jsxs)(`button`,{id:`${g}-item-${t+1}`,type:`button`,role:`option`,"aria-selected":m===e.id,"data-hl":_===t+1||void 0,className:`${eC} font-mono text-xs`,onClick:()=>h(e.id),children:[(0,R.jsx)(`span`,{className:`text-[color:var(--text-strong)]`,children:e.id}),m===e.id&&(0,R.jsx)(`span`,{className:`text-emerald-500`,children:`✓`})]},e.id))]})]})}function rC({sessionID:e,openUp:t=!1,align:n=`right`}){let{session:r,detail:i}=$S(e),a=J(e=>e.pendingAgent),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)([]),[u,d]=(0,E.useState)(null),f=XS(()=>s(!1)),p=J(e=>e.uiSignals.agents);(0,E.useEffect)(()=>{p&&s(!0)},[p]);let m=(0,E.useMemo)(()=>c.filter(e=>e.mode===`primary`&&!e.hidden),[c]),h=`menu-agents`,g=a??i?.agent??r?.agent??u??void 0;(0,E.useEffect)(()=>{o&&c.length===0&&G.agents().then(l)},[o,c.length]),(0,E.useEffect)(()=>{!r?.agent&&u===null&&QS().then(e=>{e&&d(e.id)})},[r?.agent,u]);let _=t=>{let n=m[t];n&&(Zy(e,n.id).then(Yg),s(!1))},[v,,y]=ZS({open:o,onClose:()=>s(!1),count:m.length,onSelect:_,listId:h}),b=`${t?`bottom-full mb-1`:`mt-1`} ${n===`right`?`right-0`:`left-0`}`;return(0,R.jsxs)(`div`,{ref:f,className:`relative`,children:[(0,R.jsx)(lS,{variant:`outline`,onClick:()=>s(!o),"aria-expanded":o,"aria-haspopup":`listbox`,title:`Switch agent (Tab)`,className:`h-7 max-w-28 px-2 text-[11px]`,children:(0,R.jsx)(`span`,{className:`truncate`,children:g??`agent`})}),o&&(0,R.jsx)(`div`,{id:h,role:`listbox`,"aria-label":`Switch agent`,"aria-activedescendant":`${h}-item-${v}`,className:`absolute z-40 max-h-80 w-60 overflow-y-auto rounded-lg border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] shadow-xl ${b}`,onMouseMove:y,children:m.map((e,t)=>(0,R.jsxs)(`button`,{id:`${h}-item-${t}`,type:`button`,role:`option`,"aria-selected":g===e.id,"data-hl":t===v||void 0,className:eC,onClick:()=>_(t),children:[(0,R.jsx)(`span`,{className:`text-[color:var(--text-strong)]`,children:e.name}),g===e.id&&(0,R.jsx)(`span`,{className:`text-emerald-500`,children:`✓`})]},e.id))})]})}function iC({...e}){return(0,R.jsx)(ap,{"data-slot":`popover`,...e})}function aC({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,R.jsx)(sp,{children:(0,R.jsx)(cp,{"data-slot":`popover-content`,align:t,sideOffset:n,className:V(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function oC({...e}){return(0,R.jsx)(op,{"data-slot":`popover-anchor`,...e})}function sC({open:e,query:t,location:n,onOpenChange:r,onPick:i,children:a}){let[o,s]=(0,E.useState)([]),[c,l]=(0,E.useState)(n);return(0,E.useEffect)(()=>{e&&!n&&!c&&G.location().then(e=>l(e.directory)).catch(()=>void 0)},[e,n,c]),(0,E.useEffect)(()=>{if(!e){s([]);return}let n=!1,r=setTimeout(()=>{G.fsFind(t,{location:c,limit:20}).then(e=>{n||s(e.data)}).catch(()=>{n||s([])})},120);return()=>{n=!0,clearTimeout(r)}},[e,t,c]),(0,R.jsxs)(iC,{open:e,onOpenChange:r,children:[(0,R.jsx)(oC,{asChild:!0,children:a}),(0,R.jsx)(aC,{side:`top`,align:`start`,sideOffset:8,className:`w-[min(26rem,calc(100vw-2rem))] p-0`,children:(0,R.jsx)(ph,{children:(0,R.jsxs)(gh,{children:[o.length>0&&(0,R.jsx)(vh,{heading:`Files`,children:o.map(e=>(0,R.jsxs)(bh,{value:e.path,onSelect:()=>i(e),children:[e.type===`directory`?(0,R.jsx)(Ee,{className:`text-[color:var(--text-weak)]`}):(0,R.jsx)(Ce,{className:`text-[color:var(--text-weak)]`}),(0,R.jsx)(`span`,{className:`font-mono text-[color:var(--text-strong)]`,children:e.path})]},e.path))}),o.length===0&&(0,R.jsx)(_h,{children:`No matching files`})]})})})]})}function cC({...e}){return(0,R.jsx)(Df,{"data-slot":`dropdown-menu`,...e})}function lC({...e}){return(0,R.jsx)(Of,{"data-slot":`dropdown-menu-trigger`,...e})}function uC({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,R.jsx)(kf,{children:(0,R.jsx)(Af,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:V(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function dC({className:e,inset:t,variant:n=`default`,...r}){return(0,R.jsx)(Mf,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:V(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function fC({className:e,inset:t,...n}){return(0,R.jsx)(jf,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:V(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function pC({className:e,...t}){return(0,R.jsx)(Nf,{"data-slot":`dropdown-menu-separator`,className:V(`-mx-1 my-1 h-px bg-border`,e),...t})}function mC({sessionID:e}){let t=J(t=>t.sessions.find(t=>t.id===e)),[n,r]=(0,E.useState)(!1),[i,a]=(0,E.useState)(null);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(cC,{open:n,onOpenChange:r,children:[(0,R.jsx)(lC,{asChild:!0,children:(0,R.jsx)(U,{variant:`ghost`,size:`icon`,title:`Session actions`,children:(0,R.jsx)(fe,{})})}),(0,R.jsxs)(uC,{align:`end`,className:`w-48`,children:[(0,R.jsxs)(dC,{onSelect:()=>a(`rename`),children:[(0,R.jsx)(Re,{}),` Rename…`]}),(0,R.jsxs)(dC,{onSelect:()=>a(`fork`),children:[(0,R.jsx)(Oe,{}),` Fork…`]}),(0,R.jsxs)(dC,{onSelect:()=>void vC(e),children:[(0,R.jsx)(de,{}),` Export`]}),(0,R.jsx)(pC,{}),(0,R.jsxs)(dC,{onSelect:()=>a(`compact`),children:[(0,R.jsx)(j,{}),` Compact`]})]})]}),i===`rename`&&(0,R.jsx)(hC,{sessionID:e,initialTitle:t?.title??``,onClose:()=>a(null)}),i===`fork`&&(0,R.jsx)(gC,{sessionID:e,onClose:()=>a(null)}),i===`compact`&&(0,R.jsx)(_C,{sessionID:e,onClose:()=>a(null)})]})}function hC({sessionID:e,initialTitle:t,onClose:n}){let[r,i]=(0,E.useState)(t),[a,o]=(0,E.useState)(!1),s=async()=>{let t=r.trim();if(!(!t||a)){o(!0);try{await $y(e,t),n()}finally{o(!1)}}};return(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&!a&&n(),children:(0,R.jsxs)(Zm,{children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Rename session`}),(0,R.jsx)(th,{children:`Give this session a new title.`})]}),(0,R.jsx)(nh,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s()},placeholder:`Untitled session`,autoFocus:!0}),(0,R.jsxs)($m,{children:[(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsx)(U,{variant:`outline`,disabled:a,children:`Cancel`})}),(0,R.jsx)(U,{onClick:()=>void s(),disabled:a||!r.trim(),children:`Rename`})]})]})})}function gC({sessionID:e,onClose:t}){let[n,r]=(0,E.useState)(``),[i,a]=(0,E.useState)(!1),o=async()=>{if(!i){a(!0);try{await Pv(await eb(e,n.trim()?{type:`before`,messageID:n.trim()}:{type:`through`})),t()}finally{a(!1)}}};return(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&!i&&t(),children:(0,R.jsxs)(Zm,{children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Fork session`}),(0,R.jsx)(th,{children:`Copies the conversation into a new session. Leave the boundary empty to fork the full session.`})]}),(0,R.jsx)(rh,{value:n,onChange:e=>r(e.target.value),placeholder:`Boundary message ID (msg_…) — empty forks the full session`,rows:3,autoFocus:!0}),(0,R.jsxs)($m,{children:[(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsx)(U,{variant:`outline`,disabled:i,children:`Cancel`})}),(0,R.jsx)(U,{onClick:()=>void o(),disabled:i,children:`Fork`})]})]})})}function _C({sessionID:e,onClose:t}){let[n,r]=(0,E.useState)(!1),i=async()=>{if(!n){r(!0);try{await nb(e,`steer`),t()}finally{r(!1)}}};return(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&!n&&t(),children:(0,R.jsxs)(Zm,{children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Compact session`}),(0,R.jsx)(th,{children:`Summarizes the conversation so far into a single compact message so the agent can keep going with full context.`})]}),(0,R.jsxs)($m,{children:[(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsx)(U,{variant:`outline`,disabled:n,children:`Cancel`})}),(0,R.jsx)(U,{onClick:()=>void i(),disabled:n,children:`Compact`})]})]})})}async function vC(e){try{let t=await tb(e),n=new Blob([yC(t)],{type:`text/markdown`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.slice(0,8)}.md`,i.click(),URL.revokeObjectURL(r)}catch(e){console.warn(`session export failed:`,e)}}function yC(e){let{info:t,messages:n}=e,r=[`# ${t.title||`Untitled session`}`,``];r.push(`Session \`${t.id}\` · exported ${new Date(t.time.created).toISOString()}`,``);for(let e of n)if(e.type===`assistant`){r.push(`## assistant`,``);for(let t of e.content)t.type===`text`&&t.text?r.push(t.text,``):t.type===`reasoning`&&t.text?r.push("```reasoning",t.text,"```",``):t.type===`tool`&&r.push(`> tool: \`${t.name}\` (\`${t.id}\`)`,``)}else`text`in e&&typeof e.text==`string`&&e.text?r.push(`## ${e.type}`,``,e.text,``):e.type===`shell`&&r.push(`## shell`,``,`> \`${e.command}\``,``);return r.join(`
52
- `)}var bC=null;function xC(){return bC??=G.models().catch(()=>[]),bC}var SC=null;function CC(){return SC??=G.agents().catch(()=>[]),SC}var wC=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e);async function TC(e){try{let t=await tb(e);await navigator.clipboard.writeText(yC(t))}catch{}}var EC=10;function DC(e,t){let n=0;for(let r of t)if(r===e[n]&&(n+=1),n===e.length)return!0;return n===e.length}function OC(e,t){let n=t.trim().toLowerCase();if(!n)return e.slice(0,EC);let r=[];for(let t of e){let e=0,i=`/${t.names[0]}`;if(i.startsWith(`/${n}`))e=1e3;else if(i.includes(n))e=600;else if(DC(n,i))e=200;else for(let r of t.names.slice(1)){let t=`/${r}`;t.startsWith(`/${n}`)?e=Math.max(e,800):t.includes(n)&&(e=Math.max(e,400))}e<100&&t.description?.toLowerCase().includes(n)&&(e=100),e>0&&r.push({entry:t,score:e})}return r.sort((e,t)=>t.score-e.score||e.entry.display.localeCompare(t.entry.display)),r.slice(0,EC).map(e=>e.entry)}function kC(){let[e,t]=(0,E.useState)(Dh);return(0,E.useEffect)(()=>kh(()=>t(Dh())),[]),e}function AC(e){let[t,n]=(0,E.useState)({shells:[],ptys:[]});return(0,E.useEffect)(()=>{async function t(){try{let t=e?{directory:e}:void 0,[r,i]=await Promise.all([G.shellList(t),G.ptyList(t)]);n({shells:r.data,ptys:i.data})}catch{}}return t(),og({name:`composer-runs`,minInterval:5e3,intervals:{live:5e3,idle:15e3},run:()=>t()})},[e]),t}function jC(e,t){let n=(0,E.useRef)(null);return(0,E.useEffect)(()=>{if(!e)return;function r(e){n.current&&!n.current.contains(e.target)&&t()}return document.addEventListener(`mousedown`,r),()=>document.removeEventListener(`mousedown`,r)},[e,t]),n}function MC(e){let t=e.value.length;e.setSelectionRange(t,t)}function NC({sessionID:e,paneKey:t=`main`,onNavigate:n}){let r=e=>n?n(e):void Pv(e),[i,a]=(0,E.useState)(()=>Wx(e)),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)([]),[u,d]=(0,E.useState)([]),f=kC(),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)([]),[_,v]=(0,E.useState)([]),[y,b]=(0,E.useState)(0),[x,S]=(0,E.useState)(!1),[C,w]=(0,E.useState)(!1),[T,D]=(0,E.useState)([]),[O,k]=(0,E.useState)([]),A=J(t=>t.running[e]??!1),j=J(t=>!!t.queued[e]),M=J(e=>e.interruptArmed),N=J(t=>t.messages[e]),ee=J(t=>t.sessionDetails[e]),te=J(t=>t.sessions.find(t=>t.id===e)?.parentID??t.sessionDetails[e]?.parentID),[P,F]=(0,E.useState)(0);(0,E.useEffect)(()=>pt(()=>F(e=>e+1)),[]);let ne=(0,E.useMemo)(()=>Ct(),[P]),re=J(t=>t.sessions.find(t=>t.id===e)?.location?.directory),ie=(0,E.useRef)(null),[ae,I]=(0,E.useState)(0);function L(e){I(e.selectionStart??e.value.length)}let oe=(0,E.useMemo)(()=>(N??[]).filter(e=>e.type===`user`&&!e.id.startsWith(`msg_local_`)).map(e=>e.text).filter(e=>e&&!e.startsWith(`/`)).reverse(),[N]),[se,ce]=(0,E.useState)(null),le=(0,E.useRef)(``),ue=(0,E.useRef)(e);(0,E.useEffect)(()=>{ce(null),ue.current!==e&&(ue.current=e,a(Wx(e)))},[e]),(0,E.useEffect)(()=>{ue.current===e&&Gx(e,i)},[e,i]);let de=J(t=>Ov(t.sessions,e)),fe=J(e=>e.running),pe=J(e=>e.activeIDs),me=AC(re),he=e=>fe[e]||pe.includes(e),ge=de.filter(e=>he(e.id)).length,_e=me.shells.filter(e=>e.status===`running`).length+me.ptys.filter(e=>e.status===`running`).length,ve=me.shells.length+me.ptys.length,ye=[de.length>0?ge>0?`${ge}/${de.length} agents`:`${de.length} agents`:null,ve>0?_e>0?`${_e}/${ve} shells`:`${ve} shells`:null].filter(Boolean).join(` · `)||`runs`,be=ge>0||_e>0,xe=J(e=>e.runsPanelOpen),[Se,Ce]=(0,E.useState)(!1),we=jC(Se,()=>Ce(!1)),[Te,Ee]=(0,E.useState)(!1),De=J(e=>e.pendingEdit),Oe=De?.sessionID===e;(0,E.useEffect)(()=>{G.commands().then(l),G.skills().then(d),xC().then(D),CC().then(k)},[]);function ke(){let e=ie.current;e&&(e.focus(),MC(e),I(e.value.length))}(0,E.useEffect)(()=>{let e=ie.current;e&&(e.focus(),MC(e),I(e.value.length))},[e]);let Ae=J(e=>e.revertPrompt);(0,E.useEffect)(()=>{Ae&&(a(Ae),Dv(),I(0),requestAnimationFrame(()=>ie.current?.setSelectionRange(0,0)))},[Ae]);let Me=Math.min(ae,i.length),Ne=i.slice(0,Me),Pe=!C&&Ne.startsWith(`/`)&&!/^\S+\s+\S/.test(Ne)&&p!==Ne,Fe=Ne.slice(1),Ie=(0,E.useMemo)(()=>[{name:`new`,aliases:[`clear`],description:`New session`,run:()=>void Xy()},{name:`sessions`,aliases:[`resume`,`continue`],description:`Switch session`,run:()=>r(null)},{name:`move`,description:`Move session to another workspace`,run:t=>{let n=t.trim();if(Eg(e)){window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Create a session first`,variant:`destructive`}}));return}if(n){G.moveSession(e,n).then(()=>{window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Moved to ${n}`}})),M_(e),Yg()}).catch(e=>{let t=e instanceof Error?e.message:String(e);window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Move failed: ${t}`,variant:`destructive`}}))});return}Ee(!0)}},{name:`undo`,description:`Undo previous message`,run:()=>void rb(e)},{name:`redo`,description:`Redo`,run:()=>void ib(e)},{name:`thinking`,aliases:[`toggle-thinking`],description:f.showReasoning?`Collapse all thinking`:`Expand all thinking`,run:()=>Oh(`showReasoning`,!Dh().showReasoning)},{name:`timestamps`,aliases:[`toggle-timestamps`],description:f.showTimestamps?`Hide timestamps`:`Show timestamps`,run:()=>Oh(`showTimestamps`,!Dh().showTimestamps)},{name:`rename`,description:`Rename session`,run:t=>{let n=t.trim();n&&$y(e,n)}},{name:`fork`,description:`Fork session`,run:()=>void eb(e,{type:`through`}).then(e=>r(e))},{name:`export`,description:`Export session transcript`,run:()=>void vC(e)},{name:`copy`,description:`Copy session transcript`,run:()=>void TC(e)},{name:`compact`,aliases:[`summarize`],description:`Compact session`,run:()=>void nb(e,`steer`)},{name:`connect`,description:`Connect providers & integrations`,run:()=>VS(`integrations`)},{name:`models`,aliases:[`mo`],description:`Switch model`,run:()=>Sv(`models`)},{name:`variants`,description:`Switch model variant`,run:()=>Sv(`variants`)},{name:`agents`,description:`Switch agent`,run:()=>Sv(`agents`)},{name:`themes`,description:`Switch theme`,run:()=>Sv(`themes`)},{name:`skills`,description:`Browse skills`,run:()=>Ce(!0)},{name:`mcps`,description:`Toggle MCPs`,run:()=>VS(`mcp`)},{name:`status`,description:`View status`,run:()=>VS(`server`)},{name:`diff`,description:`Open diff viewer`,run:()=>Sv(`explorer`)},{name:`help`,description:`Help`,run:()=>Sv(`help`)}],[e,f.showReasoning,f.showTimestamps]),Le=(0,E.useMemo)(()=>new Set(c.map(e=>e.name)),[c]);function ze(e){Le.has(e.name)?(a(`/${e.name} `),m(`/${e.name} `),ke()):(a(``),jy(e.id))}let Be=ee?.model,Ve=(0,E.useMemo)(()=>Be?(T.find(e=>e.enabled&&e.modelID===Be.id&&e.providerID===Be.providerID)?.variants?.length??0)>0:!1,[T,Be]),He=(0,E.useMemo)(()=>{let t=[];for(let e of Ie)e.name===`variants`&&!Ve||t.push({key:`action:${e.name}`,display:`/${e.name}`,names:[e.name,...e.aliases??[]],description:e.description,onSelect:()=>{a(``),e.run(``)}});for(let n of ne)t.push({key:`slash:${n.id}`,display:`/${n.name}`,names:[n.name,...n.aliases??[]],description:n.description,onSelect:()=>{a(``),n.run(``,{sessionID:e})}});for(let e of c)t.push({key:`command:${e.name}`,display:`/${e.name}`,names:[e.name],description:e.description,onSelect:()=>{a(`/${e.name} `),m(`/${e.name} `),ke()}});for(let e of u)t.push({key:`skill:${e.id}`,display:`/${e.name}`,names:[e.name],description:e.description,onSelect:()=>ze(e)});return t.sort((e,t)=>e.display.localeCompare(t.display))},[Ie,ne,c,u,Le,Ve,e]),Ue=(0,E.useMemo)(()=>OC(He,Fe),[He,Fe]),We=(0,E.useMemo)(()=>{let e=i.lastIndexOf(`@`);if(e===-1)return;let t=e===0?``:i[e-1],n=i.slice(e+1);if((e===0||/\s/.test(t))&&!/\s/.test(n))return n},[i]);(0,E.useEffect)(()=>{S(!1)},[i]);let Ge=(0,E.useMemo)(()=>{let e=N??[];for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`assistant`)return n}},[N]),Ke=Ge?.type===`assistant`?Ge.tokens:void 0,qe=Ke?Ke.input+Ke.output+Ke.reasoning+Ke.cache.read+Ke.cache.write:void 0,Ye=(Ge?.type===`assistant`?Ge.cost:void 0)??ee?.cost??0,Xe=T.find(e=>e.enabled&&e.modelID===Be?.id&&e.providerID===Be?.providerID)?.limit?.context,Ze=qe&&Xe?Math.round(qe/Xe*100):void 0,Qe=[qe===void 0?void 0:`${wC(qe)} tok`,Ze===void 0?void 0:`${Ze}% ctx`,Ye>0?`$${Ye.toFixed(4)}`:void 0].filter(Boolean),$e=ee?.agent;function et(t){let n=O.filter(e=>e.mode===`primary`&&!e.hidden);if(n.length===0)return;let r=n.findIndex(e=>e.id===$e),i=n[(((r===-1?0:r)+t)%n.length+n.length)%n.length];Zy(e,i.id).then(()=>void M_(e))}function nt(e,t){let n=Fx(e)??`application/octet-stream`;v(r=>[...r,{id:`att_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,name:e.split(`/`).pop()||e,mime:n,uri:`data:${n};base64,${Rx(t)}`}])}function rt(e){let t=i.lastIndexOf(`@`);if(t===-1)return;if(e.type===`file`&&Ax(e.path)){a(i.slice(0,t)+i.slice(t+1+(We?.length??0))),ke(),G.fsReadBytes(e.path,re).then(t=>nt(e.path,t)).catch(()=>void 0);return}let n=`@${e.path}`;a(i.slice(0,t)+n+` `),g(t=>[...t,{path:e.path}]),re&&G.fsRead(e.path,re).then(t=>g(n=>n.map(n=>n.path===e.path?{path:n.path,content:t}:n))).catch(()=>void 0),ke()}async function it(){if(Eg(e))try{return await Yy(i)}catch{return null}return e||null}async function ot(t){let n=i.trim();if(!(!n&&_.length===0||o)){s(!0),ce(null);try{if(!C&&n.startsWith(`/`)){let t=n.slice(1).split(` `),r=t[0],i=Ie.find(e=>e.name===r||e.aliases?.includes(r));if(i){i.run(t.slice(1).join(` `)),a(``),g([]),v([]);return}let o=ne.find(e=>e.name===r||e.aliases?.includes(r));if(o){await o.run(t.slice(1).join(` `),{sessionID:e}),a(``),g([]),v([]);return}}let r=await it();if(!r)return;let i=Ng().pendingEdit;if(i&&i.sessionID===r){let{commitPendingEdit:e}=await ug(async()=>{let{commitPendingEdit:e}=await Promise.resolve().then(()=>dg);return{commitPendingEdit:e}},void 0);await e(r)}if(C)await gy(n.startsWith(`!`)?n.slice(1):n);else if(n.startsWith(`!`))await gy(n.slice(1));else if(n.startsWith(`/`)){let e=n.slice(1).split(` `),t=e[0];await hy(t,e.slice(1).join(` `)||void 0)}else if(h.length>0||_.length>0){let e=Ng().draftWorkspace,i=re??e??void 0,a=[];for(let e of h){if(!i)continue;let t=`@${e.path}`,r=n.indexOf(t);a.push({uri:`file://${encodeURI(`${i.replace(/\/+$/,``)}/${e.path}`)}`,name:e.path,mention:r===-1?void 0:{start:r,end:r+t.length,text:t}})}for(let e of _)a.push(Px(e));a.length>0?await _y(n,a):await ey(r,n,t)}else await ey(r,n,t);a(``),g([]),v([])}catch{a(n)}finally{s(!1),ke()}}}let st=C?`bash — esc to exit`:A?`Agent is working… — ↵ steers · ctrl+↵ queues`:j?`Waiting for the agent… — ↵ steers · ctrl+↵ queues`:`Message the agent…`,ct=C?(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--surface-brand-base)]`,children:`Shell`}),` · esc to exit`]}):A&&M?(0,R.jsx)(`p`,{className:`font-medium text-[color:var(--surface-warning-strong)]`,children:`Press esc again to interrupt`}):A||j?(0,R.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(uS,{className:`size-3`}),A?`Working… · esc to interrupt`:`Waiting…`,i.trim()?` · ↵ steer · ctrl+↵ queue`:``]}):(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--text-weak)]`,children:`Tab`}),` agent,`,` `,(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--text-weak)]`,children:`/`}),` commands,`,` `,(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--text-weak)]`,children:`@`}),` files,`,` `,(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--text-weak)]`,children:`!`}),` bash`]}),lt=re?.split(`/`).filter(Boolean).pop();return(0,R.jsxs)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2.5 pt-2`,children:[(0,R.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,R.jsx)(`div`,{className:`relative`,children:Se&&(0,R.jsxs)(`div`,{ref:we,className:`absolute bottom-full left-0 z-40 mb-2 max-h-80 w-[min(26rem,calc(100vw-2rem))] overflow-y-auto rounded-lg border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] p-1 shadow-xl`,children:[u.length===0&&(0,R.jsx)(`p`,{className:`px-2.5 py-1.5 text-xs text-[color:var(--text-weaker)]`,children:`No skills available`}),u.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{Ce(!1),ze(e)},className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-[color:var(--surface-base-hover)]`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-[color:var(--text-strong)]`,children:[`/`,e.name]}),e.description&&(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-[color:var(--text-weaker)]`,children:e.description})]},e.id))]})}),(0,R.jsxs)(iC,{open:Pe,children:[(0,R.jsx)(oC,{asChild:!0,children:(0,R.jsxs)(`div`,{onDragEnter:e=>{Array.from(e.dataTransfer.types).includes(`Files`)&&b(e=>e+1)},onDragOver:e=>{Array.from(e.dataTransfer.types).includes(`Files`)&&e.preventDefault()},onDragLeave:()=>b(e=>Math.max(0,e-1)),onDrop:e=>{b(0),e.dataTransfer.files.length!==0&&(e.preventDefault(),Nx(e.dataTransfer.files).then(e=>{e.length>0&&v(t=>[...t,...e])}))},className:`rounded-lg border bg-[color:var(--input-base)] p-2 transition-colors focus-within:border-[color:var(--border-selected)] ${y>0||C?`border-[color:var(--surface-brand-base)]`:`border-[color:var(--border-base)]`}`,children:[(0,R.jsx)(Nt,{region:`composer.above`,sessionID:e}),Oe&&De&&(0,R.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1.5 text-xs`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 font-medium text-amber-700 dark:text-amber-300`,children:[(0,R.jsx)(Re,{className:`size-3`}),` Editing`]}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[var(--text-weaker)]`,title:De.originalText,children:De.originalText.slice(0,80).replace(/\s+/g,` `)||`(empty)`}),(0,R.jsx)(`span`,{className:`hidden text-[10px] text-[var(--text-weaker)] sm:inline`,children:`will revert on send`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ug(()=>Promise.resolve().then(()=>dg).then(e=>e.clearPendingEdit()),void 0)},title:`Dismiss edit — next send is a normal message`,className:`ml-auto flex size-6 cursor-pointer items-center justify-center rounded-md hover:bg-black/10 dark:hover:bg-white/10`,children:(0,R.jsx)(at,{className:`size-3`})})]}),_.length>0&&(0,R.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-start gap-2 border-b border-[color:var(--border-weak-base)] pb-1.5`,children:[_.map(e=>(0,R.jsxs)(`span`,{className:`relative inline-block`,title:`${e.name} (${e.mime})`,children:[(0,R.jsx)(`img`,{src:e.uri,alt:e.name,draggable:!1,className:`size-12 rounded-md border border-[color:var(--border-weak-base)] object-cover`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>v(t=>t.filter(t=>t.id!==e.id)),title:`Remove attachment`,className:`absolute -right-1.5 -top-1.5 flex size-4 cursor-pointer items-center justify-center rounded-full border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] text-[color:var(--text-weak)] transition-colors hover:text-[color:var(--text-strong)]`,children:(0,R.jsx)(at,{className:`size-2.5`})})]},e.id)),(0,R.jsxs)(`span`,{className:`self-center text-[11px] text-[color:var(--text-weaker)]`,children:[`image`,_.length===1?``:`s`,` attached`]})]}),(0,R.jsx)(sC,{open:We!==void 0&&!x&&!Pe,query:We??``,location:re,onOpenChange:S,onPick:rt,children:(0,R.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,R.jsx)(rh,{id:`composer-input-${t}`,ref:ie,value:i,placeholder:st,className:`max-h-40 min-h-0 flex-1 resize-none border-0 bg-transparent px-1.5 py-1 text-sm placeholder:text-[color:var(--text-weaker)] focus-visible:ring-0 ${C?`font-mono`:``}`,onChange:e=>{ce(null),a(e.target.value),L(e.currentTarget)},onSelect:e=>L(e.currentTarget),onClick:e=>L(e.currentTarget),onKeyUp:e=>L(e.currentTarget),onPaste:e=>{let t=[];for(let n of Array.from(e.clipboardData?.items??[])){if(n.kind!==`file`)continue;let e=n.getAsFile();e&&t.push(e)}t.some(e=>e.type.startsWith(`image/`)||Ax(e.name))&&(e.preventDefault(),Nx(t).then(e=>{e.length>0&&v(t=>[...t,...e])}))},onKeyDown:t=>{if(Pe){if(t.key===`Escape`){t.preventDefault(),Me===i.length&&!i.endsWith(` `)?a(``):m(Ne);return}if(t.key===`ArrowDown`){t.preventDefault(),uh(1);return}if(t.key===`ArrowUp`){t.preventDefault(),uh(-1);return}if(t.key===`Enter`){t.preventDefault(),dh();return}if(t.key===`Tab`){t.preventDefault(),dh();return}}if(We!==void 0&&!x&&!Pe&&document.querySelector(`[data-slot="command-item"]`)){if(t.key===`ArrowDown`){t.preventDefault(),uh(1);return}if(t.key===`ArrowUp`){t.preventDefault(),uh(-1);return}if(t.key===`Enter`&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey){t.preventDefault(),dh();return}}if(Se&&t.key===`Escape`){t.preventDefault(),Ce(!1);return}if(!Pe&&We===void 0&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&!t.shiftKey){if(t.key===`ArrowUp`){let e=t.currentTarget;if(e.selectionStart===0&&e.selectionEnd===0&&oe.length>0){t.preventDefault(),se===null&&(le.current=i);let n=se===null?0:Math.min(se+1,oe.length-1);ce(n);let r=oe[n]??``;a(r),I(0),requestAnimationFrame(()=>e.setSelectionRange(0,0))}return}if(t.key===`ArrowDown`){let e=t.currentTarget;if(e.selectionStart===i.length&&e.selectionEnd===i.length){if(se===null)t.preventDefault(),Cv();else if(se<=0)t.preventDefault(),ce(null),a(le.current),I(le.current.length),requestAnimationFrame(()=>e.setSelectionRange(le.current.length,le.current.length));else{t.preventDefault();let n=Math.min(se-1,oe.length-1);ce(n);let r=oe[Math.max(n,0)]??``;a(r),I(r.length),requestAnimationFrame(()=>e.setSelectionRange(r.length,r.length))}}return}}if(t.key.toLowerCase()===`b`&&t.ctrlKey&&!t.metaKey&&!t.altKey&&!t.shiftKey){Pe||(t.preventDefault(),(A||j)&&Ly(e));return}if(t.key===`Escape`){if(t.preventDefault(),C){w(!1);return}if(A){Iy();return}return}if(t.key===`Tab`){t.preventDefault(),et(t.shiftKey?-1:1);return}if(t.key===`Backspace`&&!i&&te){t.preventDefault(),r(te);return}if(t.key===`Enter`&&!t.shiftKey&&!t.altKey&&(t.ctrlKey||t.metaKey)&&!Pe&&We===void 0){t.preventDefault(),ot(C?void 0:{delivery:`queue`});return}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ot())}}),o?(0,R.jsx)(uS,{className:`mb-1.5 mr-2`}):(0,R.jsxs)(U,{variant:`default`,size:`sm`,disabled:!i.trim()&&_.length===0,onClick:()=>void ot(),title:A?`Send (↵ steer · ctrl+↵ queue)`:`Send (Enter)`,children:[(0,R.jsx)(Je,{}),`Send`]})]})}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 border-t border-[color:var(--border-weak-base)] px-1 pt-1`,children:[(0,R.jsxs)(`button`,{type:`button`,"data-runs-panel-trigger":!0,onClick:()=>xe?wv():Cv(),title:xe?`Close subagents & shells (↓)`:`Subagents & shells — opens the runs panel (↓)`,className:`flex h-6 cursor-pointer items-center gap-1 rounded-md px-1.5 font-mono text-[11px] transition-colors ${be?`text-[color:var(--surface-brand-base)] hover:bg-[color:var(--surface-base-hover)]`:`text-[color:var(--text-weaker)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`}`,children:[(0,R.jsx)(je,{className:`size-3`}),ye]}),(0,R.jsx)(`button`,{type:`button`,title:`Shell mode (! command)`,onClick:()=>w(e=>!e),className:`flex size-6 cursor-pointer items-center justify-center rounded-md transition-colors ${C?`bg-[color:var(--surface-brand-weak)] text-[color:var(--surface-brand-strong)]`:`text-[color:var(--text-weaker)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`}`,children:(0,R.jsx)(tt,{className:`size-3.5`})}),(0,R.jsx)(rC,{sessionID:e,openUp:!0,align:`left`}),(0,R.jsx)(tC,{sessionID:e,openUp:!0,align:`left`}),(0,R.jsx)(nC,{sessionID:e,openUp:!0,align:`left`}),(0,R.jsx)(Nt,{region:`composer.toolbar`,sessionID:e}),Qe.length>0&&(0,R.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-[color:var(--text-weaker)]`,title:`Tokens used · share of model context window · session cost`,children:Qe.join(` · `)})]}),(0,R.jsx)(Nt,{region:`composer.below`,sessionID:e})]})}),(0,R.jsx)(aC,{side:`top`,align:`start`,sideOffset:8,className:`w-[min(26rem,calc(100vw-2rem))] p-0`,onOpenAutoFocus:e=>e.preventDefault(),children:(0,R.jsx)(ph,{children:(0,R.jsxs)(gh,{children:[Ue.map(e=>(0,R.jsxs)(bh,{value:e.key,onSelect:e.onSelect,children:[(0,R.jsx)(`span`,{className:`font-mono text-[color:var(--text-base)]`,children:e.display}),e.description&&(0,R.jsx)(`span`,{className:`ml-auto max-w-[55%] truncate pl-3 text-xs text-[color:var(--text-weaker)]`,children:e.description})]},e.key)),Ue.length===0&&(0,R.jsx)(_h,{children:`No matching items`})]})})})]}),(0,R.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between px-1 text-[11px] text-[color:var(--text-weaker)]`,children:[ct,lt&&(0,R.jsx)(`p`,{className:`hidden truncate font-mono sm:block`,children:lt})]})]}),Te&&(0,R.jsx)(PC,{sessionID:e,currentDirectory:re,onClose:()=>Ee(!1),onMoved:t=>{Ee(!1),window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Moved to ${t}`}})),M_(e),Yg()}})]})}function PC({sessionID:e,currentDirectory:t,onClose:n,onMoved:r}){let[i,a]=(0,E.useState)([]),[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(!0);(0,E.useEffect)(()=>{let e=!1;return(async()=>{try{let[n,r]=await Promise.all([G.projectList().catch(()=>[]),G.location().catch(()=>null)]);if(e)return;let i=new Set;for(let e of n){let t=e.directory;t&&i.add(t)}r?.directory&&i.add(r.directory),t&&i.add(t),a([...i].sort())}catch{}e||l(!1)})(),()=>{e=!0}},[t]);let u=t=>{let n=t.trim();n&&G.moveSession(e,n).then(()=>r(n)).catch(e=>{let t=e instanceof Error?e.message:String(e);window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Move failed: ${t}`,variant:`destructive`}}))})};return(0,R.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:n,children:(0,R.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-[var(--text-strong)]`,children:`Move session`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-[var(--text-weaker)]`,children:`Pick a workspace or enter a path. Mirrors the TUI picker.`}),c?(0,R.jsx)(`p`,{className:`mt-4 text-xs text-[var(--text-weaker)]`,children:`Loading workspaces…`}):(0,R.jsxs)(`div`,{className:`mt-3 max-h-56 overflow-y-auto rounded-md border border-[var(--border-weak-base)]`,children:[i.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs hover:bg-[var(--surface-base-hover)] ${e===t?`bg-[var(--surface-raised-base-active)] font-medium`:``}`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-[var(--text-strong)]`,children:e.replace(/^\/(home|Users)\/[^/]+/,`~`)}),e===t&&(0,R.jsx)(`span`,{className:`ml-2 text-[10px] text-[var(--text-weaker)]`,children:`current`})]},e)),i.length===0&&(0,R.jsx)(`p`,{className:`px-3 py-2 text-xs text-[var(--text-weaker)]`,children:`No workspaces found`})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,R.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u(o),e.key===`Escape`&&n()},placeholder:`Custom path — e.g. /home/z/projects/foo`,className:`flex-1 rounded-md border border-[var(--border-base)] bg-[var(--input-base)] px-2.5 py-1.5 font-mono text-xs outline-none focus:border-[var(--border-selected)]`,autoFocus:!0}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>u(o),disabled:!o.trim(),className:`rounded-md bg-[var(--surface-brand-base)] px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50`,children:`Move`}),(0,R.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-md border border-[var(--border-weak-base)] px-3 py-1.5 text-xs`,children:`Cancel`})]})]})})}function FC(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var IC=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,LC=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,RC={};function zC(e,t){return((t||RC).jsx?LC:IC).test(e)}var BC=/[ \t\n\f\r]/g;function VC(e){return typeof e==`object`?e.type===`text`&&HC(e.value):HC(e)}function HC(e){return e.replace(BC,``)===``}var UC=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};UC.prototype.normal={},UC.prototype.property={},UC.prototype.space=void 0;function WC(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new UC(n,r,t)}function GC(e){return e.toLowerCase()}var KC=class{constructor(e,t){this.attribute=t,this.property=e}};KC.prototype.attribute=``,KC.prototype.booleanish=!1,KC.prototype.boolean=!1,KC.prototype.commaOrSpaceSeparated=!1,KC.prototype.commaSeparated=!1,KC.prototype.defined=!1,KC.prototype.mustUseProperty=!1,KC.prototype.number=!1,KC.prototype.overloadedBoolean=!1,KC.prototype.property=``,KC.prototype.spaceSeparated=!1,KC.prototype.space=void 0;var qC=s({boolean:()=>YC,booleanish:()=>XC,commaOrSpaceSeparated:()=>ew,commaSeparated:()=>$C,number:()=>Y,overloadedBoolean:()=>ZC,spaceSeparated:()=>QC}),JC=0,YC=tw(),XC=tw(),ZC=tw(),Y=tw(),QC=tw(),$C=tw(),ew=tw();function tw(){return 2**++JC}var nw=Object.keys(qC),rw=class extends KC{constructor(e,t,n,r){let i=-1;if(super(e,t),iw(this,`space`,r),typeof n==`number`)for(;++i<nw.length;){let e=nw[i];iw(this,nw[i],(n&qC[e])===qC[e])}}};rw.prototype.defined=!0;function iw(e,t,n){n&&(e[t]=n)}function aw(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new rw(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[GC(r)]=r,n[GC(a.attribute)]=r}return new UC(t,n,e.space)}var ow=aw({properties:{ariaActiveDescendant:null,ariaAtomic:XC,ariaAutoComplete:null,ariaBusy:XC,ariaChecked:XC,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:QC,ariaCurrent:null,ariaDescribedBy:QC,ariaDetails:null,ariaDisabled:XC,ariaDropEffect:QC,ariaErrorMessage:null,ariaExpanded:XC,ariaFlowTo:QC,ariaGrabbed:XC,ariaHasPopup:null,ariaHidden:XC,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:QC,ariaLevel:Y,ariaLive:null,ariaModal:XC,ariaMultiLine:XC,ariaMultiSelectable:XC,ariaOrientation:null,ariaOwns:QC,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:XC,ariaReadOnly:XC,ariaRelevant:null,ariaRequired:XC,ariaRoleDescription:QC,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:XC,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function sw(e,t){return t in e?e[t]:t}function cw(e,t){return sw(e,t.toLowerCase())}var lw=aw({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:$C,acceptCharset:QC,accessKey:QC,action:null,allow:null,allowFullScreen:YC,allowPaymentRequest:YC,allowUserMedia:YC,alpha:YC,alt:null,as:null,async:YC,autoCapitalize:null,autoComplete:QC,autoFocus:YC,autoPlay:YC,blocking:QC,capture:null,charSet:null,checked:YC,cite:null,className:QC,closedBy:null,colorSpace:null,cols:Y,colSpan:Y,command:null,commandFor:null,content:null,contentEditable:XC,controls:YC,controlsList:QC,coords:Y|$C,crossOrigin:null,data:null,dateTime:null,decoding:null,default:YC,defer:YC,dir:null,dirName:null,disabled:YC,download:ZC,draggable:XC,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:YC,formTarget:null,headers:QC,height:Y,hidden:ZC,high:Y,href:null,hrefLang:null,htmlFor:QC,httpEquiv:QC,id:null,imageSizes:null,imageSrcSet:null,inert:YC,inputMode:null,integrity:null,is:null,isMap:YC,itemId:null,itemProp:QC,itemRef:QC,itemScope:YC,itemType:QC,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:YC,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:YC,muted:YC,name:null,nonce:null,noModule:YC,noValidate:YC,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:YC,optimum:Y,pattern:null,ping:QC,placeholder:null,playsInline:YC,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:YC,referrerPolicy:null,rel:QC,required:YC,reversed:YC,rows:Y,rowSpan:Y,sandbox:QC,scope:null,scoped:YC,seamless:YC,selected:YC,shadowRootClonable:YC,shadowRootCustomElementRegistry:YC,shadowRootDelegatesFocus:YC,shadowRootMode:null,shadowRootSerializable:YC,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:XC,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:YC,useMap:null,value:XC,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:QC,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:YC,declare:YC,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:YC,noHref:YC,noShade:YC,noWrap:YC,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:XC,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:YC,disablePictureInPicture:YC,disableRemotePlayback:YC,exportParts:$C,part:QC,prefix:null,property:null,results:Y,security:null,unselectable:null},space:`html`,transform:cw}),uw=aw({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:ew,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:QC,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:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:YC,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,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:$C,g2:$C,glyphName:$C,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:ew,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,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:Y,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:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:QC,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ew,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ew,rev:ew,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ew,requiredFeatures:ew,requiredFonts:ew,requiredFormats:ew,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:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:ew,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ew,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ew,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:sw}),dw=aw({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()}}),fw=aw({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:cw}),pw=aw({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),mw={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`},hw=/[A-Z]/g,gw=/-[a-z]/g,_w=/^data[-\w.:]+$/i;function vw(e,t){let n=GC(t),r=t,i=KC;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&_w.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(gw,bw);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!gw.test(e)){let n=e.replace(hw,yw);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=rw}return new i(r,t)}function yw(e){return`-`+e.toLowerCase()}function bw(e){return e.charAt(1).toUpperCase()}var xw=WC([ow,lw,dw,fw,pw],`html`),Sw=WC([ow,uw,dw,fw,pw],`svg`);function Cw(e){return e.join(` `).trim()}var ww=o(((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;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
53
- `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),Tw=o((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(ww());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}})),Ew=o((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))}})),Dw=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Tw()),r=Ew();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})),Ow=Aw(`end`),kw=Aw(`start`);function Aw(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 jw(e){let t=kw(e),n=Ow(e);if(t&&n)return{start:t,end:n}}function Mw(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Pw(e.position):`start`in e||`end`in e?Pw(e):`line`in e||`column`in e?Nw(e):``}function Nw(e){return Fw(e&&e.line)+`:`+Fw(e&&e.column)}function Pw(e){return Nw(e&&e.start)+`-`+Nw(e&&e.end)}function Fw(e){return e&&typeof e==`number`?e:1}var Iw=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=Mw(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}};Iw.prototype.file=``,Iw.prototype.name=``,Iw.prototype.reason=``,Iw.prototype.message=``,Iw.prototype.stack=``,Iw.prototype.column=void 0,Iw.prototype.line=void 0,Iw.prototype.ancestors=void 0,Iw.prototype.cause=void 0,Iw.prototype.fatal=void 0,Iw.prototype.place=void 0,Iw.prototype.ruleId=void 0,Iw.prototype.source=void 0;var Lw=l(Dw(),1),Rw={}.hasOwnProperty,zw=new Map,Bw=/[A-Z]/g,Vw=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Hw=new Set([`td`,`th`]);function Uw(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=eT(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=$w(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`?Sw:xw,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Ww(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Ww(e,t,n){if(t.type===`element`)return Gw(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Kw(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Jw(e,t,n);if(t.type===`mdxjsEsm`)return qw(e,t);if(t.type===`root`)return Yw(e,t,n);if(t.type===`text`)return Xw(e,t)}function Gw(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Sw,e.schema=i),e.ancestors.push(t);let a=oT(e,t.tagName,!1),o=tT(e,t),s=rT(e,t);return Vw.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!VC(e)})),Zw(e,o,a,t),Qw(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Kw(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)}sT(e,t.position)}function qw(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);sT(e,t.position)}function Jw(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Sw,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:oT(e,t.name,!0),o=nT(e,t),s=rT(e,t);return Zw(e,o,a,t),Qw(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Yw(e,t,n){let r={};return Qw(r,rT(e,t)),e.create(t,e.Fragment,r,n)}function Xw(e,t){return t.value}function Zw(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Qw(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function $w(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 eT(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=kw(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 tT(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Rw.call(t.properties,i)){let a=iT(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Hw.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 nT(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 sT(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 sT(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function rT(e,t){let n=[],r=-1,i=e.passKeys?new Map:zw;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=Ww(e,a,o);s!==void 0&&n.push(s)}return n}function iT(e,t,n){let r=vw(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?FC(n):Cw(n)),r.property===`style`){let t=typeof n==`object`?n:aT(e,String(n));return e.stylePropertyNameCase===`css`&&(t=cT(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?mw[r.property]||r.property:r.attribute,n]}}function aT(e,t){try{return(0,Lw.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Iw("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=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function oT(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=zC(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=zC(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Rw.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);sT(e)}function sT(e,t){let n=new Iw("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=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function cT(e){let t={},n;for(n in e)Rw.call(e,n)&&(t[lT(n)]=e[n]);return t}function lT(e){let t=e.replace(Bw,uT);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function uT(e){return`-`+e.toLowerCase()}var dT={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`]},fT={};function pT(e,t){let n=t||fT;return mT(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function mT(e,t,n){if(gT(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 hT(e.children,t,n)}return Array.isArray(e)?hT(e,t,n):``}function hT(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=mT(e[i],t,n);return r.join(``)}function gT(e){return!!(e&&typeof e==`object`)}var _T=document.createElement(`i`);function vT(e){let t=`&`+e+`;`;_T.innerHTML=t;let n=_T.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function yT(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 bT(e,t){return e.length>0?(yT(e,e.length,0,t),e):t}var xT={}.hasOwnProperty;function ST(e){let t={},n=-1;for(;++n<e.length;)CT(t,e[n]);return t}function CT(e,t){let n;for(n in t){let r=(xT.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){xT.call(r,a)||(r[a]=[]);let e=i[a];wT(r[a],Array.isArray(e)?e:e?[e]:[])}}}function wT(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);yT(e,0,0,r)}function TT(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 ET(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var DT=RT(/[A-Za-z]/),OT=RT(/[\dA-Za-z]/),kT=RT(/[#-'*+\--9=?A-Z^-~]/);function AT(e){return e!==null&&(e<32||e===127)}var jT=RT(/\d/),MT=RT(/[\dA-Fa-f]/),NT=RT(/[!-/:-@[-`{-~]/);function X(e){return e!==null&&e<-2}function PT(e){return e!==null&&(e<0||e===32)}function FT(e){return e===-2||e===-1||e===32}var IT=RT(/\p{P}|\p{S}/u),LT=RT(/\s/);function RT(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function zT(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&OT(e.charCodeAt(n+1))&&OT(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 BT(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return FT(r)?(e.enter(n),s(r)):t(r)}function s(r){return FT(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var VT={tokenize:HT};function HT(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`),BT(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 X(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var UT={tokenize:GT},WT={tokenize:KT};function GT(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 yT(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(WT,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(WT,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 X(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++;yT(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 KT(e,t,n){return BT(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function qT(e){if(e===null||PT(e)||LT(e))return 1;if(IT(e))return 2}function JT(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 YT={name:`attention`,resolveAll:XT,tokenize:ZT};function XT(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};QT(d,-c),QT(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=bT(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=bT(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=bT(l,JT(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=bT(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=bT(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,yT(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 ZT(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=qT(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=qT(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 QT(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var $T={name:`autolink`,tokenize:eE};function eE(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 DT(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||OT(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||OT(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||AT(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):kT(t)?(e.consume(t),l):n(t)}function u(e){return OT(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||OT(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var tE={partial:!0,tokenize:nE};function nE(e,t,n){return r;function r(t){return FT(t)?BT(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||X(e)?t(e):n(e)}}var rE={continuation:{tokenize:aE},exit:oE,name:`blockQuote`,tokenize:iE};function iE(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 FT(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function aE(e,t,n){let r=this;return i;function i(t){return FT(t)?BT(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(rE,t,n)(r)}}function oE(e){e.exit(`blockQuote`)}var sE={name:`characterEscape`,tokenize:cE};function cE(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 NT(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var lE={name:`characterReference`,tokenize:uE};function uE(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=OT,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=MT,u):(e.enter(`characterReferenceValue`),a=7,o=jT,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===OT&&!vT(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 dE={partial:!0,tokenize:mE},fE={concrete:!0,name:`codeFenced`,tokenize:pE};function pE(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`),FT(t)?BT(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||X(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(dE,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):FT(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),BT(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||X(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||X(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&&FT(t)?BT(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||X(t)?e.check(dE,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||X(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`),FT(t)?BT(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`),FT(t)?BT(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||X(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function mE(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 hE={name:`codeIndented`,tokenize:_E},gE={partial:!0,tokenize:vE};function _E(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),BT(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):X(t)?e.attempt(gE,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||X(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function vE(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):BT(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):X(e)?i(e):n(e)}}var yE={name:`codeText`,previous:xE,resolve:bE,tokenize:SE};function bE(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 xE(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function SE(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)):X(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||X(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 CE=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&&wE(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),wE(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),wE(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);wE(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);wE(this.left,t.reverse())}}}};function wE(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 TE(e){let t={},n=-1,r,i,a,o,s,c,l,u=new CE(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,EE(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 yT(e,0,1/0,u.slice(0)),!l}function EE(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 DE={resolve:kE,tokenize:AE},OE={partial:!0,tokenize:jE};function kE(e){return TE(e),e}function AE(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):X(t)?e.check(OE,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 jE(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),BT(e,a,`linePrefix`)}function a(i){if(i===null||X(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 ME(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||AT(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||X(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||PT(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||AT(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 NE(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):X(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||X(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!FT(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function PE(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):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),BT(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||X(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 FE(e,t){let n;return r;function r(i){return X(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):FT(i)?BT(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var IE={name:`definition`,tokenize:RE},LE={partial:!0,tokenize:zE};function RE(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return NE.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=ET(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 PT(t)?FE(e,l)(t):l(t)}function l(t){return ME(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(LE,d,d)(t)}function d(t){return FT(t)?BT(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||X(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function zE(e,t,n){return r;function r(t){return PT(t)?FE(e,i)(t):n(t)}function i(t){return PE(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return FT(t)?BT(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||X(e)?t(e):n(e)}}var BE={name:`hardBreakEscape`,tokenize:VE};function VE(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return X(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var HE={name:`headingAtx`,resolve:UE,tokenize:WE};function UE(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`},yT(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function WE(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||PT(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||X(n)?(e.exit(`atxHeading`),t(n)):FT(n)?BT(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||PT(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var GE=`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(`.`),KE=[`pre`,`script`,`style`,`textarea`],qE={concrete:!0,name:`htmlFlow`,resolveTo:XE,tokenize:ZE},JE={partial:!0,tokenize:$E},YE={partial:!0,tokenize:QE};function XE(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 ZE(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:P):DT(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):DT(a)?(e.consume(a),i=4,r.interrupt?t:P):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:P):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 DT(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||PT(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&KE.includes(l)?(i=1,r.interrupt?t(s):O(s)):GE.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||OT(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 FT(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||DT(t)?(e.consume(t),b):FT(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||OT(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):FT(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):FT(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||X(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||PT(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||FT(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||X(t)?O(t):FT(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),F):t===63&&i===3?(e.consume(t),P):t===93&&i===5?(e.consume(t),te):X(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(JE,ne,k)(t)):t===null||X(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(YE,A,ne)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||X(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),P):O(t)}function N(t){return t===47?(e.consume(t),o=``,ee):O(t)}function ee(t){if(t===62){let n=o.toLowerCase();return KE.includes(n)?(e.consume(t),F):O(t)}return DT(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ee):O(t)}function te(t){return t===93?(e.consume(t),P):O(t)}function P(t){return t===62?(e.consume(t),F):t===45&&i===2?(e.consume(t),P):O(t)}function F(t){return t===null||X(t)?(e.exit(`htmlFlowData`),ne(t)):(e.consume(t),F)}function ne(n){return e.exit(`htmlFlow`),t(n)}}function QE(e,t,n){let r=this;return i;function i(t){return X(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 $E(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(tE,t,n)}}var eD={name:`htmlText`,tokenize:tD};function tD(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):DT(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):DT(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):X(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):X(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):X(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):X(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return DT(t)?(e.consume(t),S):n(t)}function S(t){return t===45||OT(t)?(e.consume(t),S):C(t)}function C(t){return X(t)?(o=C,N(t)):FT(t)?(e.consume(t),C):M(t)}function w(t){return t===45||OT(t)?(e.consume(t),w):t===47||t===62||PT(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||DT(t)?(e.consume(t),E):X(t)?(o=T,N(t)):FT(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||OT(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):X(t)?(o=D,N(t)):FT(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):X(t)?(o=O,N(t)):FT(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):X(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||PT(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||PT(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`),ee}function ee(t){return FT(t)?BT(e,te,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):te(t)}function te(t){return e.enter(`htmlTextData`),o(t)}}var nD={name:`labelEnd`,resolveAll:oD,resolveTo:sD,tokenize:cD},rD={tokenize:lD},iD={tokenize:uD},aD={tokenize:dD};function oD(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&&yT(e,0,e.length,n),e}function sD(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=bT(s,e.slice(a+1,a+r+3)),s=bT(s,[[`enter`,u,t]]),s=bT(s,JT(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=bT(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=bT(s,e.slice(o+1)),s=bT(s,[[`exit`,c,t]]),yT(e,a,e.length,s),e}function cD(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(ET(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(rD,u,o?u:d)(t):t===91?e.attempt(iD,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(aD,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function lD(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 PT(t)?FE(e,a)(t):a(t)}function a(t){return t===41?u(t):ME(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return PT(t)?FE(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?PE(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return PT(t)?FE(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 uD(e,t,n){let r=this;return i;function i(t){return NE.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(ET(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function dD(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 fD={name:`labelStartImage`,resolveAll:nD.resolveAll,tokenize:pD};function pD(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 mD={name:`labelStartLink`,resolveAll:nD.resolveAll,tokenize:hD};function hD(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 gD={name:`lineEnding`,tokenize:_D};function _D(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),BT(e,t,`linePrefix`)}}var vD={name:`thematicBreak`,tokenize:yD};function yD(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||X(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),FT(t)?BT(e,s,`whitespace`)(t):s(t))}}var bD={continuation:{tokenize:wD},exit:ED,name:`list`,tokenize:CD},xD={partial:!0,tokenize:DD},SD={partial:!0,tokenize:TD};function CD(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:jT(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(vD,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 jT(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(tE,r.interrupt?n:u,e.attempt(xD,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return FT(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 wD(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(tE,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,BT(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!FT(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(SD,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,BT(e,e.attempt(bD,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function TD(e,t,n){let r=this;return BT(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 ED(e){e.exit(this.containerState.type)}function DD(e,t,n){let r=this;return BT(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!FT(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var OD={name:`setextUnderline`,resolveTo:kD,tokenize:AD};function kD(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 AD(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`),FT(t)?BT(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||X(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var jD={tokenize:MD};function MD(e){let t=this,n=e.attempt(tE,r,e.attempt(this.parser.constructs.flowInitial,i,BT(e,e.attempt(this.parser.constructs.flow,i,e.attempt(DE,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 ND={resolveAll:LD()},PD=ID(`string`),FD=ID(`text`);function ID(e){return{resolveAll:LD(e===`text`?RD: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 LD(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 RD(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 zD=s({attentionMarkers:()=>qD,contentInitial:()=>VD,disable:()=>JD,document:()=>BD,flow:()=>UD,flowInitial:()=>HD,insideSpan:()=>KD,string:()=>WD,text:()=>GD}),BD={42:bD,43:bD,45:bD,48:bD,49:bD,50:bD,51:bD,52:bD,53:bD,54:bD,55:bD,56:bD,57:bD,62:rE},VD={91:IE},HD={[-2]:hE,[-1]:hE,32:hE},UD={35:HE,42:vD,45:[OD,vD],60:qE,61:OD,95:vD,96:fE,126:fE},WD={38:lE,92:sE},GD={[-5]:gD,[-4]:gD,[-3]:gD,33:fD,38:lE,42:YT,60:[$T,eD],91:mD,92:[BE,sE],93:nD,95:YT,96:yE},KD={null:[YT,ND]},qD={null:[42,95]},JD={null:[]};function YD(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=bT(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=JT(a,l.events,l),l.events):[]}function f(e,t){return ZD(p(e),t)}function p(e){return XD(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){X(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&&yT(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 XD(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 ZD(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=`
50
+ `))if(e.startsWith(`data:`))try{let t=JSON.parse(e.slice(5).trim());if(t.type===`log.synced`&&typeof t.seq==`number`)return t.seq}catch{}return null}catch{return null}},createSession:e=>W(`/api/session`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),getSession:e=>W(`/api/session/${e}`),renameSession:(e,t)=>W(`/api/session/${e}/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:t})}),forkSession:(e,t)=>W(`/api/session/${e}/fork`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({boundary:t})}),exportSession:(e,t=!1)=>W(`/api/session/${e}/export?sanitize=${t}`),compactSession:(e,t=`steer`)=>W(`/api/session/${e}/compact`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:null,delivery:t})}),deleteSession:e=>W(`/api/session/${e}`,{method:`DELETE`}),switchAgent:(e,t)=>W(`/api/session/${e}/agent`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({agent:t})}),switchModel:(e,t)=>W(`/api/session/${e}/model`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({model:t})}),interrupt:(e,t)=>W(`/api/session/${e}/interrupt${t===void 0?``:`?continue=${t}`}`,{method:`POST`}),moveSession:(e,t)=>W(`/api/session/${e}/move`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({directory:t})}),revertStage:(e,t)=>W(`/api/session/${e}/revert/stage`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({messageID:t})}),revertClear:e=>W(`/api/session/${e}/revert/clear`,{method:`POST`}),revertCommit:e=>W(`/api/session/${e}/revert/commit`,{method:`POST`}),sessionBackground:e=>W(`/api/session/${e}/background`,{method:`POST`}),sessionShell:(e,t)=>W(`/api/session/${e}/shell`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:crypto.randomUUID(),command:t})}),messages:(e,t=100)=>W(`/api/session/${e}/message?limit=${t}&order=desc`),messagesWithCursor:(e,t=100,n)=>{let r=new URLSearchParams({limit:String(t)});return n?r.set(`cursor`,n):r.set(`order`,`desc`),W(`/api/session/${e}/message?${r.toString()}`)},prompt:(e,t,n)=>W(`/api/session/${e}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n?{text:t,delivery:n}:{text:t})}).then(e=>e.data),promptWithFiles:(e,t,n,r)=>W(`/api/session/${e}/prompt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r?{text:t,files:n,delivery:r}:{text:t,files:n})}).then(e=>e.data),runCommand:(e,t,n)=>W(`/api/session/${e}/command`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({command:t,arguments:n??null})}),activateSkill:(e,t)=>W(`/api/session/${e}/skill`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({skill:t})}),pendingPermissions:()=>W(`/api/permission/request`),replyPermission:(e,t,n)=>W(`/api/session/${e}/permission/${t}/reply`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({reply:n,message:null})}),pendingForms:()=>W(`/api/form/request`),sessionForms:e=>W(`/api/session/${e}/form`),formState:(e,t)=>W(`/api/session/${e}/form/${t}/state`),replyForm:(e,t,n)=>W(`/api/session/${e}/form/${t}/reply`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answer:n})}),cancelForm:(e,t)=>W(`/api/session/${e}/form/${t}/cancel`,{method:`POST`}),questionRequestGet:()=>W(`/api/question/request`),sessionQuestionList:e=>W(`/api/session/${e}/question`),sessionQuestionReply:(e,t,n)=>W(`/api/session/${e}/question/${t}/reply`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answers:n})}),sessionQuestionReject:(e,t)=>W(`/api/session/${e}/question/${t}/reject`,{method:`POST`}),inboxList:e=>W(`/api/session/${e}/inbox`),inboxQueue:(e,t)=>W(`/api/session/${e}/inbox/${t}/queue`,{method:`POST`}),inboxSteer:(e,t)=>W(`/api/session/${e}/inbox/${t}/steer`,{method:`POST`}),inboxDelete:(e,t)=>W(`/api/session/${e}/inbox/${t}`,{method:`DELETE`}),inboxPrompt:(e,t)=>G.prompt(e,t,`queue`),location:()=>W(`/api/location`),locationInfo:()=>W(`/api/location`),projectCurrent:()=>W(`/api/project/current`),projectList:()=>W(`/api/project`),fsFind:(e,t)=>{let n=new URLSearchParams({query:e});return t?.location&&n.set(`location[directory]`,t.location),t?.type&&n.set(`type`,t.type),t?.limit!==void 0&&n.set(`limit`,String(t.limit)),W(`/api/fs/find?${n.toString()}`)},fsList:e=>{let t=new URLSearchParams;return e?.location&&t.set(`location[directory]`,e.location),e?.path&&t.set(`path`,e.path),W(`/api/fs/list?${t.toString()}`)},fsRead:async(e,t)=>{let n=e.split(`/`).map(encodeURIComponent).join(`/`),r=new URLSearchParams;t&&r.set(`location[directory]`,t);let i=r.toString(),a=await fetch(`/api/fs/read/${n}${i?`?${i}`:``}`);if(!a.ok){let e=`${a.status} ${a.statusText}`;try{let t=await a.json();t.message&&(e=t.message)}catch{}throw Error(e)}return a.text()},fsReadBytes:async(e,t)=>{let n=e.split(`/`).map(encodeURIComponent).join(`/`),r=new URLSearchParams;t&&r.set(`location[directory]`,t);let i=r.toString(),a=await fetch(`/api/fs/read/${n}${i?`?${i}`:``}`);if(!a.ok)throw Error(`${a.status} ${a.statusText}`);return a.arrayBuffer()},models:async()=>(await W(`/api/model`)).data,agents:async()=>(await W(`/api/agent`)).data,commands:async()=>(await W(`/api/command`)).data,skills:async()=>(await W(`/api/skill`)).data,vcsStatus:e=>W(`/api/vcs/status?${Ah(e)}`),vcsDiff:(e,t,n,r)=>W(`/api/vcs/diff?${Ah(t,{mode:e,context:n,base:r})}`),vcsBase:e=>W(`/api/vcs/base?${Ah(e)}`),shellList:e=>W(`/api/shell?${Ah(e)}`),shellCreate:(e,t)=>W(`/api/shell?${Ah(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),shellGet:(e,t)=>W(`/api/shell/${e}?${Ah(t)}`),shellDelete:(e,t)=>W(`/api/shell/${e}?${Ah(t)}`,{method:`DELETE`}),shellOutput:(e,t,n)=>W(`/api/shell/${e}/output?${Ah(n,{cursor:t?.cursor,limit:t?.limit})}`),shellTimeout:(e,t,n)=>W(`/api/shell/${e}/timeout?${Ah(n)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({timeout:t})}),ptyList:e=>W(`/api/pty?${Ah(e)}`),ptyCreate:(e,t)=>W(`/api/pty?${Ah(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),ptyDelete:(e,t)=>W(`/api/pty/${e}?${Ah(t)}`,{method:`DELETE`}),ptyConnectToken:(e,t)=>W(`/api/pty/${e}/connect-token?${Ah(t)}`,{method:`POST`,headers:{"x-opencode-ticket":`1`}}),ptyUpdate:(e,t,n)=>W(`/api/pty/${e}?${Ah(n)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),providerList:()=>W(`/api/provider`),providerGet:e=>W(`/api/provider/${e}`),integrationList:()=>W(`/api/integration`),integrationConnectKey:(e,t)=>jh(`/api/integration/${e}/connect/key`,{key:t.key,answer:t.answer??null,label:t.label??null}),integrationConnectOauth:(e,t)=>jh(`/api/integration/${e}/connect/oauth`,{methodID:t.methodID,answer:t.answer??null,label:t.label??null}),integrationConnectCommand:(e,t)=>jh(`/api/integration/${e}/connect/command`,{methodID:t.methodID,label:t.label??null}),integrationOauthAttempt:(e,t)=>W(`/api/integration/${e}/connect/oauth/${t}`),integrationCommandAttempt:(e,t)=>W(`/api/integration/${e}/connect/command/${t}`),mcpList:()=>W(`/api/mcp`),mcpResource:()=>W(`/api/mcp/resource`),mcpPut:(e,t)=>Mh(`/api/mcp/${e}`,{config:t}),mcpDelete:e=>W(`/api/mcp/${e}`,{method:`DELETE`}),mcpConnect:e=>jh(`/api/mcp/${e}/connect`,null),mcpDisconnect:e=>jh(`/api/mcp/${e}/disconnect`,null),pluginList:()=>W(`/api/plugin`),websearchProviders:()=>W(`/api/websearch/provider`),websearch:(e,t)=>jh(`/api/websearch`,{query:e,providerID:t}),configGet:()=>W(`/api/config`),credentialPatch:(e,t)=>Mh(`/api/credential/${e}`,{label:t}),credentialActivate:e=>jh(`/api/credential/${e}/activate`,void 0),credentialDelete:e=>W(`/api/credential/${e}`,{method:`DELETE`}),serverInfo:()=>W(`/api/server`),serviceStop:e=>jh(`/api/service/stop`,{instanceID:e??``}),generate:(e,t)=>jh(`/api/generate`,{prompt:e,model:t??null}),referenceList:()=>W(`/api/reference`)},Nh=[],Ph=null,Fh=new Map,Ih=new Map;function Lh(e){return e.length===0?``:` `+e.map(e=>typeof e==`string`?e:Rh(e)).join(` `)}function Rh(e){if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}function zh(e){Nh.push(e),Ph||=setTimeout(()=>{Ph=null,Bh()},400)}async function Bh(){if(Nh.length===0)return;let e=Nh.splice(0);try{await fetch(`/api/debug`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}catch{}}var Vh=1e3;function Hh(e,t,...n){let r=e+`|`+t,i=Date.now(),a=(Fh.get(r)??0)+1;Fh.set(r,a);let o=Ih.get(r)??0;if(a===1||i-o>=Vh){Ih.set(r,i);let o=`[${new Date().toISOString().slice(11,23)}] [${e}] ${t}${a>1?` (x${a})`:``}${Lh(n)}`;typeof window<`u`&&window.__WEBUI_DEBUG_CONSOLE__&&console.debug(o),zh(o)}}var Uh=2e4,Wh=3e4,Gh=0;function Kh(){return Gh===0?1/0:Date.now()-Gh}function qh(){return Kh()>Wh}async function Jh(e,t={}){for(;!t.signal?.aborted;){let n=!1,r=0;try{let i=await fetch(`/api/event`,{signal:t.signal});if(!i.ok||!i.body)throw Error(`event stream: ${i.status}`);Hh(`sse`,`connected`,i.status),Gh=Date.now(),t.onOpen?.();let a=i.body.getReader(),o=new TextDecoder,s=``,c=()=>setTimeout(()=>{n=!0,Hh(`sse`,`STALLED - no data for ${Uh/1e3}s (rx=${r}B total); forcing reconnect`),console.warn(`[events] no data for ${Uh/1e3}s; forcing reconnect`),a.cancel()},Uh),l=c(),u=null,d=t=>{let n;try{n=JSON.parse(t)}catch{return!1}let r=typeof n.type==`string`?n.type:null;if(!r)return!1;let i={id:typeof n.id==`string`?n.id:``,created:typeof n.created==`number`?n.created:Date.now(),type:r,data:n.data??{}};return e({id:i.id,event:r,data:i}),!0};for(;;){let{done:e,value:t}=await a.read();if(e)break;clearTimeout(l),Gh=Date.now(),r+=t.byteLength,s+=o.decode(t,{stream:!0});let n=s.split(`
51
+ `);s=n.pop()??``;for(let e of n){let t=e.trim();if(!t){u=null;continue}if(!t.startsWith(`data:`))continue;let n=t.slice(5).trim();u=d(u?u+n:n)?null:u?u+n:n}l=c()}if(clearTimeout(l),a.releaseLock(),n)throw Error(`event stream stalled`);Hh(`sse`,`stream ended cleanly; reconnecting (rx=${r}B)`)}catch(e){if(t.signal?.aborted)return;Hh(`sse`,`reconnect`,String(e)),console.warn(`[events] stream ended, reconnecting:`,e)}n?await new Promise(e=>setTimeout(e,500)):await new Promise(e=>setTimeout(e,1500))}}var Yh=new Map,Xh=1,Zh=null,Qh=null,$h=1e3;function eg(){return typeof document<`u`&&document.hidden?`hidden`:Qh?Qh.isBusy()||Qh.isSseStale()?`live`:`idle`:`live`}function tg(e,t){return Math.max(e.minInterval,e.intervals[t]??e.minInterval)}function ng(e,t){e.lastRun=t,e.inFlight=!0;let n;try{n=e.run()}catch(t){e.inFlight=!1,Hh(`poll`,`${e.name} failed: ${t instanceof Error?t.message:String(t)}`);return}n instanceof Promise?n.catch(t=>{Hh(`poll`,`${e.name} failed: ${t instanceof Error?t.message:String(t)}`)}).finally(()=>{e.inFlight=!1}):e.inFlight=!1}function rg(){let e=eg(),t=Date.now();for(let n of Yh.values())e===`hidden`&&!n.whenHidden||n.inFlight||t-n.lastRun<tg(n,e)||ng(n,t)}function ig(e){Qh=e,!Zh&&(Zh=setInterval(rg,$h),typeof document<`u`&&document.addEventListener(`visibilitychange`,ag))}function ag(){document.hidden||rg()}function og(e){let t=Xh++,n={name:e.name,minInterval:e.minInterval,intervals:e.intervals??{},whenHidden:e.whenHidden??!1,run:e.run,lastRun:Date.now()-Math.random()*e.minInterval,inFlight:!1};return Yh.set(t,n),()=>{Yh.delete(t)}}var sg=`modulepreload`,cg=function(e){return`/`+e},lg={},ug=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}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=cg(t,n),t=s(t),t in lg)return;lg[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:sg,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.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)})},dg=s({DRAFT_SESSION_ID:()=>Tg,MAIN_PANE:()=>wg,MAX_SPLITS:()=>3,NEW_SESSION_HREF:()=>Pg,activateSkill:()=>jy,addSplitPane:()=>Gv,applyRevertView:()=>Av,backgroundSubagents:()=>Ly,cancelForm:()=>By,cancelPendingRequest:()=>Uy,childSessionsOf:()=>Ov,clearPendingEdit:()=>ob,clearSendError:()=>vy,closeRunsPanel:()=>wv,closeSplitPicker:()=>Wv,commitPendingEdit:()=>sb,compactSession:()=>nb,consumeRevertPrompt:()=>Dv,createRealSession:()=>Jy,dismissRunNotice:()=>G_,editAtMessage:()=>cb,ensureSessionWait:()=>ov,exportSession:()=>tb,fetchReplay:()=>tv,flushSteersNow:()=>Sy,focusPane:()=>Hv,focusedPaneKey:()=>Yv,forkAtMessage:()=>lb,forkSession:()=>eb,getState:()=>Ng,handleEvent:()=>$_,interrupt:()=>My,isDraftSession:()=>Eg,lastLiveSignalAt:()=>Jg,liveToolPart:()=>A_,loadMessages:()=>Qg,loadMoreSessions:()=>Xg,loadSessionDetail:()=>M_,materializeDraft:()=>Yy,navigateFocused:()=>Jv,newSession:()=>Xy,openRunsPanel:()=>Cv,openSplitPicker:()=>Uv,pendingDelete:()=>yy,pendingRequests:()=>Sg,pendingSendNow:()=>xy,pendingSetDelivery:()=>by,prefetchSession:()=>Xv,reconcileInbox:()=>dy,redoSession:()=>ib,refreshSessions:()=>Yg,rejectQuestion:()=>Hy,removeSplitPane:()=>Kv,renameSession:()=>$y,replyForm:()=>zy,replyPermission:()=>Ry,replyQuestion:()=>Vy,requestInterrupt:()=>Iy,requestShellPanel:()=>xv,resolveDefaultModel:()=>P_,revealSubagentComposer:()=>Ev,revertMarkerFor:()=>jv,selectSession:()=>Pv,sendCommand:()=>hy,sendPromptTo:()=>ey,sendPromptWithFiles:()=>_y,sendShell:()=>gy,sessionHref:()=>Fg,sessionLabel:()=>Cg,sessionOrSubagentsLive:()=>kv,setHighlightMessage:()=>Ky,setPaneSession:()=>qv,setPendingWorkspace:()=>Gy,setRunsSelection:()=>Tv,signalUI:()=>Sv,startDraftSession:()=>Wy,startEditAtMessage:()=>ab,startStore:()=>mv,switchAgent:()=>Zy,switchModel:()=>Qy,undoSession:()=>rb,useStore:()=>J}),fg=0,pg=()=>++fg,mg=new Map,hg=6e4;function gg(e){let t=Date.now();for(let n of e)mg.has(n)||mg.set(n,t);if(mg.size>500)for(let[e,n]of mg)t-n>10*hg&&mg.delete(e)}var _g=new Map;function vg(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>n.get(e.id)||{...e,seq:pg()})}function yg(e){return e.metadata?.kind===`question`}function bg(e){let t=e.metadata;return{id:e.id,sessionID:e.sessionID,seq:e.seq,channel:`form`,tool:t?.tool,questions:e.fields.map(e=>{let t=e;return{header:(`title`in e?e.title:void 0)??e.key,question:(`description`in e?e.description:void 0)??``,options:(`options`in e?e.options??[]:[]).map(e=>({label:e.label,value:e.value,description:e.description??``})),multiple:`type`in e&&e.type===`multiselect`,custom:t.custom===!0}})}}var xg=null;function Sg(e){if(xg&&xg.permissions===e.permissions&&xg.forms===e.forms&&xg.questions===e.questions)return xg.out;let t=[];for(let n of e.permissions)t.push({kind:`permission`,req:n});for(let n of e.questions)t.push({kind:`question`,req:n});for(let n of e.forms)yg(n)?t.push({kind:`question`,req:bg(n)}):t.push({kind:`form`,req:n});let n=t.sort((e,t)=>e.req.seq-t.req.seq);return xg={permissions:e.permissions,forms:e.forms,questions:e.questions,out:n},n}function Cg(e,t){return Eg(t)?`New session`:e.sessions.find(e=>e.id===t)?.title??e.sessionDetails[t]?.title??`session ${t.slice(0,8)}…`}var wg=`main`,Tg=`__draft__`;function Eg(e){return e===Tg}var K={connected:!1,serviceOK:!1,sessions:[],sessionsCursor:null,activeIDs:[],messages:{},sessionDetails:{},live:[],running:{},queued:{},permissions:[],forms:[],questions:[],currentSessionID:null,panes:[{id:wg,sessionID:null}],focusedPane:wg,splitPickerOpen:!1,shellPanelTick:0,uiSignals:{models:0,agents:0,themes:0,explorer:0,runsDialog:0,help:0,variants:0},revertPrompt:null,runsPanelOpen:!1,runsSelection:null,subagentComposerOpen:!1,draftWorkspace:null,pendingAgent:null,pendingModel:null,sendErrors:{},pending:{},runNotices:{},pendingWorkspace:null,interruptArmed:!1,highlightMessageID:null,highlightSessionID:null,pendingEdit:null,revertMarkers:{}},Dg=new Set,Og=0,kg=!1;function q(e){if(K={...K,...e},Og>0){kg=!0;return}Ag()}function Ag(){for(let e of Dg)e()}function jg(e){Og+=1;try{e()}finally{--Og,Og===0&&kg&&(kg=!1,Ag())}}function Mg(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.is(e[r],t[r]))return!1;return!0}function J(e){let t=(0,E.useRef)(null);return(0,E.useSyncExternalStore)(e=>(Dg.add(e),()=>Dg.delete(e)),()=>{let n=e(K);return t.current&&Mg(t.current.value,n)?t.current.value:(t.current={value:n},n)})}function Ng(){return K}var Pg=`/new-session`;function Fg(e){return`/session/${encodeURIComponent(e)}`}function Ig(){if(typeof window>`u`)return null;let e=window.location.pathname.match(/^\/session\/([^/]+)\/?$/);if(!e)return null;let t=e[1];if(!t)return null;try{return decodeURIComponent(t)}catch{return null}}function Lg(){return typeof window<`u`&&window.location.pathname===`/new-session`}function Rg(e,t){if(typeof window>`u`)return;let n=e===`__draft__`?Pg:e?Fg(e):`/`;window.location.pathname===n&&!window.location.search&&!window.location.hash||window.history[t===`replace`?`replaceState`:`pushState`]({},``,n)}var zg=null;function Bg(){zg&&clearTimeout(zg),zg=setTimeout(()=>void Yg(),400)}var Vg=100,Hg=3e4,Ug=15e3,Wg=45e3,Gg=new Map,Kg=new Map;function qg(e){e&&Gg.set(e,Date.now())}function Jg(e){return Kg.get(e)??0}async function Yg(){try{let e=await G.listSessions({limit:Math.max(Vg,K.sessions.length+1)}),t=await G.activeSessions(),n=new Set(Object.keys(t.data)),r=Date.now(),i={...K.running},a=[];for(let e of n)i[e]||r-(Gg.get(e)??0)<Hg||(i[e]=!0,a.push(e));for(let e of a)ov(e);for(let[e,t]of Object.entries(i))!t||n.has(e)||r-Jg(e)<Ug||delete i[e];let o={...K.queued};for(let[e,t]of Object.entries(o))!t||n.has(e)||i[e]||r-Jg(e)<Wg||delete o[e];let s=[...e.data].sort((e,t)=>t.time.updated-e.time.updated),c=K.sessions.length!==s.length||K.sessions.some((e,t)=>{let n=s[t];return!n||n.id!==e.id||n.time.updated!==e.time.updated||n.title!==e.title}),l=(e,t)=>{let n=Object.keys(e).filter(t=>e[t]),r=Object.keys(t).filter(e=>t[e]);return n.length===r.length&&n.every(e=>t[e])},u=[...n],d=K.activeIDs.length!==u.length||K.activeIDs.some((e,t)=>e!==u[t]);if(!c&&!d&&l(K.running,i)&&l(K.queued,o))return;q({...c?{sessions:s,sessionsCursor:e.cursor.next}:{},...d?{activeIDs:u}:{},...l(K.running,i)?{}:{running:i},...l(K.queued,o)?{}:{queued:o}})}catch(e){console.warn(`refreshSessions failed:`,e)}}async function Xg(){try{let e=await G.listSessions({limit:Vg,cursor:K.sessionsCursor}),t=new Map;for(let e of K.sessions)t.set(e.id,e);for(let n of e.data)t.set(n.id,n);q({sessions:[...t.values()].sort((e,t)=>t.time.updated-e.time.updated),sessionsCursor:e.cursor.next})}catch(e){console.warn(`loadMoreSessions failed:`,e)}}async function Zg(){let e=new Set(K.panes.map(e=>e.sessionID).filter(e=>!!e)),[t,n,...r]=await Promise.allSettled([G.pendingPermissions(),G.pendingForms(),...[...e].map(e=>G.sessionForms(e))]);function i(e,t){let n=new Map(vg(e,t).map(e=>[e.id,e]));for(let t of e)n.has(t.id)||n.set(t.id,t);return[...n.values()]}if(t.status===`fulfilled`){let e=t.value.data;q({permissions:i(K.permissions,e)})}else console.warn(`refreshQueues permissions failed:`,t.reason);if(n.status===`fulfilled`){let e=new Map,t=t=>{e.has(t.id)||e.set(t.id,t)};n.value.data.forEach(t);for(let e of r)e.status===`fulfilled`?e.value.data.forEach(t):console.warn(`refreshQueues session forms failed:`,e.reason);let a=[...e.values()],o=K.forms;gg([...o.map(e=>e.id),...a.map(e=>e.id)]);let s=new Set(o.map(e=>e.id)),c=new Set;await Promise.all([...s].map(async t=>{let n=K.forms.find(e=>e.id===t)??e.get(t);if(n)try{((await G.formState(n.sessionID,t)).data?.status??`pending`)!==`pending`&&c.add(t)}catch(e){let n=e instanceof Error?e.message:String(e),r=mg.get(t)??Date.now();n.includes(`404`)&&Date.now()-r>hg&&c.add(t)}}));let l=Date.now();for(let e of c)_g.set(e,l);if(_g.size>500)for(let[e,t]of _g)l-t>hg&&_g.delete(e);let u=a.filter(e=>{let t=_g.get(e.id);return t===void 0||Date.now()-t>hg});Hh(`queue`,`refresh forms=${o.length} listed=${a.length} settled=${c.size}`),q({forms:i(K.forms,u).filter(e=>!c.has(e.id))})}else console.warn(`refreshQueues forms failed:`,n.reason)}async function Qg(e){if(Eg(e))return;let t=e_(e),n=[],r,i=0;try{do{let a=r?await G.messagesWithCursor(e,200,r):await G.messages(e,200);if($g.get(e)!==t)return;let o=a.data;if(n.push(...o),r=a.cursor?.next,i++,o.length<200)break}while(r&&i<5)}catch(e){if(n.length===0){console.warn(`loadMessages failed:`,e);return}console.warn(`loadMessages partial failure, using`,n.length,`messages:`,e)}if($g.get(e)!==t)return;let a=[...n].reverse();Hh(`load`,`messages ${e}: ${a.length} (${i} pages)`),S_(e,a)}var $g=new Map;function e_(e){let t=($g.get(e)??0)+1;return $g.set(e,t),t}function t_(e){return e?.type===`assistant`&&e.time.completed===void 0}function n_(e){return K.panes.some(t=>t.sessionID===e)}function r_(e){return K.live.filter(t=>t.sessionID===e)}function i_(e){return e?!!(n_(e)||e===K.currentSessionID||r_(e).length>0||K.running[e]||K.queued[e]||K.activeIDs.includes(e)):!1}function a_(e){let t=new Set(e.map(e=>e.sessionID));return K.live.filter(e=>t.has(e.sessionID)||!!K.running[e.sessionID]||!!K.queued[e.sessionID]||K.activeIDs.includes(e.sessionID))}var o_=`webui.live.`;function s_(e){return`${o_}${e}`}function c_(e){if(!(!e||Eg(e)))try{if(typeof localStorage>`u`)return;let t=r_(e);if(t.length===0){localStorage.removeItem(s_(e));return}let n=t.map(e=>({id:e.id,sessionID:e.sessionID,agent:e.agent,model:e.model,started:e.started,completed:e.completed,finish:e.finish,cost:e.cost,error:e.error,content:e.content.map(e=>e.type===`tool`?{type:`tool`,tool:{id:e.tool.id,name:e.tool.name,inputText:e.tool.inputText,input:e.tool.input,status:e.tool.status,content:e.tool.content,metadata:e.tool.metadata,error:e.tool.error,executed:e.tool.executed,created:e.tool.created,ran:e.tool.ran,completed:e.tool.completed}}:{type:e.type,ordinal:e.ordinal,text:e.text})}));localStorage.setItem(s_(e),JSON.stringify(n))}catch{}}function l_(e){try{if(typeof localStorage>`u`)return;localStorage.removeItem(s_(e))}catch{}}function u_(e){if(!e||Eg(e)||r_(e).length>0)return!1;try{if(typeof localStorage>`u`)return!1;let t=localStorage.getItem(s_(e));if(!t)return!1;let n=JSON.parse(t);if(!Array.isArray(n)||n.length===0)return!1;let r=[];for(let t of n){if(!t||typeof t.id!=`string`||typeof t.sessionID!=`string`||t.sessionID!==e)continue;let n=Array.isArray(t.content)?t.content:[],i=[],a=new Map;for(let e of n)if(!(!e||typeof e.type!=`string`)){if(e.type===`tool`&&e.tool&&typeof e.tool.id==`string`){let t=e.tool,n={id:t.id,name:t.name??`tool`,inputText:t.inputText??``,input:t.input,status:t.status??`streaming`,content:t.content,metadata:t.metadata,error:t.error,executed:t.executed,created:t.created,ran:t.ran,completed:t.completed};a.set(n.id,n),i.push({type:`tool`,tool:n})}else(e.type===`text`||e.type===`reasoning`)&&typeof e.ordinal==`number`&&typeof e.text==`string`&&i.push({type:e.type,ordinal:e.ordinal,text:e.text})}let o={sessionID:t.sessionID,id:t.id,agent:t.agent,model:t.model,content:i,text:``,reasoning:``,tools:a,finish:t.finish,cost:t.cost,error:t.error,started:typeof t.started==`number`?t.started:Date.now(),completed:t.completed};r.push(f_(o,i))}return r.length!==0&&(q({live:[...K.live,...r]}),Hh(`load`,`restored ${r.length} live assistant(s) for ${e} from localStorage`),!0)}catch{return!1}}function d_(e){return{text:e.filter(e=>e.type===`text`).map(e=>e.text).join(``),reasoning:e.filter(e=>e.type===`reasoning`).map(e=>e.text).join(``),tools:new Map(e.filter(e=>e.type===`tool`).map(e=>[e.tool.id,e.tool]))}}function f_(e,t){return{...e,content:t,...d_(t)}}function p_(e){let t=e.state,n=t.status===`streaming`?t.input:JSON.stringify(t.input);return{id:e.id,name:e.name,inputText:n,input:t.status===`streaming`?void 0:t.input,status:t.status,content:`content`in t?t.content:void 0,metadata:`metadata`in t?t.metadata:void 0,error:t.status===`error`?t.error:void 0,executed:e.executed,created:e.time.created,ran:e.time.ran,completed:e.time.completed}}function m_(e,t){let n={text:0,reasoning:0},r=t.content.map(e=>{if(e.type===`tool`)return{type:`tool`,tool:p_(e)};let t=n[e.type]++;return{type:e.type,ordinal:t,text:e.text}});return f_({sessionID:e,id:t.id,agent:t.agent,model:t.model,content:[],text:``,reasoning:``,tools:new Map,finish:t.finish,cost:t.cost,error:t.error,started:t.time.created,completed:t.time.completed},r)}function h_(e,t){return e?t?t.startsWith(e)||e.endsWith(t)?t.length>=e.length?t:e:e.startsWith(t)?e:`${e}${t}`:e:t}function g_(e,t){if(!t)return e;if(!e)return t;if(e.endsWith(t))return e;let n=Math.min(e.length,t.length-1);for(let r=n;r>0;r--)if(e.endsWith(t.slice(0,r)))return e+t.slice(r);return e+t}function __(e){return e.type===`tool`?`tool:${e.tool.id}`:`${e.type}:${e.ordinal}`}function v_(e,t){let n=m_(e.sessionID,t);if(e.content.length===0)return{...n,id:e.id,started:e.started,sessionID:e.sessionID};let r=new Map(e.content.map(e=>[__(e),e])),i=n.content.map(e=>{let t=r.get(__(e));if(!t)return e;if(e.type===`tool`&&t.type===`tool`){let n=e.tool,r=t.tool;return{type:`tool`,tool:{...n,...r,inputText:h_(n.inputText,r.inputText),input:r.input??n.input,status:r.status===`streaming`&&n.status!==`streaming`?n.status:r.status,content:r.content??n.content,metadata:r.metadata??n.metadata,error:r.error??n.error,executed:r.executed??n.executed,created:n.created??r.created,ran:r.ran??n.ran,completed:r.completed??n.completed}}}return e.type!==`tool`&&t.type!==`tool`?{...e,text:h_(e.text,t.text)}:e}),a=new Set(i.map(__));return i.push(...e.content.filter(e=>!a.has(__(e)))),f_({...e,agent:e.agent??n.agent,model:e.model??n.model,finish:e.finish??n.finish,cost:e.cost??n.cost,error:e.error??n.error,completed:e.completed??n.completed},i)}function y_(e,t){if(r_(e).length===0&&u_(e),!i_(e)&&!n_(e))return;let n=r_(e).length>0,r=e===K.currentSessionID;if(!(K.running[e]||K.queued[e]||K.activeIDs.includes(e)||n)&&!(r&&n))return;let i=new Map(t.filter(e=>e.type===`assistant`&&t_(e)).map(e=>[e.id,e])),a=new Set(r_(e).map(e=>e.id)),o=[];for(let n of t)n.type!==`assistant`||!t_(n)||a.has(n.id)||(a.add(n.id),o.push(m_(e,n)));let s=!1,c=K.live.map(t=>{if(t.sessionID!==e)return t;let n=i.get(t.id);if(!n)return t;let r=v_(t,n);return s||=r!==t,r});o.length>0&&(Hh(`load`,`seeded ${o.length} in-flight assistant(s) for ${e}`),c=[...c,...o],s=!0),s&&q({live:c})}function b_(e,t){let n=new Map(t.map(e=>[e.id,e]));return new Set(r_(e).filter(e=>{let t=n.get(e.id);return e.id!==`pending`&&(!t||t_(t))}).map(e=>e.id))}function x_(e,t){let n=K.messages[e]??[],r=b_(e,t),i=new Map,a=new Map;for(let e of n)e.type===`user`&&!e.id.startsWith(`msg_local_`)&&i.set(e.text,(i.get(e.text)??0)+1);for(let e of t)e.type===`user`&&a.set(e.text,(a.get(e.text)??0)+1);let o=new Map;for(let[e,t]of a){let n=t-(i.get(e)??0);n>0&&o.set(e,n)}let s=new Map;for(let e of n)if(!r.has(e.id)){if(e.id.startsWith(`msg_local_`)&&e.type===`user`){let t=o.get(e.text)??0;if(t>0){o.set(e.text,t-1);continue}}s.set(e.id,e)}for(let e of t)r.has(e.id)||s.set(e.id,e);return[...s.values()].sort((e,t)=>e.time.created-t.time.created||e.id.localeCompare(t.id))}function S_(e,t){y_(e,t);let n=x_(e,t);if(!n_(e)){let r=new Map(t.map(e=>[e.id,e])),i=!K.running[e]&&!K.queued[e],a=r_(e),o=new Set(a.filter(e=>{if(e.id===`pending`)return!1;if(i&&!r.has(e.id)&&Date.now()-e.started>3e4)return!0;let t=r.get(e.id);return t?.type===`assistant`&&t.time.completed!==void 0}).map(e=>e.id)),s=o.size>0?K.live.filter(t=>!(t.sessionID===e&&o.has(t.id))):K.live;q({messages:{...K.messages,[e]:n},...s===K.live?{}:{live:s}}),a.length>0&&o.size===a.length&&l_(e);return}let r=new Map(t.map(e=>[e.id,e])),i=r_(e),a=i.find(e=>e.id===`pending`),o=!!a&&t.some(e=>e.type===`assistant`&&e.time.completed!==void 0&&e.time.created>=a.started-5e3),s=new Set(i.filter(e=>{let t=r.get(e.id);return t?.type===`assistant`&&t.time.completed!==void 0}).map(e=>e.id)),c=!K.running[e]&&!K.queued[e],l=new Set(c?i.filter(e=>e.id!==`pending`&&!r.has(e.id)&&Date.now()-e.started>3e4).map(e=>e.id):[]),u={...K.running};o&&(delete u[e],K_.delete(e));let d=K.live.filter(t=>t.sessionID!==e||(t.id===`pending`?!o:!(s.has(t.id)||l.has(t.id)))),f=K.live.some(t=>t.sessionID===e),p=d.some(t=>t.sessionID===e);q({messages:{...K.messages,[e]:n},live:d,running:u}),(f&&!p&&(s.size>0||l.size>0||o)||f&&!p&&t.some(e=>e.type===`assistant`&&e.time.completed!==void 0))&&l_(e)}function C_(e,t,n=Date.now()){let r=K.live.find(n=>n.sessionID===e&&n.id===t);if(r)return r;let i=K.messages[e],a=i?.find(e=>e.id===t&&e.type===`assistant`&&t_(e)),o=a?m_(e,a):{sessionID:e,id:t,content:[],text:``,reasoning:``,tools:new Map,started:n};return q({live:[...K.live,o],...a?{messages:{...K.messages,[e]:i.filter(e=>e.id!==t)}}:{}}),o.id!==`pending`&&c_(e),o}function w_(e,t){let n=K.messages[e];n?.some(e=>e.id===t&&t_(e))&&q({messages:{...K.messages,[e]:n.filter(e=>e.id!==t)}})}function T_(e,t){let n=K.live.find(t=>t.id===e)?.sessionID;q({live:K.live.map(n=>{if(n.id!==e)return n;let r={...n,...t,tools:new Map(n.tools)};return t.content?f_(r,t.content):r})}),n&&c_(n)}function E_(e,t,n,r){let i=C_(e,t),a=i.content.find(e=>e.type===n&&e.ordinal===r);if(a)return a;let o={type:n,ordinal:r,text:``};return T_(t,{content:[...i.content,o]}),o}function D_(e,t,n,r,i){let a=K.live.find(t=>t.id===e);a&&T_(e,{content:a.content.map(e=>e.type!==t||e.ordinal!==n?e:{...e,text:i===`append`?g_(e.text,r):r})})}function O_(e,t,n,r){let i=C_(e,t),a=i.tools.get(n);if(a)return a;let o={id:n,name:r??`tool`,inputText:``,status:`streaming`,created:Date.now()};return T_(t,{content:[...i.content,{type:`tool`,tool:o}]}),o}function k_(e,t,n){let r=K.live.find(t=>t.id===e);if(!r)return;let i=r.tools.get(t);if(!i)return;let a=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0)),o={...i,...a};T_(e,{content:r.content.map(e=>e.type===`tool`&&e.tool.id===t?{type:`tool`,tool:o}:e)})}function A_(e){let t=e.status===`streaming`?e.inputText:e.input===void 0?{}:e.input,n=e.status===`error`?{status:`error`,input:t,error:e.error??{type:`error`,message:`tool failed`},content:e.content}:e.status===`completed`?{status:`completed`,input:t,content:e.content??[],metadata:e.metadata}:e.status===`running`?{status:`running`,input:t,metadata:e.metadata}:{status:`streaming`,input:e.inputText};return{type:`tool`,id:e.id,name:e.name,executed:e.executed,state:n,time:{created:e.created??Date.now(),ran:e.ran,completed:e.completed}}}function j_(e,t,n){let r=K.live.find(t=>t.sessionID===e&&t.id===`pending`&&t.text===``&&t.reasoning===``&&t.tools.size===0);if(!r){C_(e,t),T_(t,n);return}let i=K.live.find(n=>n.sessionID===e&&n.id===t);if(i&&(i.content.length>0||i.tools.size>0)){q({live:K.live.filter(e=>e!==r).map(e=>e===i?{...e,...n,tools:new Map(e.tools)}:e)}),c_(e);return}q({live:K.live.map(i=>i===r?{...i,...n,id:t}:i.sessionID===e&&i.id===t?null:i).filter(e=>e!==null)}),t!==`pending`&&c_(e)}async function M_(e){if(!Eg(e))try{let t=(await G.getSession(e)).data,n=K.revertMarkers;if(n[e]===void 0){let r=t.revert?.messageID;r&&(n={...n,[e]:r})}q({sessionDetails:{...K.sessionDetails,[e]:t},...n===K.revertMarkers?{}:{revertMarkers:n}})}catch(e){console.warn(`loadSessionDetail failed:`,e)}}var N_=null;function P_(){return N_??=(async()=>{try{let e=(await G.agents()).find(e=>e.mode===`primary`&&!e.hidden);if(e?.model)return e.model}catch{}try{let e=(await G.models()).filter(e=>e.enabled);if(e.length>0)return{id:e[0].modelID,providerID:e[0].providerID}}catch{}})(),N_}async function F_(e){if(K.pendingAgent&&!Eg(e)){let t=K.pendingAgent;try{await G.switchAgent(e,t),Hh(`model`,`committed agent ${t} on send`)}catch(e){console.warn(`switchAgent on send failed:`,e)}q({pendingAgent:null})}if(K.pendingModel&&!Eg(e)){let t=K.pendingModel;try{await G.switchModel(e,t),Hh(`model`,`committed model ${t.providerID}/${t.id} on send`)}catch(e){console.warn(`switchModel on send failed:`,e)}q({pendingModel:null})}}async function I_(e){if(Eg(e))return;if(K.sessions.find(t=>t.id===e)?.model||K.pendingModel){await F_(e);return}let t=await P_();if(t)try{await G.switchModel(e,t),Hh(`model`,`pinned ${e} -> ${t.providerID}/${t.id}`)}catch(e){console.warn(`ensureSessionModel failed:`,e)}}async function L_(e){await Qg(e);let t=r_(e).filter(e=>e.id!==`pending`).map(e=>e.id);if(t.length===0)return;let n=K.messages[e]??[];t.filter(e=>!n.some(t=>t.id===e)).length>0&&setTimeout(()=>void Qg(e),1500)}var R_=15e3,z_=0;function B_(e,t){let n={...K.runNotices};t&&t.length>0?n[e]=t:delete n[e],q({runNotices:n})}function V_(e){K.runNotices[e]&&B_(e,null)}function H_(e){let t=K.runNotices[e];t?.some(e=>e.kind===`retry`)&&B_(e,t.filter(e=>e.kind!==`retry`))}function U_(e){if(!e||typeof e!=`object`)return!1;let t=e,n=(t.type??``).toLowerCase(),r=(t.message??``).toLowerCase();return n===`aborted`||n===`abort`||r.includes(`aborted`)||r.includes(`step interrupted`)||r.includes(`run interrupted`)||r.includes(`interrupted`)}function W_(e,t,n,r=Date.now()){if(!e||Eg(e)||t===`interrupted`||t===`failed`&&/aborted|step interrupted|run interrupted/i.test(n))return;let i=K.runNotices[e]??[],a=i[i.length-1];if(a&&a.kind===t&&a.text===n&&r-a.at<R_)return;let o={id:`rn_${++z_}`,kind:t,text:n,at:r};B_(e,[...i,o].slice(-3))}function G_(e,t){let n=K.runNotices[e];n?.some(e=>e.id===t)&&B_(e,n.filter(e=>e.id!==t))}var K_=new Set,q_=new Set,J_=new Set([`session.execution.started`,`session.execution.succeeded`,`session.execution.failed`,`session.execution.interrupted`,`session.step.started`,`session.step.ended`,`session.step.failed`,`session.text.started`,`session.text.delta`,`session.text.ended`,`session.reasoning.started`,`session.reasoning.delta`,`session.reasoning.ended`,`session.tool.called`,`session.tool.input.started`,`session.tool.input.delta`,`session.tool.input.ended`,`session.tool.progress`,`session.tool.success`,`session.tool.failed`,`session.retry.scheduled`]);function Y_(e){return[...K.live].reverse().find(t=>t.sessionID===e&&t.id!==`pending`)}function X_(e){!e||K.running[e]||(Hh(`run`,`live via stream delta ${e}`),q({running:{...K.running,[e]:!0},queued:{...K.queued,[e]:!1}}))}function Z_(e){H_(e);let t={...K.running};delete t[e],K_.delete(e),qg(e),q({running:t,queued:{...K.queued,[e]:!1}}),K.live.some(t=>t.sessionID===e&&t.id===`pending`)&&q({live:K.live.filter(t=>t.sessionID!==e||t.id!==`pending`)}),L_(e),Ty(e),Bg()}function Q_(e,t,n){let r={...K.running};delete r[e],K_.delete(e),qg(e),q({running:r,queued:{...K.queued,[e]:!1}}),K.live.some(t=>t.sessionID===e&&t.id===`pending`)&&q({live:K.live.filter(t=>t.sessionID!==e||t.id!==`pending`)});let i=Y_(e);i&&T_(i.id,{finish:t===`session.execution.succeeded`?`stop`:t===`session.execution.failed`?`error`:`interrupted`,error:n??(t===`session.execution.succeeded`?void 0:i.error)}),L_(e),Ty(e),Bg()}function $_(e){let{type:t,data:n}=e,r=n.sessionID;r&&(J_.has(t)||t===`session.status`)&&Kg.set(r,Date.now());let i=r?i_(r)||n_(r):!1;if(e.id&&r&&i&&q_.has(e.id))return;e.id&&r&&i&&(q_.size>2e4&&q_.clear(),q_.add(e.id));let a=e=>!!e&&n_(e),o=e=>!!e&&i_(e);switch(Hh(`evt`,t,`sid=${n.sessionID??`-`}`,`current=${K.currentSessionID??`-`}`,`mid=${n.assistantMessageID??`-`}`),r&&J_.has(t)&&!n_(r)&&!i_(r)?Hh(`gate`,`${t} for non-pane session ${r} — skipped`):r&&J_.has(t)&&!n_(r)&&Hh(`gate`,`${t} for non-pane session ${r} — tracked via shouldTrackLive`),t){case`session.created`:case`session.renamed`:case`session.deleted`:case`session.moved`:case`session.forked`:case`session.usage.updated`:Bg(),r&&(K.messages[r]?.length??0)>0&&Qg(r),t!==`session.usage.updated`&&M_(n.sessionID);break;case`session.revert.staged`:{let e=n.revert?.messageID;r&&e&&Mv(r,e),Bg(),r&&(K.messages[r]?.length??0)>0&&Qg(r),r&&M_(n.sessionID);break}case`session.revert.committed`:{let e=n.to;if(r&&e){let t=K.messages[r]??[],n=t.findIndex(t=>t.id===e);if(n!==-1){let e=[...t.slice(0,n),...t.slice(n).filter(e=>e.id.startsWith(`msg_local_`))];q({messages:{...K.messages,[r]:e},revertMarkers:{...K.revertMarkers,[r]:null}})}else Mv(r,null)}Bg(),r&&(Qg(r),M_(r));break}case`session.revert.cleared`:r&&Mv(r,null),Bg(),r&&(K.messages[r]?.length??0)>0&&Qg(r),r&&M_(n.sessionID);break;case`session.agent.selected`:case`session.model.selected`:Bg(),M_(n.sessionID);break;case`session.inbox.enqueued`:{let e=n,t=typeof e.id==`string`&&e.id?e.id:typeof e.inboxID==`string`&&e.inboxID?e.inboxID:void 0;e.sessionID&&!Eg(e.sessionID)&&t&&typeof e.payload?.text==`string`&&fy(e.sessionID,{id:t,text:e.payload.text,delivery:e.delivery}),a(n.sessionID)&&(Hh(`run`,`queued ${n.sessionID}`),q({queued:{...K.queued,[n.sessionID]:!0}}));break}case`session.inbox.delivered`:{let e=n,t=typeof e.id==`string`&&e.id?e.id:typeof e.inboxID==`string`&&e.inboxID?e.inboxID:void 0;t&&py(t);break}case`session.error`:if(n.sessionID){let t=n.error;t&&!U_(t)?(q({sendErrors:{...K.sendErrors,[n.sessionID]:{type:t.type??`error`,message:t.message,status:t.status}}}),W_(n.sessionID,`error`,`${t.type}: ${t.message}`,e.created)):t&&U_(t),ky(n.sessionID)}break;case`session.execution.started`:K_.add(n.sessionID),Hh(`run`,`started ${n.sessionID}`),q({running:{...K.running,[n.sessionID]:!0},queued:{...K.queued,[n.sessionID]:!1}}),ov(n.sessionID),o(n.sessionID)&&C_(n.sessionID,n.assistantMessageID??`pending`,e.created);break;case`session.retry.scheduled`:if(n.sessionID&&n.error){let t=n.attempt;W_(n.sessionID,`retry`,`Retry attempt ${t??`?`} scheduled — ${n.error.message}`,e.created)}o(n.sessionID)&&n.assistantMessageID&&n.error&&T_(n.assistantMessageID,{error:{type:n.error.type,message:`Retrying${n.at?` at ${new Date(n.at).toLocaleTimeString()}`:``} — ${n.error.message}`,status:n.error.status}});break;case`session.execution.succeeded`:case`session.execution.failed`:case`session.execution.interrupted`:if(Hh(`run`,`finished ${n.sessionID} (${t})`),t===`session.execution.succeeded`)V_(n.sessionID);else if(H_(n.sessionID),t===`session.execution.failed`){let t=n.error;t&&!U_(t)?W_(n.sessionID,`failed`,`${t.type}: ${t.message}`,e.created):t||W_(n.sessionID,`failed`,`Run failed`,e.created)}Q_(n.sessionID,t,n.error);break;case`session.step.started`:o(n.sessionID)&&n.assistantMessageID&&(j_(n.sessionID,n.assistantMessageID,{agent:n.agent,model:n.model}),C_(n.sessionID,n.assistantMessageID,e.created),w_(n.sessionID,n.assistantMessageID),T_(n.assistantMessageID,{agent:n.agent,model:n.model,finish:void 0,error:void 0,completed:void 0}),K.running[n.sessionID]||(Hh(`run`,`live via step.started ${n.sessionID}`),q({running:{...K.running,[n.sessionID]:!0},queued:{...K.queued,[n.sessionID]:!1}}),ov(n.sessionID)));break;case`session.step.ended`:if(o(n.sessionID)&&n.assistantMessageID&&(T_(n.assistantMessageID,{finish:n.finish,cost:n.cost,completed:e.created}),!K_.has(n.sessionID)&&n.finish===`stop`)){let e={...K.running};delete e[n.sessionID],q({running:e})}break;case`session.step.failed`:if(n.sessionID&&n.error&&!U_(n.error)&&W_(n.sessionID,`failed`,`${n.error.type}: ${n.error.message}`,e.created),o(n.sessionID)&&n.assistantMessageID&&(T_(n.assistantMessageID,{finish:`error`,error:n.error,cost:n.cost,completed:e.created}),!K_.has(n.sessionID))){let e={...K.running};delete e[n.sessionID],q({running:e})}break;case`session.text.started`:o(n.sessionID)&&n.assistantMessageID&&(X_(n.sessionID),E_(n.sessionID,n.assistantMessageID,`text`,n.ordinal??0),K.queued[n.sessionID]&&q({queued:{...K.queued,[n.sessionID]:!1}}));break;case`session.text.delta`:o(n.sessionID)&&n.assistantMessageID&&(E_(n.sessionID,n.assistantMessageID,`text`,n.ordinal??0),D_(n.assistantMessageID,`text`,n.ordinal??0,n.delta??``,`append`));break;case`session.text.ended`:o(n.sessionID)&&n.assistantMessageID&&(E_(n.sessionID,n.assistantMessageID,`text`,n.ordinal??0),D_(n.assistantMessageID,`text`,n.ordinal??0,n.text??``,`replace`));break;case`session.reasoning.started`:o(n.sessionID)&&n.assistantMessageID&&(X_(n.sessionID),E_(n.sessionID,n.assistantMessageID,`reasoning`,n.ordinal??0));break;case`session.reasoning.delta`:o(n.sessionID)&&n.assistantMessageID&&(E_(n.sessionID,n.assistantMessageID,`reasoning`,n.ordinal??0),D_(n.assistantMessageID,`reasoning`,n.ordinal??0,n.delta??``,`append`));break;case`session.reasoning.ended`:o(n.sessionID)&&n.assistantMessageID&&(E_(n.sessionID,n.assistantMessageID,`reasoning`,n.ordinal??0),D_(n.assistantMessageID,`reasoning`,n.ordinal??0,n.text??``,`replace`));break;case`session.tool.input.started`:o(n.sessionID)&&n.assistantMessageID&&n.id&&(X_(n.sessionID),O_(n.sessionID,n.assistantMessageID,n.id,n.name));break;case`session.tool.input.delta`:if(o(n.sessionID)&&n.assistantMessageID&&n.id){O_(n.sessionID,n.assistantMessageID,n.id);let e=K.live.find(e=>e.id===n.assistantMessageID)?.tools.get(n.id);k_(n.assistantMessageID,n.id,{inputText:g_(e?.inputText??``,n.delta??``)})}break;case`session.tool.input.ended`:if(o(n.sessionID)&&n.assistantMessageID&&n.id){let e=O_(n.sessionID,n.assistantMessageID,n.id),t;try{t=JSON.parse(n.text??``)}catch{t=n.text}k_(n.assistantMessageID,n.id,{input:t,inputText:n.text??``,status:e.status===`streaming`?`running`:e.status})}break;case`session.tool.called`:if(o(n.sessionID)&&n.assistantMessageID&&n.id){let t=O_(n.sessionID,n.assistantMessageID,n.id);k_(n.assistantMessageID,n.id,{input:n.input,inputText:n.input===void 0?t.inputText:JSON.stringify(n.input),status:t.status===`streaming`?`running`:t.status,executed:n.executed,ran:e.created})}break;case`session.tool.progress`:o(n.sessionID)&&n.assistantMessageID&&n.id&&(O_(n.sessionID,n.assistantMessageID,n.id),k_(n.assistantMessageID,n.id,{metadata:n.metadata}));break;case`session.tool.success`:o(n.sessionID)&&n.assistantMessageID&&n.id&&(X_(n.sessionID),k_(n.assistantMessageID,n.id,{...typeof n.name==`string`?{name:n.name}:{},status:`completed`,content:n.content??void 0,metadata:n.metadata,executed:n.executed,completed:e.created}));break;case`session.tool.failed`:o(n.sessionID)&&n.assistantMessageID&&n.id&&k_(n.assistantMessageID,n.id,{...typeof n.name==`string`?{name:n.name}:{},status:`error`,error:n.error,content:n.content??void 0,metadata:n.metadata,executed:n.executed,completed:e.created});break;case`session.status`:{let e=n.status?.type;e===`busy`?q({running:{...K.running,[n.sessionID]:!0},queued:{...K.queued,[n.sessionID]:!1}}):e===`idle`&&Z_(n.sessionID);break}case`session.idle`:Z_(n.sessionID);break;case`permission.asked`:K.permissions.some(e=>e.id===n.id)||q({permissions:[...K.permissions,{id:n.id,sessionID:n.sessionID,action:n.action??``,resources:n.resources??[],seq:pg()}]});break;case`form.created`:{let e=n.form;e?.id&&!K.forms.some(t=>t.id===e.id)&&q({forms:[...K.forms,{...e,seq:pg()}]});break}case`form.replied`:case`form.cancelled`:case`form.deleted`:q({forms:K.forms.filter(e=>e.id!==n.id)});break;case`permission.replied`:q({permissions:K.permissions.filter(e=>e.id!==n.id)});break;case`question.asked`:if(!K.questions.some(e=>e.id===n.id)){let e=n;q({questions:[...K.questions,{id:n.id,sessionID:n.sessionID,questions:e.questions??[],tool:e.tool,seq:pg()}]})}break;case`question.replied`:case`question.rejected`:q({questions:K.questions.filter(e=>e.id!==n.requestID)});break;case`session.shell.started`:case`session.shell.ended`:r&&Qg(r);break;case`session.compaction.started`:case`session.compaction.ended`:case`session.compaction.failed`:r&&(Qg(r),M_(r));break;default:(t.startsWith(`form.`)||t.startsWith(`question.`)||t===`session.skill.activated`)&&Zg()}}var ev=new Map;async function tv(e){if(!(!e||Eg(e))){lv(e);try{let t=(await G.webuiReplay(e,ev.get(e))).data??[];for(let n of t)n.id&&ev.set(e,n.id),pv({id:n.id,created:n.created,type:n.type,data:n.data});t.length>0&&Hh(`sse`,`replay ${e}: ${t.length} event(s)`)}catch{}}}function nv(){let e=new Set;for(let t of K.panes)t.sessionID&&e.add(t.sessionID);K.currentSessionID&&e.add(K.currentSessionID);for(let[t,n]of Object.entries(K.running))n&&e.add(t);return[...e].filter(e=>!!e&&!Eg(e))}var rv=new Set,iv=1e3,av=3e5;function ov(e){!e||Eg(e)||rv.has(e)||(rv.add(e),sv(e).finally(()=>rv.delete(e)))}async function sv(e){for(;;){if(!K.running[e]&&!K.queued[e])return;let t=await G.sessionWait(e,AbortSignal.timeout(av)).catch(()=>-1);if(t===204){if(K.running[e]){Hh(`run`,`wait: engine idle ${e}`),qg(e);let t={...K.running};delete t[e],K_.delete(e),q({running:t}),L_(e),Ty(e)}if(!K.running[e]&&!K.queued[e])return;await new Promise(e=>setTimeout(e,iv));continue}if(t===404){bv(e,`wait 404`);return}if(!K.running[e]&&!K.queued[e])return;await new Promise(e=>setTimeout(e,iv))}}var cv=new Map;function lv(e){!e||Eg(e)||G.sessionLogHead(e).then(t=>{t!==null&&cv.get(e)!==t&&(cv.set(e,t),Hh(`sse`,`log head ${e}: ${t}`))}).catch(()=>void 0)}var uv=!1,dv=[],fv=null;function pv(e){dv.push(e),!fv&&(fv=setTimeout(()=>{fv=null;let e=dv.splice(0,dv.length);jg(()=>{for(let t of e)try{$_(t)}catch(e){console.warn(`event handler failed:`,t.type,e)}})},16))}function mv(){if(!uv){if(uv=!0,Hh(`boot`,`start`),Hh(`boot`,`build pending-panel-v6`),typeof window<`u`){let e=()=>{let e=Ig();e?Pv(e,{history:`none`}):Lg()?(Wy(null),$v().catch(()=>void 0)):(Pv(null,{history:`none`}),$v())};window.addEventListener(`popstate`,e);let t=zv();t.length>0&&q({panes:[{id:wg,sessionID:null},...t]}),e()}Yg().then(Bv).catch(()=>void 0),Zg(),G.health().then(e=>q({serviceOK:e.ok})).catch(()=>q({serviceOK:!1})),Jh(e=>pv(e.data),{onOpen:()=>{q({connected:!0}),Yg(),Zg();for(let e of nv())tv(e)}}).then(()=>q({connected:!1})),hv()}}function hv(){ig({isBusy:()=>{let e=K;for(let t of Object.values(e.running))if(t)return!0;for(let t of Object.values(e.queued))if(t)return!0;for(let t of Object.values(e.pending))if(t.length>0)return!0;return e.live.length>0},isSseStale:qh}),og({name:`messages`,minInterval:2e3,intervals:{live:2e3,idle:12e3,hidden:6e4},run:()=>vv()}),og({name:`queues`,minInterval:1e4,intervals:{live:1e4,idle:12e3,hidden:6e4},run:()=>Zg()}),og({name:`sessions`,minInterval:1e4,intervals:{live:1e4,idle:2e4,hidden:6e4},run:()=>Yg()})}async function gv(e,t){K.panes.some(t=>t.sessionID===e)&&S_(e,t)}var _v=!1;async function vv(){if(_v)return;let e=new Set;for(let[t,n]of Object.entries(K.running))n&&e.add(t);for(let t of Object.keys(K.pending))(K.pending[t]?.length??0)>0&&!Eg(t)&&e.add(t);for(let t of K.panes){let n=t.sessionID;n&&!Eg(n)&&(r_(n).length>0||K.queued[n])&&e.add(n)}for(let t of K.live)Eg(t.sessionID)||e.add(t.sessionID);if(e.size!==0){_v=!0;try{for(let t of e){let e=e_(t);try{let n=await G.messages(t,50);if($g.get(t)!==e)continue;yv.delete(t);let r=K.messages[t]?.length??0,i=[...n.data].reverse();await gv(t,i);let a=K.messages[t]?.length??0;a!==r&&Hh(`poll`,`reconcile ${t}: ${r} -> ${a} messages`),((K.pending[t]?.length??0)>0||K.queued[t])&&await dy(t,i)}catch(e){let n=e instanceof Error?e.message:String(e),r=yv.get(t)??{count:0};r.count+=1,yv.set(t,r),(n.includes(`404`)||r.count>=3)&&(bv(t,n),yv.delete(t))}}}finally{_v=!1}}}var yv=new Map;function bv(e,t){Hh(`poll`,`retiring vanished session ${e} (${t})`);let n={...K.running};delete n[e];let r={...K.queued};delete r[e];let i={...K.pending};delete i[e],K_.delete(e),Gg.delete(e),Kg.delete(e),ev.delete(e);let a=wy.get(e);a&&(clearTimeout(a),wy.delete(e)),q({running:n,queued:r,pending:i,live:K.live.filter(t=>t.sessionID!==e)}),l_(e),yv.delete(e)}function xv(){q({shellPanelTick:K.shellPanelTick+1})}function Sv(e){if(e===`runsDialog`){q({runsPanelOpen:!0,uiSignals:{...K.uiSignals,[e]:K.uiSignals[e]+1}});return}q({uiSignals:{...K.uiSignals,[e]:K.uiSignals[e]+1}})}function Cv(){q({runsPanelOpen:!0,uiSignals:{...K.uiSignals,runsDialog:K.uiSignals.runsDialog+1}})}function wv(){K.runsPanelOpen&&q({runsPanelOpen:!1})}function Tv(e){q({runsSelection:e})}function Ev(){K.subagentComposerOpen||q({subagentComposerOpen:!0})}function Dv(){let e=K.revertPrompt;return K.revertPrompt!==null&&q({revertPrompt:null}),e}function Ov(e,t){return e.filter(e=>e.parentID===t).sort((e,t)=>t.time.updated-e.time.updated)}function kv(e,t){if(!t)return!1;if(e.running[t]||e.queued[t])return!0;for(let n of e.sessions)if(n.parentID===t&&(e.running[n.id]||e.queued[n.id]))return!0;return!1}function Av(e,t){if(!t)return e;let n=e.findIndex(e=>e.id===t);return n===-1?e:e.slice(0,n)}function jv(e,t,n){let r=e.revertMarkers[t];return r===void 0?(n??e.sessionDetails[t])?.revert?.messageID:r??void 0}function Mv(e,t){K.revertMarkers[e]!==t&&q({revertMarkers:{...K.revertMarkers,[e]:t}})}function Nv(e){let t=jv(K,e);if(!t)return;let n=Av(K.messages[e]??[],t);q({messages:{...K.messages,[e]:n}})}async function Pv(e,t={}){if(Hh(`session`,`select`,e??`null`),t.history!==`none`&&Rg(e,t.history??`push`),q_.clear(),e===`__draft__`){let e=Lv(Tg);q({currentSessionID:Tg,live:a_(e),subagentComposerOpen:!1,panes:e,focusedPane:wg});return}let n=Lv(e);q({currentSessionID:e,live:a_(n),subagentComposerOpen:!1,panes:n,focusedPane:wg,queued:e?{...K.queued,[e]:!1}:K.queued}),e?(Qv(e),u_(e),tv(e),K.draftWorkspace!==null&&q({draftWorkspace:null}),!K.sessions.some(t=>t.id===e)&&!K.sessionDetails[e]&&M_(e),await Qg(e),dy(e).catch(()=>void 0)):K.draftWorkspace!==null&&q({draftWorkspace:null})}var Fv=`webui.splits`,Iv=0;function Lv(e){let t=K.panes.length>0?K.panes.slice():[{id:wg,sessionID:null}];return t[0]={id:wg,sessionID:e},t}function Rv(){try{localStorage.setItem(Fv,JSON.stringify(K.panes.slice(1)))}catch{}}function zv(){try{let e=localStorage.getItem(Fv);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>!!e&&typeof e.id==`string`&&typeof e.sessionID==`string`&&e.id!==`main`):[]}catch{return[]}}function Bv(){let e=e=>K.sessions.some(t=>t.id===e)||!!K.sessionDetails[e],t=K.panes.filter((t,n)=>n===0||e(t.sessionID));t.length!==K.panes.length&&q({panes:t,...t.some(e=>e.id===K.focusedPane)?{}:{focusedPane:wg}})}async function Vv(e){K.currentSessionID!==e&&(q({currentSessionID:e,live:a_(K.panes),subagentComposerOpen:!1,pendingAgent:null,pendingModel:null,...e?{queued:{...K.queued,[e]:!1}}:{}}),e&&!Eg(e)&&(u_(e),tv(e),await Qg(e),dy(e).catch(()=>void 0)))}async function Hv(e){let t=K.panes.find(t=>t.id===e);t&&K.focusedPane!==e&&(Hh(`pane`,`focus ${e}`),q({focusedPane:e}),await Vv(t.sessionID))}function Uv(){q({splitPickerOpen:!0})}function Wv(){K.splitPickerOpen&&q({splitPickerOpen:!1})}async function Gv(e){if(!e||Eg(e)||K.panes.length-1>=3||K.panes.some(t=>t.sessionID===e))return!1;let t={id:`${wg}-${Date.now().toString(36)}-${++Iv}`,sessionID:e};return Hh(`pane`,`split open ${e} (${t.id})`),q({panes:[...K.panes,t],focusedPane:t.id,splitPickerOpen:!1}),Rv(),!K.sessions.some(t=>t.id===e)&&!K.sessionDetails[e]&&M_(e),await Vv(e),!0}async function Kv(e){if(e===`main`)return;let t=K.panes.filter(t=>t.id!==e);if(t.length===K.panes.length)return;Hh(`pane`,`close ${e}`);let n=K.focusedPane===e;q({panes:t,...n?{focusedPane:wg}:{}}),Rv(),n&&await Vv(K.panes[0].sessionID)}async function qv(e,t){let n=K.panes.findIndex(t=>t.id===e);if(n<=0||!t||Eg(t))return;let r=K.panes.slice();r[n]={...r[n],sessionID:t},q({panes:r}),Rv(),K.focusedPane===e?await Vv(t):Qg(t)}async function Jv(e){if(K.focusedPane===`main`||K.panes.length<=1){await Pv(e);return}await qv(K.focusedPane,e)}function Yv(e=Ng()){return e.focusedPane}function Xv(e){Eg(e)||(K.messages[e]?.length??0)>0||Qg(e)}var Zv=`webui.last-session`;function Qv(e){try{localStorage.setItem(Zv,e)}catch{}}async function $v(){if(/^\/ext\//.test(window.location.pathname))return;let e=null;try{e=localStorage.getItem(Zv)}catch{return}!e||K.currentSessionID||(await Yg(),!(K.currentSessionID||!e)&&K.sessions.some(t=>t.id===e)&&(Hh(`session`,`reopen last session ${e}`),await Pv(e,{history:`replace`})))}async function ey(e,t,n){if(Hh(`send`,`prompt ${e}: ${t.slice(0,80)}${n?.delivery?` (${n.delivery})`:``}`),await I_(e),!Eg(e)&&ty(e)){Nv(e),await oy(e,t,n?.delivery);return}Nv(e),Dy(e,t),Oy(e);try{if(await G.prompt(e,t),ov(e),e===`__draft__`||(K.messages.__draft__?.length??0)===0)try{let{clearDraft:e}=await ug(async()=>{let{clearDraft:e}=await Promise.resolve().then(()=>zx);return{clearDraft:e}},void 0);e(Tg)}catch{}}catch(t){throw ky(e),Ay(e,t),t}}function ty(e){return K.running[e]||K.queued[e]||K.activeIDs.includes(e)?!0:n_(e)&&r_(e).length>0}var ny=0;function ry(e,t){let n={...K.pending};t&&t.length>0?n[e]=t:delete n[e],q({pending:n})}function iy(e,t){ry(e,[...K.pending[e]??[],t])}function ay(e,t,n){let r=K.pending[e];if(!r?.some(e=>e.key===t))return;let i=!1,a=r.map(e=>{if(e.key!==t)return e;let r=n(e);return r!==e&&(i=!0),r});i&&ry(e,a)}async function oy(e,t,n){let r=`pend_${Date.now().toString(36)}_${++ny}`;iy(e,{key:r,text:t,state:`sending`,admittedAt:Date.now(),...n?{delivery:n}:{}});try{let i=await G.prompt(e,t,n);ov(e);let a=i?.data??i;a?.id&&ay(e,r,e=>({...e,state:`tracked`,inboxID:a.id,delivery:a.delivery??n}))}catch(t){throw sy(e,r),Ay(e,t),t}}function sy(e,t){let n=K.pending[e];n?.some(e=>e.key===t)&&ry(e,n.filter(e=>e.key!==t))}function cy(e){let t=e.payload;return typeof t?.text==`string`?t.text:``}function ly(e,t){return t===``||ty(e)?!1:(K.messages[e]??[]).some(e=>e.type===`user`&&e.id.startsWith(`msg_local_`)&&e.text===t)}function uy(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.key===r.key&&e.text===r.text&&e.state===r.state&&e.inboxID===r.inboxID&&e.delivery===r.delivery})}async function dy(e,t){let n=(await G.inboxList(e)).data.filter(e=>e.type===`user`),r=new Set(n.map(e=>e.id)),i=K.pending[e]??[],a=[...i],o=null,s=new Set;if(t){o=new Set(t.filter(e=>e.type===`user`&&!e.id.startsWith(`msg_local_`)).map(e=>e.id));for(let e of i)(e.inboxID&&o.has(e.inboxID)||!e.inboxID&&e.admittedAt!==void 0&&t.some(t=>t.type===`user`&&!t.id.startsWith(`msg_local_`)&&t.text===e.text&&t.time.created>=e.admittedAt-6e4))&&s.add(e.key)}let c=new Set(a.filter(e=>e.inboxID).map(e=>e.inboxID));a=a.map(e=>{if(e.state!==`sending`)return e;let t=n.filter(t=>!c.has(t.id)&&cy(t)===e.text);if(t.length===0)return e;let r=t.reduce((e,t)=>t.timeCreated>=e.timeCreated?t:e);return c.add(r.id),{...e,state:`tracked`,inboxID:r.id,delivery:r.delivery}}),a=a.filter(e=>!s.has(e.key)&&!(e.state===`tracked`&&e.inboxID&&!r.has(e.inboxID)));for(let t of[...n].sort((e,t)=>e.timeCreated-t.timeCreated)){if(a.some(e=>e.inboxID===t.id)||o?.has(t.id))continue;let n=cy(t);ly(e,n)||a.push({key:`inbox_${t.id}`,text:n,state:`tracked`,inboxID:t.id,delivery:t.delivery,admittedAt:Date.now()})}let l=new Set(s);for(let e of i)e.state===`tracked`&&e.inboxID&&!r.has(e.inboxID)&&l.add(e.key);let u=new Set(a.map(e=>e.key));for(let t of K.pending[e]??[])!u.has(t.key)&&!l.has(t.key)&&a.push(t);uy(i,a)||ry(e,a)}function fy(e,t){let n=K.pending[e];n?.some(e=>e.inboxID===t.id)||n?.some(e=>e.state===`sending`&&e.text===t.text)||ly(e,t.text)||iy(e,{key:`inbox_${t.id}`,text:t.text,state:`tracked`,inboxID:t.id,delivery:t.delivery??`steer`,admittedAt:Date.now()})}function py(e){let t=!1,n={...K.pending};for(let[r,i]of Object.entries(n)){if(!i.some(t=>t.inboxID===e))continue;let a=i.filter(t=>t.inboxID!==e);t=!0,a.length>0?n[r]=a:delete n[r]}t&&q({pending:n})}function my(e){if(!e||Eg(e))throw Error(`send before materialize`);return!0}async function hy(e,t){let n=K.currentSessionID;if(n){my(n),Hh(`send`,`command ${n}: /${e} ${t??``}`.trim()),await I_(n),Nv(n),Dy(n,t?`/${e} ${t}`:`/${e}`),Oy(n);try{await G.runCommand(n,e,t)}catch(e){throw ky(n),Ay(n,e),e}}}async function gy(e){let t=K.currentSessionID;if(t){my(t),Hh(`send`,`shell ${t}: !${e.slice(0,60)}`),await I_(t),Nv(t),Dy(t,`!${e}`),Oy(t);try{await G.sessionShell(t,e)}catch(e){throw ky(t),Ay(t,e),e}}}async function _y(e,t){let n=K.currentSessionID;if(n){my(n),Hh(`send`,`prompt+files ${n}: ${e.slice(0,80)}`),await I_(n),Nv(n),Dy(n,e),Oy(n);try{await G.promptWithFiles(n,e,t);try{let{clearDraft:e}=await ug(async()=>{let{clearDraft:e}=await Promise.resolve().then(()=>zx);return{clearDraft:e}},void 0);e(Tg)}catch{}}catch(e){throw ky(n),Ay(n,e),e}}}function vy(e){if(!K.sendErrors[e])return;let t={...K.sendErrors};delete t[e],q({sendErrors:t})}function yy(e,t){let n=K.pending[e]?.find(e=>e.key===t);n&&(sy(e,t),n.state===`tracked`&&n.inboxID&&G.inboxDelete(e,n.inboxID).catch(t=>{Ay(e,t),iy(e,n)}))}function by(e,t,n){let r=K.pending[e]?.find(e=>e.key===t);if(!r||(r.delivery??`steer`)===n)return;let i=r.delivery??`steer`;ay(e,t,e=>({...e,delivery:n})),(r.state===`tracked`&&r.inboxID?n===`steer`?G.inboxSteer(e,r.inboxID):G.inboxQueue(e,r.inboxID):Promise.resolve()).catch(n=>{ay(e,t,e=>({...e,delivery:i})),Ay(e,n)})}function xy(e,t){let n=K.pending[e]?.find(e=>e.key===t);!n||n.state!==`tracked`||(n.delivery??`steer`)===`queue`&&by(e,t,`steer`)}async function Sy(e){!e||Eg(e)||(Fy(),await G.interrupt(e,!0),qg(e),q({running:{...K.running,[e]:!1},queued:{...K.queued,[e]:!1}}))}var Cy=1800,wy=new Map;function Ty(e){if(Eg(e))return;let t=wy.get(e);t&&clearTimeout(t);let n=setTimeout(()=>{wy.delete(e),Ey(e)},Cy);wy.set(e,n)}async function Ey(e){let t=(K.pending[e]??[]).find(e=>e.delivery===`queue`&&e.state===`tracked`&&!!e.inboxID);if(t?.inboxID&&!(K.running[e]||K.queued[e]))try{if(!(await G.inboxList(e)).data.some(e=>e.id===t.inboxID)||K.running[e]||K.queued[e])return;Hh(`run`,`drain ${e}: steering parked queue item ${t.inboxID}`),ay(e,t.key,e=>({...e,delivery:`steer`})),await G.inboxSteer(e,t.inboxID)}catch(e){console.warn(`queue drain failed:`,e)}}function Dy(e,t){let n={id:`msg_local_${Date.now()}`,type:`user`,text:t,time:{created:Date.now()}};q({messages:{...K.messages,[e]:[...K.messages[e]??[],n]}})}function Oy(e){Hh(`run`,`pending ${e} (awaiting run start)`),V_(e),q({queued:{...K.queued,[e]:!0}})}function ky(e){q({queued:{...K.queued,[e]:!1}})}function Ay(e,t){let n=t instanceof Error?t.message:String(t),r;t&&typeof t==`object`&&`payload`in t&&(r=t.payload);let i=r&&typeof r==`object`&&`message`in r?{type:String(r.name??`error`),message:String(r.message??n)}:{type:`request-failed`,message:n};console.warn(`send failed:`,i.type,i.message),q({sendErrors:{...K.sendErrors,[e]:i}})}async function jy(e){let t=K.currentSessionID;!t||Eg(t)||(await G.activateSkill(t,e),Zg())}async function My(e){let t=e??K.currentSessionID;!t||Eg(t)||(Fy(),await G.interrupt(t),qg(t),q({running:{...K.running,[t]:!1},queued:{...K.queued,[t]:!1}}))}var Ny=2500,Py=null;function Fy(){Py&&=(clearTimeout(Py),null),K.interruptArmed&&q({interruptArmed:!1})}function Iy(){let e=K.currentSessionID;if(!(!e||!K.running[e])){if(!K.interruptArmed){Py&&clearTimeout(Py),q({interruptArmed:!0}),Py=setTimeout(()=>{Py=null,q({interruptArmed:!1})},Ny);return}My()}}async function Ly(e){try{await G.sessionBackground(e),Bg()}catch(e){console.warn(`backgroundSubagents failed:`,e)}}async function Ry(e,t){let n=K.permissions.find(t=>t.id===e);if(n)try{await G.replyPermission(n.sessionID,e,t)}finally{q({permissions:K.permissions.filter(t=>t.id!==e)})}}async function zy(e,t){let n=K.forms.find(t=>t.id===e);if(n)try{await G.replyForm(n.sessionID,e,t)}finally{q({forms:K.forms.filter(t=>t.id!==e)})}}async function By(e){let t=K.forms.find(t=>t.id===e);if(t)try{await G.cancelForm(t.sessionID,e)}finally{q({forms:K.forms.filter(t=>t.id!==e)})}}async function Vy(e,t){let n=K.questions.find(t=>t.id===e);if(n){try{await G.sessionQuestionReply(n.sessionID,e,t)}catch(t){return Hh(`panel`,`question reply FAILED ${e}:`,t instanceof Error?t.message:String(t)),!1}return q({questions:K.questions.filter(t=>t.id!==e)}),!0}let r=K.forms.find(t=>t.id===e&&yg(t));if(!r)return!1;let i={};r.fields.forEach((e,n)=>{let r=t[n]??[],a=e.type===`multiselect`;i[e.key]=a?r:r[0]??``});try{await G.replyForm(r.sessionID,r.id,i)}catch(e){return Hh(`panel`,`question reply FAILED ${r.id}:`,e instanceof Error?e.message:String(e)),!1}return q({forms:K.forms.filter(e=>e.id!==r.id)}),!0}async function Hy(e){let t=K.questions.find(t=>t.id===e);if(t){try{await G.sessionQuestionReject(t.sessionID,e)}finally{q({questions:K.questions.filter(t=>t.id!==e)})}return}let n=K.forms.find(t=>t.id===e&&yg(t));n&&await By(n.id)}function Uy(e){e.kind===`permission`?Ry(e.req.id,`reject`):e.kind===`question`?Hy(e.req.id):By(e.req.id)}function Wy(e){let t=e=>{if(!(!e||Eg(e)))return(K.sessions.find(t=>t.id===e)??K.sessionDetails[e])?.location?.directory},n=K.currentSessionID&&!Eg(K.currentSessionID)?K.sessions.find(e=>e.id===K.currentSessionID)??K.sessionDetails[K.currentSessionID]:void 0,r=t(K.currentSessionID)??(n?.parentID?t(n.parentID):void 0),i=e??K.pendingWorkspace??K.draftWorkspace??r??null,a=Eg(K.currentSessionID);Hh(`session`,`draft ${a?`retarget`:`open`} (workspace=${i??`default`})`);let o=Lv(Tg);q({currentSessionID:Tg,panes:o,focusedPane:wg,draftWorkspace:i,pendingWorkspace:null,live:a_(o),...a?{}:{pendingAgent:null,pendingModel:null}}),typeof window<`u`&&Rg(Tg,`push`)}function Gy(e){q({pendingWorkspace:e})}function Ky(e,t){q({highlightSessionID:e,highlightMessageID:t})}var qy=!1;async function Jy(e){let t=await P_(),n=(await G.createSession({title:null,agent:null,model:t??null,location:e?{directory:e}:null})).data.id;return t&&Hh(`model`,`new session ${n} -> ${t.providerID}/${t.id}`),await Yg(),await M_(n),n}async function Yy(e){if(!Eg(K.currentSessionID)&&K.draftWorkspace===null)throw Error(`no draft session`);if(qy)throw Error(`draft already materializing`);qy=!0;try{let e=K.draftWorkspace;Hh(`session`,`draft -> create (workspace=${e??`default`})`);let t=await Jy(e),n=K.messages.__draft__??[];q_.clear();let r=Lv(t);return q({currentSessionID:t,panes:r,focusedPane:wg,draftWorkspace:null,live:a_(r),messages:{...K.messages,[t]:n,[Tg]:[]}}),Qv(t),typeof window<`u`&&Rg(t,`replace`),t}finally{qy=!1}}async function Xy(e={}){Wy(null)}async function Zy(e,t){q({pendingAgent:t})}async function Qy(e,t){q({pendingModel:t})}async function $y(e,t){await G.renameSession(e,t),await Yg()}async function eb(e,t){let n=await G.forkSession(e,t);return await Yg(),n.data.id}async function tb(e){return(await G.exportSession(e)).data}async function nb(e,t=`steer`){await G.compactSession(e,t),await Yg()}async function rb(e){K.running[e]&&await My(e);let t=K.sessionDetails[e]??await G.getSession(e).then(e=>e.data).catch(()=>void 0),n=jv(K,e,t??void 0),r=[...Av(K.messages[e]??[],n)].reverse().find(e=>e.type===`user`);if(!(!r||r.id.startsWith(`msg_local_`))){try{await G.revertStage(e,r.id),Mv(e,r.id)}finally{M_(e),Qg(e),Bg()}q({revertPrompt:r.text??null})}}async function ib(e){let t=K.sessionDetails[e]??await G.getSession(e).then(e=>e.data).catch(()=>void 0),n=jv(K,e,t??void 0);if(n)try{let t=(K.messages[e]??[]).find(e=>e.type===`user`&&e.id>n);t?(await G.revertStage(e,t.id),Mv(e,t.id)):(await G.revertClear(e),Mv(e,null))}finally{M_(e),Qg(e),Bg()}}function ab(e,t,n){q({pendingEdit:{sessionID:e,messageID:t,originalText:n??``},revertPrompt:n??null})}function ob(){q({pendingEdit:null})}async function sb(e){let t=K.pendingEdit;if(!t||t.sessionID!==e)return;K.running[e]&&await My(e);try{await G.revertStage(e,t.messageID)}finally{M_(e),Qg(e),Bg()}let n=K.messages[e]??[],r=n.findIndex(e=>e.id===t.messageID),i=r===-1?n:n.slice(0,r);q({messages:{...K.messages,[e]:i},revertMarkers:{...K.revertMarkers,[e]:t.messageID},pendingEdit:null})}async function cb(e,t,n){ab(e,t,n)}async function lb(e,t){let n=(await G.forkSession(e,{type:`before`,messageID:t})).data.id;return n&&await Pv(n),n}var ub=[`ctrl`,`shift`,`meta`,`alt`],db={control:`ctrl`,cmd:`meta`,command:`meta`,super:`meta`,esc:`escape`,return:`enter`,up:`arrowup`,down:`arrowdown`,left:`arrowleft`,right:`arrowright`};function fb(e){let t=e.trim().toLowerCase();return db[t]??t}function pb(e){let t=new Set,n=``;for(let r of e.split(`+`).map(fb))ub.includes(r)?t.add(r):n=r;return{mods:t,key:n}}function mb(e,t){let{mods:n,key:r}=pb(e);return!(!r||r!==fb(t.key)||n.has(`ctrl`)!==t.ctrlKey||n.has(`shift`)!==t.shiftKey||n.has(`meta`)!==t.metaKey||n.has(`alt`)!==t.altKey)}function hb(e){let t=(0,E.useRef)(e);t.current=e,(0,E.useEffect)(()=>{let e=e=>{if(e.repeat)return;let n=Object.keys(t.current).find(t=>mb(t,e));if(!n)return;let r=t.current[n];if(!r)return;let{mods:i}=pb(n);i.size===0&&gb(e.target)||(e.preventDefault(),r(e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function gb(e){let t=e;return t?t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable:!1}function _b(){let[e,t]=(0,E.useState)(Dh);return(0,E.useEffect)(()=>kh(()=>t(Dh())),[]),e}var vb=`../theme/themes`;function yb(){let[e,t]=(0,E.useState)(!1),n=J(e=>e.sessions),r=J(e=>e.currentSessionID),i=_b(),[a,o]=(0,E.useState)(null);hb({"ctrl+p":()=>t(e=>!e),escape:()=>t(!1)}),(0,E.useEffect)(()=>{let e=!1;return ug(()=>import(vb).then(t=>{if(e)return;let n=t;if(typeof n.applyTheme!=`function`)return;let r=n.listThemes?n.listThemes():(n.THEMES??[]).map(e=>({id:e.id,label:e.label}));r.length&&o({list:r,apply:n.applyTheme,current:n.getTheme?.()??null})}),[]).catch(()=>{}),()=>{e=!0}},[]);let s=[...n].filter(e=>!e.parentID).sort((e,t)=>t.time.updated-e.time.updated),c=typeof St==`function`?St():[];return(0,R.jsxs)(mh,{open:e,onOpenChange:t,children:[(0,R.jsx)(hh,{placeholder:`Type a command or search…`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),uh(1)):e.key===`ArrowUp`?(e.preventDefault(),uh(-1)):e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),dh())}}),(0,R.jsxs)(gh,{children:[(0,R.jsx)(_h,{children:`No results found.`}),(0,R.jsxs)(vh,{heading:`Actions`,children:[(0,R.jsxs)(bh,{onSelect:()=>{t(!1),Xy()},children:[(0,R.jsx)(xe,{}),(0,R.jsx)(`span`,{children:`New session`}),(0,R.jsx)(xh,{children:`Ctrl N`})]}),(0,R.jsxs)(bh,{onSelect:()=>Oh(`showReasoning`,!i.showReasoning),children:[i.showReasoning?(0,R.jsx)(me,{}):(0,R.jsx)(he,{}),(0,R.jsxs)(`span`,{children:[i.showReasoning?`Hide`:`Show`,` thinking`]})]}),(0,R.jsxs)(bh,{onSelect:()=>Oh(`showToolDetails`,!i.showToolDetails),children:[i.showToolDetails?(0,R.jsx)(me,{}):(0,R.jsx)(he,{}),(0,R.jsxs)(`span`,{children:[i.showToolDetails?`Hide`:`Show`,` tool details`]})]})]}),(0,R.jsx)(yh,{}),(0,R.jsxs)(vh,{heading:`Sessions`,children:[s.length===0&&(0,R.jsxs)(bh,{disabled:!0,children:[(0,R.jsx)(we,{}),(0,R.jsx)(`span`,{children:`No sessions yet`})]}),s.map(e=>(0,R.jsxs)(bh,{value:`${e.title??`Untitled session`} ${e.id}`,onSelect:()=>{t(!1),Pv(e.id)},children:[(0,R.jsx)(we,{}),(0,R.jsx)(`span`,{className:`truncate`,children:e.title??`Untitled session`})]},e.id))]}),c.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(yh,{}),(0,R.jsx)(vh,{heading:`Extension commands`,children:c.map(e=>{let n=e.keybind;return(0,R.jsxs)(bh,{value:`${e.title} ${e.id} ${n??``}`,onSelect:()=>{t(!1);try{e.run({sessionID:r??void 0})}catch(e){console.error(`[extensions] command failed:`,e)}},children:[(0,R.jsx)(We,{}),(0,R.jsx)(`span`,{className:`truncate`,children:e.title}),n?(0,R.jsx)(xh,{children:n}):null]},e.id)})})]}),a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(yh,{}),(0,R.jsx)(vh,{heading:`Themes`,children:a.list.map(e=>(0,R.jsxs)(bh,{onSelect:()=>a.apply(e.id),children:[(0,R.jsx)(Pe,{}),(0,R.jsx)(`span`,{children:e.label}),a.current===e.id&&(0,R.jsx)(ae,{className:`ml-auto size-4 opacity-100`})]},e.id))})]})]})]})}function bb({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:i}){let a=xb(Sb(r,i),t);if(!n)return E.createElement(e,a);if(typeof n==`function`)return n(a,r);if(!E.isValidElement(n))return null;let o=n.props,s={...xb(a,o),ref:Tb(a.ref,o.ref)};return E.cloneElement(n,s)}function xb(...e){let t={};for(let n of e){if(!n)continue;let e=n;for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let i=t[n];t[n]=n===`className`?[i,r].filter(Boolean).join(` `):n===`style`?{...i,...r}:n===`ref`?Tb(i,r):wb(n)&&typeof i==`function`&&typeof r==`function`?Cb(r,i):r}}return t}function Sb(e,t){let n={};for(let r of Object.keys(e)){let i=e[r],a=t?.[r]?.(i);if(a){Object.assign(n,a);continue}if(r===`slot`){n[`data-slot`]=i;continue}let o=`data-${String(r).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`;typeof i==`boolean`?n[o]=i?``:void 0:i!=null&&(n[o]=String(i))}return n}function Cb(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function wb(e){return/^on[A-Z]/.test(e)}function Tb(...e){let t=e.filter(Boolean);if(t.length!==0)return e=>{for(let n of t)typeof n==`function`?n(e):n&&(n.current=e)}}var Eb=8,Db=64,Ob=0,kb=.5,Ab=180,jb=new Set([`ArrowDown`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`,` `]),Mb={start:!1,end:!1},Nb={currentAnchorId:null,visibleMessageIds:[]};function Pb({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return Mb;let i=Kb({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:i-r.scrollTop-r.clientHeight>t}}function Fb({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:i,visibleMessageIds:a}){if(!e||!i)return Nb;let o=i.getBoundingClientRect(),s=o.top+t+n,c=typeof IntersectionObserver>`u`,l=[],u=null;for(let t of Ib(e,r)){let e=t.dataset.messageId;if(!e)continue;let n=t.dataset.scrollAnchor===`true`,r=n||c?t.getBoundingClientRect():null;(c&&r?r.bottom>s&&r.top<o.bottom:a.has(e))&&l.push(e),n&&r&&r.top<=s+kb&&(u=e)}return l.length===0&&u===null?Nb:{currentAnchorId:u,visibleMessageIds:l}}function Ib(e,t){return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e!==t)}function Lb(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t?.dataset.scrollAnchor===`true`)return t}return null}function Rb(e,t){for(let n of e)if(n.dataset.scrollAnchor===`true`&&!t.has(n))return n;return null}function zb(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor===`true`&&(n+=1,n>1))return!0;return!1}function Bb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor===`true`)return n}return null}function Vb({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let n of Ib(e,t)){if(!n.dataset.messageId)continue;let e=n.getBoundingClientRect();if(e.bottom>r.top&&e.top<r.bottom)return n}return null}function Hb({align:e,element:t,scrollMargin:n,spacer:r,viewport:i}){let a=Ub(t,i),o=t.getBoundingClientRect().height,s=Yb(r);if(e===`center`){let e=Math.max(0,i.clientHeight-s.start-s.end);return a-s.start-(e-o)/2-n}if(e===`end`)return a-i.clientHeight+o+s.end+n;if(e===`nearest`){let e=a+o,t=i.scrollTop+s.start,r=i.scrollTop+i.clientHeight-s.end;return a>=t&&e<=r?i.scrollTop:a<t?a-s.start-n:e-i.clientHeight+s.end+n}return a-s.start-n}function Ub(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Wb(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Gb({content:e,scrollTop:t,spacer:n,viewport:r}){let i=Kb({content:e,spacer:n,viewport:r});return t+r.clientHeight-i}function Kb({content:e,spacer:t,viewport:n}){let r=Ib(e,t),i=Jb(e),a=n.getBoundingClientRect(),o=n.scrollTop,s=i.start+i.end;for(let e of r){let t=e.getBoundingClientRect();s=Math.max(s,t.bottom-a.top+o+i.end)}return s}function qb(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Jb(e){let t=window.getComputedStyle(e);return{end:Zb(t.paddingBlockEnd||t.paddingBottom),start:Zb(t.paddingBlockStart||t.paddingTop)}}function Yb(e){let t=e?.parentElement;return t?Jb(t):{end:0,start:0}}function Xb(e){if(!e)return 0;let t=window.getComputedStyle(e);return Zb(t.rowGap===`normal`?t.gap:t.rowGap)}function Zb(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Qb({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:i,autoScrollRef:a,autoscrollingRef:o,autoscrollingTimeoutRef:s,contentRef:c,defaultScrollPositionAppliedRef:l,itemCountRef:u,messageElementsRef:d,modeRef:f,pendingScrollToMessageRef:p,prependRestoreRef:m,scrollMarginRef:h,scrollPreviousItemPeekRef:g,spacerGapRef:_,spacerHeightRef:v,spacerRef:y,viewportRef:b}=e,x=E.useCallback(e=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),o.current!==e&&(o.current=e,t()),e&&(s.current=window.setTimeout(()=>{s.current=null,o.current=!1,t()},Ab))},[t]),S=E.useCallback(e=>{let t=y.current;if(!t)return;let n=Math.max(0,Math.ceil(e));v.current!==n&&(v.current=n,t.hidden=n===0,t.style.height=`${n}px`,t.style.marginTop=n>0?`${-_.current}px`:``)},[]),C=E.useCallback((e,{behavior:r=`auto`,autoscrolling:i=!1}={})=>{let a=b.current;if(!a)return;let o=Math.max(0,e);if(Math.abs(a.scrollTop-o)<=kb){a.scrollTop=o,t();return}i&&x(!0),a.scrollTo({top:o,behavior:r}),n()},[t,n,x]),w=E.useCallback(({behavior:e=`auto`}={})=>b.current?(S(0),i.current=null,f.current=`free-scrolling`,C(0,{behavior:e}),r(),!0):!1,[r,C,S]),T=E.useCallback(({behavior:e=`auto`}={})=>{let t=b.current;return t?(S(0),i.current=null,f.current=a.current?`following-bottom`:`free-scrolling`,C(qb(t),{autoscrolling:!0,behavior:e}),r(),!0):!1},[r,C,S]),D=E.useCallback((e,{align:t=`start`,behavior:n=`auto`,scrollMargin:a=h.current}={},{keepPreviousPeek:o=!1}={})=>{let s=c.current,l=b.current;if(!s||!l||!s.contains(e))return!1;let u=Hb({align:t,element:e,scrollMargin:o?a+g.current:a,spacer:y.current,viewport:l}),d=Gb({content:s,scrollTop:u,spacer:y.current,viewport:l});return S(d),m.current={element:e,viewportTop:Wb(e,l)},f.current=o?`anchored-to-message`:`settling-jump`,i.current=o?e:null,C(u,{behavior:n}),r(),!0},[r,C,S]),O=E.useCallback(()=>{let e=i.current;return!e||!e.isConnected||f.current!==`anchored-to-message`?!1:D(e,{align:`start`},{keepPreviousPeek:!0})},[D]),k=E.useCallback((e,t)=>{let n=d.current.get(e);return n?(l.current=!0,D(n,t)?(p.current=null,!0):(p.current={messageId:e,options:t},!0)):u.current===0&&(p.current={messageId:e,options:t},l.current=!0,!0)},[D]);return{flushPendingScrollToMessage:E.useCallback(()=>{let e=p.current;if(!e)return!1;let t=d.current.get(e.messageId);return!t||!D(t,e.options)?!1:(p.current=null,l.current=!0,!0)},[D]),reanchorToAnchoredMessage:O,scrollToElement:D,scrollToEnd:T,scrollToMessage:k,scrollToStart:w}}function $b(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:e=>{t(n,e)||(n=e,r.forEach(e=>e()))},subscribe:(e,t,n)=>{let i=r.size===0;return r.add(e),i&&t?.(),()=>{r.delete(e),r.size===0&&n?.()}}}}function ex(e,t){return $b(e,t)}function tx(){return $b(Nb,rx)}function nx(e,t){return e.start===t.start&&e.end===t.end}function rx(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((e,n)=>e===t.visibleMessageIds[n])}function ix({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let i=E.useRef(e),a=E.useRef(!1),o=E.useRef(null),s=E.useRef(!1),c=E.useRef(t),l=E.useRef(0),u=E.useRef(null),d=E.useRef(0),f=E.useRef(e?`following-bottom`:`free-scrolling`),p=E.useRef(new Map),m=E.useRef(null),h=E.useRef(null),g=E.useRef(null),_=E.useRef(r),v=E.useRef(!0),y=E.useRef(null),b=E.useRef(n),x=E.useRef(null),S=E.useRef(0),C=E.useRef(0),w=E.useRef(null),T=E.useRef(null),D=E.useRef(null),O=E.useRef(null),k=E.useRef(null),A=E.useRef(null),j=E.useRef(null),M=E.useRef(null),N=E.useRef(new Set),ee=E.useRef(new WeakSet);return D.current===null&&(D.current=ex(Mb,nx)),M.current===null&&(M.current=tx()),i.current=e,c.current=t,b.current=n,_.current=r,{autoScrollRef:i,autoscrollingRef:a,autoscrollingTimeoutRef:O,streamingTurnRef:g,contentRef:o,defaultScrollPositionAppliedRef:s,firstItemRef:u,itemCountRef:l,lastScrollTopRef:d,messageElementsRef:p,modeRef:f,pendingScrollFrameRef:x,pendingScrollToMessageRef:m,prependRestoreRef:h,preserveScrollOnPrependRef:v,rootRef:y,scrollEdgeThresholdRef:c,scrollMarginRef:b,scrollPreviousItemPeekRef:_,spacerGapRef:S,spacerHeightRef:C,spacerRef:w,stateFrameRef:T,stateStore:D.current,viewportRef:k,visibilityFrameRef:A,visibilityObserverRef:j,visibilityStore:M.current,visibleMessageIdsRef:N,handledScrollAnchorsRef:ee}}function ax(e,t){return E.useCallback(n=>{e.current=n,n&&t()},[e,t])}function ox({autoScroll:e=!1,defaultScrollPosition:t=`end`,scrollEdgeThreshold:n=Eb,scrollPreviousItemPeek:r=Db,scrollMargin:i=Ob}){let a=ix({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:i,scrollPreviousItemPeek:r}),{streamingTurnRef:o,autoScrollRef:s,autoscrollingRef:c,autoscrollingTimeoutRef:l,contentRef:u,defaultScrollPositionAppliedRef:d,firstItemRef:f,itemCountRef:p,lastScrollTopRef:m,messageElementsRef:h,modeRef:g,pendingScrollFrameRef:_,pendingScrollToMessageRef:v,prependRestoreRef:y,preserveScrollOnPrependRef:b,rootRef:x,scrollEdgeThresholdRef:S,scrollMarginRef:C,scrollPreviousItemPeekRef:w,spacerGapRef:T,spacerHeightRef:D,spacerRef:O,stateFrameRef:k,stateStore:A,viewportRef:j,visibilityFrameRef:M,visibilityObserverRef:N,visibilityStore:ee,visibleMessageIdsRef:te,handledScrollAnchorsRef:P}=a,F=E.useRef(t);F.current!==t&&(F.current=t,d.current=!1);let ne=E.useCallback(e=>{let t=x.current,n=j.current,r=[e.start&&`start`,e.end&&`end`].filter(Boolean).join(` `),i=c.current;for(let e of[t,n])e&&(r?e.setAttribute(`data-scrollable`,r):e.removeAttribute(`data-scrollable`),e.toggleAttribute(`data-autoscrolling`,i))},[]),re=E.useCallback(e=>{let t=j.current?.scrollTop??0,n=t<m.current-kb;m.current=t,s.current&&!e.end&&g.current!==`settling-jump`&&g.current!==`anchored-to-message`?g.current=`following-bottom`:g.current===`following-bottom`&&e.end&&n&&!c.current&&(g.current=`free-scrolling`)},[]),ie=E.useCallback(()=>{let e=Pb({content:u.current,scrollEdgeThreshold:S.current,spacer:O.current,viewport:j.current});re(e);let t=g.current===`following-bottom`?{...e,end:!1}:e;ne(t),A.setSnapshot(t)},[re,A,ne]),ae=E.useCallback(()=>{k.current===null&&(k.current=window.requestAnimationFrame(()=>{k.current=null,ie()}))},[ie]),I=E.useCallback(()=>{ee.hasListeners()&&M.current===null&&(M.current=window.requestAnimationFrame(()=>{M.current=null,ee.hasListeners()&&ee.setSnapshot(Fb({content:u.current,scrollMargin:C.current,scrollPreviousItemPeek:w.current,spacer:O.current,viewport:j.current,visibleMessageIds:te.current}))}))},[ee]),{flushPendingScrollToMessage:L,reanchorToAnchoredMessage:oe,scrollToElement:se,scrollToEnd:ce,scrollToMessage:le,scrollToStart:ue}=Qb({refs:a,commitScrollState:ie,scheduleStateCommit:ae,scheduleVisibilitySync:I}),de=E.useCallback(()=>{let e=y.current,t=j.current;if(!e||!t||!e.element.isConnected)return!1;let n=Wb(e.element,t)-e.viewportTop;return Math.abs(n)<=kb?!1:(t.scrollTop+=n,e.viewportTop=Wb(e.element,t),ae(),I(),!0)},[ae,I]),fe=E.useCallback(()=>{let e=u.current,t=j.current;if(!e||!t){y.current=null;return}let n=Vb({content:e,spacer:O.current,viewport:t});y.current=n?{element:n,viewportTop:Wb(n,t)}:null},[]),pe=E.useCallback(()=>{_.current===null&&(_.current=window.requestAnimationFrame(()=>{_.current=null,L()&&fe()}))},[fe,L]),me=E.useCallback(()=>{if(!t||d.current||p.current===0)return!1;let e=!1;if(t===`last-anchor`){let t=u.current,n=j.current,r=t&&n?Bb(Ib(t,O.current)):null;if(!t||!n||!r)e=ce({behavior:`auto`});else{let i=Ub(r,n);e=Kb({content:t,spacer:O.current,viewport:n})-i<=n.clientHeight?ce({behavior:`auto`}):se(r,{align:`start`},{keepPreviousPeek:!0})}}else e=t===`end`?ce({behavior:`auto`}):ue({behavior:`auto`});return e?(d.current=!0,!0):!1},[t,se,ce,ue]),he=E.useCallback(()=>{let e=u.current;if(!e)return;let t=Ib(e,O.current),n=p.current,r=f.current;p.current=t.length,f.current=t[0]??null,(()=>{if(L())return;if(n===0){if(me()||t.length>0&&s.current&&ce({behavior:`auto`}))return;ie(),I();return}let e=r?t.indexOf(r):-1;if(b.current&&e>0){de();return}if(t.length>n){let e=Lb(t,n);if(e){if(s.current&&g.current===`following-bottom`&&zb(t,n)){ce({behavior:`auto`});return}se(e,{align:`start`},{keepPreviousPeek:!0}),P.current.add(e);return}}if(t.length===n){let e=Rb(t,P.current);if(e){se(e,{align:`start`},{keepPreviousPeek:!0}),P.current.add(e);return}}g.current===`following-bottom`&&s.current?ce({behavior:`auto`}):(ie(),I())})(),fe()},[me,fe,ie,L,de,I,se,ce]),ge=E.useCallback(()=>{if(g.current===`following-bottom`&&s.current){ce({behavior:`auto`});return}let e=D.current;if(oe()){s.current&&e>0&&D.current===0&&ce({behavior:`auto`});return}ae(),I()},[oe,ae,I,ce]),_e=E.useCallback(()=>{let e=j.current;if(!(!e||!ee.hasListeners())){if(typeof IntersectionObserver>`u`){I();return}N.current||=new IntersectionObserver(e=>{for(let t of e){let e=t.target.dataset.messageId;e&&(t.isIntersecting?te.current.add(e):te.current.delete(e))}I()},{root:e,rootMargin:`${-(C.current+w.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]}),h.current.forEach(e=>{N.current?.observe(e)}),I()}},[I,ee]),ve=E.useCallback(()=>{M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),N.current?.disconnect(),N.current=null,te.current.clear(),ee.setSnapshot(Nb)},[ee]),ye=E.useCallback((e,t,n)=>{if(t){h.current.set(e,t),N.current?.observe(t),I(),v.current?.messageId===e&&pe();return}n&&h.current.get(e)===n&&(h.current.delete(e),te.current.delete(e),N.current?.unobserve(n),I())},[pe,I]),be=E.useCallback(()=>{(g.current===`following-bottom`||g.current===`anchored-to-message`||g.current===`settling-jump`)&&(o.current=null,g.current=`free-scrolling`)},[]),xe=E.useCallback(()=>ne(A.getSnapshot()),[A,ne]),Se=ax(x,xe),Ce=ax(j,xe),we=E.useCallback(e=>{u.current=e},[]),Te=E.useCallback(e=>{O.current=e,T.current=Xb(e?.parentElement??null)},[]),Ee=E.useCallback(()=>{ie(),I(),fe()},[fe,ie,I]),De=E.useMemo(()=>({handleContentChange:he,handleResize:ge,observeVisibility:_e,preserveScrollOnPrependRef:b,scrollToEnd:ce,scrollToMessage:le,scrollToStart:ue,setContentElement:we,setRootElement:Se,setSpacerElement:Te,setViewportElement:Ce,stateStore:A,syncAfterScroll:Ee,unobserveVisibility:ve,userScrollIntent:be,viewportRef:j,visibilityStore:ee}),[he,ge,_e,ce,le,ue,we,Se,Te,Ce,A,Ee,ve,be,ee]);return E.useLayoutEffect(()=>{me()},[me]),E.useEffect(()=>()=>{k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),M.current!==null&&(window.cancelAnimationFrame(M.current),M.current=null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),N.current?.disconnect(),N.current=null},[]),E.useLayoutEffect(()=>{if(e&&g.current===`following-bottom`&&p.current>0){ce({behavior:`auto`});return}ie()},[e,ie,ce]),{context:De,registerMessage:ye}}function sx(e){let t=E.useRef(e);return t.current=e,t}var cx=E.createContext(null),lx=E.createContext(null);function ux(){let e=E.useContext(cx);if(!e)throw Error(`useMessageScroller must be used within a MessageScroller.`);return e}function dx(){let e=E.useContext(lx);if(!e)throw Error(`MessageScrollerItem must be used within a MessageScroller.`);return e}function fx(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=ux();return E.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function px({autoScroll:e=!1,children:t,defaultScrollPosition:n=`end`,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a}){let{context:o,registerMessage:s}=ox({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a});return(0,R.jsx)(cx.Provider,{value:o,children:(0,R.jsx)(lx.Provider,{value:s,children:t})})}function mx({children:e,...t}){let{setRootElement:n}=ux();return(0,R.jsx)(`div`,{ref:n,...t,children:e})}function hx({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:i,onWheel:a,preserveScrollOnPrepend:o=!0,ref:s,role:c,tabIndex:l,...u}){let{handleResize:d,preserveScrollOnPrependRef:f,setViewportElement:p,syncAfterScroll:m,userScrollIntent:h,viewportRef:g}=ux();f.current=o;let _=E.useCallback(e=>{p(e),Tb(s)?.(e)},[s,p]);function v(e){m(),r?.(e)}function y(e){h(),a?.(e)}function b(e){h(),i?.(e)}function x(e){jb.has(e.key)&&h(),n?.(e)}return E.useEffect(()=>{let e=g.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(d)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[d,g]),(0,R.jsx)(`div`,{ref:_,role:c??`region`,"aria-label":e??`Messages`,tabIndex:l??0,onKeyDown:x,onScroll:v,onTouchMove:b,onWheel:y,...u,children:t})}function gx({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:i,...a}){let{handleContentChange:o,handleResize:s,setContentElement:c,setSpacerElement:l}=ux(),u=E.useRef(null),d=E.useCallback(e=>{u.current=e,c(e),Tb(n)?.(e)},[n,c]);return E.useLayoutEffect(()=>{let e=u.current;if(!e||(o(),typeof MutationObserver>`u`))return;let t=new MutationObserver(()=>{o()});return t.observe(e,{childList:!0}),()=>t.disconnect()},[o]),E.useEffect(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(s)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[s]),(0,R.jsxs)(`div`,{ref:d,role:r??`log`,"aria-relevant":e??`additions`,...a,children:[t,(0,R.jsx)(`div`,{ref:l,"aria-hidden":`true`,"data-message-scroller-spacer":``,hidden:!0,className:i})]})}function _x({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let i=dx(),a=E.useRef(null),o=E.useCallback(n=>{let r=a.current;a.current=n,e&&i(e,n,r),Tb(t)?.(n)},[e,t,i]);return(0,R.jsx)(`div`,{ref:o,"data-message-id":e,"data-scroll-anchor":n?`true`:`false`,...r})}function vx({behavior:e=`smooth`,children:t,direction:n=`end`,onClick:r,render:i,tabIndex:a,type:o=`button`,...s}){let{scrollToEnd:c,scrollToStart:l,stateStore:u}=ux(),d=sx(r),f=E.useCallback(e=>u.subscribe(e),[u]),p=E.useCallback(()=>{let e=u.getSnapshot();return n===`start`?e.start:e.end},[n,u]),m=E.useSyncExternalStore(f,p,p),h=E.useCallback(t=>{m&&(d.current?.(t),t.defaultPrevented||(t.currentTarget.blur(),n===`start`?l({behavior:e}):c({behavior:e})))},[e,n,m,d,c,l]);return bb({defaultTagName:`button`,props:xb({type:o,inert:!m,tabIndex:m?a:-1,children:t??(0,R.jsxs)(`span`,{children:[`Scroll to `,n]}),onClick:h},s),render:i,state:{active:m,direction:n},stateAttributesMapping:{active:e=>({"data-active":e?`true`:`false`})}})}var yx={Provider:px,Root:mx,Viewport:hx,Content:gx,Item:_x,Button:vx};function bx(e){return(0,R.jsx)(yx.Provider,{...e})}function xx({className:e,...t}){return(0,R.jsx)(yx.Root,{"data-slot":`message-scroller`,className:V(`group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden`,e),...t})}function Sx({className:e,...t}){return(0,R.jsx)(yx.Viewport,{"data-slot":`message-scroller-viewport`,className:V(`size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content [overflow-anchor:none]`,e),...t})}function Cx({className:e,...t}){return(0,R.jsx)(yx.Content,{"data-slot":`message-scroller-content`,className:V(`flex h-max min-h-full flex-col gap-6`,e),...t})}function wx({className:e,scrollAnchor:t=!1,...n}){return(0,R.jsx)(yx.Item,{"data-slot":`message-scroller-item`,scrollAnchor:t,className:V(`min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]`,e),...n})}function Tx({direction:e=`end`,className:t,children:n,render:r,variant:i=`secondary`,size:a=`icon-sm`,...o}){return(0,R.jsx)(yx.Button,{"data-slot":`message-scroller-button`,"data-direction":e,"data-variant":i,"data-size":a,direction:e,className:V(`absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180`,t),render:r??(0,R.jsx)(U,{variant:i,size:a}),...o,children:n??(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(N,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:e===`end`?`Scroll to end`:`Scroll to start`})]})})}var Ex=Wm(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function Dx({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?vr:`span`;return(0,R.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:V(Ex({variant:t}),e),...r})}var Ox=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i;function kx(e){return!!e&&e.startsWith(`image/`)}function Ax(e){return e?Ox.test(e.split(`?`)[0]??``):!1}function jx(e){return kx(e.type)||Ax(e.name)}function Mx(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`could not read ${e.name}`)),r.onload=()=>{let i=String(r.result??``);if(!i.startsWith(`data:`)){n(Error(`unexpected read result for ${e.name}`));return}t({id:`att_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,name:e.name||`image`,mime:e.type||Fx(e.name)||`application/octet-stream`,uri:i})},r.readAsDataURL(e)})}async function Nx(e){let t=[];for(let n of Array.from(e))if(jx(n))try{t.push(await Mx(n))}catch{}return t}function Px(e){return{uri:e.uri,name:e.name}}function Fx(e){switch((e.split(`.`).pop()??``).toLowerCase()){case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;case`avif`:return`image/avif`;case`bmp`:return`image/bmp`;case`svg`:return`image/svg+xml`;default:return}}function Ix(e){if(!kx(e.mime)&&!Ax(e.name))return null;if(e.data)return`data:${e.mime};base64,${e.data}`;if(e.source?.type===`uri`){let t=e.source.uri;if(/^(https?:|blob:|data:image\/)/i.test(t))return t}return null}function Lx(e){if(!kx(e.mime)&&!Ax(e.name)||e.data)return null;if(e.source?.type===`uri`){let t=e.source.uri;if(/^file:\/\//i.test(t))try{return decodeURIComponent(new URL(t).pathname)}catch{return null}if(/^\//.test(t)||Ax(t))return t}return null}function Rx(e){let t=new Uint8Array(e),n=32768,r=``;for(let e=0;e<t.length;e+=n)r+=String.fromCharCode(...t.subarray(e,e+n));return btoa(r)}var zx=s({clearDraft:()=>Kx,loadDraft:()=>Wx,saveDraft:()=>Gx}),Bx=`webui.drafts`,Vx=50;function Hx(){try{let e=localStorage.getItem(Bx);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}function Ux(e){try{let t=Object.entries(e).sort((e,t)=>t[1].at-e[1].at).slice(0,Vx);localStorage.setItem(Bx,JSON.stringify(Object.fromEntries(t)))}catch{}}function Wx(e){return Hx()[e]?.text??``}function Gx(e,t){let n=Hx();if(t)n[e]={text:t,at:Date.now()};else{if(!(e in n))return;delete n[e]}Ux(n)}function Kx(e){let t=Hx();e in t&&(delete t[e],Ux(t))}function qx({className:e,children:t,...n}){return(0,R.jsxs)(Jp,{"data-slot":`scroll-area`,className:V(`relative`,e),...n,children:[(0,R.jsx)(Yp,{"data-slot":`scroll-area-viewport`,className:`size-full min-w-0 max-w-full overflow-x-hidden rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,R.jsx)(Jx,{}),(0,R.jsx)(Xp,{})]})}function Jx({className:e,orientation:t=`vertical`,...n}){return(0,R.jsx)(Sp,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:V(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,R.jsx)(Np,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function Yx({className:e,size:t=`default`,...n}){return(0,R.jsx)(mm,{"data-slot":`switch`,"data-size":t,className:V(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,R.jsx)(gm,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}function Xx({className:e,orientation:t=`horizontal`,...n}){return(0,R.jsx)(Rm,{"data-slot":`tabs`,"data-orientation":t,className:V(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var Zx=Wm(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Qx({className:e,variant:t=`default`,...n}){return(0,R.jsx)(zm,{"data-slot":`tabs-list`,"data-variant":t,className:V(Zx({variant:t}),e),...n})}function $x({className:e,...t}){return(0,R.jsx)(Bm,{"data-slot":`tabs-trigger`,className:V(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function eS({className:e,...t}){return(0,R.jsx)(Vm,{"data-slot":`tabs-content`,className:V(`flex-1 text-sm outline-none`,e),...t})}var tS=`webui.ext.disabled`,nS=null,rS=new Set;function iS(){if(nS)return nS;try{let e=JSON.parse(localStorage.getItem(tS)??`[]`);nS=Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{nS=[]}return nS}function aS(e){return iS().includes(e)}function oS(e,t){let n=new Set(iS());t?n.add(e):n.delete(e),nS=[...n];try{localStorage.setItem(tS,JSON.stringify(nS))}catch{}for(let e of rS)e()}function sS(e){return rS.add(e),()=>rS.delete(e)}var cS={primary:`default`,secondary:`secondary`,ghost:`ghost`,outline:`outline`,danger:`destructive`};function lS({children:e,onClick:t,variant:n=`ghost`,disabled:r,className:i=``,title:a,type:o=`button`}){return(0,R.jsx)(U,{type:o,title:a,variant:cS[n],className:i,onClick:t,disabled:r,children:e})}function uS({className:e=`size-4`}){return(0,R.jsx)(`span`,{className:`inline-block animate-spin rounded-full border-2 border-[color-mix(in_oklch,var(--border-selected)_30%,transparent)] border-t-[var(--border-selected)] ${e}`})}var dS={neutral:`bg-[var(--surface-raised-base)] text-[var(--text-weak)]`,green:`bg-[color-mix(in_oklch,var(--surface-success-strong)_12%,transparent)] text-[var(--surface-success-strong)]`,red:`bg-[color-mix(in_oklch,var(--surface-critical-strong)_12%,transparent)] text-[var(--surface-critical-strong)]`,blue:`bg-[color-mix(in_oklch,var(--border-selected)_12%,transparent)] text-[var(--text-interactive-base)]`,amber:`bg-[color-mix(in_oklch,var(--surface-warning-strong)_12%,transparent)] text-[var(--surface-warning-strong)]`};function fS({children:e,tone:t=`neutral`}){return(0,R.jsx)(Dx,{variant:`secondary`,className:V(dS[t]),children:e})}function pS(e){let t=Math.max(1,Math.floor((Date.now()-e)/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function mS(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}var hS=`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--input-base)] px-2.5 py-1.5 text-sm text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)] focus:ring-1 focus:ring-[var(--border-selected)]`;function gS({title:e,note:t,onRefresh:n,loading:r}){return(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`h3`,{className:`shrink-0 text-[13px] font-medium text-[var(--text-strong)]`,children:e}),t&&(0,R.jsx)(`span`,{className:`truncate text-[11px] text-[var(--text-weaker)]`,children:t})]}),n&&(0,R.jsx)(U,{variant:`ghost`,size:`icon-sm`,title:`Refresh`,disabled:r,onClick:n,children:(0,R.jsx)(Ge,{className:r?`animate-spin`:``})})]})}function _S({children:e}){return(0,R.jsx)(`p`,{className:`py-3 text-center text-xs text-[var(--text-weaker)]`,children:e})}function vS(e){let[t,n]=(0,E.useState)(null),[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!0),[s,c]=(0,E.useState)(0);return(0,E.useEffect)(()=>{let t=!1;return o(!0),i(null),e().then(e=>{t||n(e)}).catch(e=>{t||i(e instanceof Error?e.message:String(e))}).finally(()=>{t||o(!1)}),()=>{t=!0}},[s]),{data:t,error:r,loading:a,refresh:(0,E.useCallback)(()=>c(e=>e+1),[])}}function yS({message:e}){return(0,R.jsx)(`p`,{className:`rounded-md border border-[var(--surface-critical-base)] bg-[var(--surface-critical-weak)] px-2.5 py-1.5 text-xs text-[var(--surface-critical-strong)]`,children:e})}function bS({text:e}){let[t,n]=(0,E.useState)(!1);return(0,R.jsx)(U,{variant:`ghost`,size:`xs`,title:`Copy`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1200)})},children:t?`copied`:`copy`})}function xS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.configGet());return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Configuration`,note:`Read-only — edit server-side in opencode.jsonc`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No configuration found.`}),(0,R.jsx)(`div`,{className:`space-y-2`,children:e?.map((e,t)=>(0,R.jsx)(SS,{entry:e},t))})]})}function SS({entry:e}){return(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] p-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(fS,{tone:e.type===`document`?`blue`:`neutral`,children:e.type}),e.path&&(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-[var(--text-weak)]`,children:e.path})]}),e.type===`document`&&(0,R.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-[var(--text-base)] mt-2 max-h-72`,children:JSON.stringify(e.info,null,2)})]})}var CS=[],wS=new Set,TS=0;function ES(){for(let e of wS)e()}function DS(e){return wS.add(e),()=>wS.delete(e)}function OS(){return CS}function kS(e){let t=CS.length;CS=CS.filter(t=>t.id!==e),CS.length!==t&&ES()}function AS(e){let t=`toast_${Date.now().toString(36)}_${++TS}`,n={id:t,title:e.title,description:e.description,variant:e.variant??`default`,created:Date.now()};return CS=[...CS,n],ES(),setTimeout(()=>kS(t),3e3),t}var jS=e=>e instanceof Error?e.message:String(e),MS=`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-3 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`;function NS(e,t,n,r){let[i,a]=(0,E.useState)({kind:`idle`}),o=i.kind===`active`?i.attemptID:null,s=i.kind===`active`?i.status:null;return(0,E.useEffect)(()=>{if(!e){a({kind:`idle`});return}let n=!1;return a({kind:`starting`}),t(e).then(e=>{n||a({kind:`active`,attemptID:e.attemptID,url:e.url,instructions:e.instructions,status:`pending`})}).catch(e=>a({kind:`starting`,error:e instanceof Error?e.message:String(e)})),()=>{n=!0}},[e?.integrationID,e?.methodID]),(0,E.useEffect)(()=>{if(!e||!o||s!==`pending`)return;let t=async()=>{try{let t=await n(e,o);a(e=>e.kind===`active`?{...e,status:t.status,message:t.message}:e),t.status===`complete`&&r()}catch{}};return og({name:`integration-attempt`,minInterval:2e3,run:()=>t()})},[e?.integrationID,e?.methodID,o,s]),i}function PS({state:e,onCancel:t,label:n}){return e.kind===`idle`?null:e.kind===`starting`?(0,R.jsxs)(`div`,{className:`space-y-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[e.error?(0,R.jsx)(yS,{message:e.error}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--text-base)]`,children:[(0,R.jsx)(Me,{className:`size-3.5 animate-spin`}),` starting `,n,`…`]}),(0,R.jsx)(U,{variant:`ghost`,size:`xs`,onClick:t,children:`cancel`})]}):(0,R.jsxs)(`div`,{className:`space-y-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-xs text-[var(--text-base)]`,children:[n,` attempt`]}),(0,R.jsx)(fS,{tone:e.status===`complete`?`green`:e.status===`pending`?`amber`:`red`,children:e.status})]}),e.url&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`a`,{className:`min-w-0 truncate text-xs text-[var(--text-interactive-base)] underline underline-offset-2`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url}),(0,R.jsx)(pe,{className:`size-3 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(bS,{text:e.url})]}),e.instructions&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weak)]`,children:e.instructions}),e.message&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weak)]`,children:e.message}),e.status===`pending`&&(0,R.jsx)(U,{variant:`ghost`,size:`xs`,onClick:t,children:`cancel`})]})}function FS({integration:e,method:t,open:n,onClose:r,onDone:i}){let[a,o]=(0,E.useState)(``),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(!1),[d,f]=(0,E.useState)(null);return(0,R.jsx)(Km,{open:n,onOpenChange:e=>!e&&r(),children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/60`}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:MS,children:[(0,R.jsxs)(Qm,{children:[(0,R.jsxs)(eh,{children:[e.name,` · API key`]}),(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:t.label??`Connect with an API key for ${e.id}`})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`input`,{className:hS,placeholder:`API key`,type:`password`,autoComplete:`off`,value:a,onChange:e=>o(e.target.value)}),(0,R.jsx)(`input`,{className:hS,placeholder:`Label (optional)`,value:s,onChange:e=>c(e.target.value)}),d&&(0,R.jsx)(yS,{message:d})]}),(0,R.jsxs)($m,{className:`rounded-b-lg`,children:[(0,R.jsx)(U,{variant:`ghost`,onClick:r,disabled:l,children:`Cancel`}),(0,R.jsx)(U,{disabled:a.trim().length===0||l,onClick:()=>{u(!0),f(null),G.integrationConnectKey(e.id,{key:a.trim(),label:s.trim()||null}).then(()=>{r(),i()}).catch(e=>f(e instanceof Error?e.message:String(e))).finally(()=>u(!1))},children:l?`Connecting…`:`Connect`})]}),(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})})}function IS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.integrationList().then(e=>e.data)),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)(``),c=vS(()=>G.models()),l=vS(()=>G.providerList().then(e=>e.data)),[u,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(null),[m,h]=(0,E.useState)(null),g=NS(f,e=>G.integrationConnectOauth(e.integrationID,{methodID:e.methodID}).then(e=>({attemptID:e.data.attemptID,url:e.data.url,instructions:e.data.instructions})),(e,t)=>G.integrationOauthAttempt(e.integrationID,t).then(e=>e.data),r),_=NS(m,e=>G.integrationConnectCommand(e.integrationID,{methodID:e.methodID}).then(e=>({attemptID:e.data.attemptID})),(e,t)=>G.integrationCommandAttempt(e.integrationID,t).then(e=>e.data),r),v=(0,E.useMemo)(()=>{let e=new Map;if(!c.data||!l.data)return e;let t=new Map;for(let e of l.data){if(!e.integrationID)continue;let n=t.get(e.integrationID)??new Set;n.add(e.id),t.set(e.integrationID,n)}for(let n of c.data)for(let[r,i]of t)i.has(n.providerID)&&e.set(r,(e.get(r)??0)+1);return e},[c.data,l.data]),y=(0,E.useMemo)(()=>e?[...e].sort((e,t)=>{let n=+(e.connections.length>0),r=+(t.connections.length>0);return n===r?(e.name||e.id).localeCompare(t.name||t.id):r-n}):[],[e]),b=o.trim().toLowerCase(),x=(0,E.useMemo)(()=>b?y.filter(e=>e.name.toLowerCase().includes(b)||e.id.toLowerCase().includes(b)):y,[y,b]);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Integrations`,note:`Connect providers — API keys, OAuth, CLI commands`,onRefresh:r,loading:n}),(0,R.jsx)(`p`,{className:`-mt-1 mb-2 text-xs text-[var(--text-weaker)]`,children:`An integration is how the engine authenticates to a model provider. Connect one to enable its models.`}),(0,R.jsxs)(`div`,{className:`relative mb-2`,children:[(0,R.jsx)(qe,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(`input`,{className:`${hS} h-7 pl-7`,placeholder:`Search integrations`,value:o,onChange:e=>s(e.target.value)})]}),b&&(0,R.jsxs)(`p`,{className:`mb-1 px-1 text-[11px] text-[var(--text-weaker)]`,"aria-live":`polite`,children:[x.length,` of `,y.length]}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No integrations available.`}),!t&&e&&e.length>0&&x.length===0&&(0,R.jsxs)(_S,{children:[`No integrations match “`,o.trim(),`”.`]}),(0,R.jsx)(`div`,{className:`space-y-1`,children:x.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-raised-base-hover)]`,onClick:()=>a(i===e.id?null:e.id),children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(L,{className:`size-3.5 shrink-0 text-[var(--text-weaker)] transition-transform ${i===e.id?`rotate-90`:``}`}),(0,R.jsx)(`span`,{className:`truncate text-[13px] text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-[var(--text-weaker)]`,children:e.id})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(v.get(e.id)??0)>0&&(0,R.jsxs)(`span`,{className:`text-[11px] text-[var(--text-weaker)]`,children:[`· `,v.get(e.id),` models`]}),e.connections.length>0?(0,R.jsxs)(fS,{tone:`green`,children:[`connected`,e.connections.length>1?` · ${e.connections.length}`:``]}):(0,R.jsx)(fS,{children:`not connected`}),e.connections.map((e,t)=>(0,R.jsx)(fS,{tone:`blue`,children:e.type===`credential`?e.label:e.name},t))]})]}),i===e.id&&(0,R.jsxs)(`div`,{className:`mt-1 ml-4 space-y-1.5 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[e.connections.length===0&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:`No connections yet.`}),e.connections.length>0&&(0,R.jsx)(`div`,{className:`space-y-1`,children:e.connections.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,R.jsx)(fS,{tone:e.type===`credential`?`blue`:`neutral`,children:e.type===`credential`?`credential`:`env`}),(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:e.type===`credential`?e.label:e.name}),e.type===`credential`&&(0,R.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--text-weaker)]`,children:e.id}),e.type===`credential`&&(0,R.jsx)(`button`,{type:`button`,className:`rounded border border-[var(--border-weak-base)] px-1.5 py-0.5 text-[10px] text-[var(--text-weak)] transition-colors hover:bg-[var(--surface-raised-base-hover)] hover:text-[var(--text-strong)]`,onClick:()=>{G.credentialActivate(e.id).then(r).catch(e=>AS({title:`Activate failed`,description:jS(e),variant:`destructive`}))},children:`activate`})]},t))}),(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 pt-1`,children:e.methods.map((t,n)=>(0,R.jsx)(LS,{method:t,onKey:()=>d({integration:e,method:t}),onOauth:()=>p({integrationID:e.id,methodID:t.id}),onCommand:()=>h({integrationID:e.id,methodID:t.id})},n))}),f?.integrationID===e.id&&(0,R.jsx)(PS,{state:g,onCancel:()=>p(null),label:`OAuth`}),m?.integrationID===e.id&&(0,R.jsx)(PS,{state:_,onCancel:()=>h(null),label:`Command`})]})]},e.id))}),u&&(0,R.jsx)(FS,{integration:u.integration,method:u.method,open:!0,onClose:()=>d(null),onDone:r})]})}function LS({method:e,onKey:t,onOauth:n,onCommand:r}){let i=e.type===`env`?`env: ${e.names.join(`, `)}`:e.label??e.type;return e.type===`env`?(0,R.jsx)(U,{size:`xs`,variant:`outline`,disabled:!0,title:`Configured via environment variables`,children:i}):(0,R.jsx)(U,{size:`xs`,variant:`outline`,onClick:e.type===`key`?t:e.type===`oauth`?n:r,children:i})}var RS=`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-3 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`;function zS(e){switch(e.status){case`connected`:return`green`;case`pending`:case`needs_auth`:return`amber`;case`failed`:return`red`;default:return`neutral`}}function BS(e){return e.status===`needs_auth`?`needs auth`:e.status}function VS(){let e=vS(()=>G.mcpList().then(e=>e.data)),t=vS(()=>G.mcpResource().then(e=>e.data)),[n,r]=(0,E.useState)(null),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)(null),c=()=>{e.refresh(),t.refresh()},l=(e,t)=>{r(e),a(null),t().catch(e=>a(e instanceof Error?e.message:String(e))).finally(()=>{r(null),c()})};return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`MCP servers`,note:`Model Context Protocol endpoints`,onRefresh:c,loading:e.loading}),e.error&&(0,R.jsx)(yS,{message:e.error}),i&&(0,R.jsx)(yS,{message:i}),!e.error&&e.data&&e.data.length===0&&(0,R.jsx)(_S,{children:`No MCP servers configured.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e.data?.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-[13px] text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(fS,{tone:zS(e.status),children:BS(e.status)}),e.status.status===`failed`&&(0,R.jsx)(`span`,{className:`max-w-40 truncate text-[10px] text-[var(--text-on-critical-base)]`,children:e.status.error})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.status.status!==`connected`&&(0,R.jsx)(U,{size:`xs`,variant:`outline`,disabled:n!==null,onClick:()=>l(`connect:${e.name}`,()=>G.mcpConnect(e.name)),children:n===`connect:${e.name}`?`Connecting…`:`Connect`}),e.status.status===`connected`&&(0,R.jsx)(U,{size:`xs`,variant:`outline`,disabled:n!==null,onClick:()=>l(`disconnect:${e.name}`,()=>G.mcpDisconnect(e.name)),children:n===`disconnect:${e.name}`?`Disconnecting…`:`Disconnect`}),(0,R.jsx)(U,{size:`xs`,variant:`ghost`,disabled:n!==null,className:`text-[var(--surface-critical-strong)]`,onClick:()=>s(e),children:`Remove`})]})]},e.name))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Resources`,note:`Read-only catalog`,onRefresh:t.refresh,loading:t.loading}),t.error&&(0,R.jsx)(yS,{message:t.error}),!t.error&&t.data&&t.data.resources.length===0&&(0,R.jsx)(_S,{children:`No resources exposed.`}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[t.data?.resources.map(e=>(0,R.jsx)(HS,{resource:e},`${e.server}:${e.name}`)),t.data?.templates.map(e=>(0,R.jsx)(US,{template:e},`${e.server}:${e.name}`))]})]}),o&&(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&s(null),children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/60`}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:RS,children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Remove MCP server`}),(0,R.jsxs)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:[`Remove`,` `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:o.name}),` `,`from the config? This affects the server-side configuration.`]})]}),(0,R.jsxs)($m,{className:`rounded-b-lg`,children:[(0,R.jsx)(U,{variant:`ghost`,onClick:()=>s(null),children:`Cancel`}),(0,R.jsx)(U,{variant:`destructive`,onClick:()=>{l(`remove:${o.name}`,()=>G.mcpDelete(o.name)),s(null)},children:`Remove`})]}),(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})})]})}function HS({resource:e}){return(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`truncate text-xs text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:e.server})]}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[(0,R.jsx)(Ae,{className:`size-3 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-weak)]`,children:e.uri})]}),e.description&&(0,R.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-[var(--text-weaker)]`,children:e.description})]})}function US({template:e}){return(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`truncate text-xs text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:e.server})]}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5`,children:[(0,R.jsx)(Ae,{className:`size-3 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-weak)]`,children:e.uriTemplate})]})]})}function WS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.pluginList().then(e=>e.data));return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Plugins`,note:`Read-only — installed plugins`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No plugins installed.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e?.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-1.5`,children:[(0,R.jsx)(We,{className:`size-3.5 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-[var(--text-strong)]`,children:e.id})]},e.id))})]})}function GS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.providerList().then(e=>e.data)),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)(null),[c,l]=(0,E.useState)(null);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Providers`,note:`Registered model providers`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No providers registered.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e?.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-raised-base-hover)]`,onClick:()=>{if(i===e.id){a(null),s(null);return}a(e.id),s(null),l(null),G.providerGet(e.id).then(e=>s(e.data)).catch(e=>l(e instanceof Error?e.message:String(e)))},children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(L,{className:`size-3.5 shrink-0 text-[var(--text-weaker)] transition-transform ${i===e.id?`rotate-90`:``}`}),(0,R.jsx)(`span`,{className:`truncate text-[13px] text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-[var(--text-weaker)]`,children:e.id})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.disabled&&(0,R.jsx)(`span`,{className:`rounded border border-[var(--border-weak-base)] px-1.5 py-0.5 text-[10px] text-[var(--text-weaker)]`,children:`disabled`}),(0,R.jsx)(`span`,{className:`max-w-48 truncate font-mono text-[10px] text-[var(--text-weak)]`,children:e.package})]})]}),i===e.id&&(0,R.jsxs)(`div`,{className:`mt-1 ml-4 space-y-1.5 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[c&&(0,R.jsx)(yS,{message:c}),!o&&!c&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(Me,{className:`size-3.5 animate-spin`}),` loading…`]}),o&&(0,R.jsxs)(R.Fragment,{children:[o.integrationID&&(0,R.jsxs)(`p`,{className:`text-[11px] text-[var(--text-weak)]`,children:[`integration:`,` `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:o.integrationID})]}),o.settings&&Object.keys(o.settings).length>0&&(0,R.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-[var(--text-base)]`,children:JSON.stringify(o.settings,null,2)}),o.headers&&Object.keys(o.headers).length>0&&(0,R.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-[var(--text-base)]`,children:JSON.stringify(o.headers,null,2)}),o.body&&Object.keys(o.body).length>0&&(0,R.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-[var(--text-base)]`,children:JSON.stringify(o.body,null,2)}),(!o.settings||Object.keys(o.settings).length===0)&&(!o.headers||Object.keys(o.headers).length===0)&&(!o.body||Object.keys(o.body).length===0)&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:`No settings.`})]})]})]},e.id))})]})}var KS=`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-3 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`;function qS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.serverInfo()),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)(null),[u,d]=(0,E.useState)(null);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Server`,note:`Backend service`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.urls.length===0&&(0,R.jsx)(_S,{children:`No server endpoints.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e?.urls.map(e=>(0,R.jsx)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-1.5`,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-[var(--text-strong)]`,children:e})},e))})]}),(0,R.jsxs)(`div`,{className:`space-y-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-[13px] font-medium text-[var(--text-strong)]`,children:`Stop service`}),(0,R.jsx)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`Request the managed opencode service to shut down. The web UI itself keeps running.`})]}),(0,R.jsxs)(U,{variant:`destructive`,onClick:()=>a(!0),disabled:o,children:[(0,R.jsx)(Ue,{}),o?`Stopping…`:`Stop`]})]}),c&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-base)]`,children:c}),u&&(0,R.jsx)(yS,{message:u})]}),i&&(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&a(!1),children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/60`}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:KS,children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Stop the service?`}),(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:`This stops the background opencode service. Running sessions will be interrupted.`})]}),(0,R.jsxs)($m,{className:`rounded-b-lg`,children:[(0,R.jsx)(U,{variant:`ghost`,onClick:()=>a(!1),disabled:o,children:`Cancel`}),(0,R.jsx)(U,{variant:`destructive`,disabled:o,onClick:()=>{s(!0),l(null),d(null),G.serviceStop().then(e=>{l(e.accepted?`Stop accepted — the service is shutting down.`:`Stop not accepted — this instance is not the service owner.`)}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>{s(!1),a(!1)})},children:`Stop service`})]}),(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})})]})}function JS(){let{data:e,error:t,loading:n,refresh:r}=vS(()=>G.websearchProviders().then(e=>e.data)),[i,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(null),[u,d]=(0,E.useState)(!1),[f,p]=(0,E.useState)(null),m=i||e?.[0]?.id||``;return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Websearch`,note:`Test search providers`,onRefresh:r,loading:n}),t&&(0,R.jsx)(yS,{message:t}),!t&&e&&e.length===0&&(0,R.jsx)(_S,{children:`No websearch providers available.`}),(0,R.jsx)(`div`,{className:`space-y-1`,children:e?.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`truncate text-xs text-[var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-[var(--text-weaker)]`,children:e.id})]}),(0,R.jsx)(U,{size:`xs`,variant:i===e.id?`default`:`outline`,onClick:()=>a(i===e.id?``:e.id),children:i===e.id?`selected`:`select`})]},e.id))})]}),e&&e.length>0&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{className:`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--input-base)] px-2.5 py-1.5 text-sm text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)] focus:ring-1 focus:ring-[var(--border-selected)] h-8 flex-1`,placeholder:`Search query…`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()&&!u&&h()}}),(0,R.jsxs)(U,{variant:`default`,disabled:!o.trim()||u||!m,onClick:h,children:[(0,R.jsx)(qe,{}),u?`Searching…`:`Search`]})]}),!m&&(0,R.jsx)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`Select a provider to search.`}),f&&(0,R.jsx)(yS,{message:f}),c&&(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsxs)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:[c.results.length,` results · provider `,c.providerID]}),c.results.length===0&&(0,R.jsx)(_S,{children:`No results.`}),c.results.map((e,t)=>(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-2`,children:[(0,R.jsx)(`a`,{className:`block truncate text-xs text-[var(--text-interactive-base)] underline underline-offset-2`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.title??e.url}),(0,R.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-[var(--text-weak)]`,children:e.content}),(0,R.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-[var(--text-weaker)]`,children:e.url})]},`${e.url}:${t}`))]})]}),(0,R.jsx)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-2`,children:(0,R.jsxs)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:[`Searching with`,` `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:e?.find(e=>e.id===m)?.name??m})]})})]});function h(){!o.trim()||u||(d(!0),p(null),G.websearch(o.trim(),m).then(e=>l(e.data)).catch(e=>p(e instanceof Error?e.message:String(e))).finally(()=>d(!1)))}}var YS=null;function XS(e){YS?.(e)}var ZS=`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 grid-rows-[auto_minmax(0,1fr)] gap-3 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-3xl h-[min(84vh,660px)] data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,QS=[{id:`providers`,label:`Providers`,icon:ue},{id:`integrations`,label:`Integrations`,icon:Ve},{id:`mcp`,label:`MCP`,icon:ne},{id:`plugins`,label:`Plugins`,icon:We},{id:`extensions`,label:`Extensions`,icon:F},{id:`config`,label:`Config`,icon:ve},{id:`websearch`,label:`Websearch`,icon:ke},{id:`server`,label:`Server`,icon:Ye}];function $S(){let[e,t]=(0,E.useState)(!1),[n,r]=(0,E.useState)(`providers`);return(0,E.useEffect)(()=>(YS=e=>{e&&r(e),t(!0)},()=>{YS=null}),[]),(0,R.jsx)(Km,{open:e,onOpenChange:e=>{t(e),e||r(`providers`)},children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/60`}),(0,R.jsxs)(fs,{"data-slot":`dialog-content`,className:ZS,children:[(0,R.jsxs)(Qm,{className:`pr-8`,children:[(0,R.jsx)(eh,{children:`Settings`}),(0,R.jsx)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:`Providers · integrations · MCP · plugins · extensions · config`})]}),(0,R.jsxs)(Xx,{value:n,onValueChange:r,className:`flex min-h-0 flex-col`,children:[(0,R.jsx)(Qx,{className:`mb-2 flex w-full flex-wrap justify-start gap-1 rounded-md bg-[var(--surface-base)] p-1`,children:QS.map(e=>(0,R.jsxs)($x,{value:e.id,title:e.id===`integrations`?`Connect providers`:void 0,className:`h-7 gap-1.5 rounded px-2 text-xs`,children:[(0,R.jsx)(e.icon,{className:`size-3.5`}),e.label]},e.id))}),(0,R.jsxs)(qx,{className:`min-h-0 flex-1 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] p-3`,children:[(0,R.jsx)(eS,{value:`providers`,children:(0,R.jsx)(GS,{})}),(0,R.jsx)(eS,{value:`integrations`,children:(0,R.jsx)(IS,{})}),(0,R.jsx)(eS,{value:`mcp`,children:(0,R.jsx)(VS,{})}),(0,R.jsx)(eS,{value:`plugins`,children:(0,R.jsx)(WS,{})}),(0,R.jsx)(eS,{value:`extensions`,children:(0,R.jsx)(nC,{})}),(0,R.jsx)(eS,{value:`config`,children:(0,R.jsx)(xS,{})}),(0,R.jsx)(eS,{value:`websearch`,children:(0,R.jsx)(JS,{})}),(0,R.jsx)(eS,{value:`server`,children:(0,R.jsx)(qS,{})})]})]}),(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`icon-sm`,className:`absolute top-2 right-2`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})})}function eC(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),e}function tC(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>sS(()=>t(e=>e+1)),[]),e}function nC(){tC();let e=eC(),[t,n]=(0,E.useState)(null);(0,E.useEffect)(()=>{let e=async()=>{if(!document.hidden)try{let e=await fetch(`/api/webui/extensions`);if(!e.ok)throw Error(String(e.status));let t=await e.json();n(t.data??[])}catch{n([])}};return e(),og({name:`extensions-runtime-list`,minInterval:1e4,run:()=>e()})},[]);let r=(0,E.useMemo)(()=>Et(),[e]);return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Extensions`,note:`plugin-shipped UI — toggle off to disable`}),t===null?null:t.length===0?(0,R.jsx)(_S,{children:`No plugin extensions installed.`}):(0,R.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate font-mono text-xs text-[var(--text-strong)]`,children:e.id}),(0,R.jsx)(`p`,{className:`truncate text-[11px] text-[var(--text-weaker)]`,children:e.source})]}),(0,R.jsx)(Yx,{size:`sm`,checked:!aS(e.id),onCheckedChange:t=>oS(e.id,t),"aria-label":`Toggle ${e.id}`,title:aS(e.id)?`Disabled`:`Enabled`})]},e.id))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Built-in extensions`}),st.length>0&&(0,R.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-1`,children:st.map(e=>(0,R.jsx)(`span`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2 py-1 font-mono text-xs text-[var(--text-strong)]`,children:e},e))}),(0,R.jsx)(`p`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`built-in — manage in ui-extensions/config.ts`})]}),r.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(gS,{title:`Extension settings`,note:`contributed by enabled extensions`}),(0,R.jsx)(`div`,{className:`space-y-2`,children:r.map(t=>(0,R.jsx)(rC,{id:t.id,children:(0,R.jsxs)(`section`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] p-2.5`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-medium text-[var(--text-strong)]`,children:t.title}),t.description&&(0,R.jsx)(`p`,{className:`mt-0.5 text-[11px] text-[var(--text-weaker)]`,children:t.description}),(0,R.jsx)(`div`,{className:`mt-2`,children:t.render()})]})},`${e}:${t.id}`))})]})]})}var rC=class extends E.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[extensions] settings section "${this.props.id}" crashed:`,e)}render(){return this.state.failed?(0,R.jsx)(`p`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-raised-base)] px-2.5 py-2 text-xs text-[var(--text-weaker)]`,children:`This extension's settings crashed.`}):this.props.children}};function iC(e){let t=e.variant&&e.variant!=="default"?e.variant:`default`;return`${e.providerID}/${e.id}@${t}`}function aC(e){let t=(0,E.useRef)(null);return(0,E.useEffect)(()=>{function n(n){t.current&&!t.current.contains(n.target)&&e()}return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),t}function oC({open:e,onClose:t,count:n,onSelect:r,listId:i,query:a,onQueryChange:o}){let[s,c]=(0,E.useState)(0),l=(0,E.useRef)(0);l.current=s;let u=(0,E.useRef)({prefix:``,at:0});(0,E.useEffect)(()=>{e&&c(0)},[e,a]),(0,E.useEffect)(()=>{e&&document.getElementById(`${i}-item-${s}`)?.scrollIntoView({block:`nearest`})},[e,s,i]);function d(e){let t=e.currentTarget,n=Array.from(t.querySelectorAll(`[role="option"]`));for(let t of n){let r=t.getBoundingClientRect();if(e.clientY>=r.top&&e.clientY<r.bottom){c(n.indexOf(t));return}}}return(0,E.useEffect)(()=>{if(!e)return;let s=null,d=e=>{if(e.key===`Escape`||e.key===`Tab`){if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`&&o&&a){o(``);return}t();return}if(n===0)return;if(e.key===`ArrowDown`){e.preventDefault(),e.stopPropagation(),c(e=>(e+1)%n);return}if(e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation(),c(e=>e<=0?n-1:e-1);return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),c(0);return}if(e.key===`End`){e.preventDefault(),e.stopPropagation(),c(n-1);return}if(e.key===`Enter`){e.preventDefault(),e.stopPropagation(),r(l.current<n?l.current:0);return}if(o)return;let d=e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey?e.key.toLowerCase():null;if(!d)return;let f=Date.now(),p=u.current,m=f-p.at<1e3?p.prefix+d:d;p.prefix=m,p.at=f,s??=Array.from(document.querySelectorAll(`#${i} > button`)).map(e=>(e.textContent??``).trim().toLowerCase()),c(e=>{for(let t=1;t<=n;t++){let r=(e+t)%n;if((s?.[r]??``).startsWith(m))return r}return e})};return window.addEventListener(`keydown`,d,!0),()=>window.removeEventListener(`keydown`,d,!0)},[e,n,t,r,i,a,o]),[s,c,d]}async function sC(){try{let e=await G.agents();return e.find(e=>e.mode===`primary`&&!e.hidden)??e[0]}catch{return}}function cC(e){let t=J(t=>t.sessions.find(t=>t.id===e)),n=J(t=>t.sessionDetails[e]);return(0,E.useEffect)(()=>{M_(e)},[e]),{session:t,detail:n}}var lC=`flex w-full cursor-pointer items-center justify-between px-3 py-2 text-left transition-colors hover:bg-[color:var(--surface-base-hover)] data-[hl=true]:bg-[color:var(--surface-raised-base-active)]`;function uC({sessionID:e,openUp:t=!1,align:n=`right`}){let{session:r,detail:i}=cC(e),a=J(e=>e.pendingModel),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)([]),[u,d]=(0,E.useState)(null),f=aC(()=>s(!1)),p=J(e=>e.uiSignals.models);(0,E.useEffect)(()=>{p&&s(!0)},[p]);let m=(0,E.useMemo)(()=>c.filter(e=>e.enabled),[c]),h=`menu-models`;function g(e,t){if(t.includes(e)){let n=t.indexOf(e),r=1e3-n*2;return(n===0||t[n-1]===` `||t[n-1]===`/`||t[n-1]===`-`)&&(r+=20),r}let n=0,r=-2,i=0,a=0,o=0,s=0,c=0;for(let l=0;l<t.length&&n<e.length;l++)t[l]===e[n]&&((l===0||t[l-1]===` `||t[l-1]===`/`||t[l-1]===`-`)&&c++,r+1===l?(a++,s++,o=Math.max(o,s)):(i+=l-r-1,s=1),r=l,n++);return n===e.length?500-r*.5-i*2+a*10+c*2+o*3:null}let[_,v]=(0,E.useState)(``),y=_.trim().toLowerCase(),b=(0,E.useMemo)(()=>{if(!y)return m;let e=[];for(let t=0;t<m.length;t++){let n=m[t],r=`${n.name} ${n.modelID} ${n.providerID} ${n.id}`.toLowerCase(),i=g(y,r);i!==null&&e.push({m:n,s:i,i:t})}return e.sort((e,t)=>t.s-e.s||e.i-t.i),e.map(e=>e.m)},[m,y]),x=(0,E.useRef)(null);(0,E.useEffect)(()=>{o&&(v(``),x.current?.focus())},[o]);let S=a??i?.model??r?.model??u??void 0;(0,E.useEffect)(()=>{o&&c.length===0&&G.models().then(l)},[o,c.length]),(0,E.useEffect)(()=>{!r?.model&&u===null&&P_().then(e=>{e&&d(e)})},[r?.model,u]);let C=t=>{let n=b[t];n&&(Qy(e,{id:n.modelID,providerID:n.providerID}).then(Yg),s(!1))},[w,,T]=oC({open:o,onClose:()=>s(!1),count:b.length,onSelect:C,listId:h,query:_,onQueryChange:v}),D=`${t?`bottom-full mb-1`:`mt-1`} ${n===`right`?`right-0`:`left-0`}`;return(0,R.jsxs)(`div`,{ref:f,className:`relative`,children:[(0,R.jsx)(lS,{variant:`outline`,onClick:()=>s(!o),"aria-expanded":o,"aria-haspopup":`listbox`,title:`Switch model`,className:`h-7 max-w-48 gap-1 px-2 font-mono text-[11px]`,children:(0,R.jsx)(`span`,{className:`truncate`,children:S?iC(S):`model`})}),o&&(0,R.jsxs)(`div`,{className:`absolute z-40 w-72 overflow-hidden rounded-lg border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] shadow-xl ${D}`,children:[(0,R.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-[color:var(--border-weak-base)] px-2.5`,children:[(0,R.jsx)(qe,{className:`size-3.5 shrink-0 text-[color:var(--text-weaker)]`}),(0,R.jsx)(`input`,{ref:x,value:_,onChange:e=>v(e.target.value),placeholder:`Filter models…`,"aria-label":`Filter models`,autoComplete:`off`,spellCheck:!1,className:`h-full w-full bg-transparent font-mono text-[11px] text-[color:var(--text-strong)] outline-none placeholder:text-[color:var(--text-weaker)]`})]}),(0,R.jsx)(`div`,{id:h,role:`listbox`,"aria-label":`Switch model`,"aria-activedescendant":b.length>0?`${h}-item-${w}`:void 0,className:`max-h-72 overflow-y-auto`,onMouseMove:T,children:b.length===0?(0,R.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-[color:var(--text-weaker)]`,children:`No matching models`}):b.map((e,t)=>(0,R.jsxs)(`button`,{id:`${h}-item-${t}`,type:`button`,role:`option`,"aria-selected":S?.id===e.modelID&&S?.providerID===e.providerID,"data-hl":t===w||void 0,className:lC,onClick:()=>C(t),children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`font-mono text-[color:var(--text-strong)]`,children:e.name}),(0,R.jsx)(`span`,{className:`ml-2 font-mono text-[color:var(--text-weaker)]`,children:e.providerID})]}),S?.id===e.modelID&&S?.providerID===e.providerID&&(0,R.jsx)(`span`,{className:`text-emerald-500`,children:`✓`})]},`${e.providerID}/${e.modelID}`))})]})]})}function dC({sessionID:e,openUp:t=!1,align:n=`right`}){let{session:r,detail:i}=cC(e),a=J(e=>e.pendingModel),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)([]),u=aC(()=>s(!1)),d=J(e=>e.uiSignals.variants);(0,E.useEffect)(()=>{d&&s(!0)},[d]),(0,E.useEffect)(()=>{o&&c.length===0&&G.models().then(l)},[o,c.length]);let f=a??i?.model??r?.model,p=c.find(e=>e.enabled&&e.modelID===f?.id&&e.providerID===f?.providerID)?.variants??[],m=f?.variant&&f.variant!=="default"?f.variant:void 0;function h(t){Qy(e,{id:f.id,providerID:f.providerID,...t?{variant:t}:{}}),s(!1)}let g=`menu-variants`,[_,,v]=oC({open:o,onClose:()=>s(!1),count:p.length+1,onSelect:e=>{e===0?h():h(p[e-1]?.id)},listId:g});if(!f||p.length===0)return null;let y=`${t?`bottom-full mb-1`:`mt-1`} ${n===`right`?`right-0`:`left-0`}`;return(0,R.jsxs)(`div`,{ref:u,className:`relative`,children:[(0,R.jsx)(lS,{variant:`outline`,onClick:()=>s(!o),"aria-expanded":o,"aria-haspopup":`listbox`,title:`Switch model variant`,className:`h-7 max-w-20 px-2 font-mono text-[11px]`,children:(0,R.jsx)(`span`,{className:`truncate`,children:m?`@${m}`:`@default`})}),o&&(0,R.jsxs)(`div`,{id:g,role:`listbox`,"aria-label":`Switch model variant`,"aria-activedescendant":`${g}-item-${_}`,className:`absolute z-40 max-h-80 w-48 overflow-y-auto rounded-lg border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] shadow-xl ${y}`,onMouseMove:v,children:[(0,R.jsxs)(`button`,{id:`${g}-item-0`,type:`button`,role:`option`,"aria-selected":!m,"data-hl":_===0||void 0,className:lC,onClick:()=>h(),children:[(0,R.jsx)(`span`,{className:`text-[color:var(--text-strong)]`,children:`Default`}),!m&&(0,R.jsx)(`span`,{className:`text-emerald-500`,children:`✓`})]}),p.map((e,t)=>(0,R.jsxs)(`button`,{id:`${g}-item-${t+1}`,type:`button`,role:`option`,"aria-selected":m===e.id,"data-hl":_===t+1||void 0,className:`${lC} font-mono text-xs`,onClick:()=>h(e.id),children:[(0,R.jsx)(`span`,{className:`text-[color:var(--text-strong)]`,children:e.id}),m===e.id&&(0,R.jsx)(`span`,{className:`text-emerald-500`,children:`✓`})]},e.id))]})]})}function fC({sessionID:e,openUp:t=!1,align:n=`right`}){let{session:r,detail:i}=cC(e),a=J(e=>e.pendingAgent),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)([]),[u,d]=(0,E.useState)(null),f=aC(()=>s(!1)),p=J(e=>e.uiSignals.agents);(0,E.useEffect)(()=>{p&&s(!0)},[p]);let m=(0,E.useMemo)(()=>c.filter(e=>e.mode===`primary`&&!e.hidden),[c]),h=`menu-agents`,g=a??i?.agent??r?.agent??u??void 0;(0,E.useEffect)(()=>{o&&c.length===0&&G.agents().then(l)},[o,c.length]),(0,E.useEffect)(()=>{!r?.agent&&u===null&&sC().then(e=>{e&&d(e.id)})},[r?.agent,u]);let _=t=>{let n=m[t];n&&(Zy(e,n.id).then(Yg),s(!1))},[v,,y]=oC({open:o,onClose:()=>s(!1),count:m.length,onSelect:_,listId:h}),b=`${t?`bottom-full mb-1`:`mt-1`} ${n===`right`?`right-0`:`left-0`}`;return(0,R.jsxs)(`div`,{ref:f,className:`relative`,children:[(0,R.jsx)(lS,{variant:`outline`,onClick:()=>s(!o),"aria-expanded":o,"aria-haspopup":`listbox`,title:`Switch agent (Tab)`,className:`h-7 max-w-28 px-2 text-[11px]`,children:(0,R.jsx)(`span`,{className:`truncate`,children:g??`agent`})}),o&&(0,R.jsx)(`div`,{id:h,role:`listbox`,"aria-label":`Switch agent`,"aria-activedescendant":`${h}-item-${v}`,className:`absolute z-40 max-h-80 w-60 overflow-y-auto rounded-lg border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] shadow-xl ${b}`,onMouseMove:y,children:m.map((e,t)=>(0,R.jsxs)(`button`,{id:`${h}-item-${t}`,type:`button`,role:`option`,"aria-selected":g===e.id,"data-hl":t===v||void 0,className:lC,onClick:()=>_(t),children:[(0,R.jsx)(`span`,{className:`text-[color:var(--text-strong)]`,children:e.name}),g===e.id&&(0,R.jsx)(`span`,{className:`text-emerald-500`,children:`✓`})]},e.id))})]})}function pC({...e}){return(0,R.jsx)(ap,{"data-slot":`popover`,...e})}function mC({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,R.jsx)(sp,{children:(0,R.jsx)(cp,{"data-slot":`popover-content`,align:t,sideOffset:n,className:V(`z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function hC({...e}){return(0,R.jsx)(op,{"data-slot":`popover-anchor`,...e})}function gC({open:e,query:t,location:n,onOpenChange:r,onPick:i,children:a}){let[o,s]=(0,E.useState)([]),[c,l]=(0,E.useState)(n);return(0,E.useEffect)(()=>{e&&!n&&!c&&G.location().then(e=>l(e.directory)).catch(()=>void 0)},[e,n,c]),(0,E.useEffect)(()=>{if(!e){s([]);return}let n=!1,r=setTimeout(()=>{G.fsFind(t,{location:c,limit:20}).then(e=>{n||s(e.data)}).catch(()=>{n||s([])})},120);return()=>{n=!0,clearTimeout(r)}},[e,t,c]),(0,R.jsxs)(pC,{open:e,onOpenChange:r,children:[(0,R.jsx)(hC,{asChild:!0,children:a}),(0,R.jsx)(mC,{side:`top`,align:`start`,sideOffset:8,className:`w-[min(26rem,calc(100vw-2rem))] p-0`,children:(0,R.jsx)(ph,{children:(0,R.jsxs)(gh,{children:[o.length>0&&(0,R.jsx)(vh,{heading:`Files`,children:o.map(e=>(0,R.jsxs)(bh,{value:e.path,onSelect:()=>i(e),children:[e.type===`directory`?(0,R.jsx)(Ee,{className:`text-[color:var(--text-weak)]`}):(0,R.jsx)(Ce,{className:`text-[color:var(--text-weak)]`}),(0,R.jsx)(`span`,{className:`font-mono text-[color:var(--text-strong)]`,children:e.path})]},e.path))}),o.length===0&&(0,R.jsx)(_h,{children:`No matching files`})]})})})]})}function _C({...e}){return(0,R.jsx)(Df,{"data-slot":`dropdown-menu`,...e})}function vC({...e}){return(0,R.jsx)(Of,{"data-slot":`dropdown-menu-trigger`,...e})}function yC({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,R.jsx)(kf,{children:(0,R.jsx)(Af,{"data-slot":`dropdown-menu-content`,sideOffset:n,align:t,className:V(`z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function bC({className:e,inset:t,variant:n=`default`,...r}){return(0,R.jsx)(Mf,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:V(`group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function xC({className:e,inset:t,...n}){return(0,R.jsx)(jf,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:V(`px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7`,e),...n})}function SC({className:e,...t}){return(0,R.jsx)(Nf,{"data-slot":`dropdown-menu-separator`,className:V(`-mx-1 my-1 h-px bg-border`,e),...t})}function CC({sessionID:e}){let t=J(t=>t.sessions.find(t=>t.id===e)),[n,r]=(0,E.useState)(!1),[i,a]=(0,E.useState)(null);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(_C,{open:n,onOpenChange:r,children:[(0,R.jsx)(vC,{asChild:!0,children:(0,R.jsx)(U,{variant:`ghost`,size:`icon`,title:`Session actions`,children:(0,R.jsx)(fe,{})})}),(0,R.jsxs)(yC,{align:`end`,className:`w-48`,children:[(0,R.jsxs)(bC,{onSelect:()=>a(`rename`),children:[(0,R.jsx)(Re,{}),` Rename…`]}),(0,R.jsxs)(bC,{onSelect:()=>a(`fork`),children:[(0,R.jsx)(Oe,{}),` Fork…`]}),(0,R.jsxs)(bC,{onSelect:()=>void DC(e),children:[(0,R.jsx)(de,{}),` Export`]}),(0,R.jsx)(SC,{}),(0,R.jsxs)(bC,{onSelect:()=>a(`compact`),children:[(0,R.jsx)(j,{}),` Compact`]})]})]}),i===`rename`&&(0,R.jsx)(wC,{sessionID:e,initialTitle:t?.title??``,onClose:()=>a(null)}),i===`fork`&&(0,R.jsx)(TC,{sessionID:e,onClose:()=>a(null)}),i===`compact`&&(0,R.jsx)(EC,{sessionID:e,onClose:()=>a(null)})]})}function wC({sessionID:e,initialTitle:t,onClose:n}){let[r,i]=(0,E.useState)(t),[a,o]=(0,E.useState)(!1),s=async()=>{let t=r.trim();if(!(!t||a)){o(!0);try{await $y(e,t),n()}finally{o(!1)}}};return(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&!a&&n(),children:(0,R.jsxs)(Zm,{children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Rename session`}),(0,R.jsx)(th,{children:`Give this session a new title.`})]}),(0,R.jsx)(nh,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s()},placeholder:`Untitled session`,autoFocus:!0}),(0,R.jsxs)($m,{children:[(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsx)(U,{variant:`outline`,disabled:a,children:`Cancel`})}),(0,R.jsx)(U,{onClick:()=>void s(),disabled:a||!r.trim(),children:`Rename`})]})]})})}function TC({sessionID:e,onClose:t}){let[n,r]=(0,E.useState)(``),[i,a]=(0,E.useState)(!1),o=async()=>{if(!i){a(!0);try{await Pv(await eb(e,n.trim()?{type:`before`,messageID:n.trim()}:{type:`through`})),t()}finally{a(!1)}}};return(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&!i&&t(),children:(0,R.jsxs)(Zm,{children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Fork session`}),(0,R.jsx)(th,{children:`Copies the conversation into a new session. Leave the boundary empty to fork the full session.`})]}),(0,R.jsx)(rh,{value:n,onChange:e=>r(e.target.value),placeholder:`Boundary message ID (msg_…) — empty forks the full session`,rows:3,autoFocus:!0}),(0,R.jsxs)($m,{children:[(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsx)(U,{variant:`outline`,disabled:i,children:`Cancel`})}),(0,R.jsx)(U,{onClick:()=>void o(),disabled:i,children:`Fork`})]})]})})}function EC({sessionID:e,onClose:t}){let[n,r]=(0,E.useState)(!1),i=async()=>{if(!n){r(!0);try{await nb(e,`steer`),t()}finally{r(!1)}}};return(0,R.jsx)(Km,{open:!0,onOpenChange:e=>!e&&!n&&t(),children:(0,R.jsxs)(Zm,{children:[(0,R.jsxs)(Qm,{children:[(0,R.jsx)(eh,{children:`Compact session`}),(0,R.jsx)(th,{children:`Summarizes the conversation so far into a single compact message so the agent can keep going with full context.`})]}),(0,R.jsxs)($m,{children:[(0,R.jsx)(Ym,{asChild:!0,children:(0,R.jsx)(U,{variant:`outline`,disabled:n,children:`Cancel`})}),(0,R.jsx)(U,{onClick:()=>void i(),disabled:n,children:`Compact`})]})]})})}async function DC(e){try{let t=await tb(e),n=new Blob([OC(t)],{type:`text/markdown`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.slice(0,8)}.md`,i.click(),URL.revokeObjectURL(r)}catch(e){console.warn(`session export failed:`,e)}}function OC(e){let{info:t,messages:n}=e,r=[`# ${t.title||`Untitled session`}`,``];r.push(`Session \`${t.id}\` · exported ${new Date(t.time.created).toISOString()}`,``);for(let e of n)if(e.type===`assistant`){r.push(`## assistant`,``);for(let t of e.content)t.type===`text`&&t.text?r.push(t.text,``):t.type===`reasoning`&&t.text?r.push("```reasoning",t.text,"```",``):t.type===`tool`&&r.push(`> tool: \`${t.name}\` (\`${t.id}\`)`,``)}else`text`in e&&typeof e.text==`string`&&e.text?r.push(`## ${e.type}`,``,e.text,``):e.type===`shell`&&r.push(`## shell`,``,`> \`${e.command}\``,``);return r.join(`
52
+ `)}var kC=null;function AC(){return kC??=G.models().catch(()=>[]),kC}var jC=null;function MC(){return jC??=G.agents().catch(()=>[]),jC}var NC=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e);async function PC(e){try{let t=await tb(e);await navigator.clipboard.writeText(OC(t))}catch{}}var FC=10;function IC(e,t){let n=0;for(let r of t)if(r===e[n]&&(n+=1),n===e.length)return!0;return n===e.length}function LC(e,t){let n=t.trim().toLowerCase();if(!n)return e.slice(0,FC);let r=[];for(let t of e){let e=0,i=`/${t.names[0]}`;if(i.startsWith(`/${n}`))e=1e3;else if(i.includes(n))e=600;else if(IC(n,i))e=200;else for(let r of t.names.slice(1)){let t=`/${r}`;t.startsWith(`/${n}`)?e=Math.max(e,800):t.includes(n)&&(e=Math.max(e,400))}e<100&&t.description?.toLowerCase().includes(n)&&(e=100),e>0&&r.push({entry:t,score:e})}return r.sort((e,t)=>t.score-e.score||e.entry.display.localeCompare(t.entry.display)),r.slice(0,FC).map(e=>e.entry)}function RC(){let[e,t]=(0,E.useState)(Dh);return(0,E.useEffect)(()=>kh(()=>t(Dh())),[]),e}function zC(e){let[t,n]=(0,E.useState)({shells:[],ptys:[]});return(0,E.useEffect)(()=>{async function t(){try{let t=e?{directory:e}:void 0,[r,i]=await Promise.all([G.shellList(t),G.ptyList(t)]);n({shells:r.data,ptys:i.data})}catch{}}return t(),og({name:`composer-runs`,minInterval:5e3,intervals:{live:5e3,idle:15e3},run:()=>t()})},[e]),t}function BC(e,t){let n=(0,E.useRef)(null);return(0,E.useEffect)(()=>{if(!e)return;function r(e){n.current&&!n.current.contains(e.target)&&t()}return document.addEventListener(`mousedown`,r),()=>document.removeEventListener(`mousedown`,r)},[e,t]),n}function VC(e){let t=e.value.length;e.setSelectionRange(t,t)}function HC({sessionID:e,paneKey:t=`main`,onNavigate:n}){let r=e=>n?n(e):void Pv(e),[i,a]=(0,E.useState)(()=>Wx(e)),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)([]),[u,d]=(0,E.useState)([]),f=RC(),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)([]),[_,v]=(0,E.useState)([]),[y,b]=(0,E.useState)(0),[x,S]=(0,E.useState)(!1),[C,w]=(0,E.useState)(!1),[T,D]=(0,E.useState)([]),[O,k]=(0,E.useState)([]),A=J(t=>t.running[e]??!1),j=J(t=>!!t.queued[e]),M=J(e=>e.interruptArmed),N=J(t=>t.messages[e]),ee=J(t=>t.sessionDetails[e]),te=J(t=>t.sessions.find(t=>t.id===e)?.parentID??t.sessionDetails[e]?.parentID),[P,F]=(0,E.useState)(0);(0,E.useEffect)(()=>pt(()=>F(e=>e+1)),[]);let ne=(0,E.useMemo)(()=>Ct(),[P]),re=J(t=>t.sessions.find(t=>t.id===e)?.location?.directory),ie=(0,E.useRef)(null),[ae,I]=(0,E.useState)(0);function L(e){I(e.selectionStart??e.value.length)}let oe=(0,E.useMemo)(()=>(N??[]).filter(e=>e.type===`user`&&!e.id.startsWith(`msg_local_`)).map(e=>e.text).filter(e=>e&&!e.startsWith(`/`)).reverse(),[N]),[se,ce]=(0,E.useState)(null),le=(0,E.useRef)(``),ue=(0,E.useRef)(e);(0,E.useEffect)(()=>{ce(null),ue.current!==e&&(ue.current=e,a(Wx(e)))},[e]),(0,E.useEffect)(()=>{ue.current===e&&Gx(e,i)},[e,i]);let de=J(t=>Ov(t.sessions,e)),fe=J(e=>e.running),pe=J(e=>e.activeIDs),me=zC(re),he=e=>fe[e]||pe.includes(e),ge=de.filter(e=>he(e.id)).length,_e=me.shells.filter(e=>e.status===`running`).length+me.ptys.filter(e=>e.status===`running`).length,ve=me.shells.length+me.ptys.length,ye=[de.length>0?ge>0?`${ge}/${de.length} agents`:`${de.length} agents`:null,ve>0?_e>0?`${_e}/${ve} shells`:`${ve} shells`:null].filter(Boolean).join(` · `)||`runs`,be=ge>0||_e>0,xe=J(e=>e.runsPanelOpen),[Se,Ce]=(0,E.useState)(!1),we=BC(Se,()=>Ce(!1)),[Te,Ee]=(0,E.useState)(!1),De=J(e=>e.pendingEdit),Oe=De?.sessionID===e;(0,E.useEffect)(()=>{G.commands().then(l),G.skills().then(d),AC().then(D),MC().then(k)},[]);function ke(){let e=ie.current;e&&(e.focus(),VC(e),I(e.value.length))}(0,E.useEffect)(()=>{let e=ie.current;e&&(e.focus(),VC(e),I(e.value.length))},[e]);let Ae=J(e=>e.revertPrompt);(0,E.useEffect)(()=>{Ae&&(a(Ae),Dv(),I(0),requestAnimationFrame(()=>ie.current?.setSelectionRange(0,0)))},[Ae]);let Me=Math.min(ae,i.length),Ne=i.slice(0,Me),Pe=!C&&Ne.startsWith(`/`)&&!/^\S+\s+\S/.test(Ne)&&p!==Ne,Fe=Ne.slice(1),Ie=(0,E.useMemo)(()=>[{name:`new`,aliases:[`clear`],description:`New session`,run:()=>void Xy()},{name:`sessions`,aliases:[`resume`,`continue`],description:`Switch session`,run:()=>r(null)},{name:`move`,description:`Move session to another workspace`,run:t=>{let n=t.trim();if(Eg(e)){window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Create a session first`,variant:`destructive`}}));return}if(n){G.moveSession(e,n).then(()=>{window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Moved to ${n}`}})),M_(e),Yg()}).catch(e=>{let t=e instanceof Error?e.message:String(e);window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Move failed: ${t}`,variant:`destructive`}}))});return}Ee(!0)}},{name:`undo`,description:`Undo previous message`,run:()=>void rb(e)},{name:`redo`,description:`Redo`,run:()=>void ib(e)},{name:`thinking`,aliases:[`toggle-thinking`],description:f.showReasoning?`Collapse all thinking`:`Expand all thinking`,run:()=>Oh(`showReasoning`,!Dh().showReasoning)},{name:`timestamps`,aliases:[`toggle-timestamps`],description:f.showTimestamps?`Hide timestamps`:`Show timestamps`,run:()=>Oh(`showTimestamps`,!Dh().showTimestamps)},{name:`rename`,description:`Rename session`,run:t=>{let n=t.trim();n&&$y(e,n)}},{name:`fork`,description:`Fork session`,run:()=>void eb(e,{type:`through`}).then(e=>r(e))},{name:`export`,description:`Export session transcript`,run:()=>void DC(e)},{name:`copy`,description:`Copy session transcript`,run:()=>void PC(e)},{name:`compact`,aliases:[`summarize`],description:`Compact session`,run:()=>void nb(e,`steer`)},{name:`connect`,description:`Connect providers & integrations`,run:()=>XS(`integrations`)},{name:`models`,aliases:[`mo`],description:`Switch model`,run:()=>Sv(`models`)},{name:`variants`,description:`Switch model variant`,run:()=>Sv(`variants`)},{name:`agents`,description:`Switch agent`,run:()=>Sv(`agents`)},{name:`themes`,description:`Switch theme`,run:()=>Sv(`themes`)},{name:`skills`,description:`Browse skills`,run:()=>Ce(!0)},{name:`mcps`,description:`Toggle MCPs`,run:()=>XS(`mcp`)},{name:`status`,description:`View status`,run:()=>XS(`server`)},{name:`diff`,description:`Open diff viewer`,run:()=>Sv(`explorer`)},{name:`help`,description:`Help`,run:()=>Sv(`help`)}],[e,f.showReasoning,f.showTimestamps]),Le=(0,E.useMemo)(()=>new Set(c.map(e=>e.name)),[c]);function ze(e){Le.has(e.name)?(a(`/${e.name} `),m(`/${e.name} `),ke()):(a(``),jy(e.id))}let Be=ee?.model,Ve=(0,E.useMemo)(()=>Be?(T.find(e=>e.enabled&&e.modelID===Be.id&&e.providerID===Be.providerID)?.variants?.length??0)>0:!1,[T,Be]),He=(0,E.useMemo)(()=>{let t=[];for(let e of Ie)e.name===`variants`&&!Ve||t.push({key:`action:${e.name}`,display:`/${e.name}`,names:[e.name,...e.aliases??[]],description:e.description,onSelect:()=>{a(``),e.run(``)}});for(let n of ne)t.push({key:`slash:${n.id}`,display:`/${n.name}`,names:[n.name,...n.aliases??[]],description:n.description,onSelect:()=>{a(``),n.run(``,{sessionID:e})}});for(let e of c)t.push({key:`command:${e.name}`,display:`/${e.name}`,names:[e.name],description:e.description,onSelect:()=>{a(`/${e.name} `),m(`/${e.name} `),ke()}});for(let e of u)t.push({key:`skill:${e.id}`,display:`/${e.name}`,names:[e.name],description:e.description,onSelect:()=>ze(e)});return t.sort((e,t)=>e.display.localeCompare(t.display))},[Ie,ne,c,u,Le,Ve,e]),Ue=(0,E.useMemo)(()=>LC(He,Fe),[He,Fe]),We=(0,E.useMemo)(()=>{let e=i.lastIndexOf(`@`);if(e===-1)return;let t=e===0?``:i[e-1],n=i.slice(e+1);if((e===0||/\s/.test(t))&&!/\s/.test(n))return n},[i]);(0,E.useEffect)(()=>{S(!1)},[i]);let Ge=(0,E.useMemo)(()=>{let e=N??[];for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`assistant`)return n}},[N]),Ke=Ge?.type===`assistant`?Ge.tokens:void 0,qe=Ke?Ke.input+Ke.output+Ke.reasoning+Ke.cache.read+Ke.cache.write:void 0,Ye=(Ge?.type===`assistant`?Ge.cost:void 0)??ee?.cost??0,Xe=T.find(e=>e.enabled&&e.modelID===Be?.id&&e.providerID===Be?.providerID)?.limit?.context,Ze=qe&&Xe?Math.round(qe/Xe*100):void 0,Qe=[qe===void 0?void 0:`${NC(qe)} tok`,Ze===void 0?void 0:`${Ze}% ctx`,Ye>0?`$${Ye.toFixed(4)}`:void 0].filter(Boolean),$e=ee?.agent;function et(t){let n=O.filter(e=>e.mode===`primary`&&!e.hidden);if(n.length===0)return;let r=n.findIndex(e=>e.id===$e),i=n[(((r===-1?0:r)+t)%n.length+n.length)%n.length];Zy(e,i.id).then(()=>void M_(e))}function nt(e,t){let n=Fx(e)??`application/octet-stream`;v(r=>[...r,{id:`att_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,name:e.split(`/`).pop()||e,mime:n,uri:`data:${n};base64,${Rx(t)}`}])}function rt(e){let t=i.lastIndexOf(`@`);if(t===-1)return;if(e.type===`file`&&Ax(e.path)){a(i.slice(0,t)+i.slice(t+1+(We?.length??0))),ke(),G.fsReadBytes(e.path,re).then(t=>nt(e.path,t)).catch(()=>void 0);return}let n=`@${e.path}`;a(i.slice(0,t)+n+` `),g(t=>[...t,{path:e.path}]),re&&G.fsRead(e.path,re).then(t=>g(n=>n.map(n=>n.path===e.path?{path:n.path,content:t}:n))).catch(()=>void 0),ke()}async function it(){if(Eg(e))try{return await Yy(i)}catch{return null}return e||null}async function ot(t){let n=i.trim();if(!(!n&&_.length===0||o)){s(!0),ce(null);try{if(!C&&n.startsWith(`/`)){let t=n.slice(1).split(` `),r=t[0],i=Ie.find(e=>e.name===r||e.aliases?.includes(r));if(i){i.run(t.slice(1).join(` `)),a(``),g([]),v([]);return}let o=ne.find(e=>e.name===r||e.aliases?.includes(r));if(o){await o.run(t.slice(1).join(` `),{sessionID:e}),a(``),g([]),v([]);return}}let r=await it();if(!r)return;let i=Ng().pendingEdit;if(i&&i.sessionID===r){let{commitPendingEdit:e}=await ug(async()=>{let{commitPendingEdit:e}=await Promise.resolve().then(()=>dg);return{commitPendingEdit:e}},void 0);await e(r)}if(C)await gy(n.startsWith(`!`)?n.slice(1):n);else if(n.startsWith(`!`))await gy(n.slice(1));else if(n.startsWith(`/`)){let e=n.slice(1).split(` `),t=e[0];await hy(t,e.slice(1).join(` `)||void 0)}else if(h.length>0||_.length>0){let e=Ng().draftWorkspace,i=re??e??void 0,a=[];for(let e of h){if(!i)continue;let t=`@${e.path}`,r=n.indexOf(t);a.push({uri:`file://${encodeURI(`${i.replace(/\/+$/,``)}/${e.path}`)}`,name:e.path,mention:r===-1?void 0:{start:r,end:r+t.length,text:t}})}for(let e of _)a.push(Px(e));a.length>0?await _y(n,a):await ey(r,n,t)}else await ey(r,n,t);a(``),g([]),v([])}catch{a(n)}finally{s(!1),ke()}}}let st=C?`bash — esc to exit`:A?`Agent is working… — ↵ steers · ctrl+↵ queues`:j?`Waiting for the agent… — ↵ steers · ctrl+↵ queues`:`Message the agent…`,ct=C?(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--surface-brand-base)]`,children:`Shell`}),` · esc to exit`]}):A&&M?(0,R.jsx)(`p`,{className:`font-medium text-[color:var(--surface-warning-strong)]`,children:`Press esc again to interrupt`}):A||j?(0,R.jsxs)(`p`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(uS,{className:`size-3`}),A?`Working… · esc to interrupt`:`Waiting…`,i.trim()?` · ↵ steer · ctrl+↵ queue`:``]}):(0,R.jsxs)(`p`,{children:[(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--text-weak)]`,children:`Tab`}),` agent,`,` `,(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--text-weak)]`,children:`/`}),` commands,`,` `,(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--text-weak)]`,children:`@`}),` files,`,` `,(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--text-weak)]`,children:`!`}),` bash`]}),lt=re?.split(`/`).filter(Boolean).pop();return(0,R.jsxs)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2.5 pt-2`,children:[(0,R.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,R.jsx)(`div`,{className:`relative`,children:Se&&(0,R.jsxs)(`div`,{ref:we,className:`absolute bottom-full left-0 z-40 mb-2 max-h-80 w-[min(26rem,calc(100vw-2rem))] overflow-y-auto rounded-lg border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] p-1 shadow-xl`,children:[u.length===0&&(0,R.jsx)(`p`,{className:`px-2.5 py-1.5 text-xs text-[color:var(--text-weaker)]`,children:`No skills available`}),u.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{Ce(!1),ze(e)},className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-[color:var(--surface-base-hover)]`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-[color:var(--text-strong)]`,children:[`/`,e.name]}),e.description&&(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-[color:var(--text-weaker)]`,children:e.description})]},e.id))]})}),(0,R.jsxs)(pC,{open:Pe,children:[(0,R.jsx)(hC,{asChild:!0,children:(0,R.jsxs)(`div`,{onDragEnter:e=>{Array.from(e.dataTransfer.types).includes(`Files`)&&b(e=>e+1)},onDragOver:e=>{Array.from(e.dataTransfer.types).includes(`Files`)&&e.preventDefault()},onDragLeave:()=>b(e=>Math.max(0,e-1)),onDrop:e=>{b(0),e.dataTransfer.files.length!==0&&(e.preventDefault(),Nx(e.dataTransfer.files).then(e=>{e.length>0&&v(t=>[...t,...e])}))},className:`rounded-lg border bg-[color:var(--input-base)] p-2 transition-colors focus-within:border-[color:var(--border-selected)] ${y>0||C?`border-[color:var(--surface-brand-base)]`:`border-[color:var(--border-base)]`}`,children:[(0,R.jsx)(Nt,{region:`composer.above`,sessionID:e}),Oe&&De&&(0,R.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1.5 text-xs`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 font-medium text-amber-700 dark:text-amber-300`,children:[(0,R.jsx)(Re,{className:`size-3`}),` Editing`]}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[var(--text-weaker)]`,title:De.originalText,children:De.originalText.slice(0,80).replace(/\s+/g,` `)||`(empty)`}),(0,R.jsx)(`span`,{className:`hidden text-[10px] text-[var(--text-weaker)] sm:inline`,children:`will revert on send`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ug(()=>Promise.resolve().then(()=>dg).then(e=>e.clearPendingEdit()),void 0)},title:`Dismiss edit — next send is a normal message`,className:`ml-auto flex size-6 cursor-pointer items-center justify-center rounded-md hover:bg-black/10 dark:hover:bg-white/10`,children:(0,R.jsx)(at,{className:`size-3`})})]}),_.length>0&&(0,R.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-start gap-2 border-b border-[color:var(--border-weak-base)] pb-1.5`,children:[_.map(e=>(0,R.jsxs)(`span`,{className:`relative inline-block`,title:`${e.name} (${e.mime})`,children:[(0,R.jsx)(`img`,{src:e.uri,alt:e.name,draggable:!1,className:`size-12 rounded-md border border-[color:var(--border-weak-base)] object-cover`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>v(t=>t.filter(t=>t.id!==e.id)),title:`Remove attachment`,className:`absolute -right-1.5 -top-1.5 flex size-4 cursor-pointer items-center justify-center rounded-full border border-[color:var(--border-weak-base)] bg-[color:var(--surface-float-base)] text-[color:var(--text-weak)] transition-colors hover:text-[color:var(--text-strong)]`,children:(0,R.jsx)(at,{className:`size-2.5`})})]},e.id)),(0,R.jsxs)(`span`,{className:`self-center text-[11px] text-[color:var(--text-weaker)]`,children:[`image`,_.length===1?``:`s`,` attached`]})]}),(0,R.jsx)(gC,{open:We!==void 0&&!x&&!Pe,query:We??``,location:re,onOpenChange:S,onPick:rt,children:(0,R.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,R.jsx)(rh,{id:`composer-input-${t}`,ref:ie,value:i,placeholder:st,className:`max-h-40 min-h-0 flex-1 resize-none border-0 bg-transparent px-1.5 py-1 text-sm placeholder:text-[color:var(--text-weaker)] focus-visible:ring-0 ${C?`font-mono`:``}`,onChange:e=>{ce(null),a(e.target.value),L(e.currentTarget)},onSelect:e=>L(e.currentTarget),onClick:e=>L(e.currentTarget),onKeyUp:e=>L(e.currentTarget),onPaste:e=>{let t=[];for(let n of Array.from(e.clipboardData?.items??[])){if(n.kind!==`file`)continue;let e=n.getAsFile();e&&t.push(e)}t.some(e=>e.type.startsWith(`image/`)||Ax(e.name))&&(e.preventDefault(),Nx(t).then(e=>{e.length>0&&v(t=>[...t,...e])}))},onKeyDown:t=>{if(Pe){if(t.key===`Escape`){t.preventDefault(),Me===i.length&&!i.endsWith(` `)?a(``):m(Ne);return}if(t.key===`ArrowDown`){t.preventDefault(),uh(1);return}if(t.key===`ArrowUp`){t.preventDefault(),uh(-1);return}if(t.key===`Enter`){t.preventDefault(),dh();return}if(t.key===`Tab`){t.preventDefault(),dh();return}}if(We!==void 0&&!x&&!Pe&&document.querySelector(`[data-slot="command-item"]`)){if(t.key===`ArrowDown`){t.preventDefault(),uh(1);return}if(t.key===`ArrowUp`){t.preventDefault(),uh(-1);return}if(t.key===`Enter`&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey){t.preventDefault(),dh();return}}if(Se&&t.key===`Escape`){t.preventDefault(),Ce(!1);return}if(!Pe&&We===void 0&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&!t.shiftKey){if(t.key===`ArrowUp`){let e=t.currentTarget;if(e.selectionStart===0&&e.selectionEnd===0&&oe.length>0){t.preventDefault(),se===null&&(le.current=i);let n=se===null?0:Math.min(se+1,oe.length-1);ce(n);let r=oe[n]??``;a(r),I(0),requestAnimationFrame(()=>e.setSelectionRange(0,0))}return}if(t.key===`ArrowDown`){let e=t.currentTarget;if(e.selectionStart===i.length&&e.selectionEnd===i.length){if(se===null)t.preventDefault(),Cv();else if(se<=0)t.preventDefault(),ce(null),a(le.current),I(le.current.length),requestAnimationFrame(()=>e.setSelectionRange(le.current.length,le.current.length));else{t.preventDefault();let n=Math.min(se-1,oe.length-1);ce(n);let r=oe[Math.max(n,0)]??``;a(r),I(r.length),requestAnimationFrame(()=>e.setSelectionRange(r.length,r.length))}}return}}if(t.key.toLowerCase()===`b`&&t.ctrlKey&&!t.metaKey&&!t.altKey&&!t.shiftKey){Pe||(t.preventDefault(),(A||j)&&Ly(e));return}if(t.key===`Escape`){if(t.preventDefault(),C){w(!1);return}if(A){Iy();return}return}if(t.key===`Tab`){t.preventDefault(),et(t.shiftKey?-1:1);return}if(t.key===`Backspace`&&!i&&te){t.preventDefault(),r(te);return}if(t.key===`Enter`&&!t.shiftKey&&!t.altKey&&(t.ctrlKey||t.metaKey)&&!Pe&&We===void 0){t.preventDefault(),ot(C?void 0:{delivery:`queue`});return}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),ot())}}),o?(0,R.jsx)(uS,{className:`mb-1.5 mr-2`}):(0,R.jsxs)(U,{variant:`default`,size:`sm`,disabled:!i.trim()&&_.length===0,onClick:()=>void ot(),title:A?`Send (↵ steer · ctrl+↵ queue)`:`Send (Enter)`,children:[(0,R.jsx)(Je,{}),`Send`]})]})}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 border-t border-[color:var(--border-weak-base)] px-1 pt-1`,children:[(0,R.jsxs)(`button`,{type:`button`,"data-runs-panel-trigger":!0,onClick:()=>xe?wv():Cv(),title:xe?`Close subagents & shells (↓)`:`Subagents & shells — opens the runs panel (↓)`,className:`flex h-6 cursor-pointer items-center gap-1 rounded-md px-1.5 font-mono text-[11px] transition-colors ${be?`text-[color:var(--surface-brand-base)] hover:bg-[color:var(--surface-base-hover)]`:`text-[color:var(--text-weaker)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`}`,children:[(0,R.jsx)(je,{className:`size-3`}),ye]}),(0,R.jsx)(`button`,{type:`button`,title:`Shell mode (! command)`,onClick:()=>w(e=>!e),className:`flex size-6 cursor-pointer items-center justify-center rounded-md transition-colors ${C?`bg-[color:var(--surface-brand-weak)] text-[color:var(--surface-brand-strong)]`:`text-[color:var(--text-weaker)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`}`,children:(0,R.jsx)(tt,{className:`size-3.5`})}),(0,R.jsx)(fC,{sessionID:e,openUp:!0,align:`left`}),(0,R.jsx)(uC,{sessionID:e,openUp:!0,align:`left`}),(0,R.jsx)(dC,{sessionID:e,openUp:!0,align:`left`}),(0,R.jsx)(Nt,{region:`composer.toolbar`,sessionID:e}),Qe.length>0&&(0,R.jsx)(`span`,{className:`ml-auto font-mono text-[11px] text-[color:var(--text-weaker)]`,title:`Tokens used · share of model context window · session cost`,children:Qe.join(` · `)})]}),(0,R.jsx)(Nt,{region:`composer.below`,sessionID:e})]})}),(0,R.jsx)(mC,{side:`top`,align:`start`,sideOffset:8,className:`w-[min(26rem,calc(100vw-2rem))] p-0`,onOpenAutoFocus:e=>e.preventDefault(),children:(0,R.jsx)(ph,{children:(0,R.jsxs)(gh,{children:[Ue.map(e=>(0,R.jsxs)(bh,{value:e.key,onSelect:e.onSelect,children:[(0,R.jsx)(`span`,{className:`font-mono text-[color:var(--text-base)]`,children:e.display}),e.description&&(0,R.jsx)(`span`,{className:`ml-auto max-w-[55%] truncate pl-3 text-xs text-[color:var(--text-weaker)]`,children:e.description})]},e.key)),Ue.length===0&&(0,R.jsx)(_h,{children:`No matching items`})]})})})]}),(0,R.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between px-1 text-[11px] text-[color:var(--text-weaker)]`,children:[ct,lt&&(0,R.jsx)(`p`,{className:`hidden truncate font-mono sm:block`,children:lt})]})]}),Te&&(0,R.jsx)(UC,{sessionID:e,currentDirectory:re,onClose:()=>Ee(!1),onMoved:t=>{Ee(!1),window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Moved to ${t}`}})),M_(e),Yg()}})]})}function UC({sessionID:e,currentDirectory:t,onClose:n,onMoved:r}){let[i,a]=(0,E.useState)([]),[o,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(!0);(0,E.useEffect)(()=>{let e=!1;return(async()=>{try{let[n,r]=await Promise.all([G.projectList().catch(()=>[]),G.location().catch(()=>null)]);if(e)return;let i=new Set;for(let e of n){let t=e.directory;t&&i.add(t)}r?.directory&&i.add(r.directory),t&&i.add(t),a([...i].sort())}catch{}e||l(!1)})(),()=>{e=!0}},[t]);let u=t=>{let n=t.trim();n&&G.moveSession(e,n).then(()=>r(n)).catch(e=>{let t=e instanceof Error?e.message:String(e);window.dispatchEvent(new CustomEvent(`opencode:notify`,{detail:{title:`Move failed: ${t}`,variant:`destructive`}}))})};return(0,R.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4`,onClick:n,children:(0,R.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium text-[var(--text-strong)]`,children:`Move session`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-[var(--text-weaker)]`,children:`Pick a workspace or enter a path. Mirrors the TUI picker.`}),c?(0,R.jsx)(`p`,{className:`mt-4 text-xs text-[var(--text-weaker)]`,children:`Loading workspaces…`}):(0,R.jsxs)(`div`,{className:`mt-3 max-h-56 overflow-y-auto rounded-md border border-[var(--border-weak-base)]`,children:[i.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs hover:bg-[var(--surface-base-hover)] ${e===t?`bg-[var(--surface-raised-base-active)] font-medium`:``}`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-[var(--text-strong)]`,children:e.replace(/^\/(home|Users)\/[^/]+/,`~`)}),e===t&&(0,R.jsx)(`span`,{className:`ml-2 text-[10px] text-[var(--text-weaker)]`,children:`current`})]},e)),i.length===0&&(0,R.jsx)(`p`,{className:`px-3 py-2 text-xs text-[var(--text-weaker)]`,children:`No workspaces found`})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,R.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u(o),e.key===`Escape`&&n()},placeholder:`Custom path — e.g. /home/z/projects/foo`,className:`flex-1 rounded-md border border-[var(--border-base)] bg-[var(--input-base)] px-2.5 py-1.5 font-mono text-xs outline-none focus:border-[var(--border-selected)]`,autoFocus:!0}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>u(o),disabled:!o.trim(),className:`rounded-md bg-[var(--surface-brand-base)] px-3 py-1.5 text-xs font-medium text-white disabled:opacity-50`,children:`Move`}),(0,R.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-md border border-[var(--border-weak-base)] px-3 py-1.5 text-xs`,children:`Cancel`})]})]})})}function WC(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var GC=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,KC=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,qC={};function JC(e,t){return((t||qC).jsx?KC:GC).test(e)}var YC=/[ \t\n\f\r]/g;function XC(e){return typeof e==`object`?e.type===`text`&&ZC(e.value):ZC(e)}function ZC(e){return e.replace(YC,``)===``}var QC=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};QC.prototype.normal={},QC.prototype.property={},QC.prototype.space=void 0;function $C(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new QC(n,r,t)}function ew(e){return e.toLowerCase()}var tw=class{constructor(e,t){this.attribute=t,this.property=e}};tw.prototype.attribute=``,tw.prototype.booleanish=!1,tw.prototype.boolean=!1,tw.prototype.commaOrSpaceSeparated=!1,tw.prototype.commaSeparated=!1,tw.prototype.defined=!1,tw.prototype.mustUseProperty=!1,tw.prototype.number=!1,tw.prototype.overloadedBoolean=!1,tw.prototype.property=``,tw.prototype.spaceSeparated=!1,tw.prototype.space=void 0;var nw=s({boolean:()=>iw,booleanish:()=>aw,commaOrSpaceSeparated:()=>lw,commaSeparated:()=>cw,number:()=>Y,overloadedBoolean:()=>ow,spaceSeparated:()=>sw}),rw=0,iw=uw(),aw=uw(),ow=uw(),Y=uw(),sw=uw(),cw=uw(),lw=uw();function uw(){return 2**++rw}var dw=Object.keys(nw),fw=class extends tw{constructor(e,t,n,r){let i=-1;if(super(e,t),pw(this,`space`,r),typeof n==`number`)for(;++i<dw.length;){let e=dw[i];pw(this,dw[i],(n&nw[e])===nw[e])}}};fw.prototype.defined=!0;function pw(e,t,n){n&&(e[t]=n)}function mw(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new fw(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ew(r)]=r,n[ew(a.attribute)]=r}return new QC(t,n,e.space)}var hw=mw({properties:{ariaActiveDescendant:null,ariaAtomic:aw,ariaAutoComplete:null,ariaBusy:aw,ariaChecked:aw,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:sw,ariaCurrent:null,ariaDescribedBy:sw,ariaDetails:null,ariaDisabled:aw,ariaDropEffect:sw,ariaErrorMessage:null,ariaExpanded:aw,ariaFlowTo:sw,ariaGrabbed:aw,ariaHasPopup:null,ariaHidden:aw,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:sw,ariaLevel:Y,ariaLive:null,ariaModal:aw,ariaMultiLine:aw,ariaMultiSelectable:aw,ariaOrientation:null,ariaOwns:sw,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:aw,ariaReadOnly:aw,ariaRelevant:null,ariaRequired:aw,ariaRoleDescription:sw,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:aw,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function gw(e,t){return t in e?e[t]:t}function _w(e,t){return gw(e,t.toLowerCase())}var vw=mw({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:cw,acceptCharset:sw,accessKey:sw,action:null,allow:null,allowFullScreen:iw,allowPaymentRequest:iw,allowUserMedia:iw,alpha:iw,alt:null,as:null,async:iw,autoCapitalize:null,autoComplete:sw,autoFocus:iw,autoPlay:iw,blocking:sw,capture:null,charSet:null,checked:iw,cite:null,className:sw,closedBy:null,colorSpace:null,cols:Y,colSpan:Y,command:null,commandFor:null,content:null,contentEditable:aw,controls:iw,controlsList:sw,coords:Y|cw,crossOrigin:null,data:null,dateTime:null,decoding:null,default:iw,defer:iw,dir:null,dirName:null,disabled:iw,download:ow,draggable:aw,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:iw,formTarget:null,headers:sw,height:Y,hidden:ow,high:Y,href:null,hrefLang:null,htmlFor:sw,httpEquiv:sw,id:null,imageSizes:null,imageSrcSet:null,inert:iw,inputMode:null,integrity:null,is:null,isMap:iw,itemId:null,itemProp:sw,itemRef:sw,itemScope:iw,itemType:sw,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:iw,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:iw,muted:iw,name:null,nonce:null,noModule:iw,noValidate:iw,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:iw,optimum:Y,pattern:null,ping:sw,placeholder:null,playsInline:iw,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:iw,referrerPolicy:null,rel:sw,required:iw,reversed:iw,rows:Y,rowSpan:Y,sandbox:sw,scope:null,scoped:iw,seamless:iw,selected:iw,shadowRootClonable:iw,shadowRootCustomElementRegistry:iw,shadowRootDelegatesFocus:iw,shadowRootMode:null,shadowRootSerializable:iw,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:aw,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:iw,useMap:null,value:aw,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:sw,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:iw,declare:iw,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:iw,noHref:iw,noShade:iw,noWrap:iw,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:aw,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:iw,disablePictureInPicture:iw,disableRemotePlayback:iw,exportParts:cw,part:sw,prefix:null,property:null,results:Y,security:null,unselectable:null},space:`html`,transform:_w}),yw=mw({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:lw,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:sw,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:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:iw,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,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:cw,g2:cw,glyphName:cw,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:lw,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,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:Y,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:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:sw,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:lw,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:lw,rev:lw,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:lw,requiredFeatures:lw,requiredFonts:lw,requiredFormats:lw,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:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:lw,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:lw,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:lw,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:gw}),bw=mw({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()}}),xw=mw({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:_w}),Sw=mw({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Cw={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`},ww=/[A-Z]/g,Tw=/-[a-z]/g,Ew=/^data[-\w.:]+$/i;function Dw(e,t){let n=ew(t),r=t,i=tw;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Ew.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Tw,kw);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Tw.test(e)){let n=e.replace(ww,Ow);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=fw}return new i(r,t)}function Ow(e){return`-`+e.toLowerCase()}function kw(e){return e.charAt(1).toUpperCase()}var Aw=$C([hw,vw,bw,xw,Sw],`html`),jw=$C([hw,yw,bw,xw,Sw],`svg`);function Mw(e){return e.join(` `).trim()}var Nw=o(((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;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
53
+ `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),Pw=o((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(Nw());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}})),Fw=o((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))}})),Iw=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Pw()),r=Fw();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})),Lw=zw(`end`),Rw=zw(`start`);function zw(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 Bw(e){let t=Rw(e),n=Lw(e);if(t&&n)return{start:t,end:n}}function Vw(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Uw(e.position):`start`in e||`end`in e?Uw(e):`line`in e||`column`in e?Hw(e):``}function Hw(e){return Ww(e&&e.line)+`:`+Ww(e&&e.column)}function Uw(e){return Hw(e&&e.start)+`-`+Hw(e&&e.end)}function Ww(e){return e&&typeof e==`number`?e:1}var Gw=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=Vw(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}};Gw.prototype.file=``,Gw.prototype.name=``,Gw.prototype.reason=``,Gw.prototype.message=``,Gw.prototype.stack=``,Gw.prototype.column=void 0,Gw.prototype.line=void 0,Gw.prototype.ancestors=void 0,Gw.prototype.cause=void 0,Gw.prototype.fatal=void 0,Gw.prototype.place=void 0,Gw.prototype.ruleId=void 0,Gw.prototype.source=void 0;var Kw=l(Iw(),1),qw={}.hasOwnProperty,Jw=new Map,Yw=/[A-Z]/g,Xw=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Zw=new Set([`td`,`th`]);function Qw(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=lT(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=cT(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`?jw:Aw,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=$w(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function $w(e,t,n){if(t.type===`element`)return eT(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return tT(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return rT(e,t,n);if(t.type===`mdxjsEsm`)return nT(e,t);if(t.type===`root`)return iT(e,t,n);if(t.type===`text`)return aT(e,t)}function eT(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=jw,e.schema=i),e.ancestors.push(t);let a=hT(e,t.tagName,!1),o=uT(e,t),s=fT(e,t);return Xw.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!XC(e)})),oT(e,o,a,t),sT(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function tT(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)}gT(e,t.position)}function nT(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);gT(e,t.position)}function rT(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=jw,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:hT(e,t.name,!0),o=dT(e,t),s=fT(e,t);return oT(e,o,a,t),sT(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function iT(e,t,n){let r={};return sT(r,fT(e,t)),e.create(t,e.Fragment,r,n)}function aT(e,t){return t.value}function oT(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function sT(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function cT(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 lT(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Rw(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 uT(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&qw.call(t.properties,i)){let a=pT(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Zw.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 dT(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 gT(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 gT(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function fT(e,t){let n=[],r=-1,i=e.passKeys?new Map:Jw;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=$w(e,a,o);s!==void 0&&n.push(s)}return n}function pT(e,t,n){let r=Dw(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?WC(n):Mw(n)),r.property===`style`){let t=typeof n==`object`?n:mT(e,String(n));return e.stylePropertyNameCase===`css`&&(t=_T(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Cw[r.property]||r.property:r.attribute,n]}}function mT(e,t){try{return(0,Kw.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Gw("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=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function hT(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=JC(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=JC(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return qw.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);gT(e)}function gT(e,t){let n=new Gw("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=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function _T(e){let t={},n;for(n in e)qw.call(e,n)&&(t[vT(n)]=e[n]);return t}function vT(e){let t=e.replace(Yw,yT);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function yT(e){return`-`+e.toLowerCase()}var bT={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`]},xT={};function ST(e,t){let n=t||xT;return CT(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function CT(e,t,n){if(TT(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 wT(e.children,t,n)}return Array.isArray(e)?wT(e,t,n):``}function wT(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=CT(e[i],t,n);return r.join(``)}function TT(e){return!!(e&&typeof e==`object`)}var ET=document.createElement(`i`);function DT(e){let t=`&`+e+`;`;ET.innerHTML=t;let n=ET.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function OT(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 kT(e,t){return e.length>0?(OT(e,e.length,0,t),e):t}var AT={}.hasOwnProperty;function jT(e){let t={},n=-1;for(;++n<e.length;)MT(t,e[n]);return t}function MT(e,t){let n;for(n in t){let r=(AT.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){AT.call(r,a)||(r[a]=[]);let e=i[a];NT(r[a],Array.isArray(e)?e:e?[e]:[])}}}function NT(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);OT(e,0,0,r)}function PT(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 FT(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var IT=qT(/[A-Za-z]/),LT=qT(/[\dA-Za-z]/),RT=qT(/[#-'*+\--9=?A-Z^-~]/);function zT(e){return e!==null&&(e<32||e===127)}var BT=qT(/\d/),VT=qT(/[\dA-Fa-f]/),HT=qT(/[!-/:-@[-`{-~]/);function X(e){return e!==null&&e<-2}function UT(e){return e!==null&&(e<0||e===32)}function WT(e){return e===-2||e===-1||e===32}var GT=qT(/\p{P}|\p{S}/u),KT=qT(/\s/);function qT(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function JT(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&LT(e.charCodeAt(n+1))&&LT(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 YT(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return WT(r)?(e.enter(n),s(r)):t(r)}function s(r){return WT(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var XT={tokenize:ZT};function ZT(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`),YT(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 X(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var QT={tokenize:eE},$T={tokenize:tE};function eE(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 OT(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($T,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($T,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 X(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++;OT(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 tE(e,t,n){return YT(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function nE(e){if(e===null||UT(e)||KT(e))return 1;if(GT(e))return 2}function rE(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 iE={name:`attention`,resolveAll:aE,tokenize:oE};function aE(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};sE(d,-c),sE(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=kT(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=kT(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=kT(l,rE(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=kT(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=kT(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,OT(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 oE(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=nE(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=nE(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 sE(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var cE={name:`autolink`,tokenize:lE};function lE(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 IT(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||LT(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||LT(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||zT(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):RT(t)?(e.consume(t),l):n(t)}function u(e){return LT(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||LT(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var uE={partial:!0,tokenize:dE};function dE(e,t,n){return r;function r(t){return WT(t)?YT(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||X(e)?t(e):n(e)}}var fE={continuation:{tokenize:mE},exit:hE,name:`blockQuote`,tokenize:pE};function pE(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 WT(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function mE(e,t,n){let r=this;return i;function i(t){return WT(t)?YT(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(fE,t,n)(r)}}function hE(e){e.exit(`blockQuote`)}var gE={name:`characterEscape`,tokenize:_E};function _E(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 HT(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var vE={name:`characterReference`,tokenize:yE};function yE(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=LT,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=VT,u):(e.enter(`characterReferenceValue`),a=7,o=BT,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===LT&&!DT(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 bE={partial:!0,tokenize:CE},xE={concrete:!0,name:`codeFenced`,tokenize:SE};function SE(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`),WT(t)?YT(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||X(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(bE,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||X(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):WT(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),YT(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||X(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||X(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&&WT(t)?YT(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||X(t)?e.check(bE,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||X(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`),WT(t)?YT(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`),WT(t)?YT(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||X(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function CE(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 wE={name:`codeIndented`,tokenize:EE},TE={partial:!0,tokenize:DE};function EE(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),YT(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):X(t)?e.attempt(TE,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||X(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function DE(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):YT(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):X(e)?i(e):n(e)}}var OE={name:`codeText`,previous:AE,resolve:kE,tokenize:jE};function kE(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 AE(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function jE(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)):X(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||X(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 ME=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&&NE(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),NE(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),NE(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);NE(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);NE(this.left,t.reverse())}}}};function NE(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 PE(e){let t={},n=-1,r,i,a,o,s,c,l,u=new ME(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,FE(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 OT(e,0,1/0,u.slice(0)),!l}function FE(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 IE={resolve:RE,tokenize:zE},LE={partial:!0,tokenize:BE};function RE(e){return PE(e),e}function zE(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):X(t)?e.check(LE,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 BE(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),YT(e,a,`linePrefix`)}function a(i){if(i===null||X(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 VE(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||zT(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||X(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||UT(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||zT(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 HE(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):X(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||X(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!WT(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function UE(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):X(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),YT(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||X(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 WE(e,t){let n;return r;function r(i){return X(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):WT(i)?YT(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var GE={name:`definition`,tokenize:qE},KE={partial:!0,tokenize:JE};function qE(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return HE.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=FT(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 UT(t)?WE(e,l)(t):l(t)}function l(t){return VE(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(KE,d,d)(t)}function d(t){return WT(t)?YT(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||X(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function JE(e,t,n){return r;function r(t){return UT(t)?WE(e,i)(t):n(t)}function i(t){return UE(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return WT(t)?YT(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||X(e)?t(e):n(e)}}var YE={name:`hardBreakEscape`,tokenize:XE};function XE(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return X(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var ZE={name:`headingAtx`,resolve:QE,tokenize:$E};function QE(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`},OT(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function $E(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||UT(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||X(n)?(e.exit(`atxHeading`),t(n)):WT(n)?YT(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||UT(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var eD=`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(`.`),tD=[`pre`,`script`,`style`,`textarea`],nD={concrete:!0,name:`htmlFlow`,resolveTo:aD,tokenize:oD},rD={partial:!0,tokenize:cD},iD={partial:!0,tokenize:sD};function aD(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 oD(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:P):IT(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):IT(a)?(e.consume(a),i=4,r.interrupt?t:P):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:P):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 IT(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||UT(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&tD.includes(l)?(i=1,r.interrupt?t(s):O(s)):eD.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||LT(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 WT(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||IT(t)?(e.consume(t),b):WT(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||LT(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):WT(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):WT(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||X(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||UT(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||WT(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||X(t)?O(t):WT(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),F):t===63&&i===3?(e.consume(t),P):t===93&&i===5?(e.consume(t),te):X(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(rD,ne,k)(t)):t===null||X(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(iD,A,ne)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||X(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),P):O(t)}function N(t){return t===47?(e.consume(t),o=``,ee):O(t)}function ee(t){if(t===62){let n=o.toLowerCase();return tD.includes(n)?(e.consume(t),F):O(t)}return IT(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ee):O(t)}function te(t){return t===93?(e.consume(t),P):O(t)}function P(t){return t===62?(e.consume(t),F):t===45&&i===2?(e.consume(t),P):O(t)}function F(t){return t===null||X(t)?(e.exit(`htmlFlowData`),ne(t)):(e.consume(t),F)}function ne(n){return e.exit(`htmlFlow`),t(n)}}function sD(e,t,n){let r=this;return i;function i(t){return X(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 cD(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(uE,t,n)}}var lD={name:`htmlText`,tokenize:uD};function uD(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):IT(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):IT(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):X(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):X(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):X(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):X(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return IT(t)?(e.consume(t),S):n(t)}function S(t){return t===45||LT(t)?(e.consume(t),S):C(t)}function C(t){return X(t)?(o=C,N(t)):WT(t)?(e.consume(t),C):M(t)}function w(t){return t===45||LT(t)?(e.consume(t),w):t===47||t===62||UT(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||IT(t)?(e.consume(t),E):X(t)?(o=T,N(t)):WT(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||LT(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):X(t)?(o=D,N(t)):WT(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):X(t)?(o=O,N(t)):WT(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):X(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||UT(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||UT(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`),ee}function ee(t){return WT(t)?YT(e,te,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):te(t)}function te(t){return e.enter(`htmlTextData`),o(t)}}var dD={name:`labelEnd`,resolveAll:hD,resolveTo:gD,tokenize:_D},fD={tokenize:vD},pD={tokenize:yD},mD={tokenize:bD};function hD(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&&OT(e,0,e.length,n),e}function gD(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=kT(s,e.slice(a+1,a+r+3)),s=kT(s,[[`enter`,u,t]]),s=kT(s,rE(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=kT(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=kT(s,e.slice(o+1)),s=kT(s,[[`exit`,c,t]]),OT(e,a,e.length,s),e}function _D(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(FT(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(fD,u,o?u:d)(t):t===91?e.attempt(pD,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(mD,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function vD(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 UT(t)?WE(e,a)(t):a(t)}function a(t){return t===41?u(t):VE(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return UT(t)?WE(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?UE(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return UT(t)?WE(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 yD(e,t,n){let r=this;return i;function i(t){return HE.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(FT(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function bD(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 xD={name:`labelStartImage`,resolveAll:dD.resolveAll,tokenize:SD};function SD(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 CD={name:`labelStartLink`,resolveAll:dD.resolveAll,tokenize:wD};function wD(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 TD={name:`lineEnding`,tokenize:ED};function ED(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),YT(e,t,`linePrefix`)}}var DD={name:`thematicBreak`,tokenize:OD};function OD(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||X(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),WT(t)?YT(e,s,`whitespace`)(t):s(t))}}var kD={continuation:{tokenize:ND},exit:FD,name:`list`,tokenize:MD},AD={partial:!0,tokenize:ID},jD={partial:!0,tokenize:PD};function MD(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:BT(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(DD,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 BT(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(uE,r.interrupt?n:u,e.attempt(AD,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return WT(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 ND(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(uE,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,YT(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!WT(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(jD,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,YT(e,e.attempt(kD,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function PD(e,t,n){let r=this;return YT(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 FD(e){e.exit(this.containerState.type)}function ID(e,t,n){let r=this;return YT(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!WT(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var LD={name:`setextUnderline`,resolveTo:RD,tokenize:zD};function RD(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 zD(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`),WT(t)?YT(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||X(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var BD={tokenize:VD};function VD(e){let t=this,n=e.attempt(uE,r,e.attempt(this.parser.constructs.flowInitial,i,YT(e,e.attempt(this.parser.constructs.flow,i,e.attempt(IE,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 HD={resolveAll:KD()},UD=GD(`string`),WD=GD(`text`);function GD(e){return{resolveAll:KD(e===`text`?qD: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 KD(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 qD(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 JD=s({attentionMarkers:()=>nO,contentInitial:()=>XD,disable:()=>rO,document:()=>YD,flow:()=>QD,flowInitial:()=>ZD,insideSpan:()=>tO,string:()=>$D,text:()=>eO}),YD={42:kD,43:kD,45:kD,48:kD,49:kD,50:kD,51:kD,52:kD,53:kD,54:kD,55:kD,56:kD,57:kD,62:fE},XD={91:GE},ZD={[-2]:wE,[-1]:wE,32:wE},QD={35:ZE,42:DD,45:[LD,DD],60:nD,61:LD,95:DD,96:xE,126:xE},$D={38:vE,92:gE},eO={[-5]:TD,[-4]:TD,[-3]:TD,33:xD,38:vE,42:iE,60:[cE,lD],91:CD,92:[YE,gE],93:dD,95:iE,96:OE},tO={null:[iE,HD]},nO={null:[42,95]},rO={null:[]};function iO(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=kT(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=rE(a,l.events,l),l.events):[]}function f(e,t){return oO(p(e),t)}function p(e){return aO(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){X(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&&OT(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 aO(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 oO(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=`
54
54
  `;break;case-3:o=`\r
55
- `;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 QD(e){let t={constructs:ST([zD,...(e||{}).extensions||[]]),content:n(VT),defined:[],document:n(UT),flow:n(jD),lazy:{},string:n(PD),text:n(FD)};return t;function n(e){return n;function n(n){return YD(t,e,n)}}}function $D(e){for(;!TE(e););return e}var eO=/[\0\t\n\r]/g;function tO(){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(eO.lastIndex=u,c=eO.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 nO=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function rO(e){return e.replace(nO,iO)}function iO(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return TT(n.slice(t?2:1),t?16:10)}return vT(n)||e}var aO={}.hasOwnProperty;function oO(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),sO(n)($D(QD(n).document().write(tO()(e,t,!0))))}function sO(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(_e),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(pe),blockQuote:a(ce),characterEscape:T,characterReference:T,codeFenced:a(le),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(le,o),codeText:a(ue,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(fe),hardBreakEscape:a(me),hardBreakTrailing:a(me),htmlFlow:a(he,o),htmlFlowData:T,htmlText:a(he,o),htmlTextData:T,image:a(ge),label:o,link:a(_e),listItem:a(ye),listItemValue:f,listOrdered:a(ve,d),listUnordered:a(ve),paragraph:a(be),reference:re,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(pe),strong:a(xe),thematicBreak:a(Ce)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:se,autolinkProtocol:oe,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:I,characterReference:L,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:te,labelText:ee,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ie,resourceDestinationString:P,resourceTitleString:F,resource:ne,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};lO(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]];aO.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]||dO).call(a,void 0,e[0])}for(r.position={start:cO(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:cO(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:cO(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]||dO).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Mw({start:e.start,end:e.end})+`): it’s not open`);n.position.end=cO(e.end)}function u(){return pT(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=ET(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=Se(),n.position={start:cO(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=cO(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=cO(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 ee(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=rO(t),n.identifier=ET(t).toLowerCase()}function te(){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 P(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ne(){this.data.inReference=void 0}function re(){this.data.referenceType=`collapsed`}function ie(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=ET(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ae(e){this.data.characterReferenceType=e.type}function I(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=TT(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=vT(t);let i=this.stack[this.stack.length-1];i.value+=r}function L(e){let t=this.stack.pop();t.position.end=cO(e.end)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function se(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ce(){return{type:`blockquote`,children:[]}}function le(){return{type:`code`,lang:null,meta:null,value:``}}function ue(){return{type:`inlineCode`,value:``}}function de(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function fe(){return{type:`emphasis`,children:[]}}function pe(){return{type:`heading`,depth:0,children:[]}}function me(){return{type:`break`}}function he(){return{type:`html`,value:``}}function ge(){return{type:`image`,title:null,url:``,alt:null}}function _e(){return{type:`link`,title:null,url:``,children:[]}}function ve(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ye(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function be(){return{type:`paragraph`,children:[]}}function xe(){return{type:`strong`,children:[]}}function Se(){return{type:`text`,value:``}}function Ce(){return{type:`thematicBreak`}}}function cO(e){return{line:e.line,column:e.column,offset:e.offset}}function lO(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?lO(e,r):uO(e,r)}}function uO(e,t){let n;for(n in t)if(aO.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 dO(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Mw({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Mw({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Mw({start:t.start,end:t.end})+`) is still open`)}function fO(e){let t=this;t.parser=n;function n(n){return oO(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function pO(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 mO(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
56
- `}]}function hO(e,t){let n=t.value?t.value+`
57
- `:``,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 gO(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _O(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vO(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=zT(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 yO(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 bO(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xO(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 SO(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xO(e,t);let i={src:zT(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 CO(e,t){let n={src:zT(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 wO(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 TO(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xO(e,t);let i={href:zT(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 EO(e,t){let n={href:zT(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 DO(e,t,n){let r=e.all(t),i=n?OO(n):kO(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:`
55
+ `;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 sO(e){let t={constructs:jT([JD,...(e||{}).extensions||[]]),content:n(XT),defined:[],document:n(QT),flow:n(BD),lazy:{},string:n(UD),text:n(WD)};return t;function n(e){return n;function n(n){return iO(t,e,n)}}}function cO(e){for(;!PE(e););return e}var lO=/[\0\t\n\r]/g;function uO(){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(lO.lastIndex=u,c=lO.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 dO=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function fO(e){return e.replace(dO,pO)}function pO(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return PT(n.slice(t?2:1),t?16:10)}return DT(n)||e}var mO={}.hasOwnProperty;function hO(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),gO(n)(cO(sO(n).document().write(uO()(e,t,!0))))}function gO(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(_e),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(pe),blockQuote:a(ce),characterEscape:T,characterReference:T,codeFenced:a(le),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(le,o),codeText:a(ue,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(fe),hardBreakEscape:a(me),hardBreakTrailing:a(me),htmlFlow:a(he,o),htmlFlowData:T,htmlText:a(he,o),htmlTextData:T,image:a(ge),label:o,link:a(_e),listItem:a(ye),listItemValue:f,listOrdered:a(ve,d),listUnordered:a(ve),paragraph:a(be),reference:re,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(pe),strong:a(xe),thematicBreak:a(Ce)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:se,autolinkProtocol:oe,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:I,characterReference:L,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:te,labelText:ee,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ie,resourceDestinationString:P,resourceTitleString:F,resource:ne,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};vO(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]];mO.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]||bO).call(a,void 0,e[0])}for(r.position={start:_O(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:_O(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:_O(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]||bO).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Vw({start:e.start,end:e.end})+`): it’s not open`);n.position.end=_O(e.end)}function u(){return ST(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=FT(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=Se(),n.position={start:_O(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=_O(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=_O(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 ee(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=fO(t),n.identifier=FT(t).toLowerCase()}function te(){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 P(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ne(){this.data.inReference=void 0}function re(){this.data.referenceType=`collapsed`}function ie(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=FT(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ae(e){this.data.characterReferenceType=e.type}function I(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=PT(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=DT(t);let i=this.stack[this.stack.length-1];i.value+=r}function L(e){let t=this.stack.pop();t.position.end=_O(e.end)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function se(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ce(){return{type:`blockquote`,children:[]}}function le(){return{type:`code`,lang:null,meta:null,value:``}}function ue(){return{type:`inlineCode`,value:``}}function de(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function fe(){return{type:`emphasis`,children:[]}}function pe(){return{type:`heading`,depth:0,children:[]}}function me(){return{type:`break`}}function he(){return{type:`html`,value:``}}function ge(){return{type:`image`,title:null,url:``,alt:null}}function _e(){return{type:`link`,title:null,url:``,children:[]}}function ve(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ye(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function be(){return{type:`paragraph`,children:[]}}function xe(){return{type:`strong`,children:[]}}function Se(){return{type:`text`,value:``}}function Ce(){return{type:`thematicBreak`}}}function _O(e){return{line:e.line,column:e.column,offset:e.offset}}function vO(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?vO(e,r):yO(e,r)}}function yO(e,t){let n;for(n in t)if(mO.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 bO(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Vw({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Vw({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Vw({start:t.start,end:t.end})+`) is still open`)}function xO(e){let t=this;t.parser=n;function n(n){return hO(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function SO(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 CO(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
56
+ `}]}function wO(e,t){let n=t.value?t.value+`
57
+ `:``,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 TO(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EO(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DO(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=JT(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 OO(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 kO(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function AO(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 jO(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AO(e,t);let i={src:JT(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 MO(e,t){let n={src:JT(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 NO(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 PO(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return AO(e,t);let i={href:JT(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 FO(e,t){let n={href:JT(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 IO(e,t,n){let r=e.all(t),i=n?LO(n):RO(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:`
58
58
  `}),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:`
59
- `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function OO(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=kO(n[r])}return t}function kO(e){return e.spread??e.children.length>1}function AO(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 jO(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function MO(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function NO(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PO(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=kw(t.children[1]),o=Ow(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 FO(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 IO(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var LO=9,RO=32;function zO(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(BO(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(BO(t.slice(i),i>0,!1)),a.join(``)}function BO(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===LO||t===RO;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===LO||t===RO;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function VO(e,t){let n={type:`text`,value:zO(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function HO(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var UO={blockquote:pO,break:mO,code:hO,delete:gO,emphasis:_O,footnoteReference:vO,heading:yO,html:bO,imageReference:SO,image:CO,inlineCode:wO,linkReference:TO,link:EO,listItem:DO,list:AO,paragraph:jO,root:MO,strong:NO,table:PO,tableCell:IO,tableRow:FO,text:VO,thematicBreak:HO,toml:WO,yaml:WO,definition:WO,footnoteDefinition:WO};function WO(){}var GO=typeof self==`object`?self:globalThis,KO=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new GO[e](t)},qO=(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(typeof GO[e]==`function`?KO(e,t):Error(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(KO(a,o),i)};return r},JO=e=>qO(new Map,e)(0),YO=``,{toString:XO}={},{keys:ZO}=Object,QO=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=XO.call(e).slice(8,-1);switch(n){case`Array`:return[1,YO];case`Object`:return[2,YO];case`Date`:return[3,YO];case`RegExp`:return[4,YO];case`Map`:return[5,YO];case`Set`:return[6,YO];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},$O=([e,t])=>e===0&&(t===`function`||t===`symbol`),ek=(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]=QO(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 ZO(r))(e||!$O(QO(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,isNaN(r.getTime())?YO: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||!($O(QO(n))||$O(QO(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!$O(QO(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},tk=(e,{json:t,lossy:n}={})=>{let r=[];return ek(!(t||n),!!t,new Map,r)(e),r},nk=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?JO(tk(e,t)):structuredClone(e):(e,t)=>JO(tk(e,t));function rk(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 ik(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function ak(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||rk,r=e.options.footnoteBackLabel||ik,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=zT(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:{...nk(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
59
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function LO(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=RO(n[r])}return t}function RO(e){return e.spread??e.children.length>1}function zO(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 BO(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function VO(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function HO(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function UO(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=Rw(t.children[1]),o=Lw(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 WO(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 GO(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var KO=9,qO=32;function JO(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(YO(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(YO(t.slice(i),i>0,!1)),a.join(``)}function YO(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===KO||t===qO;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===KO||t===qO;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function XO(e,t){let n={type:`text`,value:JO(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function ZO(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var QO={blockquote:SO,break:CO,code:wO,delete:TO,emphasis:EO,footnoteReference:DO,heading:OO,html:kO,imageReference:jO,image:MO,inlineCode:NO,linkReference:PO,link:FO,listItem:IO,list:zO,paragraph:BO,root:VO,strong:HO,table:UO,tableCell:GO,tableRow:WO,text:XO,thematicBreak:ZO,toml:$O,yaml:$O,definition:$O,footnoteDefinition:$O};function $O(){}var ek=typeof self==`object`?self:globalThis,tk=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new ek[e](t)},nk=(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(typeof ek[e]==`function`?tk(e,t):Error(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(tk(a,o),i)};return r},rk=e=>nk(new Map,e)(0),ik=``,{toString:ak}={},{keys:ok}=Object,sk=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=ak.call(e).slice(8,-1);switch(n){case`Array`:return[1,ik];case`Object`:return[2,ik];case`Date`:return[3,ik];case`RegExp`:return[4,ik];case`Map`:return[5,ik];case`Set`:return[6,ik];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},ck=([e,t])=>e===0&&(t===`function`||t===`symbol`),lk=(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]=sk(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 ok(r))(e||!ck(sk(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,isNaN(r.getTime())?ik: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||!(ck(sk(n))||ck(sk(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!ck(sk(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},uk=(e,{json:t,lossy:n}={})=>{let r=[];return lk(!(t||n),!!t,new Map,r)(e),r},dk=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?rk(uk(e,t)):structuredClone(e):(e,t)=>rk(uk(e,t));function fk(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 pk(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function mk(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||fk,r=e.options.footnoteBackLabel||pk,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=JT(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:{...dk(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
60
60
  `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
61
- `}]}}var ok=(function(e){if(e==null)return dk;if(typeof e==`function`)return uk(e);if(typeof e==`object`)return Array.isArray(e)?sk(e):ck(e);if(typeof e==`string`)return lk(e);throw Error(`Expected function, string, or object as test`)});function sk(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ok(e[n]);return uk(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ck(e){let t=e;return uk(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function lk(e){return uk(t);function t(t){return t&&t.type===e}}function uk(e){return t;function t(t,n,r){return!!(fk(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function dk(){return!0}function fk(e){return typeof e==`object`&&!!e&&`type`in e}function pk(e){return e}var mk=[];function hk(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=ok(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 (`+pk(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=mk,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=gk(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 gk(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?mk:[e]}function _k(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),hk(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 vk={}.hasOwnProperty,yk={};function bk(e,t){let n=t||yk,r=new Map,i=new Map,a={all:s,applyData:Sk,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...UO,...n.handlers},one:o,options:n,patch:xk,wrap:wk};return _k(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(vk.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=nk(n);return r.children=a.all(e),r}return nk(e)}return(a.options.unknownHandler||Ck)(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=Tk(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=Tk(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function xk(e,t){e.position&&(t.position=jw(e))}function Sk(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,nk(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function Ck(e,t){let n=t.data||{},r=`value`in t&&!(vk.call(n,`hProperties`)||vk.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 wk(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
61
+ `}]}}var hk=(function(e){if(e==null)return bk;if(typeof e==`function`)return yk(e);if(typeof e==`object`)return Array.isArray(e)?gk(e):_k(e);if(typeof e==`string`)return vk(e);throw Error(`Expected function, string, or object as test`)});function gk(e){let t=[],n=-1;for(;++n<e.length;)t[n]=hk(e[n]);return yk(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function _k(e){let t=e;return yk(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function vk(e){return yk(t);function t(t){return t&&t.type===e}}function yk(e){return t;function t(t,n,r){return!!(xk(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function bk(){return!0}function xk(e){return typeof e==`object`&&!!e&&`type`in e}function Sk(e){return e}var Ck=[];function wk(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=hk(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 (`+Sk(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=Ck,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Tk(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 Tk(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Ck:[e]}function Ek(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),wk(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 Dk={}.hasOwnProperty,Ok={};function kk(e,t){let n=t||Ok,r=new Map,i=new Map,a={all:s,applyData:jk,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...QO,...n.handlers},one:o,options:n,patch:Ak,wrap:Nk};return Ek(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(Dk.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=dk(n);return r.children=a.all(e),r}return dk(e)}return(a.options.unknownHandler||Mk)(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=Pk(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=Pk(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function Ak(e,t){e.position&&(t.position=Bw(e))}function jk(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,dk(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function Mk(e,t){let n=t.data||{},r=`value`in t&&!(Dk.call(n,`hProperties`)||Dk.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 Nk(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
62
62
  `});++r<e.length;)r&&n.push({type:`text`,value:`
63
63
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
64
- `}),n}function Tk(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Ek(e,t){let n=bk(e,t),r=n.one(e,void 0),i=ak(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
65
- `},i)),a}function Dk(e,t){return e&&`run`in e?async function(n,r){let i=Ek(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Ek(n,{file:r,...e||t})}}function Ok(e){if(e)throw e}var kk=o(((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 Ak(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 jk(){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?Mk(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 Mk(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 Nk={basename:Pk,dirname:Fk,extname:Ik,join:Lk,sep:`/`};function Pk(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Bk(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 Fk(e){if(Bk(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 Ik(e){Bk(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 Lk(...e){let t=-1,n;for(;++t<e.length;)Bk(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Rk(n)}function Rk(e){Bk(e);let t=e.codePointAt(0)===47,n=zk(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function zk(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 Bk(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Vk={cwd:Hk};function Hk(){return`/`}function Uk(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Wk(e){if(typeof e==`string`)e=new URL(e);else if(!Uk(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 Gk(e)}function Gk(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 Kk=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],qk=class{constructor(e){let t;t=e?Uk(e)?{path:e}:typeof e==`string`||Zk(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Vk.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Kk.length;){let e=Kk[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)Kk.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Nk.basename(this.path):void 0}set basename(e){Yk(e,`basename`),Jk(e,`basename`),this.path=Nk.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Nk.dirname(this.path):void 0}set dirname(e){Xk(this.basename,`dirname`),this.path=Nk.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Nk.extname(this.path):void 0}set extname(e){if(Jk(e,`extname`),Xk(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=Nk.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Uk(e)&&(e=Wk(e)),Yk(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Nk.basename(this.path,this.extname):void 0}set stem(e){Yk(e,`stem`),Jk(e,`stem`),this.path=Nk.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 Iw(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 Jk(e,t){if(e&&e.includes(Nk.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Nk.sep+"`")}function Yk(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function Xk(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Zk(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Qk=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),$k=l(kk(),1),eA={}.hasOwnProperty,tA=new class e extends Qk{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=jk()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,$k.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(iA(`data`,this.frozen),this.namespace[e]=t,this):eA.call(this.namespace,e)&&this.namespace[e]||void 0:e?(iA(`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=sA(e),n=this.parser||this.Parser;return nA(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),nA(`process`,this.parser||this.Parser),rA(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=sA(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);lA(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(),nA(`processSync`,this.parser||this.Parser),rA(`processSync`,this.compiler||this.Compiler),this.process(e,r),oA(`processSync`,`process`,t),n;function r(e,r){t=!0,Ok(e),n=r}}run(e,t,n){aA(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=sA(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),oA(`runSync`,`run`,n),r;function i(e,t){Ok(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=sA(t),r=this.compiler||this.Compiler;return rA(`stringify`,r),aA(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(iA(`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,$k.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];Ak(o)&&Ak(r)&&(r=(0,$k.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function nA(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function rA(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function iA(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 aA(e){if(!Ak(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function oA(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function sA(e){return cA(e)?e:new qk(e)}function cA(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function lA(e){return typeof e==`string`||uA(e)}function uA(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var dA=[],fA={allowDangerousHtml:!0},pA=/^(https?|ircs?|mailto|xmpp)$/i,mA=[{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 hA(e){let t=gA(e),n=_A(e);return vA(t.runSync(t.parse(n),n),e)}function gA(e){let t=e.rehypePlugins||dA,n=e.remarkPlugins||dA,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...fA}:fA;return tA().use(fO).use(n).use(Dk,r).use(t)}function _A(e){let t=e.children||``,n=new qk;return typeof t==`string`?n.value=t:``+t,n}function vA(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||yA;for(let e of mA)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return _k(e,l),Uw(e,{Fragment:R.Fragment,components:i,ignoreInvalidStyle:!0,jsx:R.jsx,jsxs:R.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 dT)if(Object.hasOwn(dT,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=dT[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 yA(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||pA.test(e.slice(0,t))?e:``}function bA(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 xA(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function SA(e,t,n){let r=ok((n||{}).ignore||[]),i=CA(t),a=-1;for(;++a<i.length;)hk(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 CA(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([wA(e[0]),TA(e[1])])}return t}function wA(e){return typeof e==`string`?new RegExp(xA(e),`g`):e}function TA(e){return typeof e==`function`?e:function(){return e}}var EA=`phrasing`,DA=[`autolink`,`link`,`image`,`label`];function OA(){return{transforms:[IA],enter:{literalAutolink:AA,literalAutolinkEmail:jA,literalAutolinkHttp:jA,literalAutolinkWww:jA},exit:{literalAutolink:FA,literalAutolinkEmail:PA,literalAutolinkHttp:MA,literalAutolinkWww:NA}}}function kA(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:EA,notInConstruct:DA},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:EA,notInConstruct:DA},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:EA,notInConstruct:DA}]}}function AA(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function jA(e){this.config.enter.autolinkProtocol.call(this,e)}function MA(e){this.config.exit.autolinkProtocol.call(this,e)}function NA(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 PA(e){this.config.exit.autolinkEmail.call(this,e)}function FA(e){this.exit(e)}function IA(e){SA(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,LA],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,RA]],{ignore:[`link`,`linkReference`]})}function LA(e,t,n,r,i){let a=``;if(!VA(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!zA(n)))return!1;let o=BA(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 RA(e,t,n,r){return!VA(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function zA(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 BA(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=bA(e,`(`),a=bA(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 VA(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||LT(n)||IT(n))&&(!t||n!==47)}ZA.peek=XA;function HA(){this.buffer()}function UA(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function WA(){this.buffer()}function GA(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function KA(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ET(this.sliceSerialize(e)).toLowerCase(),n.label=t}function qA(e){this.exit(e)}function JA(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ET(this.sliceSerialize(e)).toLowerCase(),n.label=t}function YA(e){this.exit(e)}function XA(){return`[`}function ZA(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 QA(){return{enter:{gfmFootnoteCallString:HA,gfmFootnoteCall:UA,gfmFootnoteDefinitionLabelString:WA,gfmFootnoteDefinition:GA},exit:{gfmFootnoteCallString:KA,gfmFootnoteCall:qA,gfmFootnoteDefinitionLabelString:JA,gfmFootnoteDefinition:YA}}}function $A(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:ZA},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?`
66
- `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?tj:ej))),s(),o}}function ej(e,t,n){return t===0?e:tj(e,t,n)}function tj(e,t,n){return(n?``:` `)+e}var nj=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];sj.peek=cj;function rj(){return{canContainEols:[`delete`],enter:{strikethrough:aj},exit:{strikethrough:oj}}}function ij(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:nj}],handlers:{delete:sj}}}function aj(e){this.enter({type:`delete`,children:[]},e)}function oj(e){this.exit(e)}function sj(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 cj(){return`~`}function lj(e){return e.length}function uj(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||lj,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=dj(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]=fj(r[d]);else{let e=fj(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(`
67
- `)}function dj(e){return e==null?``:String(e)}function fj(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 pj(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()),mj);return i(),o}function mj(e,t,n){return`>`+(n?``:` `)+e}function hj(e,t){return gj(e,t.inConstruct,!0)&&!gj(e,t.notInConstruct,!1)}function gj(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 _j(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
68
- `&&hj(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
69
- `}function vj(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 yj(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 bj(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function xj(e,t,n,r){let i=bj(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(yj(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Sj);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(vj(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:`
64
+ `}),n}function Pk(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Fk(e,t){let n=kk(e,t),r=n.one(e,void 0),i=mk(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
65
+ `},i)),a}function Ik(e,t){return e&&`run`in e?async function(n,r){let i=Fk(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Fk(n,{file:r,...e||t})}}function Lk(e){if(e)throw e}var Rk=o(((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 zk(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 Bk(){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?Vk(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 Vk(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 Hk={basename:Uk,dirname:Wk,extname:Gk,join:Kk,sep:`/`};function Uk(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);Yk(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 Wk(e){if(Yk(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 Gk(e){Yk(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 Kk(...e){let t=-1,n;for(;++t<e.length;)Yk(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:qk(n)}function qk(e){Yk(e);let t=e.codePointAt(0)===47,n=Jk(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Jk(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 Yk(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Xk={cwd:Zk};function Zk(){return`/`}function Qk(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function $k(e){if(typeof e==`string`)e=new URL(e);else if(!Qk(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 eA(e)}function eA(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 tA=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],nA=class{constructor(e){let t;t=e?Qk(e)?{path:e}:typeof e==`string`||oA(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Xk.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<tA.length;){let e=tA[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)tA.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Hk.basename(this.path):void 0}set basename(e){iA(e,`basename`),rA(e,`basename`),this.path=Hk.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Hk.dirname(this.path):void 0}set dirname(e){aA(this.basename,`dirname`),this.path=Hk.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Hk.extname(this.path):void 0}set extname(e){if(rA(e,`extname`),aA(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=Hk.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Qk(e)&&(e=$k(e)),iA(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Hk.basename(this.path,this.extname):void 0}set stem(e){iA(e,`stem`),rA(e,`stem`),this.path=Hk.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 Gw(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 rA(e,t){if(e&&e.includes(Hk.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Hk.sep+"`")}function iA(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function aA(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function oA(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var sA=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),cA=l(Rk(),1),lA={}.hasOwnProperty,uA=new class e extends sA{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=Bk()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,cA.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(pA(`data`,this.frozen),this.namespace[e]=t,this):lA.call(this.namespace,e)&&this.namespace[e]||void 0:e?(pA(`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=gA(e),n=this.parser||this.Parser;return dA(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),dA(`process`,this.parser||this.Parser),fA(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=gA(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);vA(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(),dA(`processSync`,this.parser||this.Parser),fA(`processSync`,this.compiler||this.Compiler),this.process(e,r),hA(`processSync`,`process`,t),n;function r(e,r){t=!0,Lk(e),n=r}}run(e,t,n){mA(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=gA(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),hA(`runSync`,`run`,n),r;function i(e,t){Lk(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=gA(t),r=this.compiler||this.Compiler;return fA(`stringify`,r),mA(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(pA(`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,cA.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];zk(o)&&zk(r)&&(r=(0,cA.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function dA(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function fA(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function pA(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 mA(e){if(!zk(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function hA(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function gA(e){return _A(e)?e:new nA(e)}function _A(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function vA(e){return typeof e==`string`||yA(e)}function yA(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var bA=[],xA={allowDangerousHtml:!0},SA=/^(https?|ircs?|mailto|xmpp)$/i,CA=[{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 wA(e){let t=TA(e),n=EA(e);return DA(t.runSync(t.parse(n),n),e)}function TA(e){let t=e.rehypePlugins||bA,n=e.remarkPlugins||bA,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...xA}:xA;return uA().use(xO).use(n).use(Ik,r).use(t)}function EA(e){let t=e.children||``,n=new nA;return typeof t==`string`?n.value=t:``+t,n}function DA(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||OA;for(let e of CA)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return Ek(e,l),Qw(e,{Fragment:R.Fragment,components:i,ignoreInvalidStyle:!0,jsx:R.jsx,jsxs:R.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 bT)if(Object.hasOwn(bT,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=bT[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 OA(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||SA.test(e.slice(0,t))?e:``}function kA(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 AA(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function jA(e,t,n){let r=hk((n||{}).ignore||[]),i=MA(t),a=-1;for(;++a<i.length;)wk(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 MA(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([NA(e[0]),PA(e[1])])}return t}function NA(e){return typeof e==`string`?new RegExp(AA(e),`g`):e}function PA(e){return typeof e==`function`?e:function(){return e}}var FA=`phrasing`,IA=[`autolink`,`link`,`image`,`label`];function LA(){return{transforms:[GA],enter:{literalAutolink:zA,literalAutolinkEmail:BA,literalAutolinkHttp:BA,literalAutolinkWww:BA},exit:{literalAutolink:WA,literalAutolinkEmail:UA,literalAutolinkHttp:VA,literalAutolinkWww:HA}}}function RA(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:FA,notInConstruct:IA},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:FA,notInConstruct:IA},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:FA,notInConstruct:IA}]}}function zA(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function BA(e){this.config.enter.autolinkProtocol.call(this,e)}function VA(e){this.config.exit.autolinkProtocol.call(this,e)}function HA(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 UA(e){this.config.exit.autolinkEmail.call(this,e)}function WA(e){this.exit(e)}function GA(e){jA(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,KA],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,qA]],{ignore:[`link`,`linkReference`]})}function KA(e,t,n,r,i){let a=``;if(!XA(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!JA(n)))return!1;let o=YA(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 qA(e,t,n,r){return!XA(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function JA(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 YA(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=kA(e,`(`),a=kA(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 XA(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||KT(n)||GT(n))&&(!t||n!==47)}oj.peek=aj;function ZA(){this.buffer()}function QA(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function $A(){this.buffer()}function ej(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function tj(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=FT(this.sliceSerialize(e)).toLowerCase(),n.label=t}function nj(e){this.exit(e)}function rj(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=FT(this.sliceSerialize(e)).toLowerCase(),n.label=t}function ij(e){this.exit(e)}function aj(){return`[`}function oj(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 sj(){return{enter:{gfmFootnoteCallString:ZA,gfmFootnoteCall:QA,gfmFootnoteDefinitionLabelString:$A,gfmFootnoteDefinition:ej},exit:{gfmFootnoteCallString:tj,gfmFootnoteCall:nj,gfmFootnoteDefinitionLabelString:rj,gfmFootnoteDefinition:ij}}}function cj(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:oj},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?`
66
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?uj:lj))),s(),o}}function lj(e,t,n){return t===0?e:uj(e,t,n)}function uj(e,t,n){return(n?``:` `)+e}var dj=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];gj.peek=_j;function fj(){return{canContainEols:[`delete`],enter:{strikethrough:mj},exit:{strikethrough:hj}}}function pj(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:dj}],handlers:{delete:gj}}}function mj(e){this.enter({type:`delete`,children:[]},e)}function hj(e){this.exit(e)}function gj(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 _j(){return`~`}function vj(e){return e.length}function yj(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||vj,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=bj(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]=xj(r[d]);else{let e=xj(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(`
67
+ `)}function bj(e){return e==null?``:String(e)}function xj(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 Sj(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()),Cj);return i(),o}function Cj(e,t,n){return`>`+(n?``:` `)+e}function wj(e,t){return Tj(e,t.inConstruct,!0)&&!Tj(e,t.notInConstruct,!1)}function Tj(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 Ej(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
68
+ `&&wj(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
69
+ `}function Dj(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 Oj(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 kj(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Aj(e,t,n,r){let i=kj(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(Oj(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,jj);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(Dj(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:`
70
70
  `,encode:["`"],...s.current()})),t()}return u+=s.move(`
71
71
  `),a&&(u+=s.move(a+`
72
- `)),u+=s.move(c),l(),u}function Sj(e,t,n){return(n?``:` `)+e}function Cj(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function wj(e,t,n,r){let i=Cj(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?` `:`
73
- `,...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 Tj(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ej(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Dj(e,t,n){let r=qT(e),i=qT(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}}Oj.peek=kj;function Oj(e,t,n,r){let i=Tj(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=Dj(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Ej(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Dj(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Ej(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function kj(e,t,n){return n.options.emphasis||`*`}function Aj(e,t){let n=!1;return _k(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)&&pT(e)&&(t.options.setext||n))}function jj(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Aj(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
72
+ `)),u+=s.move(c),l(),u}function jj(e,t,n){return(n?``:` `)+e}function Mj(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Nj(e,t,n,r){let i=Mj(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?` `:`
73
+ `,...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 Pj(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Fj(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function Ij(e,t,n){let r=nE(e),i=nE(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}}Lj.peek=Rj;function Lj(e,t,n,r){let i=Pj(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=Ij(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Fj(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Ij(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Fj(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Rj(e,t,n){return n.options.emphasis||`*`}function zj(e,t){let n=!1;return Ek(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)&&ST(e)&&(t.options.setext||n))}function Bj(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(zj(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
74
74
  `,after:`
75
75
  `});return r(),t(),o+`
76
76
  `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
77
77
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
78
- `,...a.current()});return/^[\t ]/.test(l)&&(l=Ej(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Mj.peek=Nj;function Mj(e){return e.value||``}function Nj(){return`<`}Pj.peek=Fj;function Pj(e,t,n,r){let i=Cj(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 Fj(){return`!`}Ij.peek=Lj;function Ij(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 Lj(){return`!`}Rj.peek=zj;function Rj(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 zj(){return"`"}function Bj(e,t){let n=pT(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))}Vj.peek=Hj;function Vj(e,t,n,r){let i=Cj(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Bj(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 Hj(e,t,n){return Bj(e,n)?`<`:`[`}Uj.peek=Wj;function Uj(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 Wj(){return`[`}function Gj(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 Kj(e){let t=Gj(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 qj(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Jj(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 Yj(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?qj(n):Gj(n),s=e.ordered?o===`.`?`)`:`.`:Kj(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),Jj(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 Xj(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 Zj(e,t,n,r){let i=Xj(n),a=n.bulletCurrent||Gj(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 Qj(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var $j=ok([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function eM(e,t,n,r){return(e.children.some(function(e){return $j(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function tM(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}nM.peek=rM;function nM(e,t,n,r){let i=tM(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=Dj(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Ej(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Dj(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Ej(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function rM(e,t,n){return n.options.strong||`*`}function iM(e,t,n,r){return n.safe(e.value,r)}function aM(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 oM(e,t,n){let r=(Jj(n)+(n.options.ruleSpaces?` `:``)).repeat(aM(n));return n.options.ruleSpaces?r.slice(0,-1):r}var sM={blockquote:pj,break:_j,code:xj,definition:wj,emphasis:Oj,hardBreak:_j,heading:jj,html:Mj,image:Pj,imageReference:Ij,inlineCode:Rj,link:Vj,linkReference:Uj,list:Yj,listItem:Zj,paragraph:Qj,root:eM,strong:nM,text:iM,thematicBreak:oM};function cM(){return{enter:{table:lM,tableData:pM,tableHeader:pM,tableRow:dM},exit:{codeText:mM,table:uM,tableData:fM,tableHeader:fM,tableRow:fM}}}function lM(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 uM(e){this.exit(e),this.data.inTable=void 0}function dM(e){this.enter({type:`tableRow`,children:[]},e)}function fM(e){this.exit(e)}function pM(e){this.enter({type:`tableCell`,children:[]},e)}function mM(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,hM));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function hM(e,t){return t===`|`?t:e}function gM(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
78
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=Fj(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Vj.peek=Hj;function Vj(e){return e.value||``}function Hj(){return`<`}Uj.peek=Wj;function Uj(e,t,n,r){let i=Mj(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 Wj(){return`!`}Gj.peek=Kj;function Gj(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 Kj(){return`!`}qj.peek=Jj;function qj(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 Jj(){return"`"}function Yj(e,t){let n=ST(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))}Xj.peek=Zj;function Xj(e,t,n,r){let i=Mj(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(Yj(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 Zj(e,t,n){return Yj(e,n)?`<`:`[`}Qj.peek=$j;function Qj(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 $j(){return`[`}function eM(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 tM(e){let t=eM(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 nM(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function rM(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 iM(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?nM(n):eM(n),s=e.ordered?o===`.`?`)`:`.`:tM(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),rM(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 aM(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 oM(e,t,n,r){let i=aM(n),a=n.bulletCurrent||eM(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 sM(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var cM=hk([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function lM(e,t,n,r){return(e.children.some(function(e){return cM(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function uM(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}dM.peek=fM;function dM(e,t,n,r){let i=uM(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=Ij(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Fj(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=Ij(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Fj(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function fM(e,t,n){return n.options.strong||`*`}function pM(e,t,n,r){return n.safe(e.value,r)}function mM(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 hM(e,t,n){let r=(rM(n)+(n.options.ruleSpaces?` `:``)).repeat(mM(n));return n.options.ruleSpaces?r.slice(0,-1):r}var gM={blockquote:Sj,break:Ej,code:Aj,definition:Nj,emphasis:Lj,hardBreak:Ej,heading:Bj,html:Vj,image:Uj,imageReference:Gj,inlineCode:qj,link:Xj,linkReference:Qj,list:iM,listItem:oM,paragraph:sM,root:lM,strong:dM,text:pM,thematicBreak:hM};function _M(){return{enter:{table:vM,tableData:SM,tableHeader:SM,tableRow:bM},exit:{codeText:CM,table:yM,tableData:xM,tableHeader:xM,tableRow:xM}}}function vM(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 yM(e){this.exit(e),this.data.inTable=void 0}function bM(e){this.enter({type:`tableRow`,children:[]},e)}function xM(e){this.exit(e)}function SM(e){this.enter({type:`tableCell`,children:[]},e)}function CM(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,wM));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function wM(e,t){return t===`|`?t:e}function TM(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
79
79
  `,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(`
80
- `))}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 uj(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=sM.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function _M(){return{exit:{taskListCheckValueChecked:yM,taskListCheckValueUnchecked:yM,paragraph:bM}}}function vM(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:xM}}}function yM(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function bM(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 xM(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=sM.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 SM(){return[OA(),QA(),rj(),cM(),_M()]}function CM(e){return{extensions:[kA(),$A(e),ij(),gM(e),vM()]}}var wM={tokenize:RM,partial:!0},TM={tokenize:zM,partial:!0},EM={tokenize:BM,partial:!0},DM={tokenize:VM,partial:!0},OM={tokenize:HM,partial:!0},kM={name:`wwwAutolink`,tokenize:IM,previous:UM},AM={name:`protocolAutolink`,tokenize:LM,previous:WM},jM={name:`emailAutolink`,tokenize:FM,previous:GM},MM={};function NM(){return{text:MM}}for(var PM=48;PM<123;)MM[PM]=jM,PM++,PM===58?PM=65:PM===91&&(PM=97);MM[43]=jM,MM[45]=jM,MM[46]=jM,MM[95]=jM,MM[72]=[jM,AM],MM[104]=[jM,AM],MM[87]=[jM,kM],MM[119]=[jM,kM];function FM(e,t,n){let r=this,i,a;return o;function o(t){return!KM(t)||!GM.call(r,r.previous)||qM(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return KM(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(OM,u,l)(t):t===45||t===95||OT(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&&DT(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function IM(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!UM.call(r,r.previous)||qM(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(wM,e.attempt(TM,e.attempt(EM,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function LM(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&WM.call(r,r.previous)&&!qM(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(DT(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||AT(t)||PT(t)||LT(t)||IT(t)?n(t):e.attempt(TM,e.attempt(EM,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function RM(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 zM(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(DM,c,s)(t):t===null||PT(t)||LT(t)||t!==45&&IT(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 BM(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(DM,t,a)(o):o===null||PT(o)||LT(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function VM(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||PT(o)||LT(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||PT(e)||LT(e)?t(e):r(e)}function a(e){return DT(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):DT(t)?(e.consume(t),o):n(t)}}function HM(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return OT(e)?n(e):t(e)}}function UM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||PT(e)}function WM(e){return!DT(e)}function GM(e){return!(e===47||KM(e))}function KM(e){return e===43||e===45||e===46||e===95||OT(e)}function qM(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 JM={tokenize:nN,partial:!0};function YM(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:$M,continuation:{tokenize:eN},exit:tN}},text:{91:{name:`gfmFootnoteCall`,tokenize:QM},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:XM,resolveTo:ZM}}}}function XM(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=ET(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 ZM(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 QM(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||PT(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(ET(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return PT(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 $M(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||PT(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=ET(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return PT(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),BT(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function eN(e,t,n){return e.check(tE,t,e.attempt(JM,t,n))}function tN(e){e.exit(`gfmFootnoteDefinition`)}function nN(e,t,n){let r=this;return BT(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 rN(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&&yT(o,o.length,0,JT(s,e.slice(r+1,n),t)),yT(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),yT(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=qT(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=qT(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var iN=class{constructor(){this.map=[]}add(e,t,n){aN(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 aN(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 oN(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 sN(){return{flow:{null:{name:`table`,tokenize:cN,resolveAll:lN}}}}function cN(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):X(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):FT(t)?BT(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||PT(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,FT(t)?BT(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 FT(t)?BT(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||X(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 FT(t)?BT(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||X(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||X(n)?(e.exit(`tableRow`),t(n)):FT(n)?BT(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||PT(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 lN(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 iN;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(dN(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=uN(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=uN(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=uN(f,t,o,i,n,d)):(o[0]=o[1],d=uN(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&dN(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=oN(t.events,n))}return e}function uN(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},fN(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=fN(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=fN(t.events,n[2]),a=fN(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({},fN(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function dN(e,t,n,r,i){let a=[],o=fN(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 fN(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var pN={name:`tasklistCheck`,tokenize:hN};function mN(){return{text:{91:pN}}}function hN(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 PT(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 X(r)?t(r):FT(r)?e.check({tokenize:gN},t,n)(r):n(r)}}function gN(e,t,n){return BT(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function _N(e){return ST([NM(),YM(),rN(e),sN(),mN()])}var vN={};function yN(e){let t=this,n=e||vN,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(_N(n)),a.push(SM()),o.push(CM(n))}var bN=[],xN=new Set,SN=0;function CN(){for(let e of xN)e()}function wN(e){return xN.add(e),()=>xN.delete(e)}function TN(){return bN}function EN(e){let t=bN.length;bN=bN.filter(t=>t.id!==e),bN.length!==t&&CN()}function DN(e){let t=`toast_${Date.now().toString(36)}_${++SN}`,n={id:t,title:e.title,description:e.description,variant:e.variant??`default`,created:Date.now()};return bN=[...bN,n],CN(),setTimeout(()=>EN(t),3e3),t}var ON=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function kN(e){let t=[],n=0,r=0;for(let i of e.split(`
81
- `))if(!(i.startsWith(`Index: `)||i.startsWith(`=======`)||i.startsWith(`diff --git `))){if(i.startsWith(`+++ `)||i.startsWith(`--- `)){t.push({text:i,kind:`file`});continue}if(i.startsWith(`@@`)){let e=ON.exec(i);n=e?Number(e[1]):0,r=e?Number(e[3]):0,t.push({text:i,kind:`hunk`});continue}i.startsWith(`+`)?(t.push({text:i,kind:`add`,newNo:r}),r+=1):i.startsWith(`-`)?(t.push({text:i,kind:`delete`,oldNo:n}),n+=1):(t.push({text:i,kind:`context`,oldNo:n>0?n:void 0,newNo:r>0?r:void 0}),n>0&&(n+=1),r>0&&(r+=1))}return t}var AN={file:`bg-(--surface-diff-unchanged-base) text-(color:--text-strong)`,hunk:`bg-(--surface-diff-hidden-base) text-(color:--text-weak)`,add:`bg-(--surface-diff-add-weak) text-(color:--text-diff-add-base)`,delete:`bg-(--surface-diff-delete-weak) text-(color:--text-diff-delete-base)`,context:`bg-(--surface-diff-unchanged-base) text-(color:--text-base)`};function jN({diff:e,className:t}){let n=(0,E.useMemo)(()=>kN(e),[e]);return(0,R.jsx)(`div`,{className:V(`overflow-x-auto font-mono text-xs`,t),children:(0,R.jsx)(`div`,{className:`min-w-max`,children:n.map((e,t)=>(0,R.jsx)(MN,{row:e},t))})})}function MN({row:e}){let t=e.kind===`add`||e.kind===`delete`||e.kind===`context`;return(0,R.jsxs)(`div`,{className:V(`flex items-center whitespace-pre`,AN[e.kind]),children:[t&&(0,R.jsxs)(`span`,{className:`shrink-0 select-none pl-2 pr-1 text-right text-(color:--text-weaker)`,children:[(0,R.jsx)(`span`,{className:`inline-block w-9`,children:e.oldNo??``}),(0,R.jsx)(`span`,{className:`inline-block w-9`,children:e.newNo??``})]}),(0,R.jsx)(`span`,{className:V(`min-w-0`,t&&`pr-2`),children:e.text||` `})]})}var NN=new Map;function PN(e,t){for(NN.delete(e),NN.set(e,t);NN.size>2e3;){let e=NN.keys().next().value;if(!e)break;NN.delete(e)}}function FN({part:e,stateKey:t}){let[n,r]=(0,E.useState)(Dh().showToolDetails);(0,E.useEffect)(()=>kh(()=>r(Dh().showToolDetails)),[]);let i=jt(e.name);if(i)return(0,R.jsx)(R.Fragment,{children:i.render(e)});if(!e.state)return null;let a=e.state,o=a.status===`completed`&&a.content?.some(e=>e.type===`file`&&WN(e.mime));if(!n&&a.status===`completed`&&!o)return null;let s=a.status===`streaming`?{}:a.input??{},c=a.status===`streaming`?{}:`metadata`in a?a.metadata??{}:{},l={part:e,state:a,stateKey:t,input:s,meta:c,output:a.status===`completed`||a.status===`error`?LN(a.content):void 0,error:a.status===`error`?a.error:void 0,streamingText:a.status===`streaming`?a.input:void 0},u=(0,R.jsx)(Nt,{region:`tool.before`,part:e}),d=(0,R.jsx)(Nt,{region:`tool.after`,part:e}),f=(()=>{switch(e.name){case`edit`:return(0,R.jsx)(YN,{...l});case`write`:return(0,R.jsx)(XN,{...l});case`shell`:case`bash`:return(0,R.jsx)(ZN,{...l});case`subagent`:case`task`:return(0,R.jsx)($N,{...l});case`execute`:return(0,R.jsx)(sP,{...l});case`read`:return(0,R.jsx)(zN,{...l,icon:`→`,pending:`Reading file…`,label:(0,R.jsxs)(R.Fragment,{children:[`Read `,(0,R.jsx)(RN,{value:s.path}),s.offset!==void 0&&(0,R.jsxs)(`span`,{className:`text-[var(--text-weaker)]`,children:[` from `,String(s.offset)]})]})});case`grep`:return(0,R.jsx)(zN,{...l,icon:`✱`,pending:`Searching content…`,label:(0,R.jsxs)(R.Fragment,{children:[`Grep "`,s.pattern,`" `,(0,R.jsx)(RN,{value:s.path,prefix:`in `}),c.matches!==void 0&&(0,R.jsxs)(`span`,{className:`text-[var(--text-weaker)]`,children:[` (`,String(c.matches),` matches)`]})]})});case`glob`:return(0,R.jsx)(zN,{...l,icon:`✱`,pending:`Finding files…`,label:(0,R.jsxs)(R.Fragment,{children:[`Glob "`,s.pattern,`" `,(0,R.jsx)(RN,{value:s.path,prefix:`in `}),c.count!==void 0&&(0,R.jsxs)(`span`,{className:`text-[var(--text-weaker)]`,children:[` (`,String(c.count),`)`]})]})});case`webfetch`:return(0,R.jsx)(zN,{...l,icon:`%`,pending:`Fetching from the web…`,label:(0,R.jsxs)(R.Fragment,{children:[e.name,` `,s.url]})});case`websearch`:return(0,R.jsx)(zN,{...l,icon:`◈`,pending:`Searching web…`,label:(0,R.jsxs)(R.Fragment,{children:[`Search "`,s.query,`"`]})});default:return(0,R.jsx)(cP,{...l,name:e.name})}})();return(0,R.jsxs)(R.Fragment,{children:[u,f,d]})}function IN(e){return typeof e==`string`&&e?e:void 0}function LN(e){return(e??[]).filter(e=>e.type===`text`).map(e=>e.text??``).join(`
82
- `).trim()||void 0}function RN({value:e,prefix:t}){let n=IN(e);if(!n)return null;let r=n.startsWith(`/`)?n.replace(/^\/home\/[^/]+/,`~`):n;return(0,R.jsxs)(`span`,{className:`font-mono`,children:[t,r]})}function zN({icon:e,label:t,pending:n,streamingText:r,error:i,output:a,complete:o=!0,onClick:s,children:c,state:l,runningLabel:u,runningIcon:d,input:f,part:p}){let[m,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(!1),v=!!i,y=l.status===`running`||l.status===`streaming`,b=(()=>{let e=Object.entries(f??{}).filter(([,e])=>e!=null&&e!==``);if(e.length>0){let t=[];for(let[n,r]of e){if(t.length>=3)break;let e=typeof r==`string`?r:(()=>{try{return JSON.stringify(r)??String(r)}catch{return String(r)}})();!e||e===`{}`||e===`[]`||t.push(`[${n}=${UN(e,40)}]`)}if(t.length>0)return t.join(` `)}if(r&&r.trim())return UN(r,80)})(),x=y&&u!==void 0?(0,R.jsx)(`span`,{className:`text-[var(--text-base)]`,children:u}):y?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--text-base)]`,children:[(0,R.jsx)(uS,{className:`size-3`}),(0,R.jsx)(`span`,{className:`font-medium`,children:p.name}),b?(0,R.jsx)(`span`,{className:`truncate font-mono text-[var(--text-weaker)]`,children:b}):(0,R.jsx)(`span`,{className:`text-[var(--text-weaker)]`,children:n})]}):(0,R.jsx)(`span`,{className:v?``:o?`text-[var(--text-weak)]`:`text-[var(--text-base)]`,children:t??c}),S=!v&&!s&&r!==void 0&&r.trim().length>0,C=!!(s||v||S);return(0,R.jsxs)(`div`,{className:`py-0.5 pl-1 text-xs`,children:[(0,R.jsxs)(`div`,{role:C?`button`:void 0,onClick:()=>{v?h(e=>!e):S?_(e=>!e):s?.()},className:`flex min-w-0 items-center gap-2 ${C?`cursor-pointer rounded px-1 -mx-1 hover:bg-[color:var(--surface-base-hover)]`:``} ${v?`text-[color:var(--surface-critical-strong)]`:``}`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0 text-center font-mono ${v?`text-[color:var(--surface-critical-strong)]`:`text-[var(--text-weaker)]`}`,children:y&&d!==void 0?d:e}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:x}),S&&(0,R.jsx)(L,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${g?`rotate-90`:``}`})]}),v&&m&&(0,R.jsxs)(`pre`,{className:`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[var(--surface-critical-weak)] p-2 font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:[i.type,`: `,i.message]}),v&&!m&&a&&(0,R.jsx)(BN,{output:a}),S&&g&&(0,R.jsx)(`pre`,{className:`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--border-selected)_20%,transparent)] bg-[var(--background-strong)] p-2 font-mono text-[10px] leading-relaxed text-[var(--text-weak)]`,children:r})]})}function BN({output:e}){let t=e.split(`
80
+ `))}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 yj(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=gM.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function EM(){return{exit:{taskListCheckValueChecked:OM,taskListCheckValueUnchecked:OM,paragraph:kM}}}function DM(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:AM}}}function OM(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function kM(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 AM(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=gM.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 jM(){return[LA(),sj(),fj(),_M(),EM()]}function MM(e){return{extensions:[RA(),cj(e),pj(),TM(e),DM()]}}var NM={tokenize:qM,partial:!0},PM={tokenize:JM,partial:!0},FM={tokenize:YM,partial:!0},IM={tokenize:XM,partial:!0},LM={tokenize:ZM,partial:!0},RM={name:`wwwAutolink`,tokenize:GM,previous:QM},zM={name:`protocolAutolink`,tokenize:KM,previous:$M},BM={name:`emailAutolink`,tokenize:WM,previous:eN},VM={};function HM(){return{text:VM}}for(var UM=48;UM<123;)VM[UM]=BM,UM++,UM===58?UM=65:UM===91&&(UM=97);VM[43]=BM,VM[45]=BM,VM[46]=BM,VM[95]=BM,VM[72]=[BM,zM],VM[104]=[BM,zM],VM[87]=[BM,RM],VM[119]=[BM,RM];function WM(e,t,n){let r=this,i,a;return o;function o(t){return!tN(t)||!eN.call(r,r.previous)||nN(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return tN(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(LM,u,l)(t):t===45||t===95||LT(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&&IT(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function GM(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!QM.call(r,r.previous)||nN(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(NM,e.attempt(PM,e.attempt(FM,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function KM(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&$M.call(r,r.previous)&&!nN(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(IT(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||zT(t)||UT(t)||KT(t)||GT(t)?n(t):e.attempt(PM,e.attempt(FM,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function qM(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 JM(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(IM,c,s)(t):t===null||UT(t)||KT(t)||t!==45&&GT(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 YM(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(IM,t,a)(o):o===null||UT(o)||KT(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function XM(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||UT(o)||KT(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||UT(e)||KT(e)?t(e):r(e)}function a(e){return IT(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):IT(t)?(e.consume(t),o):n(t)}}function ZM(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return LT(e)?n(e):t(e)}}function QM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||UT(e)}function $M(e){return!IT(e)}function eN(e){return!(e===47||tN(e))}function tN(e){return e===43||e===45||e===46||e===95||LT(e)}function nN(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 rN={tokenize:dN,partial:!0};function iN(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:cN,continuation:{tokenize:lN},exit:uN}},text:{91:{name:`gfmFootnoteCall`,tokenize:sN},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:aN,resolveTo:oN}}}}function aN(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=FT(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 oN(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 sN(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||UT(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(FT(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return UT(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 cN(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||UT(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=FT(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return UT(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),YT(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function lN(e,t,n){return e.check(uE,t,e.attempt(rN,t,n))}function uN(e){e.exit(`gfmFootnoteDefinition`)}function dN(e,t,n){let r=this;return YT(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 fN(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&&OT(o,o.length,0,rE(s,e.slice(r+1,n),t)),OT(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),OT(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=nE(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=nE(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var pN=class{constructor(){this.map=[]}add(e,t,n){mN(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 mN(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 hN(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 gN(){return{flow:{null:{name:`table`,tokenize:_N,resolveAll:vN}}}}function _N(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):X(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):WT(t)?YT(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||UT(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,WT(t)?YT(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 WT(t)?YT(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||X(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 WT(t)?YT(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||X(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||X(n)?(e.exit(`tableRow`),t(n)):WT(n)?YT(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||UT(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 vN(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 pN;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(bN(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=yN(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=yN(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=yN(f,t,o,i,n,d)):(o[0]=o[1],d=yN(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&bN(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=hN(t.events,n))}return e}function yN(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},xN(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=xN(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=xN(t.events,n[2]),a=xN(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({},xN(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function bN(e,t,n,r,i){let a=[],o=xN(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 xN(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var SN={name:`tasklistCheck`,tokenize:wN};function CN(){return{text:{91:SN}}}function wN(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 UT(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 X(r)?t(r):WT(r)?e.check({tokenize:TN},t,n)(r):n(r)}}function TN(e,t,n){return YT(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function EN(e){return jT([HM(),iN(),fN(e),gN(),CN()])}var DN={};function ON(e){let t=this,n=e||DN,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(EN(n)),a.push(jM()),o.push(MM(n))}var kN=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function AN(e){let t=[],n=0,r=0;for(let i of e.split(`
81
+ `))if(!(i.startsWith(`Index: `)||i.startsWith(`=======`)||i.startsWith(`diff --git `))){if(i.startsWith(`+++ `)||i.startsWith(`--- `)){t.push({text:i,kind:`file`});continue}if(i.startsWith(`@@`)){let e=kN.exec(i);n=e?Number(e[1]):0,r=e?Number(e[3]):0,t.push({text:i,kind:`hunk`});continue}i.startsWith(`+`)?(t.push({text:i,kind:`add`,newNo:r}),r+=1):i.startsWith(`-`)?(t.push({text:i,kind:`delete`,oldNo:n}),n+=1):(t.push({text:i,kind:`context`,oldNo:n>0?n:void 0,newNo:r>0?r:void 0}),n>0&&(n+=1),r>0&&(r+=1))}return t}var jN={file:`bg-(--surface-diff-unchanged-base) text-(color:--text-strong)`,hunk:`bg-(--surface-diff-hidden-base) text-(color:--text-weak)`,add:`bg-(--surface-diff-add-weak) text-(color:--text-diff-add-base)`,delete:`bg-(--surface-diff-delete-weak) text-(color:--text-diff-delete-base)`,context:`bg-(--surface-diff-unchanged-base) text-(color:--text-base)`};function MN({diff:e,className:t}){let n=(0,E.useMemo)(()=>AN(e),[e]);return(0,R.jsx)(`div`,{className:V(`overflow-x-auto font-mono text-xs`,t),children:(0,R.jsx)(`div`,{className:`min-w-max`,children:n.map((e,t)=>(0,R.jsx)(NN,{row:e},t))})})}function NN({row:e}){let t=e.kind===`add`||e.kind===`delete`||e.kind===`context`;return(0,R.jsxs)(`div`,{className:V(`flex items-center whitespace-pre`,jN[e.kind]),children:[t&&(0,R.jsxs)(`span`,{className:`shrink-0 select-none pl-2 pr-1 text-right text-(color:--text-weaker)`,children:[(0,R.jsx)(`span`,{className:`inline-block w-9`,children:e.oldNo??``}),(0,R.jsx)(`span`,{className:`inline-block w-9`,children:e.newNo??``})]}),(0,R.jsx)(`span`,{className:V(`min-w-0`,t&&`pr-2`),children:e.text||` `})]})}var PN=new Map;function FN(e,t){for(PN.delete(e),PN.set(e,t);PN.size>2e3;){let e=PN.keys().next().value;if(!e)break;PN.delete(e)}}function IN({part:e,stateKey:t}){let[n,r]=(0,E.useState)(Dh().showToolDetails);(0,E.useEffect)(()=>kh(()=>r(Dh().showToolDetails)),[]);let i=jt(e.name);if(i)return(0,R.jsx)(R.Fragment,{children:i.render(e)});if(!e.state)return null;let a=e.state,o=a.status===`completed`&&a.content?.some(e=>e.type===`file`&&GN(e.mime));if(!n&&a.status===`completed`&&!o)return null;let s=a.status===`streaming`?{}:a.input??{},c=a.status===`streaming`?{}:`metadata`in a?a.metadata??{}:{},l={part:e,state:a,stateKey:t,input:s,meta:c,output:a.status===`completed`||a.status===`error`?RN(a.content):void 0,error:a.status===`error`?a.error:void 0,streamingText:a.status===`streaming`?a.input:void 0},u=(0,R.jsx)(Nt,{region:`tool.before`,part:e}),d=(0,R.jsx)(Nt,{region:`tool.after`,part:e}),f=(()=>{switch(e.name){case`edit`:return(0,R.jsx)(XN,{...l});case`write`:return(0,R.jsx)(ZN,{...l});case`shell`:case`bash`:return(0,R.jsx)(QN,{...l});case`subagent`:case`task`:return(0,R.jsx)(eP,{...l});case`execute`:return(0,R.jsx)(cP,{...l});case`read`:return(0,R.jsx)(BN,{...l,icon:`→`,pending:`Reading file…`,label:(0,R.jsxs)(R.Fragment,{children:[`Read `,(0,R.jsx)(zN,{value:s.path}),s.offset!==void 0&&(0,R.jsxs)(`span`,{className:`text-[var(--text-weaker)]`,children:[` from `,String(s.offset)]})]})});case`grep`:return(0,R.jsx)(BN,{...l,icon:`✱`,pending:`Searching content…`,label:(0,R.jsxs)(R.Fragment,{children:[`Grep "`,s.pattern,`" `,(0,R.jsx)(zN,{value:s.path,prefix:`in `}),c.matches!==void 0&&(0,R.jsxs)(`span`,{className:`text-[var(--text-weaker)]`,children:[` (`,String(c.matches),` matches)`]})]})});case`glob`:return(0,R.jsx)(BN,{...l,icon:`✱`,pending:`Finding files…`,label:(0,R.jsxs)(R.Fragment,{children:[`Glob "`,s.pattern,`" `,(0,R.jsx)(zN,{value:s.path,prefix:`in `}),c.count!==void 0&&(0,R.jsxs)(`span`,{className:`text-[var(--text-weaker)]`,children:[` (`,String(c.count),`)`]})]})});case`webfetch`:return(0,R.jsx)(BN,{...l,icon:`%`,pending:`Fetching from the web…`,label:(0,R.jsxs)(R.Fragment,{children:[e.name,` `,s.url]})});case`websearch`:return(0,R.jsx)(BN,{...l,icon:`◈`,pending:`Searching web…`,label:(0,R.jsxs)(R.Fragment,{children:[`Search "`,s.query,`"`]})});default:return(0,R.jsx)(lP,{...l,name:e.name})}})();return(0,R.jsxs)(R.Fragment,{children:[u,f,d]})}function LN(e){return typeof e==`string`&&e?e:void 0}function RN(e){return(e??[]).filter(e=>e.type===`text`).map(e=>e.text??``).join(`
82
+ `).trim()||void 0}function zN({value:e,prefix:t}){let n=LN(e);if(!n)return null;let r=n.startsWith(`/`)?n.replace(/^\/home\/[^/]+/,`~`):n;return(0,R.jsxs)(`span`,{className:`font-mono`,children:[t,r]})}function BN({icon:e,label:t,pending:n,streamingText:r,error:i,output:a,complete:o=!0,onClick:s,children:c,state:l,runningLabel:u,runningIcon:d,input:f,part:p}){let[m,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(!1),v=!!i,y=l.status===`running`||l.status===`streaming`,b=(()=>{let e=Object.entries(f??{}).filter(([,e])=>e!=null&&e!==``);if(e.length>0){let t=[];for(let[n,r]of e){if(t.length>=3)break;let e=typeof r==`string`?r:(()=>{try{return JSON.stringify(r)??String(r)}catch{return String(r)}})();!e||e===`{}`||e===`[]`||t.push(`[${n}=${WN(e,40)}]`)}if(t.length>0)return t.join(` `)}if(r&&r.trim())return WN(r,80)})(),x=y&&u!==void 0?(0,R.jsx)(`span`,{className:`text-[var(--text-base)]`,children:u}):y?(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--text-base)]`,children:[(0,R.jsx)(uS,{className:`size-3`}),(0,R.jsx)(`span`,{className:`font-medium`,children:p.name}),b?(0,R.jsx)(`span`,{className:`truncate font-mono text-[var(--text-weaker)]`,children:b}):(0,R.jsx)(`span`,{className:`text-[var(--text-weaker)]`,children:n})]}):(0,R.jsx)(`span`,{className:v?``:o?`text-[var(--text-weak)]`:`text-[var(--text-base)]`,children:t??c}),S=!v&&!s&&r!==void 0&&r.trim().length>0,C=!!(s||v||S);return(0,R.jsxs)(`div`,{className:`py-0.5 pl-1 text-xs`,children:[(0,R.jsxs)(`div`,{role:C?`button`:void 0,onClick:()=>{v?h(e=>!e):S?_(e=>!e):s?.()},className:`flex min-w-0 items-center gap-2 ${C?`cursor-pointer rounded px-1 -mx-1 hover:bg-[color:var(--surface-base-hover)]`:``} ${v?`text-[color:var(--surface-critical-strong)]`:``}`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0 text-center font-mono ${v?`text-[color:var(--surface-critical-strong)]`:`text-[var(--text-weaker)]`}`,children:y&&d!==void 0?d:e}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:x}),S&&(0,R.jsx)(L,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${g?`rotate-90`:``}`})]}),v&&m&&(0,R.jsxs)(`pre`,{className:`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[var(--surface-critical-weak)] p-2 font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:[i.type,`: `,i.message]}),v&&!m&&a&&(0,R.jsx)(VN,{output:a}),S&&g&&(0,R.jsx)(`pre`,{className:`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--border-selected)_20%,transparent)] bg-[var(--background-strong)] p-2 font-mono text-[10px] leading-relaxed text-[var(--text-weak)]`,children:r})]})}function VN({output:e}){let t=e.split(`
83
83
  `),n=t.slice(0,10).join(`
84
84
  `)+(t.length>10?`
85
- …`:``);return(0,R.jsx)(`pre`,{className:`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--border-selected)_20%,transparent)] bg-[var(--background-strong)] p-2 font-mono text-[10px] leading-relaxed text-[var(--text-weak)]`,children:n})}function VN({title:e,children:t,collapsible:n,collapsedByDefault:r,stateKey:i}){let[a,o]=(0,E.useState)(()=>n?i?NN.get(i)??!r:!r:!0);return n?(0,R.jsx)(HN,{title:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{o(!a),i&&PN(i,!a)},className:`flex w-full cursor-pointer items-center gap-1 text-left`,children:[(0,R.jsx)(L,{className:`size-3 shrink-0 transition-transform ${a?`rotate-90`:``}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]}),children:a&&t}):(0,R.jsx)(HN,{title:e,children:t})}function HN({title:e,children:t}){return(0,R.jsxs)(`div`,{className:`my-1 overflow-hidden rounded-lg border border-[var(--border-weak-base)] bg-[var(--background-strong)]`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-1.5 border-b border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-1.5 text-xs text-[var(--text-weak)]`,children:e}),t]})}function UN(e,t=120){let n=e.replace(/\s+/g,` `).trim();return n.length>t?n.slice(0,t)+`…`:n}function WN(e){return!!e&&e.startsWith(`image/`)}function GN(e){return e?e.filter(e=>e.type===`file`&&WN(e.mime)):[]}function KN(e){if(e.uri)return e.uri;if(e.data)return`data:${e.mime};base64,${e.data}`}function qN({content:e}){let t=GN(e);return t.length===0?null:(0,R.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-2 pl-1`,children:t.map((e,t)=>{let n=KN(e);return n?(0,R.jsx)(JN,{src:n,name:e.name},t):null})})}function JN({src:e,name:t}){let[n,r]=(0,E.useState)(!1);return(0,R.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),title:n?`${t??`image`} — click to shrink`:`${t??`image`} — click to enlarge`,className:`block cursor-pointer ${n?``:`cursor-zoom-in`}`,children:(0,R.jsx)(`img`,{src:e,alt:t??`image`,draggable:!1,className:`rounded-md border border-[color:var(--border-weak-base)] bg-[var(--surface-inset-base)] object-contain ${n?`max-h-[70vh] max-w-full`:`max-h-48 max-w-[16rem]`}`})})}function YN(e){let t=Array.isArray(e.meta.files)?e.meta.files:[],n=IN(e.input.path);return t.length>0?(0,R.jsx)(R.Fragment,{children:t.map((e,t)=>(0,R.jsx)(VN,{title:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`←`}),`Edit `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:e.file??n}),e.additions!==void 0&&e.deletions!==void 0&&(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px]`,children:[(0,R.jsxs)(`span`,{className:`text-[color:var(--text-diff-add-base)]`,children:[`+`,e.additions]}),` `,(0,R.jsxs)(`span`,{className:`text-[color:var(--text-diff-delete-base)]`,children:[`−`,e.deletions]})]})]}),children:e.patch?(0,R.jsx)(jN,{diff:e.patch,className:`max-h-80 overflow-y-auto py-1`}):(0,R.jsx)(`p`,{className:`px-2.5 py-2 text-xs text-[var(--text-weaker)]`,children:e.status===`deleted`?`File deleted`:`(no diff)`})},e.file??t))}):(0,R.jsx)(zN,{...e,icon:`←`,pending:`Preparing edit…`,label:(0,R.jsxs)(R.Fragment,{children:[`Edit `,(0,R.jsx)(RN,{value:e.input.path}),e.input.replaceAll!=null&&e.input.replaceAll!==!1&&(0,R.jsx)(`span`,{className:`text-[var(--text-weaker)]`,children:` (replace all)`})]})})}function XN(e){let t=IN(e.input.content),n=IN(e.input.path);return e.state.status===`completed`&&t!==void 0?(0,R.jsx)(VN,{title:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`#`}),`Wrote `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:n}),(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:[t.split(`
86
- `).length,` lines`]})]}),collapsible:!0,stateKey:e.stateKey,children:(0,R.jsx)(lP,{code:t})}):(0,R.jsx)(zN,{...e,icon:`←`,pending:`Preparing write…`,label:(0,R.jsxs)(R.Fragment,{children:[`Write `,(0,R.jsx)(RN,{value:e.input.path})]})})}function ZN(e){let t=IN(e.input.command),n=e.meta.exit;return e.state.status===`completed`?(0,R.jsx)(VN,{title:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`$`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[var(--text-base)]`,children:t}),typeof n==`number`&&n!==0&&(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:[`exit `,n]})]}),collapsible:!0,collapsedByDefault:!!e.output&&e.output.split(`
87
- `).length>10,stateKey:e.stateKey,children:e.output?(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap px-2.5 py-2 font-mono text-xs leading-relaxed text-[var(--text-base)]`,children:e.output}):(0,R.jsx)(`p`,{className:`px-2.5 py-2 text-xs text-[var(--text-weaker)]`,children:`(no output)`})}):(0,R.jsx)(zN,{...e,icon:`$`,pending:`Writing command…`,label:(0,R.jsx)(`span`,{className:`font-mono`,children:t})})}function QN(e){let t=e??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n){if(n.type===`user`){if(n.text.trim())return n.text}else if(n.type===`assistant`){let e=n.content.filter(e=>e.type===`text`).map(e=>e.text).join(` `).trim();if(e)return e}}}}function $N(e){let t=IN(e.input.agent)??`subagent`,n=IN(e.input.description),r=IN(e.meta.sessionID)??IN(e.input.sessionID),i=J(e=>r?e.sessions.find(e=>e.id===r)??e.sessionDetails[r]:void 0),a=J(e=>r?e.messages[r]:void 0),o=e.state.status===`running`||e.state.status===`streaming`,s=IN(i?.title)??QN(a)??n,c=e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t}),e&&(0,R.jsxs)(`span`,{children:[` — `,e]}),r&&(0,R.jsx)(`span`,{className:`ml-1 text-[10px] text-[var(--text-weaker)]`,children:`↗ open`})]});return(0,R.jsx)(zN,{...e,icon:e.state.status===`completed`?`✓`:`│`,runningIcon:o?(0,R.jsx)(uS,{className:`size-3`}):void 0,pending:`Delegating…`,onClick:r?()=>{Pv(r)}:void 0,label:c(n),runningLabel:o?s?c(s):(0,R.jsx)(R.Fragment,{children:`Delegating…`}):void 0})}function eP(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function tP(e){if(e==null)return``;let t=typeof e==`object`&&!Array.isArray(e)?Object.entries(e):[[`input`,e]],n=[];for(let[e,r]of t){if(n.length>=3)break;if(r==null||r===``)continue;let t=typeof r==`string`?r:eP(r);!t||t===`{}`||t===`[]`||n.push(`[${e}=${UN(t,80)}]`)}return n.length>0?` ${n.join(` `)}`:``}function nP(e){if(typeof e==`string`)return e.trim()||void 0;if(e!=null)try{let t=JSON.stringify(e,null,2);return t&&t!==`{}`?t:void 0}catch{return eP(e)}}function rP(e){if(e!=null){if(Array.isArray(e))return e.map(e=>{if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`text`in e){let t=e.text;if(typeof t==`string`)return t}return eP(e)}).join(`
88
- `).trim()||void 0;if(typeof e==`string`)return e.trim()||void 0;try{let t=JSON.stringify(e,null,2);return t&&t!==`{}`?t:void 0}catch{return String(e)}}}function iP(e){if(e!=null&&e!==!1){if(typeof e==`string`)return e.trim()||void 0;if(typeof e==`object`){let t=e,n=IN(t.message)??IN(t.text);if(n){let e=IN(t.type);return e?`${e}: ${n}`:n}return rP(e)}return String(e)}}var aP=`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--border-selected)_20%,transparent)] bg-[var(--background-strong)] p-2 font-mono text-[10px] leading-relaxed text-[var(--text-weak)]`;function oP({call:e,index:t,stateKey:n}){let r=n?`${n}:call:${t}`:void 0,[i,a]=(0,E.useState)(()=>r?NN.get(r)??!1:!1),o=nP(e.input),s=rP(e.output??e.result),c=iP(e.error),l=!!(o||s||c);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{role:l?`button`:void 0,onClick:l?()=>{a(e=>(r&&PN(r,!e),!e))}:void 0,className:`flex min-w-0 items-center gap-1 ${l?`-mx-1 cursor-pointer rounded px-1 transition-colors hover:bg-[color:var(--surface-base-hover)]`:``}`,children:[(0,R.jsxs)(`span`,{className:`ml-5 min-w-0 flex-1 truncate text-[var(--text-weaker)]`,children:[`↳ `,IN(e.tool)??`tool`,tP(e.input),e.status===`error`&&(0,R.jsx)(`span`,{className:`text-[color:var(--surface-critical-strong)]`,children:` (failed)`})]}),l&&(0,R.jsx)(L,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${i?`rotate-90`:``}`})]}),l&&i&&(0,R.jsxs)(R.Fragment,{children:[o&&(0,R.jsx)(`pre`,{className:aP,children:o}),s&&(0,R.jsx)(`pre`,{className:aP,children:s}),c&&(0,R.jsx)(`pre`,{className:`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[var(--surface-critical-weak)] p-2 font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:c})]})]})}function sP(e){let t=Array.isArray(e.meta.toolCalls)?e.meta.toolCalls:[],n=typeof e.meta.error==`object`&&e.meta.error!==null?e.meta.error:void 0,r=e.meta.error===!0||!!n?.message||!!e.error,i=e.error??(n?.message?{type:n.type??`error`,message:n.message}:void 0);return(0,R.jsxs)(`div`,{className:`py-0.5 pl-1 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0 text-center font-mono ${r?`text-[color:var(--surface-critical-strong)]`:`text-[var(--text-weaker)]`}`,children:r?`✗`:e.state.status===`completed`?`✓`:`│`}),e.state.status===`completed`?(0,R.jsx)(`span`,{className:`text-[var(--text-weak)]`,children:`execute`}):(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--text-base)]`,children:[(0,R.jsx)(uS,{className:`size-3`}),` execute`]})]}),t.map((t,n)=>(0,R.jsx)(oP,{call:t,index:n,stateKey:e.stateKey},n)),i&&(0,R.jsxs)(`pre`,{className:`ml-5 mt-1 max-h-24 overflow-auto whitespace-pre-wrap font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:[i.type,`: `,i.message]}),r&&e.output&&i===void 0&&(0,R.jsx)(`pre`,{className:`ml-5 mt-1 max-h-24 overflow-auto whitespace-pre-wrap font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:e.output.split(`
85
+ …`:``);return(0,R.jsx)(`pre`,{className:`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--border-selected)_20%,transparent)] bg-[var(--background-strong)] p-2 font-mono text-[10px] leading-relaxed text-[var(--text-weak)]`,children:n})}function HN({title:e,children:t,collapsible:n,collapsedByDefault:r,stateKey:i}){let[a,o]=(0,E.useState)(()=>n?i?PN.get(i)??!r:!r:!0);return n?(0,R.jsx)(UN,{title:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{o(!a),i&&FN(i,!a)},className:`flex w-full cursor-pointer items-center gap-1 text-left`,children:[(0,R.jsx)(L,{className:`size-3 shrink-0 transition-transform ${a?`rotate-90`:``}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e})]}),children:a&&t}):(0,R.jsx)(UN,{title:e,children:t})}function UN({title:e,children:t}){return(0,R.jsxs)(`div`,{className:`my-1 overflow-hidden rounded-lg border border-[var(--border-weak-base)] bg-[var(--background-strong)]`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-1.5 border-b border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2.5 py-1.5 text-xs text-[var(--text-weak)]`,children:e}),t]})}function WN(e,t=120){let n=e.replace(/\s+/g,` `).trim();return n.length>t?n.slice(0,t)+`…`:n}function GN(e){return!!e&&e.startsWith(`image/`)}function KN(e){return e?e.filter(e=>e.type===`file`&&GN(e.mime)):[]}function qN(e){if(e.uri)return e.uri;if(e.data)return`data:${e.mime};base64,${e.data}`}function JN({content:e}){let t=KN(e);return t.length===0?null:(0,R.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-2 pl-1`,children:t.map((e,t)=>{let n=qN(e);return n?(0,R.jsx)(YN,{src:n,name:e.name},t):null})})}function YN({src:e,name:t}){let[n,r]=(0,E.useState)(!1);return(0,R.jsx)(`button`,{type:`button`,onClick:()=>r(e=>!e),title:n?`${t??`image`} — click to shrink`:`${t??`image`} — click to enlarge`,className:`block cursor-pointer ${n?``:`cursor-zoom-in`}`,children:(0,R.jsx)(`img`,{src:e,alt:t??`image`,draggable:!1,className:`rounded-md border border-[color:var(--border-weak-base)] bg-[var(--surface-inset-base)] object-contain ${n?`max-h-[70vh] max-w-full`:`max-h-48 max-w-[16rem]`}`})})}function XN(e){let t=Array.isArray(e.meta.files)?e.meta.files:[],n=LN(e.input.path);return t.length>0?(0,R.jsx)(R.Fragment,{children:t.map((e,t)=>(0,R.jsx)(HN,{title:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`←`}),`Edit `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:e.file??n}),e.additions!==void 0&&e.deletions!==void 0&&(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px]`,children:[(0,R.jsxs)(`span`,{className:`text-[color:var(--text-diff-add-base)]`,children:[`+`,e.additions]}),` `,(0,R.jsxs)(`span`,{className:`text-[color:var(--text-diff-delete-base)]`,children:[`−`,e.deletions]})]})]}),children:e.patch?(0,R.jsx)(MN,{diff:e.patch,className:`max-h-80 overflow-y-auto py-1`}):(0,R.jsx)(`p`,{className:`px-2.5 py-2 text-xs text-[var(--text-weaker)]`,children:e.status===`deleted`?`File deleted`:`(no diff)`})},e.file??t))}):(0,R.jsx)(BN,{...e,icon:`←`,pending:`Preparing edit…`,label:(0,R.jsxs)(R.Fragment,{children:[`Edit `,(0,R.jsx)(zN,{value:e.input.path}),e.input.replaceAll!=null&&e.input.replaceAll!==!1&&(0,R.jsx)(`span`,{className:`text-[var(--text-weaker)]`,children:` (replace all)`})]})})}function ZN(e){let t=LN(e.input.content),n=LN(e.input.path);return e.state.status===`completed`&&t!==void 0?(0,R.jsx)(HN,{title:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`#`}),`Wrote `,(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-base)]`,children:n}),(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:[t.split(`
86
+ `).length,` lines`]})]}),collapsible:!0,stateKey:e.stateKey,children:(0,R.jsx)(uP,{code:t})}):(0,R.jsx)(BN,{...e,icon:`←`,pending:`Preparing write…`,label:(0,R.jsxs)(R.Fragment,{children:[`Write `,(0,R.jsx)(zN,{value:e.input.path})]})})}function QN(e){let t=LN(e.input.command),n=e.meta.exit;return e.state.status===`completed`?(0,R.jsx)(HN,{title:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`$`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[var(--text-base)]`,children:t}),typeof n==`number`&&n!==0&&(0,R.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:[`exit `,n]})]}),collapsible:!0,collapsedByDefault:!!e.output&&e.output.split(`
87
+ `).length>10,stateKey:e.stateKey,children:e.output?(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap px-2.5 py-2 font-mono text-xs leading-relaxed text-[var(--text-base)]`,children:e.output}):(0,R.jsx)(`p`,{className:`px-2.5 py-2 text-xs text-[var(--text-weaker)]`,children:`(no output)`})}):(0,R.jsx)(BN,{...e,icon:`$`,pending:`Writing command…`,label:(0,R.jsx)(`span`,{className:`font-mono`,children:t})})}function $N(e){let t=e??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n){if(n.type===`user`){if(n.text.trim())return n.text}else if(n.type===`assistant`){let e=n.content.filter(e=>e.type===`text`).map(e=>e.text).join(` `).trim();if(e)return e}}}}function eP(e){let t=LN(e.input.agent)??`subagent`,n=LN(e.input.description),r=LN(e.meta.sessionID)??LN(e.input.sessionID),i=J(e=>r?e.sessions.find(e=>e.id===r)??e.sessionDetails[r]:void 0),a=J(e=>r?e.messages[r]:void 0),o=e.state.status===`running`||e.state.status===`streaming`,s=LN(i?.title)??$N(a)??n,c=e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t}),e&&(0,R.jsxs)(`span`,{children:[` — `,e]}),r&&(0,R.jsx)(`span`,{className:`ml-1 text-[10px] text-[var(--text-weaker)]`,children:`↗ open`})]});return(0,R.jsx)(BN,{...e,icon:e.state.status===`completed`?`✓`:`│`,runningIcon:o?(0,R.jsx)(uS,{className:`size-3`}):void 0,pending:`Delegating…`,onClick:r?()=>{Pv(r)}:void 0,label:c(n),runningLabel:o?s?c(s):(0,R.jsx)(R.Fragment,{children:`Delegating…`}):void 0})}function tP(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function nP(e){if(e==null)return``;let t=typeof e==`object`&&!Array.isArray(e)?Object.entries(e):[[`input`,e]],n=[];for(let[e,r]of t){if(n.length>=3)break;if(r==null||r===``)continue;let t=typeof r==`string`?r:tP(r);!t||t===`{}`||t===`[]`||n.push(`[${e}=${WN(t,80)}]`)}return n.length>0?` ${n.join(` `)}`:``}function rP(e){if(typeof e==`string`)return e.trim()||void 0;if(e!=null)try{let t=JSON.stringify(e,null,2);return t&&t!==`{}`?t:void 0}catch{return tP(e)}}function iP(e){if(e!=null){if(Array.isArray(e))return e.map(e=>{if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`text`in e){let t=e.text;if(typeof t==`string`)return t}return tP(e)}).join(`
88
+ `).trim()||void 0;if(typeof e==`string`)return e.trim()||void 0;try{let t=JSON.stringify(e,null,2);return t&&t!==`{}`?t:void 0}catch{return String(e)}}}function aP(e){if(e!=null&&e!==!1){if(typeof e==`string`)return e.trim()||void 0;if(typeof e==`object`){let t=e,n=LN(t.message)??LN(t.text);if(n){let e=LN(t.type);return e?`${e}: ${n}`:n}return iP(e)}return String(e)}}var oP=`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--border-selected)_20%,transparent)] bg-[var(--background-strong)] p-2 font-mono text-[10px] leading-relaxed text-[var(--text-weak)]`;function sP({call:e,index:t,stateKey:n}){let r=n?`${n}:call:${t}`:void 0,[i,a]=(0,E.useState)(()=>r?PN.get(r)??!1:!1),o=rP(e.input),s=iP(e.output??e.result),c=aP(e.error),l=!!(o||s||c);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{role:l?`button`:void 0,onClick:l?()=>{a(e=>(r&&FN(r,!e),!e))}:void 0,className:`flex min-w-0 items-center gap-1 ${l?`-mx-1 cursor-pointer rounded px-1 transition-colors hover:bg-[color:var(--surface-base-hover)]`:``}`,children:[(0,R.jsxs)(`span`,{className:`ml-5 min-w-0 flex-1 truncate text-[var(--text-weaker)]`,children:[`↳ `,LN(e.tool)??`tool`,nP(e.input),e.status===`error`&&(0,R.jsx)(`span`,{className:`text-[color:var(--surface-critical-strong)]`,children:` (failed)`})]}),l&&(0,R.jsx)(L,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${i?`rotate-90`:``}`})]}),l&&i&&(0,R.jsxs)(R.Fragment,{children:[o&&(0,R.jsx)(`pre`,{className:oP,children:o}),s&&(0,R.jsx)(`pre`,{className:oP,children:s}),c&&(0,R.jsx)(`pre`,{className:`ml-5 mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[var(--surface-critical-weak)] p-2 font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:c})]})]})}function cP(e){let t=Array.isArray(e.meta.toolCalls)?e.meta.toolCalls:[],n=typeof e.meta.error==`object`&&e.meta.error!==null?e.meta.error:void 0,r=e.meta.error===!0||!!n?.message||!!e.error,i=e.error??(n?.message?{type:n.type??`error`,message:n.message}:void 0);return(0,R.jsxs)(`div`,{className:`py-0.5 pl-1 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0 text-center font-mono ${r?`text-[color:var(--surface-critical-strong)]`:`text-[var(--text-weaker)]`}`,children:r?`✗`:e.state.status===`completed`?`✓`:`│`}),e.state.status===`completed`?(0,R.jsx)(`span`,{className:`text-[var(--text-weak)]`,children:`execute`}):(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--text-base)]`,children:[(0,R.jsx)(uS,{className:`size-3`}),` execute`]})]}),t.map((t,n)=>(0,R.jsx)(sP,{call:t,index:n,stateKey:e.stateKey},n)),i&&(0,R.jsxs)(`pre`,{className:`ml-5 mt-1 max-h-24 overflow-auto whitespace-pre-wrap font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:[i.type,`: `,i.message]}),r&&e.output&&i===void 0&&(0,R.jsx)(`pre`,{className:`ml-5 mt-1 max-h-24 overflow-auto whitespace-pre-wrap font-mono text-[10px] text-[color:var(--surface-critical-strong)]`,children:e.output.split(`
89
89
  `).slice(0,4).join(`
90
- `)}),(0,R.jsx)(qN,{content:e.state.status===`completed`||e.state.status===`error`?e.state.content:void 0})]})}function cP(e){let t=Object.entries(e.input).filter(([,e])=>typeof e==`string`||typeof e==`number`).slice(0,2).map(([e,t])=>`${e}: ${UN(String(t),40)}`).join(` `);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(zN,{...e,icon:`⚙`,pending:`${e.name}…`,label:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name}),t&&(0,R.jsxs)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:[` `,t]})]})}),e.state.status===`completed`&&e.output&&(0,R.jsx)(VN,{title:`${e.name} output`,collapsible:!0,stateKey:e.stateKey,children:(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap px-2.5 py-2 font-mono text-xs leading-relaxed text-[var(--text-base)]`,children:e.output})}),(0,R.jsx)(qN,{content:e.state.status===`completed`||e.state.status===`error`?e.state.content:void 0})]})}function lP({code:e}){let t=e.split(`
91
- `);return(0,R.jsx)(`div`,{className:`max-h-64 overflow-auto font-mono text-xs leading-relaxed`,children:(0,R.jsx)(`table`,{className:`w-full border-collapse`,children:(0,R.jsx)(`tbody`,{children:t.map((e,t)=>(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{className:`w-10 shrink-0 select-none border-r border-[var(--border-weak-base)] pr-2 text-right align-top text-[var(--text-weaker)]`,children:t+1}),(0,R.jsx)(`td`,{className:`whitespace-pre-wrap break-all pl-2.5 text-[var(--text-base)]`,children:e||` `})]},t))})})})}var uP=Wm(`group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground`,{variants:{variant:{default:``,separator:`before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border`,border:`border-b border-border pb-2`}}});function dP({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?vr:`div`;return(0,R.jsx)(i,{"data-slot":`marker`,"data-variant":t,className:V(uP({variant:t,className:e})),...r})}function fP({className:e,...t}){return(0,R.jsx)(`span`,{"data-slot":`marker-content`,className:V(`min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function pP({...e}){return(0,R.jsx)(rf,{"data-slot":`context-menu`,...e})}function mP({...e}){return(0,R.jsx)(af,{"data-slot":`context-menu-trigger`,...e})}function hP({className:e,...t}){return(0,R.jsx)(of,{children:(0,R.jsx)(sf,{"data-slot":`context-menu-content`,className:V(`z-50 min-w-32 overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...t})})}function gP({className:e,inset:t,variant:n=`default`,...r}){return(0,R.jsx)(cf,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:V(`relative flex cursor-pointer items-center gap-1.5 rounded-md px-2 py-1.5 text-sm outline-none select-none focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function _P({className:e,...t}){return(0,R.jsx)(lf,{"data-slot":`context-menu-separator`,className:V(`-mx-1 my-1 h-px bg-border`,e),...t})}function vP(){let[e,t]=(0,E.useState)(Dh().showTimestamps);return(0,E.useEffect)(()=>kh(()=>t(Dh().showTimestamps)),[]),e}function yP(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),e}var bP=0,xP=new Set,SP=!1;function CP(){SP||(SP=!0,pt(()=>{bP++;for(let e of xP)e()}))}function wP(e){return CP(),xP.add(e),()=>xP.delete(e)}function TP(){return bP}function EP(){return 0}function DP(){return(0,E.useSyncExternalStore)(wP,TP,EP)}function OP({message:e,sessionID:t,children:n}){let r=DP(),i=(0,E.useMemo)(()=>Ot(`message`),[r]),a=e.type===`user`&&!e.id.startsWith(`msg_local_`),o=a&&!!t&&t!==`__draft__`;if(i.length===0&&!o)return(0,R.jsx)(R.Fragment,{children:n});let s=e.id,c=a?e.text:``;return(0,R.jsxs)(pP,{children:[(0,R.jsx)(mP,{asChild:!0,children:(0,R.jsx)(`div`,{children:n})}),(0,R.jsxs)(hP,{className:`min-w-40`,children:[o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(gP,{onSelect:()=>{cb(t,s,c).catch(e=>DN({title:`Edit failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`}))},children:[(0,R.jsx)(Re,{className:`size-3.5`}),` Edit`]}),(0,R.jsxs)(gP,{onSelect:()=>{lb(t,s).catch(e=>DN({title:`Fork failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`}))},children:[(0,R.jsx)(De,{className:`size-3.5`}),` Fork`]}),i.length>0&&(0,R.jsx)(_P,{})]}),i.map(e=>(0,R.jsx)(gP,{onSelect:()=>{try{e.run({messageID:s})}catch(t){console.error(`[extensions] contextMenu "${e.id}" crashed:`,t)}},children:e.label},e.id))]})]})}function kP({message:e,part:t,partIndex:n}){let r=DP(),i=(0,E.useMemo)(()=>Dt(),[r]);if(i.length===0)return null;let a=[];for(let r=0;r<i.length;r++){let o=i[r],s=null;try{s=o.render({messageID:e.id,message:e,part:t,partIndex:n})}catch(e){console.error(`[extensions] message.part "${o.id??r}" crashed:`,e)}s!=null&&a.push((0,R.jsx)(E.Fragment,{children:s},o.id??r))}return a.length===0?null:(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1 text-xs text-[var(--text-weak)]`,children:a})}function AP(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function jP({message:e,compact:t=!1,sessionID:n}){let r=yP(),i=(0,E.useMemo)(()=>wt(),[r]),a=e,o=(0,E.useMemo)(()=>kt(`message.render`),[r]);if(o.length>0){let t={message:{...e},sessionID:n};for(let e of o)try{let n=e.handler(t,()=>{});n instanceof Promise&&n.catch(t=>console.error(`[extensions] hook "${e.id}" failed:`,t))}catch(t){console.error(`[extensions] hook "${e.id}" crashed:`,t)}a=t.message}let s=(0,E.useMemo)(()=>Mt(a.type),[r,a.type,a.id]),c;if(s)try{c=s.render({message:a,sessionID:n})??MP(a,t,n)}catch(e){console.error(`[extensions] message "${s.id}" crashed:`,e),c=MP(a,t,n)}else c=MP(a,t,n);return(0,R.jsxs)(OP,{message:a,sessionID:n,children:[(0,R.jsx)(Nt,{region:`message.before`,messageID:a.id}),(0,R.jsxs)(R.Fragment,{children:[c,i.length>0&&(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:i.map((e,t)=>{let n=null;try{n=e.render({messageID:a.id,message:a})}catch(n){console.error(`[extensions] message decoration "${e.id??t}" crashed:`,n)}return n==null?null:(0,R.jsx)(E.Fragment,{children:n},e.id??t)})}),(0,R.jsx)(Nt,{region:`message.after`,messageID:a.id})]})]})}function MP(e,t,n){switch(e.type){case`user`:{let t=!!n&&!e.id.startsWith(`msg_local_`)&&!e.id.startsWith(`__draft__`);return(0,R.jsx)(`div`,{className:`group flex w-full justify-end mb-3.5`,children:(0,R.jsxs)(`div`,{className:`relative max-w-[85%] rounded-lg px-3 py-2`,children:[t&&(0,R.jsxs)(`div`,{className:`absolute top-1/2 right-full mr-3 hidden -translate-y-1/2 items-center gap-1.5 group-hover:flex`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{n&&ug(async()=>{let{startEditAtMessage:e}=await Promise.resolve().then(()=>dg);return{startEditAtMessage:e}},void 0).then(({startEditAtMessage:t})=>t(n,e.id,e.text??``))},title:`Edit from here`,className:`flex size-7 cursor-pointer items-center justify-center rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] text-[var(--text-weak)] shadow-sm hover:text-[var(--text-strong)]`,children:(0,R.jsx)(Re,{className:`size-3.5`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{n&&ug(async()=>{let{forkAtMessage:e}=await Promise.resolve().then(()=>dg);return{forkAtMessage:e}},void 0).then(({forkAtMessage:t})=>void t(n,e.id).catch(()=>{}))},title:`Fork from here`,className:`flex size-7 cursor-pointer items-center justify-center rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] text-[var(--text-weak)] shadow-sm hover:text-[var(--text-strong)]`,children:(0,R.jsx)(De,{className:`size-3.5`})})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(BP,{time:e.time.created}),(0,R.jsx)(it,{className:`size-3.5`}),`You`]}),e.files&&e.files.length>0&&(0,R.jsx)(FP,{files:e.files}),(0,R.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-[var(--text-strong)] whitespace-pre-wrap`,children:e.text})]})})}case`assistant`:return(0,R.jsx)(WP,{message:e,compact:t});case`system`:case`synthetic`:{let t=e.text??``,n=e.description,r=t.length>500||t.includes(`The Code Mode tool catalog has changed`),i=(n??``).startsWith(`Instructions updated`)||t.startsWith(`Instructions updated`);return(r||i)&&t.length>200?(0,R.jsx)(ZP,{children:(0,R.jsx)(NP,{message:e})}):(0,R.jsx)(ZP,{children:(0,R.jsxs)(`div`,{className:`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-3 py-2 text-xs text-[var(--text-weak)]`,children:[e.description??e.type,e.text&&(0,R.jsx)(`div`,{className:`mt-1 text-[var(--text-base)] whitespace-pre-wrap`,children:e.text})]})})}case`skill`:return(0,R.jsx)(ZP,{children:(0,R.jsxs)(`div`,{className:`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-interactive-weak)] px-3 py-2 text-xs text-[var(--text-interactive-base)]`,children:[`Activated skill `,(0,R.jsx)(`b`,{className:`font-medium text-[var(--text-strong)]`,children:e.name}),e.text&&(0,R.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap text-[var(--text-weaker)]`,children:e.text})]})});case`shell`:return(0,R.jsx)(ZP,{children:(0,R.jsx)(HP,{message:e})});case`agent-switched`:return(0,R.jsxs)(PP,{children:[`Agent switched to `,(0,R.jsx)(`b`,{children:e.agent})]});case`model-switched`:return(0,R.jsxs)(PP,{children:[`Model switched to `,(0,R.jsxs)(`b`,{children:[e.model.providerID,`/`,e.model.id]})]});case`location-switched`:return(0,R.jsxs)(PP,{children:[`Moved to `,(0,R.jsx)(`b`,{children:e.location.directory})]});case`compaction`:{let t=e.status===`running`,n=e.status===`failed`,r=n?`Compaction failed`:t?`Compacting…`:`Conversation compacted`,i=e.reason===`auto`||e.reason===`manual`?` (${e.reason})`:``,a=e.summary,o=e.recent;return n?(0,R.jsxs)(PP,{children:[r,i,e.error&&(0,R.jsxs)(`span`,{className:`text-[var(--text-on-critical-base)]`,children:[` — `,e.error.type,`: `,e.error.message]})]}):!a&&!o?(0,R.jsxs)(PP,{children:[r,i]}):(0,R.jsx)(ZP,{children:(0,R.jsx)(UP,{label:r,reason:i,summary:a,recent:o,running:t})})}default:return null}}function NP({message:e}){let[t,n]=(0,E.useState)(!1),r=e.description??e.text.split(`
90
+ `)}),(0,R.jsx)(JN,{content:e.state.status===`completed`||e.state.status===`error`?e.state.content:void 0})]})}function lP(e){let t=Object.entries(e.input).filter(([,e])=>typeof e==`string`||typeof e==`number`).slice(0,2).map(([e,t])=>`${e}: ${WN(String(t),40)}`).join(` `);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(BN,{...e,icon:`⚙`,pending:`${e.name}…`,label:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name}),t&&(0,R.jsxs)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:[` `,t]})]})}),e.state.status===`completed`&&e.output&&(0,R.jsx)(HN,{title:`${e.name} output`,collapsible:!0,stateKey:e.stateKey,children:(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap px-2.5 py-2 font-mono text-xs leading-relaxed text-[var(--text-base)]`,children:e.output})}),(0,R.jsx)(JN,{content:e.state.status===`completed`||e.state.status===`error`?e.state.content:void 0})]})}function uP({code:e}){let t=e.split(`
91
+ `);return(0,R.jsx)(`div`,{className:`max-h-64 overflow-auto font-mono text-xs leading-relaxed`,children:(0,R.jsx)(`table`,{className:`w-full border-collapse`,children:(0,R.jsx)(`tbody`,{children:t.map((e,t)=>(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{className:`w-10 shrink-0 select-none border-r border-[var(--border-weak-base)] pr-2 text-right align-top text-[var(--text-weaker)]`,children:t+1}),(0,R.jsx)(`td`,{className:`whitespace-pre-wrap break-all pl-2.5 text-[var(--text-base)]`,children:e||` `})]},t))})})})}var dP=Wm(`group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground`,{variants:{variant:{default:``,separator:`before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border`,border:`border-b border-border pb-2`}}});function fP({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?vr:`div`;return(0,R.jsx)(i,{"data-slot":`marker`,"data-variant":t,className:V(dP({variant:t,className:e})),...r})}function pP({className:e,...t}){return(0,R.jsx)(`span`,{"data-slot":`marker-content`,className:V(`min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function mP({...e}){return(0,R.jsx)(rf,{"data-slot":`context-menu`,...e})}function hP({...e}){return(0,R.jsx)(af,{"data-slot":`context-menu-trigger`,...e})}function gP({className:e,...t}){return(0,R.jsx)(of,{children:(0,R.jsx)(sf,{"data-slot":`context-menu-content`,className:V(`z-50 min-w-32 overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...t})})}function _P({className:e,inset:t,variant:n=`default`,...r}){return(0,R.jsx)(cf,{"data-slot":`context-menu-item`,"data-inset":t,"data-variant":n,className:V(`relative flex cursor-pointer items-center gap-1.5 rounded-md px-2 py-1.5 text-sm outline-none select-none focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function vP({className:e,...t}){return(0,R.jsx)(lf,{"data-slot":`context-menu-separator`,className:V(`-mx-1 my-1 h-px bg-border`,e),...t})}function yP(){let[e,t]=(0,E.useState)(Dh().showTimestamps);return(0,E.useEffect)(()=>kh(()=>t(Dh().showTimestamps)),[]),e}function bP(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),e}var xP=0,SP=new Set,CP=!1;function wP(){CP||(CP=!0,pt(()=>{xP++;for(let e of SP)e()}))}function TP(e){return wP(),SP.add(e),()=>SP.delete(e)}function EP(){return xP}function DP(){return 0}function OP(){return(0,E.useSyncExternalStore)(TP,EP,DP)}function kP({message:e,sessionID:t,children:n}){let r=OP(),i=(0,E.useMemo)(()=>Ot(`message`),[r]),a=e.type===`user`&&!e.id.startsWith(`msg_local_`),o=a&&!!t&&t!==`__draft__`;if(i.length===0&&!o)return(0,R.jsx)(R.Fragment,{children:n});let s=e.id,c=a?e.text:``;return(0,R.jsxs)(mP,{children:[(0,R.jsx)(hP,{asChild:!0,children:(0,R.jsx)(`div`,{children:n})}),(0,R.jsxs)(gP,{className:`min-w-40`,children:[o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(_P,{onSelect:()=>{cb(t,s,c).catch(e=>AS({title:`Edit failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`}))},children:[(0,R.jsx)(Re,{className:`size-3.5`}),` Edit`]}),(0,R.jsxs)(_P,{onSelect:()=>{lb(t,s).catch(e=>AS({title:`Fork failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`}))},children:[(0,R.jsx)(De,{className:`size-3.5`}),` Fork`]}),i.length>0&&(0,R.jsx)(vP,{})]}),i.map(e=>(0,R.jsx)(_P,{onSelect:()=>{try{e.run({messageID:s})}catch(t){console.error(`[extensions] contextMenu "${e.id}" crashed:`,t)}},children:e.label},e.id))]})]})}function AP({message:e,part:t,partIndex:n}){let r=OP(),i=(0,E.useMemo)(()=>Dt(),[r]);if(i.length===0)return null;let a=[];for(let r=0;r<i.length;r++){let o=i[r],s=null;try{s=o.render({messageID:e.id,message:e,part:t,partIndex:n})}catch(e){console.error(`[extensions] message.part "${o.id??r}" crashed:`,e)}s!=null&&a.push((0,R.jsx)(E.Fragment,{children:s},o.id??r))}return a.length===0?null:(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1 text-xs text-[var(--text-weak)]`,children:a})}function jP(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function MP({message:e,compact:t=!1,sessionID:n}){let r=bP(),i=(0,E.useMemo)(()=>wt(),[r]),a=e,o=(0,E.useMemo)(()=>kt(`message.render`),[r]);if(o.length>0){let t={message:{...e},sessionID:n};for(let e of o)try{let n=e.handler(t,()=>{});n instanceof Promise&&n.catch(t=>console.error(`[extensions] hook "${e.id}" failed:`,t))}catch(t){console.error(`[extensions] hook "${e.id}" crashed:`,t)}a=t.message}let s=(0,E.useMemo)(()=>Mt(a.type),[r,a.type,a.id]),c;if(s)try{c=s.render({message:a,sessionID:n})??NP(a,t,n)}catch(e){console.error(`[extensions] message "${s.id}" crashed:`,e),c=NP(a,t,n)}else c=NP(a,t,n);return(0,R.jsxs)(kP,{message:a,sessionID:n,children:[(0,R.jsx)(Nt,{region:`message.before`,messageID:a.id}),(0,R.jsxs)(R.Fragment,{children:[c,i.length>0&&(0,R.jsx)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:i.map((e,t)=>{let n=null;try{n=e.render({messageID:a.id,message:a})}catch(n){console.error(`[extensions] message decoration "${e.id??t}" crashed:`,n)}return n==null?null:(0,R.jsx)(E.Fragment,{children:n},e.id??t)})}),(0,R.jsx)(Nt,{region:`message.after`,messageID:a.id})]})]})}function NP(e,t,n){switch(e.type){case`user`:{let t=!!n&&!e.id.startsWith(`msg_local_`)&&!e.id.startsWith(`__draft__`);return(0,R.jsx)(`div`,{className:`group flex w-full justify-end mb-3.5`,children:(0,R.jsxs)(`div`,{className:`relative max-w-[85%] rounded-lg px-3 py-2`,children:[t&&(0,R.jsxs)(`div`,{className:`absolute top-1/2 right-full mr-3 hidden -translate-y-1/2 items-center gap-1.5 group-hover:flex`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{n&&ug(async()=>{let{startEditAtMessage:e}=await Promise.resolve().then(()=>dg);return{startEditAtMessage:e}},void 0).then(({startEditAtMessage:t})=>t(n,e.id,e.text??``))},title:`Edit from here`,className:`flex size-7 cursor-pointer items-center justify-center rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] text-[var(--text-weak)] shadow-sm hover:text-[var(--text-strong)]`,children:(0,R.jsx)(Re,{className:`size-3.5`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{n&&ug(async()=>{let{forkAtMessage:e}=await Promise.resolve().then(()=>dg);return{forkAtMessage:e}},void 0).then(({forkAtMessage:t})=>void t(n,e.id).catch(()=>{}))},title:`Fork from here`,className:`flex size-7 cursor-pointer items-center justify-center rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] text-[var(--text-weak)] shadow-sm hover:text-[var(--text-strong)]`,children:(0,R.jsx)(De,{className:`size-3.5`})})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(VP,{time:e.time.created}),(0,R.jsx)(it,{className:`size-3.5`}),`You`]}),e.files&&e.files.length>0&&(0,R.jsx)(IP,{files:e.files}),(0,R.jsx)(`div`,{className:`mt-1 text-sm leading-relaxed text-[var(--text-strong)] whitespace-pre-wrap`,children:e.text})]})})}case`assistant`:return(0,R.jsx)(GP,{message:e,compact:t});case`system`:case`synthetic`:{let t=e.text??``,n=e.description,r=t.length>500||t.includes(`The Code Mode tool catalog has changed`),i=(n??``).startsWith(`Instructions updated`)||t.startsWith(`Instructions updated`);return(r||i)&&t.length>200?(0,R.jsx)(QP,{children:(0,R.jsx)(PP,{message:e})}):(0,R.jsx)(QP,{children:(0,R.jsxs)(`div`,{className:`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-3 py-2 text-xs text-[var(--text-weak)]`,children:[e.description??e.type,e.text&&(0,R.jsx)(`div`,{className:`mt-1 text-[var(--text-base)] whitespace-pre-wrap`,children:e.text})]})})}case`skill`:return(0,R.jsx)(QP,{children:(0,R.jsxs)(`div`,{className:`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-interactive-weak)] px-3 py-2 text-xs text-[var(--text-interactive-base)]`,children:[`Activated skill `,(0,R.jsx)(`b`,{className:`font-medium text-[var(--text-strong)]`,children:e.name}),e.text&&(0,R.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap text-[var(--text-weaker)]`,children:e.text})]})});case`shell`:return(0,R.jsx)(QP,{children:(0,R.jsx)(UP,{message:e})});case`agent-switched`:return(0,R.jsxs)(FP,{children:[`Agent switched to `,(0,R.jsx)(`b`,{children:e.agent})]});case`model-switched`:return(0,R.jsxs)(FP,{children:[`Model switched to `,(0,R.jsxs)(`b`,{children:[e.model.providerID,`/`,e.model.id]})]});case`location-switched`:return(0,R.jsxs)(FP,{children:[`Moved to `,(0,R.jsx)(`b`,{children:e.location.directory})]});case`compaction`:{let t=e.status===`running`,n=e.status===`failed`,r=n?`Compaction failed`:t?`Compacting…`:`Conversation compacted`,i=e.reason===`auto`||e.reason===`manual`?` (${e.reason})`:``,a=e.summary,o=e.recent;return n?(0,R.jsxs)(FP,{children:[r,i,e.error&&(0,R.jsxs)(`span`,{className:`text-[var(--text-on-critical-base)]`,children:[` — `,e.error.type,`: `,e.error.message]})]}):!a&&!o?(0,R.jsxs)(FP,{children:[r,i]}):(0,R.jsx)(QP,{children:(0,R.jsx)(WP,{label:r,reason:i,summary:a,recent:o,running:t})})}default:return null}}function PP({message:e}){let[t,n]=(0,E.useState)(!1),r=e.description??e.text.split(`
92
92
  `)[0]??`Instructions updated`,i=e.description?e.text:e.text.split(`
93
93
  `).slice(1).join(`
94
- `).trim(),a=i.length>0;return(0,R.jsxs)(`div`,{className:`w-full overflow-hidden rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>a&&n(e=>!e),className:`flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-xs ${a?`cursor-pointer hover:bg-[color:var(--surface-base-hover)]`:``}`,children:[(0,R.jsx)(`span`,{className:`flex-1 truncate text-[var(--text-weak)]`,children:(0,R.jsx)(`b`,{className:`font-medium text-[var(--text-base)]`,children:r})}),a&&(0,R.jsx)(L,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${t?`rotate-90`:``}`})]}),a&&t&&(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap border-t border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-3 py-2 font-mono text-[11px] leading-relaxed text-[var(--text-weak)]`,children:i})]})}function PP({children:e}){return(0,R.jsx)(ZP,{children:(0,R.jsx)(dP,{variant:`separator`,children:(0,R.jsx)(fP,{className:`text-xs text-[var(--text-weak)] [&_b]:text-[var(--text-base)]`,children:e})})})}function FP({files:e}){return(0,R.jsx)(`div`,{className:`mt-1.5 flex flex-wrap justify-end gap-1.5`,children:e.map((e,t)=>(0,R.jsx)(IP,{file:e},`${e.name??`file`}:${t}`))})}function IP({file:e}){let t=Ix(e),n=t?null:Lx(e);return!t&&!n?(0,R.jsx)(zP,{name:e.name,mime:e.mime}):t?(0,R.jsx)(LP,{src:t,name:e.name,alt:e.name??`attached image`}):(0,R.jsx)(RP,{filePath:n,name:e.name})}function LP({src:e,name:t,alt:n}){let[r,i]=(0,E.useState)(!1);return(0,R.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),title:r?`${t??`image`} — click to shrink`:`${t??`image`} — click to enlarge`,className:`block cursor-pointer ${r?``:`cursor-zoom-in`}`,children:(0,R.jsx)(`img`,{src:e,alt:n??t??`image`,draggable:!1,className:`rounded-md border border-[color:var(--border-weak-base)] bg-[var(--surface-inset-base)] object-contain ${r?`max-h-[70vh] max-w-full`:`max-h-48 max-w-[16rem]`}`})})}function RP({filePath:e,name:t}){let n=J(e=>e.sessions.find(t=>t.id===e.currentSessionID)?.location?.directory),[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{let t=!1,r=null;return(async()=>{for(let a of[void 0,n]){if(t)return;try{let n=await G.fsReadBytes(e,a);if(t)return;r=URL.createObjectURL(new Blob([n])),i(r);return}catch{}}t||o(!0)})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e,n]),a||!r?(0,R.jsx)(zP,{name:t}):(0,R.jsx)(LP,{src:r,name:t,alt:t??`attached image`})}function zP({name:e,mime:t}){return(0,R.jsxs)(`span`,{title:t,className:`inline-flex max-w-full items-center gap-1.5 rounded-md border border-[color:var(--border-weak-base)] bg-[var(--surface-inset-base)] px-2 py-1 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(Le,{className:`size-3 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e??`file`}),t&&(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:t})]})}function BP({time:e}){return vP()?(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:AP(e)}):null}function VP({tokens:e}){let t=e.input+e.cache.read+e.cache.write,n=e.output+e.reasoning;if(t===0&&n===0)return null;let r=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e);return(0,R.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-weaker)]`,title:`${t.toLocaleString()} in · ${n.toLocaleString()} out`,children:[r(t),` in / `,r(n),` out`]})}function HP({message:e}){let{command:t,status:n,exit:r,output:i}=e,a=n===`exited`&&r!==0||n===`timeout`||n===`killed`,o=n===`running`,s=i?.output??``,c=s.length>0,[l,u]=(0,E.useState)(!1),d=o?``:a?`text-[var(--text-on-critical-base)]`:`text-[var(--text-on-success-base)]`,f=c&&s.split(`
94
+ `).trim(),a=i.length>0;return(0,R.jsxs)(`div`,{className:`w-full overflow-hidden rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>a&&n(e=>!e),className:`flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-xs ${a?`cursor-pointer hover:bg-[color:var(--surface-base-hover)]`:``}`,children:[(0,R.jsx)(`span`,{className:`flex-1 truncate text-[var(--text-weak)]`,children:(0,R.jsx)(`b`,{className:`font-medium text-[var(--text-base)]`,children:r})}),a&&(0,R.jsx)(L,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${t?`rotate-90`:``}`})]}),a&&t&&(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap border-t border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-3 py-2 font-mono text-[11px] leading-relaxed text-[var(--text-weak)]`,children:i})]})}function FP({children:e}){return(0,R.jsx)(QP,{children:(0,R.jsx)(fP,{variant:`separator`,children:(0,R.jsx)(pP,{className:`text-xs text-[var(--text-weak)] [&_b]:text-[var(--text-base)]`,children:e})})})}function IP({files:e}){return(0,R.jsx)(`div`,{className:`mt-1.5 flex flex-wrap justify-end gap-1.5`,children:e.map((e,t)=>(0,R.jsx)(LP,{file:e},`${e.name??`file`}:${t}`))})}function LP({file:e}){let t=Ix(e),n=t?null:Lx(e);return!t&&!n?(0,R.jsx)(BP,{name:e.name,mime:e.mime}):t?(0,R.jsx)(RP,{src:t,name:e.name,alt:e.name??`attached image`}):(0,R.jsx)(zP,{filePath:n,name:e.name})}function RP({src:e,name:t,alt:n}){let[r,i]=(0,E.useState)(!1);return(0,R.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),title:r?`${t??`image`} — click to shrink`:`${t??`image`} — click to enlarge`,className:`block cursor-pointer ${r?``:`cursor-zoom-in`}`,children:(0,R.jsx)(`img`,{src:e,alt:n??t??`image`,draggable:!1,className:`rounded-md border border-[color:var(--border-weak-base)] bg-[var(--surface-inset-base)] object-contain ${r?`max-h-[70vh] max-w-full`:`max-h-48 max-w-[16rem]`}`})})}function zP({filePath:e,name:t}){let n=J(e=>e.sessions.find(t=>t.id===e.currentSessionID)?.location?.directory),[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{let t=!1,r=null;return(async()=>{for(let a of[void 0,n]){if(t)return;try{let n=await G.fsReadBytes(e,a);if(t)return;r=URL.createObjectURL(new Blob([n])),i(r);return}catch{}}t||o(!0)})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e,n]),a||!r?(0,R.jsx)(BP,{name:t}):(0,R.jsx)(RP,{src:r,name:t,alt:t??`attached image`})}function BP({name:e,mime:t}){return(0,R.jsxs)(`span`,{title:t,className:`inline-flex max-w-full items-center gap-1.5 rounded-md border border-[color:var(--border-weak-base)] bg-[var(--surface-inset-base)] px-2 py-1 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(Le,{className:`size-3 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e??`file`}),t&&(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:t})]})}function VP({time:e}){return yP()?(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:jP(e)}):null}function HP({tokens:e}){let t=e.input+e.cache.read+e.cache.write,n=e.output+e.reasoning;if(t===0&&n===0)return null;let r=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e);return(0,R.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-weaker)]`,title:`${t.toLocaleString()} in · ${n.toLocaleString()} out`,children:[r(t),` in / `,r(n),` out`]})}function UP({message:e}){let{command:t,status:n,exit:r,output:i}=e,a=n===`exited`&&r!==0||n===`timeout`||n===`killed`,o=n===`running`,s=i?.output??``,c=s.length>0,[l,u]=(0,E.useState)(!1),d=o?``:a?`text-[var(--text-on-critical-base)]`:`text-[var(--text-on-success-base)]`,f=c&&s.split(`
95
95
  `).length>10,p=l||!f,m=p?s:s.split(`
96
96
  `).slice(0,10).join(`
97
97
  `),h=i?.truncated;return(0,R.jsxs)(`div`,{className:`w-full max-w-[85%] overflow-hidden rounded-lg border border-[var(--border-weak-base)] bg-[var(--background-strong)]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),title:l?`Click to collapse`:t,className:`flex w-full items-center justify-between gap-2 bg-[var(--surface-base)] px-2.5 py-1.5 text-left font-mono text-xs text-[var(--text-weak)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 ${l?`whitespace-pre-wrap break-all`:`truncate`}`,children:[(0,R.jsx)(`span`,{className:`text-[var(--text-weaker)]`,children:`$`}),` `,t]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[a&&typeof r==`number`&&(0,R.jsxs)(`span`,{className:`rounded-sm bg-[color-mix(in_oklch,var(--surface-critical-strong)_12%,transparent)] px-1 py-px text-[10px] text-[color:var(--surface-critical-strong)]`,children:[`exit `,r]}),(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 ${d}`,title:n===`timeout`?`Command timed out`:n===`killed`?`Command was killed`:void 0,children:[o&&(0,R.jsx)(uS,{className:`size-3`}),n]}),(0,R.jsx)(L,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${l?`rotate-90`:``}`})]})]}),o&&!c&&(0,R.jsx)(`div`,{className:`px-2.5 py-2 font-mono text-xs text-[var(--text-weaker)]`,children:`Running…`}),c&&(0,R.jsx)(`div`,{className:`border-t border-[var(--border-weak-base)]`,children:(0,R.jsxs)(`pre`,{onClick:()=>f&&u(e=>!e),className:`max-h-64 overflow-auto whitespace-pre-wrap px-2.5 py-2 font-mono text-xs leading-relaxed text-[var(--text-base)] ${f?`cursor-pointer hover:bg-[color:var(--surface-base-hover)]`:``}`,title:f?l?`Click to collapse`:`Click to expand full output`:void 0,children:[m,!p&&f&&`
98
- …`,h&&(0,R.jsx)(`span`,{className:`text-[var(--text-weaker)]`,children:` (truncated)`})]})}),!c&&!o&&(0,R.jsx)(`div`,{className:`border-t border-[var(--border-weak-base)] px-2.5 py-2 font-mono text-xs text-[var(--text-weaker)]`,children:`(no output)`})]})}function UP({label:e,reason:t,summary:n,recent:r,running:i}){let[a,o]=(0,E.useState)(!1),s=!!n&&n.length>400,c=!s||a?n:n?`${n.slice(0,400).trim()}…`:void 0;return(0,R.jsxs)(`div`,{className:`w-full max-w-[85%] overflow-hidden rounded-lg border border-[var(--border-weak-base)] bg-[var(--background-strong)]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-2 bg-[var(--surface-base)] px-2.5 py-1.5 text-left text-xs text-[var(--text-weak)] transition-colors hover:bg-[color:var(--surface-base-hover)]`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 font-medium text-[var(--text-strong)]`,children:[i&&(0,R.jsx)(uS,{className:`size-3`}),e,(0,R.jsx)(`span`,{className:`font-normal text-[var(--text-weaker)]`,children:t})]}),s&&(0,R.jsx)(L,{className:`ml-auto size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${a?`rotate-90`:``}`})]}),c&&(0,R.jsxs)(`div`,{className:`border-t border-[var(--border-weak-base)] px-2.5 py-2 text-xs leading-relaxed text-[var(--text-base)] whitespace-pre-wrap`,children:[c,s&&!a&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`ml-1 cursor-pointer text-[var(--text-interactive-base)] hover:underline`,children:`show more`})]}),r&&(0,R.jsxs)(`div`,{className:`border-t border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-2.5 py-2`,children:[(0,R.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-[var(--text-weaker)]`,children:`Recent context`}),(0,R.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap font-mono text-[11px] leading-relaxed text-[var(--text-weak)]`,children:r})]})]})}function WP({message:e,compact:t}){let n=vP();return(0,R.jsx)(ZP,{align:`left`,children:(0,R.jsxs)(`div`,{className:`w-full space-y-2.5 text-sm leading-relaxed`,children:[!t&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(`span`,{className:`font-medium text-[var(--text-strong)]`,children:e.agent??`assistant`}),e.model&&(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:YS(e.model)}),n&&(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:AP(e.time.created)}),e.cost!==void 0&&e.cost>0&&(0,R.jsxs)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:[`$`,e.cost.toFixed(4)]}),e.tokens&&(0,R.jsx)(VP,{tokens:e.tokens}),e.finish&&e.finish!==`stop`&&(0,R.jsx)(`span`,{className:`rounded-sm border border-[var(--border-weak-base)] px-1 py-px font-mono text-[10px] text-[var(--text-weak)]`,children:e.finish})]}),e.error&&(0,R.jsxs)(`div`,{className:`rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_40%,transparent)] bg-[var(--surface-critical-weak)] px-3 py-2 text-xs text-[var(--text-on-critical-strong)]`,children:[e.error.type,`: `,e.error.message]}),(()=>{let t={text:0,reasoning:0};return e.content.map((n,r)=>{let i=n.type===`tool`?`${e.id}:tool:${n.id}`:`${e.id}:${n.type}:${t[n.type]++}`;return(0,R.jsxs)(E.Fragment,{children:[(0,R.jsx)(GP,{stateKey:i,part:n}),(0,R.jsx)(kP,{message:e,part:n,partIndex:r})]},i)})})()]})})}function GP({part:e,stateKey:t}){return e.type===`reasoning`?(0,R.jsx)(JP,{text:e.text,stateKey:t}):e.type===`tool`?(0,R.jsx)(FN,{part:e,stateKey:t}):!e.text||!e.text.trim()?null:(0,R.jsx)(XP,{text:e.text})}var KP=new Map;function qP(e,t){for(KP.delete(e),KP.set(e,t);KP.size>2e3;){let e=KP.keys().next().value;if(!e)break;KP.delete(e)}}function JP({text:e,stateKey:t}){let[n,r]=(0,E.useState)(Dh().showReasoning),[i,a]=(0,E.useState)(()=>t?KP.get(t)??null:null);(0,E.useEffect)(()=>kh(()=>{r(Dh().showReasoning),a(null)}),[]);let o=i??n;return e?(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!o;a(e),t&&qP(t,e)},className:`flex w-full cursor-pointer items-center gap-1.5 px-2.5 py-1.5 text-left text-xs text-[var(--text-weak)] transition-colors hover:text-[var(--text-base)]`,children:[(0,R.jsx)(L,{className:`size-3 shrink-0 transition-transform ${o?`rotate-90`:``}`}),(0,R.jsx)(re,{className:`size-3.5 shrink-0`}),`Reasoning`]}),o&&(0,R.jsx)(`div`,{className:`border-t border-[var(--border-weak-base)] px-2.5 py-2 text-xs leading-relaxed text-[var(--text-weak)] italic whitespace-pre-wrap`,children:e})]}):null}function YP(e){let t=e.trim();return/^data:image\/[a-z0-9.+-]+;/i.test(t)?t:yA(e)}function XP({text:e}){return(0,R.jsx)(`div`,{className:`text-sm leading-relaxed text-[var(--text-base)] [&_h1]:text-[var(--text-strong)] [&_h2]:text-[var(--text-strong)] [&_h3]:text-[var(--text-strong)] [&_strong]:text-[var(--text-strong)] [&_a]:text-[var(--text-interactive-base)] [&_a]:underline [&_a]:underline-offset-2 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_blockquote]:border-l-2 [&_blockquote]:border-[var(--border-weak-base)] [&_blockquote]:pl-3 [&_blockquote]:text-[var(--text-weak)] [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:border [&_pre]:border-[var(--border-weak-base)] [&_pre]:bg-[var(--surface-inset-base)] [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-xs [&_pre]:text-[var(--text-base)] [&_code]:rounded [&_code]:bg-[var(--surface-base)] [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-[var(--text-base)] [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-inherit [&_img]:max-h-96 [&_img]:max-w-full [&_img]:rounded-md [&_img]:border [&_img]:border-[color:var(--border-weak-base)]`,children:(0,R.jsx)(hA,{remarkPlugins:[yN],urlTransform:YP,children:e})})}function ZP({align:e=`left`,children:t}){return(0,R.jsxs)(`div`,{className:`mb-3.5 flex w-full ${e===`right`?`justify-end`:`justify-start`}`,children:[t,e===`right`&&(0,R.jsx)(`span`,{className:`sr-only`,children:`user message`})]})}var QP={permission:`var(--surface-critical-strong)`,question:`var(--text-interactive-base)`,form:`var(--surface-warning-strong)`},$P={permission:{icon:Ze,label:`Permission required`,hint:`esc rejects`},question:{icon:se,label:`Question`,hint:`esc rejects`},form:{icon:ce,label:`Form`,hint:`esc cancels`}},eF=`overflow-x-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-2.5 py-1.5 font-mono text-xs text-[var(--text-base)]`;function tF({sessionID:e}){let t=J(t=>Sg(t).find(t=>t.req.sessionID===e)),n=J(t=>Sg(t).filter(t=>t.req.sessionID===e).length-1);return t?(0,R.jsx)(nF,{item:t,behind:n},`${t.kind}:${t.req.id}`):null}function nF({item:e,behind:t}){let n=$P[e.kind],r=n.icon,i=QP[e.kind],a=(0,E.useRef)(null),o=J(t=>Cg(t,e.req.sessionID));(0,E.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(document.querySelector(`[role="dialog"]`)||(t.preventDefault(),t.stopPropagation(),Uy(e)))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e]);let s=`${e.kind}:${e.req.id}`;return(0,E.useEffect)(()=>{Hh(`panel`,`show ${s}`);let e=requestAnimationFrame(()=>a.current?.focus({preventScroll:!0}));return()=>{cancelAnimationFrame(e),Hh(`panel`,`hide ${s}`)}},[s]),(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2 pt-2`,children:(0,R.jsx)(`div`,{className:`mx-auto max-w-3xl`,children:(0,R.jsxs)(`div`,{ref:a,tabIndex:-1,className:`max-h-72 overflow-y-auto border-l-2 bg-[color:var(--background-strong)] px-4 py-2 font-mono text-sm outline-none`,style:{borderLeftColor:i},children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 font-medium ${e.kind===`permission`?`text-[color:var(--surface-critical-strong)]`:e.kind===`question`?`text-[color:var(--text-interactive-base)]`:`text-[color:var(--surface-warning-strong)]`}`,children:[(0,R.jsx)(r,{className:`size-3.5`,"aria-hidden":!0}),e.kind===`form`?e.req.title||`Form`:n.label]}),(0,R.jsx)(Dx,{variant:`outline`,className:`max-w-52 truncate border-[var(--border-weak-base)] font-normal text-[var(--text-weak)]`,children:o})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>Uy(e),title:n.hint,className:`flex shrink-0 cursor-pointer items-center gap-1 font-mono text-xs text-[color:var(--text-weaker)] hover:text-[color:var(--text-weak)]`,children:[n.hint.replace(`esc `,``),(0,R.jsx)(at,{className:`size-3.5`})]})]}),(0,R.jsxs)(`div`,{className:`pt-1.5`,children:[e.kind===`permission`&&(0,R.jsx)(rF,{req:e.req}),e.kind===`question`&&(0,R.jsx)(iF,{req:e.req}),e.kind===`form`&&(0,R.jsx)(aF,{req:e.req})]}),t>0&&(0,R.jsxs)(`p`,{className:`pt-1.5 text-xs text-[color:var(--text-weaker)]`,children:[`+`,t,` more queued in this session`]})]})})})}function rF({req:e}){return(0,R.jsxs)(R.Fragment,{children:[e.resources.length>0&&(0,R.jsx)(`div`,{className:`space-y-1 pb-1.5`,children:e.resources.map((e,t)=>(0,R.jsx)(`pre`,{className:eF,children:e},t))}),e.metadata&&Object.keys(e.metadata).length>0&&(0,R.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 mb-1.5 font-mono text-xs whitespace-pre-wrap text-[var(--text-weak)]`,children:JSON.stringify(e.metadata,null,2)}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`font-sans text-xs text-[color:var(--text-weak)]`,children:e.source?(0,R.jsxs)(R.Fragment,{children:[`by tool `,(0,R.jsx)(`span`,{className:`font-mono`,children:e.source.id})]}):e.action||null}),(0,R.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,R.jsx)(U,{variant:`destructive`,size:`sm`,onClick:()=>void Ry(e.id,`reject`),children:`Reject`}),(0,R.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>void Ry(e.id,`once`),children:`Once`}),(0,R.jsx)(U,{size:`sm`,onClick:()=>void Ry(e.id,`always`),children:`Always allow`})]})]})]})}function iF({req:e}){let t=e.questions.length,[n,r]=(0,E.useState)(()=>e.questions.map(()=>[])),[i,a]=(0,E.useState)(()=>e.questions.map(()=>``)),[o,s]=(0,E.useState)(0),[c,l]=(0,E.useState)(0),[u,d]=(0,E.useState)(!1),f=e=>e.value??e.label,p=e.questions[Math.min(o,t-1)],m=o>=t-1,h=t=>{let r=e.questions[t];return n[t].length>0||r.custom&&i[t].trim().length>0},g=t=>e.questions.map((e,r)=>{let a=t&&t.qi===r?t.picked:n[r],o=i[r].trim();return e.multiple?[...a,...o?[o]:[]]:t?.explicit&&t.qi===r?a.slice(0,1):o?[o]:a.slice(0,1)}),_=t=>{d(!1),Vy(e.id,t).then(e=>{e||d(!0)})},v=(e,n)=>{e>=t?_(g(n)):(d(!1),s(e),l(t=>Math.max(t,e)))},y=(e,t,i)=>{if(d(!1),t.multiple){r(t=>t.map((t,n)=>n===e?t.includes(i)?t.filter(e=>e!==i):[...t,i]:t));return}let a=n[e].includes(i)?[]:[i];r(t=>t.map((t,n)=>n===e?a:t)),v(e+1,{qi:e,picked:a,explicit:!0})},b=(0,E.useRef)(()=>{});return b.current=()=>{m?e.questions.every((e,t)=>h(t))?_(g()):d(!1):h(o)&&v(o+1)},(0,E.useEffect)(()=>{let e=e=>{e.key!==`Enter`||!(e.ctrlKey||e.metaKey)||(e.preventDefault(),e.stopPropagation(),b.current())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,R.jsxs)(R.Fragment,{children:[t>1&&(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pb-1.5`,children:e.questions.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,disabled:t>c,onClick:()=>t<=c&&(s(t),d(!1)),title:e.question||e.header,className:`max-w-40 cursor-pointer truncate rounded px-1.5 py-0.5 font-mono text-xs transition-colors ${t===o?`bg-[color:var(--surface-inset-strong,var(--surface-inset-base))] text-[color:var(--text-strong)] outline outline-1 outline-[var(--border-selected,var(--border-weak-base))]`:t<c||t===c&&t!==o?`text-[color:var(--text-weak)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-strong)]`:`cursor-default text-[color:var(--text-weaker)] opacity-60`}`,children:[h(t)&&t!==o?`✓ `:``,e.header||`Q${t+1}`]},t))}),e.tool&&(0,R.jsxs)(`p`,{className:`pb-1.5 font-sans text-xs text-[color:var(--text-weak)]`,children:[`by tool `,(0,R.jsx)(`span`,{className:`font-mono`,children:e.tool.id})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[p.header&&t>1&&(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-[color:var(--text-weaker)]`,children:[o+1,`/`,t]}),(0,R.jsx)(`span`,{className:`min-w-0 break-words text-sm text-[color:var(--text-strong)]`,children:p.question})]}),p.options.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:p.options.map(e=>{let t=f(e),r=n[o].includes(t);return(0,R.jsx)(U,{type:`button`,variant:r?`default`:`secondary`,size:`xs`,title:e.description,onClick:()=>y(o,p,t),children:e.label},t)})}),p.custom&&(0,R.jsx)(rh,{value:i[o],onChange:e=>{d(!1),a(t=>t.map((t,n)=>n===o?e.target.value:t))},placeholder:`Custom answer…`,className:`mt-1 min-h-12 font-mono text-xs`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 pt-1.5`,children:[u&&(0,R.jsx)(`p`,{className:`mr-auto font-sans text-xs text-[color:var(--surface-critical-strong)]`,children:`answer rejected — request still open, adjust and retry`}),t>1&&o>0&&(0,R.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>s(o-1),children:`Back`}),(0,R.jsx)(U,{variant:`destructive`,size:`sm`,onClick:()=>void Uy(x()),children:`Reject`}),m?(0,R.jsx)(U,{size:`sm`,disabled:!e.questions.every((e,t)=>h(t)),onClick:()=>_(g()),children:`Reply`}):(0,R.jsx)(U,{size:`sm`,disabled:!h(o),onClick:()=>v(o+1),children:`Next`})]})]});function x(){return{kind:`question`,req:e}}}function aF({req:e}){let t=e.fields,[n,r]=(0,E.useState)(()=>{let e={};for(let n of t)n.type!==`external`&&(n.default===void 0?n.type===`multiselect`?e[n.key]=[]:n.type===`boolean`?e[n.key]=!1:e[n.key]=``:e[n.key]=n.default);return e}),[i,a]=(0,E.useState)(!1),o=t.filter(e=>e.type!==`external`&&e.required===!0).every(e=>{let t=n[e.key];return e.type===`boolean`?!0:Array.isArray(t)?t.length>0:typeof t==`number`||typeof t==`string`&&t.trim().length>0});function s(e,t){r(n=>({...n,[e]:t}))}return(0,R.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),!(!o||i)&&(a(!0),zy(e.id,n).finally(()=>a(!1)))},children:[t.map(e=>(0,R.jsx)(`div`,{className:`pb-1.5`,children:(0,R.jsx)(oF,{field:e,value:n[e.key],onChange:t=>s(e.key,t)})},e.key)),(0,R.jsxs)(`div`,{className:`flex justify-end gap-1.5 pt-1`,children:[(0,R.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>Uy({kind:`form`,req:e}),children:`Cancel`}),(0,R.jsx)(U,{type:`submit`,size:`sm`,disabled:!o||i,children:`Submit`})]})]})}function oF({field:e,value:t,onChange:n}){let r=`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--input-base)] px-2.5 py-1.5 font-mono text-xs text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)] focus:ring-1 focus:ring-[var(--border-selected)]`,i=(0,R.jsxs)(`label`,{className:`mb-1 block font-sans text-xs font-medium text-[var(--text-base)]`,children:[e.title??e.key,e.type!==`external`&&e.required&&(0,R.jsx)(`span`,{className:`text-[var(--surface-critical-strong)]`,children:` *`})]});switch(e.type){case`string`:return(0,R.jsxs)(`div`,{children:[i,e.options&&e.options.length>0?(0,R.jsxs)(`select`,{className:r,value:t??``,onChange:e=>n(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`—`}),e.options.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))]}):(0,R.jsx)(`input`,{className:r,placeholder:e.placeholder,value:t??``,onChange:e=>n(e.target.value)})]});case`number`:case`integer`:return(0,R.jsxs)(`div`,{children:[i,(0,R.jsx)(`input`,{type:`number`,className:r,value:t??``,onChange:e=>n(e.target.value===``?0:Number(e.target.value))})]});case`boolean`:return(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 font-sans text-sm text-[var(--text-base)]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--text-interactive-base)]`,checked:!!t,onChange:e=>n(e.target.checked)}),e.title??e.key]});case`multiselect`:return(0,R.jsxs)(`div`,{children:[i,(0,R.jsx)(`div`,{className:`space-y-1`,children:e.options.map(e=>{let r=(t??[]).includes(e.value);return(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 font-sans text-sm text-[var(--text-base)]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--text-interactive-base)]`,checked:r,onChange:r=>{let i=t??[];n(r.target.checked?[...i,e.value]:i.filter(t=>t!==e.value))}}),e.label]},e.value)})})]});case`external`:return(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-3 py-2 font-sans text-xs text-[var(--text-base)]`,children:[e.title??`External input`,`:`,` `,(0,R.jsx)(`a`,{className:`text-[var(--text-interactive-base)] underline`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url})]});default:return null}}var sF=`flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)] focus-visible:text-[var(--text-strong)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--border-selected)]`,cF=[{delivery:`steer`,caption:`⚡ steer · sent at the next step`,accent:`border-l-[color:var(--surface-warning-strong)]`},{delivery:`queue`,caption:`⏳ queue · sent after this turn`,accent:`border-l-[color:var(--text-interactive-base)]`}];function lF({sessionID:e}){let t=J(t=>t.pending[e]),n=J(t=>t.running[e]??!1);if(!t||t.length===0)return null;let r=t.filter(e=>(e.delivery??`steer`)===`steer`),i=t.filter(e=>e.delivery===`queue`);return r.length===0&&i.length===0?null:(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-1 pt-1`,children:(0,R.jsx)(`div`,{className:`mx-auto max-w-3xl overflow-hidden rounded-md border border-[color-mix(in_oklch,var(--border-base)_55%,transparent)] bg-[color-mix(in_oklch,var(--surface-base)_40%,transparent)]`,children:(0,R.jsx)(`div`,{className:`divide-y divide-[color:var(--border-weak-base)]`,children:cF.map(t=>{let a=t.delivery===`steer`?r:i;return a.length===0?null:(0,R.jsxs)(`div`,{className:`${t.accent} border-l-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pb-0.5 pt-1`,children:[(0,R.jsxs)(`span`,{className:`truncate font-mono text-[10px] tracking-wide uppercase text-[var(--text-weaker)]`,children:[t.caption,a.length>1?` (${a.length})`:``]}),t.delivery===`steer`&&n&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void Sy(e),title:`Interrupt the current step and deliver all steered messages now (queued ones stay parked)`,className:`${sF} ml-auto h-5 w-auto gap-1 px-1.5 font-mono text-[10px] normal-case`,children:[(0,R.jsx)(Be,{className:`size-3`}),`interrupt & send now`]})]}),a.map(t=>(0,R.jsx)(uF,{sessionID:e,row:t},t.key))]},t.delivery)})})})})}function uF({sessionID:e,row:t}){let n=t.state===`sending`,r=t.delivery===`queue`;return(0,R.jsxs)(`div`,{className:`group flex items-center gap-2 py-1 pr-1 pl-2.5 text-xs text-[var(--text-base)]`,children:[n?(0,R.jsx)(Me,{className:`size-3 shrink-0 animate-spin text-[var(--text-weaker)]`}):(0,R.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${r?`bg-[color:var(--text-interactive-base)]`:`bg-[color:var(--surface-warning-strong)]`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:t.text,children:t.text}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>by(e,t.key,r?`steer`:`queue`),title:r?`send at next step`:`move to queue`,className:`${sF} ${n?`pointer-events-none opacity-40`:``}`,children:r?(0,R.jsx)(te,{className:`size-3.5`}):(0,R.jsx)(M,{className:`size-3.5`})}),r&&!n&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>xy(e,t.key),title:`send now`,className:sF,children:(0,R.jsx)(Be,{className:`size-3.5`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>yy(e,t.key),title:n?`cancel send`:`cancel`,className:sF,children:(0,R.jsx)(rt,{className:`size-3.5`})})]})]})}function dF(e){requestAnimationFrame(()=>{let t=document.getElementById(`composer-input-${e}`);if(!(t instanceof HTMLTextAreaElement))return;t.focus();let n=t.value.length;t.setSelectionRange(n,n)})}function fF({sessionID:e,paneKey:t=`main`}){let n=J(e=>e.sessions),r=J(e=>e.running),i=J(e=>e.activeIDs),a=J(e=>e.runsPanelOpen),o=J(e=>e.runsSelection),s=J(t=>t.sessions.find(t=>t.id===e)??t.sessionDetails[e]),c=J(t=>t.sessions.find(t=>t.id===e)?.location?.directory),[l,u]=(0,E.useState)(`subagents`),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(0),[h,g]=(0,E.useState)([]),_=(0,E.useRef)(null),v=Ov(n,s?.parentID??e),y=e=>r[e]||i.includes(e),b=[...v].sort((e,t)=>Number(y(t.id))-Number(y(e.id))),x=Math.max(0,b.findIndex(e=>e.id===d));(0,E.useEffect)(()=>{if(!a)return;let t=b.length>0?`subagents`:`shells`,n=b.some(t=>t.id===e)?e:b[0]?.id??null,r=0,i=o,s=i?.section===`subagents`?i.subID:null;s&&b.some(e=>e.id===s)?(t=`subagents`,n=s):i?.section===`shells`&&(t=`shells`,r=Math.max(0,i.shellIndex)),u(t),f(n),m(r),document.activeElement?.blur?.(),requestAnimationFrame(()=>_.current?.focus({preventScroll:!0}))},[a]),(0,E.useEffect)(()=>{a&&Tv({section:l,subID:d,shellIndex:p})},[a,l,d,p]),(0,E.useEffect)(()=>{l===`shells`&&h.length>0&&p>h.length-1&&m(h.length-1)},[l,p,h.length]);let S=(0,E.useCallback)(async()=>{try{let e=c?{directory:c}:void 0,[t,n]=await Promise.all([G.shellList(e),G.ptyList(e)]);g([...t.data.map(e=>({id:e.id,label:e.command||e.shell,running:e.status===`running`,kind:`shell`})),...n.data.map(e=>({id:e.id,label:e.title||e.command,running:e.status===`running`,kind:`pty`}))])}catch{}},[c]);(0,E.useEffect)(()=>{if(!a){g([]);return}return S(),og({name:`runs-panel-shells`,minInterval:5e3,run:()=>S()})},[a,S]);let C=(0,E.useCallback)(async e=>{let t=c?{directory:c}:void 0;try{e.kind===`shell`?await G.shellDelete(e.id,t):await G.ptyDelete(e.id,t)}catch{}S()},[c,S]);(0,E.useEffect)(()=>{if(!a)return;let e=e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`k`){if(e.preventDefault(),e.stopPropagation(),l===`shells`){let e=h[p];e?.running&&C(e)}return}if([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,`Escape`].includes(e.key)){if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){wv(),dF(t);return}if(e.key===`ArrowLeft`||e.key===`ArrowRight`){u(e=>e===`subagents`?`shells`:`subagents`);return}if(e.key===`ArrowUp`){(l===`subagents`?b.length===0||x===0:h.length===0||p===0)?(wv(),dF(t)):l===`subagents`?f(b[x-1].id):m(e=>e-1);return}if(e.key===`ArrowDown`){l===`subagents`?b.length>0&&f(b[(x+1)%b.length].id):h.length>0&&m(e=>(e+1)%h.length);return}l===`subagents`&&b[x]?(wv(),Pv(b[x].id)):l===`shells`&&h[p]&&(wv(),xv())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[a,l,x,p,b,h,C]);let w=(0,E.useRef)(e);(0,E.useEffect)(()=>{w.current!==e&&(w.current=e,wv())},[e]);let T=(0,E.useRef)(null);return(0,E.useEffect)(()=>{if(!a)return;function e(e){let t=e.target;t instanceof Element&&(T.current?.contains(t)||t.closest(`[data-runs-panel-trigger]`)||wv())}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),a?(0,R.jsx)(`div`,{ref:T,className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2 pt-2`,children:(0,R.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,R.jsxs)(`div`,{ref:_,tabIndex:-1,className:`min-h-44 max-h-64 overflow-y-auto border-l-2 border-[color:var(--border-strong)] bg-[color:var(--background-strong)] px-4 py-2 font-mono text-sm outline-none`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,R.jsx)(pF,{active:l===`subagents`,onClick:()=>u(`subagents`),children:`Subagents`}),(0,R.jsx)(pF,{active:l===`shells`,onClick:()=>u(`shells`),children:`Shell`})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{wv(),dF(t)},className:`cursor-pointer font-mono text-xs text-[color:var(--text-weaker)] hover:text-[color:var(--text-weak)]`,children:`esc`})]}),l===`subagents`&&(b.length===0?(0,R.jsx)(`p`,{className:`pt-2 text-[color:var(--text-weak)]`,children:`No active subagents`}):b.map((t,n)=>(0,R.jsx)(mF,{selected:n===x,current:t.id===e,running:y(t.id),label:t.agent&&t.title?`${t.agent} — ${t.title}`:t.title||t.agent||t.id,onClick:()=>{wv(),Pv(t.id)}},t.id))),l===`shells`&&(h.length===0?(0,R.jsx)(`p`,{className:`pt-2 text-[color:var(--text-weak)]`,children:`No shell commands`}):h.map((e,t)=>(0,R.jsx)(mF,{selected:t===p,running:e.running,label:e.label,onKill:e.running?()=>void C(e):void 0,onClick:()=>{wv(),xv()}},e.id)))]}),(0,R.jsxs)(`p`,{className:`mt-1 pl-1 font-mono text-[10px] text-[color:var(--text-weaker)]`,children:[`tabs `,(0,R.jsx)(`span`,{className:`text-[color:var(--text-weak)]`,children:`←/→`}),(l===`subagents`?b.length:h.length)>0&&(0,R.jsxs)(R.Fragment,{children:[` · `,`↑↓ select`,` · `,(0,R.jsx)(`span`,{className:`text-[color:var(--text-weak)]`,children:`↵`}),` open`]}),l===`shells`&&h.some(e=>e.running)&&(0,R.jsxs)(R.Fragment,{children:[` · `,(0,R.jsx)(`span`,{className:`text-[color:var(--text-weak)]`,children:`ctrl+k`}),` kill`]}),` · `,(0,R.jsx)(`span`,{className:`text-[color:var(--text-weak)]`,children:`type`}),` → composer`]})]})}):null}function pF({active:e,onClick:t,children:n}){return(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer bg-transparent p-0 font-mono text-sm transition-colors ${e?`font-bold text-[color:var(--text-strong)]`:`font-normal text-[color:var(--text-weaker)] hover:text-[color:var(--text-weak)]`}`,children:n})}function mF({selected:e,current:t,running:n,label:r,hint:i,onClick:a,onKill:o}){let s=(0,E.useRef)(null);return(0,E.useEffect)(()=>{e&&s.current?.scrollIntoView({block:`nearest`})},[e]),(0,R.jsxs)(`div`,{className:`flex w-full items-center gap-1`,children:[(0,R.jsxs)(`button`,{ref:s,type:`button`,onClick:a,title:t?`Currently open session`:void 0,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-left font-mono text-xs transition-colors ${e?`bg-[color:var(--surface-raised-base-active)] text-[color:var(--text-strong)]`:`text-[color:var(--text-base)] hover:bg-[color:var(--surface-base-hover)]`}`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${n?`bg-emerald-500`:`bg-[color:var(--text-weaker)]`}`}),t&&(0,R.jsx)(L,{className:`size-3 shrink-0 text-[color:var(--text-weak)]`,"aria-label":`current session`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate ${t&&!e?`font-medium text-[color:var(--text-strong)]`:``}`,children:r}),i&&(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[color:var(--text-weaker)]`,children:i})]}),o!==void 0&&(0,R.jsx)(`button`,{type:`button`,"aria-label":`Kill`,title:`Kill`,onClick:e=>{e.stopPropagation(),o()},className:`shrink-0 cursor-pointer rounded-sm p-0.5 text-[color:var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--surface-critical-strong)]`,children:(0,R.jsx)(et,{className:`size-3`})})]})}var hF=1e4,gF=250,_F={retry:{icon:`⚠`,label:`Retry`,iconClass:`text-[color:var(--surface-warning-strong)]`,labelClass:`font-medium text-[color:var(--surface-warning-strong)]`,rowClass:`border-l-[color:var(--surface-warning-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-warning-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-warning-strong)_8%,transparent)]`,barClass:`bg-[color:var(--surface-warning-strong)]`},error:{icon:`⚠`,label:`Error`,iconClass:`text-[color:var(--surface-critical-strong)]`,labelClass:`font-medium text-[color:var(--surface-critical-strong)]`,rowClass:`border-l-[color:var(--surface-critical-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_8%,transparent)]`,barClass:`bg-[color:var(--surface-critical-strong)]`},failed:{icon:`⚠`,label:`Failed`,iconClass:`text-[color:var(--surface-critical-strong)]`,labelClass:`font-medium text-[color:var(--surface-critical-strong)]`,rowClass:`border-l-[color:var(--surface-critical-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_8%,transparent)]`,barClass:`bg-[color:var(--surface-critical-strong)]`},interrupted:{icon:`⏹`,label:`Interrupted`,iconClass:`text-[var(--text-weaker)]`,labelClass:`font-medium text-[var(--text-weaker)]`,rowClass:`border-l-[color:var(--text-weaker)] border-y border-r border-[color-mix(in_oklch,var(--text-weaker)_25%,transparent)] bg-transparent`,barClass:`bg-[color:var(--text-weaker)]`}};function vF(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));if(t<10)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function yF(e){let[,t]=(0,E.useState)(0);(0,E.useEffect)(()=>{if(e)return og({name:`run-notices-age`,minInterval:15e3,run:()=>t(e=>e+1)})},[e])}function bF(e,t){let[n,r]=(0,E.useState)({}),i=(0,E.useRef)({}),a=t?t.map(e=>e.id).join(`
98
+ …`,h&&(0,R.jsx)(`span`,{className:`text-[var(--text-weaker)]`,children:` (truncated)`})]})}),!c&&!o&&(0,R.jsx)(`div`,{className:`border-t border-[var(--border-weak-base)] px-2.5 py-2 font-mono text-xs text-[var(--text-weaker)]`,children:`(no output)`})]})}function WP({label:e,reason:t,summary:n,recent:r,running:i}){let[a,o]=(0,E.useState)(!1),s=!!n&&n.length>400,c=!s||a?n:n?`${n.slice(0,400).trim()}…`:void 0;return(0,R.jsxs)(`div`,{className:`w-full max-w-[85%] overflow-hidden rounded-lg border border-[var(--border-weak-base)] bg-[var(--background-strong)]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-2 bg-[var(--surface-base)] px-2.5 py-1.5 text-left text-xs text-[var(--text-weak)] transition-colors hover:bg-[color:var(--surface-base-hover)]`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 font-medium text-[var(--text-strong)]`,children:[i&&(0,R.jsx)(uS,{className:`size-3`}),e,(0,R.jsx)(`span`,{className:`font-normal text-[var(--text-weaker)]`,children:t})]}),s&&(0,R.jsx)(L,{className:`ml-auto size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${a?`rotate-90`:``}`})]}),c&&(0,R.jsxs)(`div`,{className:`border-t border-[var(--border-weak-base)] px-2.5 py-2 text-xs leading-relaxed text-[var(--text-base)] whitespace-pre-wrap`,children:[c,s&&!a&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`ml-1 cursor-pointer text-[var(--text-interactive-base)] hover:underline`,children:`show more`})]}),r&&(0,R.jsxs)(`div`,{className:`border-t border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-2.5 py-2`,children:[(0,R.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-[var(--text-weaker)]`,children:`Recent context`}),(0,R.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap font-mono text-[11px] leading-relaxed text-[var(--text-weak)]`,children:r})]})]})}function GP({message:e,compact:t}){let n=yP();return(0,R.jsx)(QP,{align:`left`,children:(0,R.jsxs)(`div`,{className:`w-full space-y-2.5 text-sm leading-relaxed`,children:[!t&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(`span`,{className:`font-medium text-[var(--text-strong)]`,children:e.agent??`assistant`}),e.model&&(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:iC(e.model)}),n&&(0,R.jsx)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:jP(e.time.created)}),e.cost!==void 0&&e.cost>0&&(0,R.jsxs)(`span`,{className:`font-mono text-[var(--text-weaker)]`,children:[`$`,e.cost.toFixed(4)]}),e.tokens&&(0,R.jsx)(HP,{tokens:e.tokens}),e.finish&&e.finish!==`stop`&&(0,R.jsx)(`span`,{className:`rounded-sm border border-[var(--border-weak-base)] px-1 py-px font-mono text-[10px] text-[var(--text-weak)]`,children:e.finish})]}),e.error&&(0,R.jsxs)(`div`,{className:`rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_40%,transparent)] bg-[var(--surface-critical-weak)] px-3 py-2 text-xs text-[var(--text-on-critical-strong)]`,children:[e.error.type,`: `,e.error.message]}),(()=>{let t={text:0,reasoning:0};return e.content.map((n,r)=>{let i=n.type===`tool`?`${e.id}:tool:${n.id}`:`${e.id}:${n.type}:${t[n.type]++}`;return(0,R.jsxs)(E.Fragment,{children:[(0,R.jsx)(KP,{stateKey:i,part:n}),(0,R.jsx)(AP,{message:e,part:n,partIndex:r})]},i)})})()]})})}function KP({part:e,stateKey:t}){return e.type===`reasoning`?(0,R.jsx)(YP,{text:e.text,stateKey:t}):e.type===`tool`?(0,R.jsx)(IN,{part:e,stateKey:t}):!e.text||!e.text.trim()?null:(0,R.jsx)(ZP,{text:e.text})}var qP=new Map;function JP(e,t){for(qP.delete(e),qP.set(e,t);qP.size>2e3;){let e=qP.keys().next().value;if(!e)break;qP.delete(e)}}function YP({text:e,stateKey:t}){let[n,r]=(0,E.useState)(Dh().showReasoning),[i,a]=(0,E.useState)(()=>t?qP.get(t)??null:null);(0,E.useEffect)(()=>kh(()=>{r(Dh().showReasoning),a(null)}),[]);let o=i??n;return e?(0,R.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{let e=!o;a(e),t&&JP(t,e)},className:`flex w-full cursor-pointer items-center gap-1.5 px-2.5 py-1.5 text-left text-xs text-[var(--text-weak)] transition-colors hover:text-[var(--text-base)]`,children:[(0,R.jsx)(L,{className:`size-3 shrink-0 transition-transform ${o?`rotate-90`:``}`}),(0,R.jsx)(re,{className:`size-3.5 shrink-0`}),`Reasoning`]}),o&&(0,R.jsx)(`div`,{className:`border-t border-[var(--border-weak-base)] px-2.5 py-2 text-xs leading-relaxed text-[var(--text-weak)] italic whitespace-pre-wrap`,children:e})]}):null}function XP(e){let t=e.trim();return/^data:image\/[a-z0-9.+-]+;/i.test(t)?t:OA(e)}function ZP({text:e}){return(0,R.jsx)(`div`,{className:`text-sm leading-relaxed text-[var(--text-base)] [&_h1]:text-[var(--text-strong)] [&_h2]:text-[var(--text-strong)] [&_h3]:text-[var(--text-strong)] [&_strong]:text-[var(--text-strong)] [&_a]:text-[var(--text-interactive-base)] [&_a]:underline [&_a]:underline-offset-2 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_blockquote]:border-l-2 [&_blockquote]:border-[var(--border-weak-base)] [&_blockquote]:pl-3 [&_blockquote]:text-[var(--text-weak)] [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:border [&_pre]:border-[var(--border-weak-base)] [&_pre]:bg-[var(--surface-inset-base)] [&_pre]:p-3 [&_pre]:font-mono [&_pre]:text-xs [&_pre]:text-[var(--text-base)] [&_code]:rounded [&_code]:bg-[var(--surface-base)] [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-[var(--text-base)] [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-inherit [&_img]:max-h-96 [&_img]:max-w-full [&_img]:rounded-md [&_img]:border [&_img]:border-[color:var(--border-weak-base)]`,children:(0,R.jsx)(wA,{remarkPlugins:[ON],urlTransform:XP,children:e})})}function QP({align:e=`left`,children:t}){return(0,R.jsxs)(`div`,{className:`mb-3.5 flex w-full ${e===`right`?`justify-end`:`justify-start`}`,children:[t,e===`right`&&(0,R.jsx)(`span`,{className:`sr-only`,children:`user message`})]})}var $P={permission:`var(--surface-critical-strong)`,question:`var(--text-interactive-base)`,form:`var(--surface-warning-strong)`},eF={permission:{icon:Ze,label:`Permission required`,hint:`esc rejects`},question:{icon:se,label:`Question`,hint:`esc rejects`},form:{icon:ce,label:`Form`,hint:`esc cancels`}},tF=`overflow-x-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-2.5 py-1.5 font-mono text-xs text-[var(--text-base)]`;function nF({sessionID:e}){let t=J(t=>Sg(t).find(t=>t.req.sessionID===e)),n=J(t=>Sg(t).filter(t=>t.req.sessionID===e).length-1);return t?(0,R.jsx)(rF,{item:t,behind:n},`${t.kind}:${t.req.id}`):null}function rF({item:e,behind:t}){let n=eF[e.kind],r=n.icon,i=$P[e.kind],a=(0,E.useRef)(null),o=J(t=>Cg(t,e.req.sessionID));(0,E.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(document.querySelector(`[role="dialog"]`)||(t.preventDefault(),t.stopPropagation(),Uy(e)))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e]);let s=`${e.kind}:${e.req.id}`;return(0,E.useEffect)(()=>{Hh(`panel`,`show ${s}`);let e=requestAnimationFrame(()=>a.current?.focus({preventScroll:!0}));return()=>{cancelAnimationFrame(e),Hh(`panel`,`hide ${s}`)}},[s]),(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2 pt-2`,children:(0,R.jsx)(`div`,{className:`mx-auto max-w-3xl`,children:(0,R.jsxs)(`div`,{ref:a,tabIndex:-1,className:`max-h-72 overflow-y-auto border-l-2 bg-[color:var(--background-strong)] px-4 py-2 font-mono text-sm outline-none`,style:{borderLeftColor:i},children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 font-medium ${e.kind===`permission`?`text-[color:var(--surface-critical-strong)]`:e.kind===`question`?`text-[color:var(--text-interactive-base)]`:`text-[color:var(--surface-warning-strong)]`}`,children:[(0,R.jsx)(r,{className:`size-3.5`,"aria-hidden":!0}),e.kind===`form`?e.req.title||`Form`:n.label]}),(0,R.jsx)(Dx,{variant:`outline`,className:`max-w-52 truncate border-[var(--border-weak-base)] font-normal text-[var(--text-weak)]`,children:o})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>Uy(e),title:n.hint,className:`flex shrink-0 cursor-pointer items-center gap-1 font-mono text-xs text-[color:var(--text-weaker)] hover:text-[color:var(--text-weak)]`,children:[n.hint.replace(`esc `,``),(0,R.jsx)(at,{className:`size-3.5`})]})]}),(0,R.jsxs)(`div`,{className:`pt-1.5`,children:[e.kind===`permission`&&(0,R.jsx)(iF,{req:e.req}),e.kind===`question`&&(0,R.jsx)(aF,{req:e.req}),e.kind===`form`&&(0,R.jsx)(oF,{req:e.req})]}),t>0&&(0,R.jsxs)(`p`,{className:`pt-1.5 text-xs text-[color:var(--text-weaker)]`,children:[`+`,t,` more queued in this session`]})]})})})}function iF({req:e}){return(0,R.jsxs)(R.Fragment,{children:[e.resources.length>0&&(0,R.jsx)(`div`,{className:`space-y-1 pb-1.5`,children:e.resources.map((e,t)=>(0,R.jsx)(`pre`,{className:tF,children:e},t))}),e.metadata&&Object.keys(e.metadata).length>0&&(0,R.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] p-2.5 mb-1.5 font-mono text-xs whitespace-pre-wrap text-[var(--text-weak)]`,children:JSON.stringify(e.metadata,null,2)}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`font-sans text-xs text-[color:var(--text-weak)]`,children:e.source?(0,R.jsxs)(R.Fragment,{children:[`by tool `,(0,R.jsx)(`span`,{className:`font-mono`,children:e.source.id})]}):e.action||null}),(0,R.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,R.jsx)(U,{variant:`destructive`,size:`sm`,onClick:()=>void Ry(e.id,`reject`),children:`Reject`}),(0,R.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>void Ry(e.id,`once`),children:`Once`}),(0,R.jsx)(U,{size:`sm`,onClick:()=>void Ry(e.id,`always`),children:`Always allow`})]})]})]})}function aF({req:e}){let t=e.questions.length,[n,r]=(0,E.useState)(()=>e.questions.map(()=>[])),[i,a]=(0,E.useState)(()=>e.questions.map(()=>``)),[o,s]=(0,E.useState)(0),[c,l]=(0,E.useState)(0),[u,d]=(0,E.useState)(!1),f=e=>e.value??e.label,p=e.questions[Math.min(o,t-1)],m=o>=t-1,h=t=>{let r=e.questions[t];return n[t].length>0||r.custom&&i[t].trim().length>0},g=t=>e.questions.map((e,r)=>{let a=t&&t.qi===r?t.picked:n[r],o=i[r].trim();return e.multiple?[...a,...o?[o]:[]]:t?.explicit&&t.qi===r?a.slice(0,1):o?[o]:a.slice(0,1)}),_=t=>{d(!1),Vy(e.id,t).then(e=>{e||d(!0)})},v=(e,n)=>{e>=t?_(g(n)):(d(!1),s(e),l(t=>Math.max(t,e)))},y=(e,t,i)=>{if(d(!1),t.multiple){r(t=>t.map((t,n)=>n===e?t.includes(i)?t.filter(e=>e!==i):[...t,i]:t));return}let a=n[e].includes(i)?[]:[i];r(t=>t.map((t,n)=>n===e?a:t)),v(e+1,{qi:e,picked:a,explicit:!0})},b=(0,E.useRef)(()=>{});return b.current=()=>{m?e.questions.every((e,t)=>h(t))?_(g()):d(!1):h(o)&&v(o+1)},(0,E.useEffect)(()=>{let e=e=>{e.key!==`Enter`||!(e.ctrlKey||e.metaKey)||(e.preventDefault(),e.stopPropagation(),b.current())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,R.jsxs)(R.Fragment,{children:[t>1&&(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pb-1.5`,children:e.questions.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,disabled:t>c,onClick:()=>t<=c&&(s(t),d(!1)),title:e.question||e.header,className:`max-w-40 cursor-pointer truncate rounded px-1.5 py-0.5 font-mono text-xs transition-colors ${t===o?`bg-[color:var(--surface-inset-strong,var(--surface-inset-base))] text-[color:var(--text-strong)] outline outline-1 outline-[var(--border-selected,var(--border-weak-base))]`:t<c||t===c&&t!==o?`text-[color:var(--text-weak)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-strong)]`:`cursor-default text-[color:var(--text-weaker)] opacity-60`}`,children:[h(t)&&t!==o?`✓ `:``,e.header||`Q${t+1}`]},t))}),e.tool&&(0,R.jsxs)(`p`,{className:`pb-1.5 font-sans text-xs text-[color:var(--text-weak)]`,children:[`by tool `,(0,R.jsx)(`span`,{className:`font-mono`,children:e.tool.id})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[p.header&&t>1&&(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-[color:var(--text-weaker)]`,children:[o+1,`/`,t]}),(0,R.jsx)(`span`,{className:`min-w-0 break-words text-sm text-[color:var(--text-strong)]`,children:p.question})]}),p.options.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 pt-1`,children:p.options.map(e=>{let t=f(e),r=n[o].includes(t);return(0,R.jsx)(U,{type:`button`,variant:r?`default`:`secondary`,size:`xs`,title:e.description,onClick:()=>y(o,p,t),children:e.label},t)})}),p.custom&&(0,R.jsx)(rh,{value:i[o],onChange:e=>{d(!1),a(t=>t.map((t,n)=>n===o?e.target.value:t))},placeholder:`Custom answer…`,className:`mt-1 min-h-12 font-mono text-xs`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5 pt-1.5`,children:[u&&(0,R.jsx)(`p`,{className:`mr-auto font-sans text-xs text-[color:var(--surface-critical-strong)]`,children:`answer rejected — request still open, adjust and retry`}),t>1&&o>0&&(0,R.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>s(o-1),children:`Back`}),(0,R.jsx)(U,{variant:`destructive`,size:`sm`,onClick:()=>void Uy(x()),children:`Reject`}),m?(0,R.jsx)(U,{size:`sm`,disabled:!e.questions.every((e,t)=>h(t)),onClick:()=>_(g()),children:`Reply`}):(0,R.jsx)(U,{size:`sm`,disabled:!h(o),onClick:()=>v(o+1),children:`Next`})]})]});function x(){return{kind:`question`,req:e}}}function oF({req:e}){let t=e.fields,[n,r]=(0,E.useState)(()=>{let e={};for(let n of t)n.type!==`external`&&(n.default===void 0?n.type===`multiselect`?e[n.key]=[]:n.type===`boolean`?e[n.key]=!1:e[n.key]=``:e[n.key]=n.default);return e}),[i,a]=(0,E.useState)(!1),o=t.filter(e=>e.type!==`external`&&e.required===!0).every(e=>{let t=n[e.key];return e.type===`boolean`?!0:Array.isArray(t)?t.length>0:typeof t==`number`||typeof t==`string`&&t.trim().length>0});function s(e,t){r(n=>({...n,[e]:t}))}return(0,R.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),!(!o||i)&&(a(!0),zy(e.id,n).finally(()=>a(!1)))},children:[t.map(e=>(0,R.jsx)(`div`,{className:`pb-1.5`,children:(0,R.jsx)(sF,{field:e,value:n[e.key],onChange:t=>s(e.key,t)})},e.key)),(0,R.jsxs)(`div`,{className:`flex justify-end gap-1.5 pt-1`,children:[(0,R.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>Uy({kind:`form`,req:e}),children:`Cancel`}),(0,R.jsx)(U,{type:`submit`,size:`sm`,disabled:!o||i,children:`Submit`})]})]})}function sF({field:e,value:t,onChange:n}){let r=`w-full rounded-md border border-[var(--border-weak-base)] bg-[var(--input-base)] px-2.5 py-1.5 font-mono text-xs text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)] focus:ring-1 focus:ring-[var(--border-selected)]`,i=(0,R.jsxs)(`label`,{className:`mb-1 block font-sans text-xs font-medium text-[var(--text-base)]`,children:[e.title??e.key,e.type!==`external`&&e.required&&(0,R.jsx)(`span`,{className:`text-[var(--surface-critical-strong)]`,children:` *`})]});switch(e.type){case`string`:return(0,R.jsxs)(`div`,{children:[i,e.options&&e.options.length>0?(0,R.jsxs)(`select`,{className:r,value:t??``,onChange:e=>n(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`—`}),e.options.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))]}):(0,R.jsx)(`input`,{className:r,placeholder:e.placeholder,value:t??``,onChange:e=>n(e.target.value)})]});case`number`:case`integer`:return(0,R.jsxs)(`div`,{children:[i,(0,R.jsx)(`input`,{type:`number`,className:r,value:t??``,onChange:e=>n(e.target.value===``?0:Number(e.target.value))})]});case`boolean`:return(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 font-sans text-sm text-[var(--text-base)]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--text-interactive-base)]`,checked:!!t,onChange:e=>n(e.target.checked)}),e.title??e.key]});case`multiselect`:return(0,R.jsxs)(`div`,{children:[i,(0,R.jsx)(`div`,{className:`space-y-1`,children:e.options.map(e=>{let r=(t??[]).includes(e.value);return(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 font-sans text-sm text-[var(--text-base)]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--text-interactive-base)]`,checked:r,onChange:r=>{let i=t??[];n(r.target.checked?[...i,e.value]:i.filter(t=>t!==e.value))}}),e.label]},e.value)})})]});case`external`:return(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-3 py-2 font-sans text-xs text-[var(--text-base)]`,children:[e.title??`External input`,`:`,` `,(0,R.jsx)(`a`,{className:`text-[var(--text-interactive-base)] underline`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.url})]});default:return null}}var cF=`flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)] focus-visible:text-[var(--text-strong)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--border-selected)]`,lF=[{delivery:`steer`,caption:`⚡ steer · sent at the next step`,accent:`border-l-[color:var(--surface-warning-strong)]`},{delivery:`queue`,caption:`⏳ queue · sent after this turn`,accent:`border-l-[color:var(--text-interactive-base)]`}];function uF({sessionID:e}){let t=J(t=>t.pending[e]),n=J(t=>t.running[e]??!1);if(!t||t.length===0)return null;let r=t.filter(e=>(e.delivery??`steer`)===`steer`),i=t.filter(e=>e.delivery===`queue`);return r.length===0&&i.length===0?null:(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-1 pt-1`,children:(0,R.jsx)(`div`,{className:`mx-auto max-w-3xl overflow-hidden rounded-md border border-[color-mix(in_oklch,var(--border-base)_55%,transparent)] bg-[color-mix(in_oklch,var(--surface-base)_40%,transparent)]`,children:(0,R.jsx)(`div`,{className:`divide-y divide-[color:var(--border-weak-base)]`,children:lF.map(t=>{let a=t.delivery===`steer`?r:i;return a.length===0?null:(0,R.jsxs)(`div`,{className:`${t.accent} border-l-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pb-0.5 pt-1`,children:[(0,R.jsxs)(`span`,{className:`truncate font-mono text-[10px] tracking-wide uppercase text-[var(--text-weaker)]`,children:[t.caption,a.length>1?` (${a.length})`:``]}),t.delivery===`steer`&&n&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void Sy(e),title:`Interrupt the current step and deliver all steered messages now (queued ones stay parked)`,className:`${cF} ml-auto h-5 w-auto gap-1 px-1.5 font-mono text-[10px] normal-case`,children:[(0,R.jsx)(Be,{className:`size-3`}),`interrupt & send now`]})]}),a.map(t=>(0,R.jsx)(dF,{sessionID:e,row:t},t.key))]},t.delivery)})})})})}function dF({sessionID:e,row:t}){let n=t.state===`sending`,r=t.delivery===`queue`;return(0,R.jsxs)(`div`,{className:`group flex items-center gap-2 py-1 pr-1 pl-2.5 text-xs text-[var(--text-base)]`,children:[n?(0,R.jsx)(Me,{className:`size-3 shrink-0 animate-spin text-[var(--text-weaker)]`}):(0,R.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 shrink-0 rounded-full ${r?`bg-[color:var(--text-interactive-base)]`:`bg-[color:var(--surface-warning-strong)]`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:t.text,children:t.text}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>by(e,t.key,r?`steer`:`queue`),title:r?`send at next step`:`move to queue`,className:`${cF} ${n?`pointer-events-none opacity-40`:``}`,children:r?(0,R.jsx)(te,{className:`size-3.5`}):(0,R.jsx)(M,{className:`size-3.5`})}),r&&!n&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>xy(e,t.key),title:`send now`,className:cF,children:(0,R.jsx)(Be,{className:`size-3.5`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>yy(e,t.key),title:n?`cancel send`:`cancel`,className:cF,children:(0,R.jsx)(rt,{className:`size-3.5`})})]})]})}function fF(e){requestAnimationFrame(()=>{let t=document.getElementById(`composer-input-${e}`);if(!(t instanceof HTMLTextAreaElement))return;t.focus();let n=t.value.length;t.setSelectionRange(n,n)})}function pF({sessionID:e,paneKey:t=`main`}){let n=J(e=>e.sessions),r=J(e=>e.running),i=J(e=>e.activeIDs),a=J(e=>e.runsPanelOpen),o=J(e=>e.runsSelection),s=J(t=>t.sessions.find(t=>t.id===e)??t.sessionDetails[e]),c=J(t=>t.sessions.find(t=>t.id===e)?.location?.directory),[l,u]=(0,E.useState)(`subagents`),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(0),[h,g]=(0,E.useState)([]),_=(0,E.useRef)(null),v=Ov(n,s?.parentID??e),y=e=>r[e]||i.includes(e),b=[...v].sort((e,t)=>Number(y(t.id))-Number(y(e.id))),x=Math.max(0,b.findIndex(e=>e.id===d));(0,E.useEffect)(()=>{if(!a)return;let t=b.length>0?`subagents`:`shells`,n=b.some(t=>t.id===e)?e:b[0]?.id??null,r=0,i=o,s=i?.section===`subagents`?i.subID:null;s&&b.some(e=>e.id===s)?(t=`subagents`,n=s):i?.section===`shells`&&(t=`shells`,r=Math.max(0,i.shellIndex)),u(t),f(n),m(r),document.activeElement?.blur?.(),requestAnimationFrame(()=>_.current?.focus({preventScroll:!0}))},[a]),(0,E.useEffect)(()=>{a&&Tv({section:l,subID:d,shellIndex:p})},[a,l,d,p]),(0,E.useEffect)(()=>{l===`shells`&&h.length>0&&p>h.length-1&&m(h.length-1)},[l,p,h.length]);let S=(0,E.useCallback)(async()=>{try{let e=c?{directory:c}:void 0,[t,n]=await Promise.all([G.shellList(e),G.ptyList(e)]);g([...t.data.map(e=>({id:e.id,label:e.command||e.shell,running:e.status===`running`,kind:`shell`})),...n.data.map(e=>({id:e.id,label:e.title||e.command,running:e.status===`running`,kind:`pty`}))])}catch{}},[c]);(0,E.useEffect)(()=>{if(!a){g([]);return}return S(),og({name:`runs-panel-shells`,minInterval:5e3,run:()=>S()})},[a,S]);let C=(0,E.useCallback)(async e=>{let t=c?{directory:c}:void 0;try{e.kind===`shell`?await G.shellDelete(e.id,t):await G.ptyDelete(e.id,t)}catch{}S()},[c,S]);(0,E.useEffect)(()=>{if(!a)return;let e=e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`k`){if(e.preventDefault(),e.stopPropagation(),l===`shells`){let e=h[p];e?.running&&C(e)}return}if([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Enter`,`Escape`].includes(e.key)){if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){wv(),fF(t);return}if(e.key===`ArrowLeft`||e.key===`ArrowRight`){u(e=>e===`subagents`?`shells`:`subagents`);return}if(e.key===`ArrowUp`){(l===`subagents`?b.length===0||x===0:h.length===0||p===0)?(wv(),fF(t)):l===`subagents`?f(b[x-1].id):m(e=>e-1);return}if(e.key===`ArrowDown`){l===`subagents`?b.length>0&&f(b[(x+1)%b.length].id):h.length>0&&m(e=>(e+1)%h.length);return}l===`subagents`&&b[x]?(wv(),Pv(b[x].id)):l===`shells`&&h[p]&&(wv(),xv())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[a,l,x,p,b,h,C]);let w=(0,E.useRef)(e);(0,E.useEffect)(()=>{w.current!==e&&(w.current=e,wv())},[e]);let T=(0,E.useRef)(null);return(0,E.useEffect)(()=>{if(!a)return;function e(e){let t=e.target;t instanceof Element&&(T.current?.contains(t)||t.closest(`[data-runs-panel-trigger]`)||wv())}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),a?(0,R.jsx)(`div`,{ref:T,className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2 pt-2`,children:(0,R.jsxs)(`div`,{className:`mx-auto max-w-3xl`,children:[(0,R.jsxs)(`div`,{ref:_,tabIndex:-1,className:`min-h-44 max-h-64 overflow-y-auto border-l-2 border-[color:var(--border-strong)] bg-[color:var(--background-strong)] px-4 py-2 font-mono text-sm outline-none`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,R.jsx)(mF,{active:l===`subagents`,onClick:()=>u(`subagents`),children:`Subagents`}),(0,R.jsx)(mF,{active:l===`shells`,onClick:()=>u(`shells`),children:`Shell`})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{wv(),fF(t)},className:`cursor-pointer font-mono text-xs text-[color:var(--text-weaker)] hover:text-[color:var(--text-weak)]`,children:`esc`})]}),l===`subagents`&&(b.length===0?(0,R.jsx)(`p`,{className:`pt-2 text-[color:var(--text-weak)]`,children:`No active subagents`}):b.map((t,n)=>(0,R.jsx)(hF,{selected:n===x,current:t.id===e,running:y(t.id),label:t.agent&&t.title?`${t.agent} — ${t.title}`:t.title||t.agent||t.id,onClick:()=>{wv(),Pv(t.id)}},t.id))),l===`shells`&&(h.length===0?(0,R.jsx)(`p`,{className:`pt-2 text-[color:var(--text-weak)]`,children:`No shell commands`}):h.map((e,t)=>(0,R.jsx)(hF,{selected:t===p,running:e.running,label:e.label,onKill:e.running?()=>void C(e):void 0,onClick:()=>{wv(),xv()}},e.id)))]}),(0,R.jsxs)(`p`,{className:`mt-1 pl-1 font-mono text-[10px] text-[color:var(--text-weaker)]`,children:[`tabs `,(0,R.jsx)(`span`,{className:`text-[color:var(--text-weak)]`,children:`←/→`}),(l===`subagents`?b.length:h.length)>0&&(0,R.jsxs)(R.Fragment,{children:[` · `,`↑↓ select`,` · `,(0,R.jsx)(`span`,{className:`text-[color:var(--text-weak)]`,children:`↵`}),` open`]}),l===`shells`&&h.some(e=>e.running)&&(0,R.jsxs)(R.Fragment,{children:[` · `,(0,R.jsx)(`span`,{className:`text-[color:var(--text-weak)]`,children:`ctrl+k`}),` kill`]}),` · `,(0,R.jsx)(`span`,{className:`text-[color:var(--text-weak)]`,children:`type`}),` → composer`]})]})}):null}function mF({active:e,onClick:t,children:n}){return(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer bg-transparent p-0 font-mono text-sm transition-colors ${e?`font-bold text-[color:var(--text-strong)]`:`font-normal text-[color:var(--text-weaker)] hover:text-[color:var(--text-weak)]`}`,children:n})}function hF({selected:e,current:t,running:n,label:r,hint:i,onClick:a,onKill:o}){let s=(0,E.useRef)(null);return(0,E.useEffect)(()=>{e&&s.current?.scrollIntoView({block:`nearest`})},[e]),(0,R.jsxs)(`div`,{className:`flex w-full items-center gap-1`,children:[(0,R.jsxs)(`button`,{ref:s,type:`button`,onClick:a,title:t?`Currently open session`:void 0,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-left font-mono text-xs transition-colors ${e?`bg-[color:var(--surface-raised-base-active)] text-[color:var(--text-strong)]`:`text-[color:var(--text-base)] hover:bg-[color:var(--surface-base-hover)]`}`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${n?`bg-emerald-500`:`bg-[color:var(--text-weaker)]`}`}),t&&(0,R.jsx)(L,{className:`size-3 shrink-0 text-[color:var(--text-weak)]`,"aria-label":`current session`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate ${t&&!e?`font-medium text-[color:var(--text-strong)]`:``}`,children:r}),i&&(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[color:var(--text-weaker)]`,children:i})]}),o!==void 0&&(0,R.jsx)(`button`,{type:`button`,"aria-label":`Kill`,title:`Kill`,onClick:e=>{e.stopPropagation(),o()},className:`shrink-0 cursor-pointer rounded-sm p-0.5 text-[color:var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--surface-critical-strong)]`,children:(0,R.jsx)(et,{className:`size-3`})})]})}var gF=1e4,_F=250,vF={retry:{icon:`⚠`,label:`Retry`,iconClass:`text-[color:var(--surface-warning-strong)]`,labelClass:`font-medium text-[color:var(--surface-warning-strong)]`,rowClass:`border-l-[color:var(--surface-warning-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-warning-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-warning-strong)_8%,transparent)]`,barClass:`bg-[color:var(--surface-warning-strong)]`},error:{icon:`⚠`,label:`Error`,iconClass:`text-[color:var(--surface-critical-strong)]`,labelClass:`font-medium text-[color:var(--surface-critical-strong)]`,rowClass:`border-l-[color:var(--surface-critical-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_8%,transparent)]`,barClass:`bg-[color:var(--surface-critical-strong)]`},failed:{icon:`⚠`,label:`Failed`,iconClass:`text-[color:var(--surface-critical-strong)]`,labelClass:`font-medium text-[color:var(--surface-critical-strong)]`,rowClass:`border-l-[color:var(--surface-critical-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_8%,transparent)]`,barClass:`bg-[color:var(--surface-critical-strong)]`},interrupted:{icon:`⏹`,label:`Interrupted`,iconClass:`text-[var(--text-weaker)]`,labelClass:`font-medium text-[var(--text-weaker)]`,rowClass:`border-l-[color:var(--text-weaker)] border-y border-r border-[color-mix(in_oklch,var(--text-weaker)_25%,transparent)] bg-transparent`,barClass:`bg-[color:var(--text-weaker)]`}};function yF(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));if(t<10)return`just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function bF(e){let[,t]=(0,E.useState)(0);(0,E.useEffect)(()=>{if(e)return og({name:`run-notices-age`,minInterval:15e3,run:()=>t(e=>e+1)})},[e])}function xF(e,t){let[n,r]=(0,E.useState)({}),i=(0,E.useRef)({}),a=t?t.map(e=>e.id).join(`
99
99
  `):``;return(0,E.useEffect)(()=>{let t=a?a.split(`
100
- `):[];for(let e of t)e in i.current||(i.current[e]=hF);for(let e of Object.keys(i.current))t.includes(e)||delete i.current[e];if(t.length===0){r({});return}let n=Date.now(),o=setInterval(()=>{let a=Date.now(),o=a-n;if(n=a,typeof document<`u`&&document.hidden)return;let s={},c=[];for(let e of t){let t=Math.max(0,(i.current[e]??hF)-o);i.current[e]=t,s[e]=hF-t,t===0&&c.push(e)}r(s);for(let t of c)G_(e,t)},gF);return()=>clearInterval(o)},[a,e]),n}function xF({sessionID:e}){let t=J(t=>t.runNotices[e]);yF(!!t&&t.length>0);let n=bF(e,t);return!t||t.length===0?null:(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-1 pt-2`,children:(0,R.jsx)(`div`,{className:`mx-auto flex max-h-32 max-w-3xl flex-col gap-1 overflow-y-auto`,children:t.map(t=>{let r=_F[t.kind],i=Math.min(100,(n[t.id]??0)/hF*100);return(0,R.jsxs)(`div`,{className:`relative flex items-start gap-2 rounded-md border-l-2 py-1 pl-2.5 pr-2 pb-1.5 text-xs text-[var(--text-base)] ${r.rowClass}`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 ${r.iconClass}`,children:r.icon}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:r.labelClass,children:r.label}),`: `,t.text]}),(0,R.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[var(--text-weaker)]`,children:vF(t.at)}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>G_(e,t.id),title:`Dismiss`,className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:`✕`}),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-[2px] opacity-40 ${r.barClass}`,style:{width:`${i}%`}})]},t.id)})})})}function SF({sessionID:e}){let t=J(t=>t.sendErrors[e]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(xF,{sessionID:e}),t?(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2 pt-2`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-start gap-2 rounded-md border-l-2 border-l-[color:var(--surface-critical-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_8%,transparent)] py-1.5 pl-2.5 pr-2 text-xs text-[var(--text-base)]`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-[color:var(--surface-warning-strong)]`,children:`⚠`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--surface-critical-strong)]`,children:t.type}),`: `,t.message]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>vy(e),title:`Dismiss`,className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:`✕`})]})}):null]})}function CF({sessionID:e,onNavigate:t}){let n=J(t=>Ov(t.sessions,e)),r=J(e=>e.running),i=J(e=>e.activeIDs),[a,o]=(0,E.useState)(()=>{try{return localStorage.getItem(`webui.subagentStripCollapsed`)!==`1`}catch{return!1}}),s=e=>t?t(e):void Pv(e);if(n.length===0)return null;let c=n.filter(e=>r[e.id]||i.includes(e.id)).length;return(0,R.jsxs)(`div`,{className:`border-b border-[color:var(--border-weak-base)] px-4 py-1`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>{o(e=>{let t=!e;try{localStorage.setItem(`webui.subagentStripCollapsed`,t?`0`:`1`)}catch{}return t})},className:`flex cursor-pointer items-center gap-1.5 rounded-md px-1 py-0.5 text-[11px] text-[color:var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`,title:`Subagent sessions of this session`,children:[a?(0,R.jsx)(I,{className:`size-3`}):(0,R.jsx)(L,{className:`size-3`}),(0,R.jsxs)(`span`,{className:`font-medium`,children:[`Subagents (`,n.length,`)`]}),c>0&&(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-[color:var(--surface-brand-base)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-[color:var(--surface-brand-base)]`}),c,` running`]})]}),a&&(0,R.jsx)(`div`,{className:`mt-0.5 mb-1 flex flex-col gap-0.5`,children:n.map(e=>(0,R.jsx)(wF,{id:e.id,title:e.title,agent:e.agent,running:!!r[e.id]||i.includes(e.id),onOpen:()=>s(e.id)},e.id))})]})}function wF({id:e,title:t,agent:n,running:r,onOpen:i}){let[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(``),l=()=>{let t=s.trim();t&&(ey(e,t),c(``),o(!1))};return(0,R.jsxs)(`div`,{className:`rounded-md px-1 py-0.5 transition-colors hover:bg-[color:var(--surface-base-hover)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-[color:var(--surface-success-strong)]`:`bg-[color:var(--border-base)]`}`,title:r?`Running`:`Idle`}),(0,R.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 cursor-pointer truncate text-left text-xs text-[color:var(--text-weak)] hover:text-[color:var(--text-strong)]`,title:`Open ${t??e}`,children:[n&&t?`${n} — ${t}`:t||n||`subagent`,(0,R.jsx)(`span`,{className:`ml-2 hidden font-mono text-[10px] text-[color:var(--text-weaker)] sm:inline`,children:e.slice(0,12)})]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:()=>{o(e=>!e),c(``)},title:a?`Cancel`:`Message this subagent`,children:[(0,R.jsx)(Ne,{}),`Message`]}),(0,R.jsx)(U,{variant:`ghost`,size:`xs`,onClick:i,title:`Open session`,children:`Open`})]}),a&&(0,R.jsx)(`input`,{autoFocus:!0,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(e.preventDefault(),o(!1))},placeholder:`message this subagent… (enter to send)`,className:`mt-1 w-full rounded-md border border-[color:var(--border-base)] bg-[color:var(--input-base)] px-2 py-1 font-mono text-xs text-[color:var(--text-strong)] outline-none placeholder:text-[color:var(--text-weaker)] focus:border-[color:var(--border-selected)]`})]})}var TF=`webui.theme`,EF=`oc-theme`,DF=[{id:`opencode`,label:`Opencode`,vars:{}},{id:`catppuccin`,label:`Catppuccin`,vars:{"--background-base":`#1e1e2e`,"--surface-float-base":`#181825`,"--background-weak":`#11111b`,"--text-strong":`#cdd6f4`,"--text-weak":`#9399b2`,"--border-selected":`#89b4fa`,"--surface-brand-base":`#f5c2e7`,"--surface-success-strong":`#a6e3a1`,"--surface-critical-strong":`#f38ba8`,"--surface-warning-strong":`#f9e2af`,"--surface-info-strong":`#94e2d5`}},{id:`nord`,label:`Nord`,vars:{"--background-base":`#2e3440`,"--surface-float-base":`#3b4252`,"--background-weak":`#434c5e`,"--text-strong":`#eceff4`,"--text-weak":`#8b95a7`,"--border-selected":`#88c0d0`,"--surface-brand-base":`#8fbcbb`,"--surface-success-strong":`#a3be8c`,"--surface-critical-strong":`#bf616a`,"--surface-warning-strong":`#d08770`,"--surface-info-strong":`#88c0d0`}},{id:`tokyonight`,label:`Tokyo Night`,vars:{"--background-base":`#1a1b26`,"--surface-float-base":`#1e2030`,"--background-weak":`#222436`,"--text-strong":`#c8d3f5`,"--text-weak":`#828bb8`,"--border-selected":`#82aaff`,"--surface-brand-base":`#ff966c`,"--surface-success-strong":`#c3e88d`,"--surface-critical-strong":`#ff757f`,"--surface-warning-strong":`#ffc777`,"--surface-info-strong":`#82aaff`}},{id:`dracula`,label:`Dracula`,vars:{"--background-base":`#282a36`,"--surface-float-base":`#21222c`,"--background-weak":`#44475a`,"--text-strong":`#f8f8f2`,"--text-weak":`#6272a4`,"--border-selected":`#bd93f9`,"--surface-brand-base":`#8be9fd`,"--surface-success-strong":`#50fa7b`,"--surface-critical-strong":`#ff5555`,"--surface-warning-strong":`#f1fa8c`,"--surface-info-strong":`#ffb86c`}},{id:`gruvbox`,label:`Gruvbox`,vars:{"--background-base":`#282828`,"--surface-float-base":`#3c3836`,"--background-weak":`#504945`,"--text-strong":`#ebdbb2`,"--text-weak":`#928374`,"--border-selected":`#83a598`,"--surface-brand-base":`#8ec07c`,"--surface-success-strong":`#b8bb26`,"--surface-critical-strong":`#fb4934`,"--surface-warning-strong":`#fe8019`,"--surface-info-strong":`#fabd2f`}},{id:`github`,label:`GitHub`,vars:{"--background-base":`#0d1117`,"--surface-float-base":`#010409`,"--background-weak":`#161b22`,"--text-strong":`#c9d1d9`,"--text-weak":`#8b949e`,"--border-selected":`#58a6ff`,"--surface-brand-base":`#39c5cf`,"--surface-success-strong":`#3fb950`,"--surface-critical-strong":`#f85149`,"--surface-warning-strong":`#e3b341`,"--surface-info-strong":`#d29922`}}];function OF(){let e=localStorage.getItem(TF);return DF.find(t=>t.id===e)??DF[0]}function kF(e){let t=DF.find(t=>t.id===e)??DF[0],n=document.getElementById(EF);n||(n=document.createElement(`style`),n.id=EF,document.head.appendChild(n));let r=Object.entries(t.vars);return n.textContent=r.length>0?`:root:root {\n ${r.map(([e,t])=>`${e}: ${t};`).join(`
101
- `)}\n}`:``,localStorage.setItem(TF,t.id),t}kF(OF().id);function AF(){let[e,t]=(0,E.useState)(OF().id),n=J(e=>e.uiSignals.themes),[r,i]=(0,E.useState)(!1);(0,E.useEffect)(()=>{n&&i(!0)},[n]);let a=DF.find(t=>t.id===e)?.label??DF[0].label;return(0,R.jsxs)(cC,{open:r,onOpenChange:i,children:[(0,R.jsx)(lC,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(Pe,{}),a]})}),(0,R.jsx)(uC,{align:`end`,className:`min-w-40`,children:DF.map(n=>(0,R.jsxs)(dC,{className:`justify-between`,onSelect:()=>t(kF(n.id).id),children:[(0,R.jsx)(`span`,{children:n.label}),n.id===e&&(0,R.jsx)(ae,{className:`size-3.5`})]},n.id))})]})}function jF({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`skeleton`,className:V(`animate-pulse rounded-md bg-muted`,e),...t})}function MF(e){let t=e.split(`/`).filter(Boolean);return t.length>0?t[t.length-1]:e}function NF(e){let t=MF(e.directory??e.canonical);return t&&t!==`/`?t:e.id}function PF({sessionID:e}){let t=J(t=>t.sessions.find(t=>t.id===e)),[n,r]=(0,E.useState)(null),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)([]),[c,l]=(0,E.useState)(!1),u=t?.location.directory??n?.directory;function d(){l(!0),Promise.all([G.locationInfo(),G.projectCurrent(),G.projectList()]).then(([e,t,n])=>{r(e),a(t),s(n)}).catch(()=>void 0).finally(()=>l(!1))}return(0,R.jsxs)(cC,{onOpenChange:e=>e&&d(),children:[(0,R.jsx)(lC,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,title:u,className:`max-w-44 text-xs text-muted-foreground`,children:[(0,R.jsx)(Ee,{}),(0,R.jsx)(`span`,{className:`truncate font-mono`,children:u||`workspace`})]})}),(0,R.jsxs)(uC,{align:`end`,className:`min-w-56`,children:[(0,R.jsx)(fC,{children:`Location`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 py-1 text-sm text-[var(--text-base)]`,children:[(0,R.jsx)(Ee,{className:`size-3.5 shrink-0 text-[var(--text-weak)]`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-xs`,children:n?.directory??u??`…`})]}),n?.workspaceID&&(0,R.jsx)(`div`,{className:`px-1.5 pb-1 font-mono text-[11px] text-[var(--text-weaker)]`,children:n.workspaceID}),(0,R.jsx)(pC,{}),(0,R.jsx)(fC,{children:`Project`}),c&&o.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-1.5 py-1`,children:[(0,R.jsx)(jF,{className:`h-6 w-full`}),(0,R.jsx)(jF,{className:`h-6 w-full`}),(0,R.jsx)(jF,{className:`h-6 w-3/4`})]}):o.length===0?(0,R.jsx)(`div`,{className:`px-1.5 py-1 text-xs text-[var(--text-weaker)]`,children:`No projects`}):o.map(e=>{let t=i?.id===e.id;return(0,R.jsxs)(dC,{className:`justify-between font-mono text-xs`,onSelect:e=>e.preventDefault(),children:[(0,R.jsx)(`span`,{className:`truncate`,children:NF(e)}),t&&(0,R.jsx)(ae,{className:`size-3.5 text-[var(--text-interactive-base)]`})]},e.id)})]})]})}function FF({sessionID:e,paneKey:t=`main`,focused:n=!0,onClose:r,onNavigate:i}){let a=e=>i?i(e):void Pv(e),o=J(t=>t.sessions.find(t=>t.id===e)??t.sessionDetails[e]),s=J(t=>t.messages[e]??[]),c=J(t=>t.live.filter(t=>t.sessionID===e)),l=J(t=>t.running[e]??!1),u=J(t=>!!t.queued[e]),d=J(e=>e.runsPanelOpen),f=J(e=>e.subagentComposerOpen),p=J(t=>n?Sg(t).some(t=>t.req.sessionID===e):!1),m=J(t=>jv(t,e)),h=(0,E.useMemo)(()=>Av(s,m),[s,m]);(0,E.useEffect)(()=>{Qg(e)},[e]);let g=J(e=>e.highlightMessageID),_=J(e=>e.highlightSessionID);return(0,E.useEffect)(()=>{if(!g||_!==e)return;let t=0,n=()=>{let e=document.getElementById(`msg-${g}`);return e?(e.scrollIntoView({behavior:`smooth`,block:`center`}),e.classList.add(`ring-2`,`ring-[var(--border-selected)]`,`rounded-md`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-[var(--border-selected)]`,`rounded-md`),2e3),!0):!1};if(n())return;let r=setInterval(()=>{t+=1,(n()||t>20)&&clearInterval(r)},150);return()=>clearInterval(r)},[e,g,_,h]),(0,R.jsxs)(`div`,{className:`pane-surface flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(GF,{title:o?.title,sessionID:e,running:l,queued:u,parentID:o?.parentID,go:a,onClose:r}),!Eg(e)&&(0,R.jsx)(CF,{sessionID:e,onNavigate:i}),(0,R.jsx)(Nt,{region:`transcript.above`,sessionID:e}),(0,R.jsx)(bx,{defaultScrollPosition:`end`,autoScroll:!0,children:(0,R.jsxs)(`div`,{className:`relative flex flex-1 flex-col overflow-hidden`,children:[(0,R.jsxs)(xx,{className:`flex-1`,children:[(0,R.jsx)(Sx,{children:(0,R.jsx)(HF,{sessionID:e,messages:h,live:c,running:l})}),(0,R.jsx)(Tx,{direction:`end`}),(0,R.jsx)(IF,{sessionID:e,messages:h})]}),(0,R.jsx)(qF,{messages:s})]})}),(0,R.jsx)(Nt,{region:`transcript.below`,sessionID:e}),(0,R.jsx)(SF,{sessionID:e}),(0,R.jsx)(lF,{sessionID:e}),n?p?(0,R.jsx)(tF,{sessionID:e}):d?(0,R.jsx)(fF,{sessionID:e,paneKey:t}):o?.parentID&&!f?(0,R.jsx)(LF,{sessionID:e,parentID:o.parentID,go:a}):(0,R.jsx)(Nt,{region:`composer.replace`,sessionID:e,fallback:(0,R.jsx)(NC,{sessionID:e,paneKey:t})}):(0,R.jsx)(Nt,{region:`composer.replace`,sessionID:e,fallback:(0,R.jsx)(NC,{sessionID:e,paneKey:t})})]})}function IF({sessionID:e,messages:t}){let{scrollToEnd:n}=fx(),r=(0,E.useRef)(null);return(0,E.useEffect)(()=>{let i=t[t.length-1],a=i?.id??null,o=r.current;r.current={sessionID:e,id:a},!(!o||o.sessionID!==e||o.id===a)&&i?.type===`user`&&n({behavior:`smooth`})},[e,t,n]),null}function LF({sessionID:e,parentID:t,go:n}){let r=J(e=>e.sessions),i=J(e=>e.running),a=J(e=>e.activeIDs),o=J(e=>e.sessions.find(e=>e.id===t)?.title??e.sessionDetails[t]?.title),s=e=>i[e]||a.includes(e),c=[...Ov(r,t)].sort((e,t)=>e.id<t.id?-1:1);return(0,R.jsx)(`div`,{className:`border-t border-[var(--border-base)] px-4 py-1.5`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-1`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-1 gap-y-0.5`,children:c.map(t=>(0,R.jsx)(RF,{id:t.id,label:t.title||t.agent||t.id,current:t.id===e,running:s(t.id),go:n},t.id))}),(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>Ev(),className:`cursor-pointer rounded-md border border-dashed border-[var(--border-weak-base)] px-1.5 py-0.5 font-mono transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,title:`Show the message composer`,children:`enter`}),(0,R.jsx)(`span`,{children:`to message this subagent`}),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(t),title:`Back to parent${o?`: ${o}`:``}`,className:`flex cursor-pointer items-center gap-1 rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(P,{className:`size-3`}),`back to parent`]}),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,R.jsx)(`span`,{className:`font-mono text-[10px]`,children:`←/→ switch`})]})]})})}function RF({id:e,label:t,current:n,running:r,go:i}){let a=(0,E.useRef)(null);return(0,E.useEffect)(()=>{n&&a.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[n]),(0,R.jsxs)(`button`,{ref:a,type:`button`,onClick:()=>i(e),title:n?`Currently open — ←/→ to switch`:t,className:`flex cursor-pointer items-center gap-1 rounded-full px-1.5 py-0.5 font-mono text-[11px] transition-colors ${n?`bg-[color:var(--surface-raised-base-active)] font-medium text-[color:var(--text-strong)]`:`text-[color:var(--text-weaker)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`}`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-emerald-500`:`bg-[color:var(--border-base)]`}`}),(0,R.jsx)(`span`,{className:`max-w-44 truncate`,children:t})]})}function zF(e,t){let n=[],r=e=>n.push(String(e));for(let t of e)if(r(t.id),t.type===`assistant`){r(t.content.length),r(t.finish??``);for(let e of t.content)e.type===`tool`?(r(`t${e.id}:${e.state.status}`),e.state.status===`streaming`?r(e.state.input.length):(r(BF(e.state.input)),`metadata`in e.state&&r(BF(e.state.metadata)),`content`in e.state&&e.state.content&&r(e.state.content.length),e.state.status===`error`&&r(BF(e.state.error)))):r(`${e.type}:${e.text.length}`)}else`text`in t&&typeof t.text==`string`?(r(t.text.length),`files`in t&&t.files&&r(t.files.length)):r(BF(t));for(let e of t){r(`live:${e.id}:${e.content.length}`),r(e.error?`${e.error.type}:${BF(e.error.message)}`:``);for(let t of e.content)t.type===`tool`?r(`t${t.tool.id}:${t.tool.status}:${+!!t.tool.executed}:${BF(t.tool.inputText)}:${BF(t.tool.metadata)}:${t.tool.content?.length??0}:${t.tool.error?BF(t.tool.error.message):0}`):r(`${t.type}:${t.ordinal}:${t.text.length}`)}return n.join(`|`)}function BF(e){if(e==null)return 0;if(typeof e==`string`)return e.length;try{return JSON.stringify(e)?.length??0}catch{return-1}}function VF(e,t){return e.sessionID===t.sessionID&&e.running===t.running&&zF(e.messages,e.live)===zF(t.messages,t.live)}var HF=E.memo(function({sessionID:e,messages:t,live:n,running:r}){return(0,R.jsxs)(Cx,{className:`mx-auto w-full max-w-3xl px-4 py-6`,children:[t.length===0&&n.length===0&&!r&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(wx,{children:(0,R.jsx)(UF,{})}),(0,R.jsx)(Nt,{region:`transcript.empty`,sessionID:e})]}),(()=>{let i=!1,a=[];for(let n of t){let t=n.type===`assistant`,r=t&&i;i=t,a.push((0,R.jsx)(wx,{messageId:n.id,id:`msg-${n.id}`,children:(0,R.jsx)(jP,{message:n,compact:r,sessionID:e})},n.id))}return n.length>0&&a.push((0,R.jsx)(wx,{children:(0,R.jsx)(KF,{assistants:n,running:r})},`live`)),a})()]})},VF);function UF(){return(0,R.jsx)(`div`,{className:`flex justify-center pt-16`,children:(0,R.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-1.5 rounded-lg border border-[var(--border-weak-base)] bg-[var(--background-weak)] px-8 py-10 text-center`,children:[(0,R.jsx)(`h1`,{className:`text-[var(--font-size-large)] font-medium text-[var(--text-base)]`,children:`Start a conversation`}),(0,R.jsx)(`p`,{className:`text-[var(--font-size-base)] text-[var(--text-weaker)]`,children:`The agent can read, edit, and run commands in the session workspace.`})]})})}function WF(e){return e.replace(/\/+$/,``).replace(/^\/(home|Users)\/[^/]+/,`~`)}function GF({title:e,sessionID:t,running:n,queued:r,parentID:i,go:a,onClose:o}){let s=J(e=>e.sessionDetails[i??``]?.title),c=Eg(t),l=J(e=>e.draftWorkspace);return(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--border-base)] px-4 py-2.5`,children:[(0,R.jsx)(Nt,{region:`header.session.before`,sessionID:t}),(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>a(i),title:`Back to parent session${s?`: ${s}`:``}`,className:`cursor-pointer rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-xs text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:`↑ Parent`}),(0,R.jsx)(`button`,{type:`button`,className:`mr-1 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)] lg:hidden`,onClick:()=>o?o():a(null),children:`←`}),(0,R.jsx)(`span`,{className:`truncate text-[var(--font-size-base)] font-medium text-[var(--text-strong)]`,children:c?`New session`:e??`Untitled session`}),c?(0,R.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-[var(--text-weaker)] sm:inline`,children:l?WF(l):`default workspace`}):(0,R.jsx)(`span`,{className:`hidden font-mono text-xs text-[var(--text-weaker)] sm:inline`,children:t.slice(0,12)}),r&&!n&&(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-warning-weak)] text-[var(--surface-warning-strong)]`,title:`Message sent — waiting for the agent to start responding`,children:`waiting`}),n&&(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-interactive-weak)] text-[var(--text-interactive-base)]`,children:`working`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Nt,{region:`header.session.actions`,sessionID:t}),o&&(0,R.jsx)(`button`,{type:`button`,onClick:o,title:`Close split`,className:`flex size-6 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:(0,R.jsx)(at,{className:`size-3.5`})}),(0,R.jsx)(PF,{sessionID:t}),(0,R.jsx)(AF,{}),(0,R.jsx)(mC,{sessionID:t})]})]})}function KF({assistants:e,running:t}){let n=e.flatMap(e=>e.content.map(t=>({key:JF(e.id,t),part:t}))),r=e.filter(e=>e.error).map(e=>({id:e.id,error:e.error}));return n.length===0&&!t&&r.length===0?null:(0,R.jsxs)(`div`,{children:[r.map(({id:e,error:t})=>(0,R.jsxs)(`div`,{className:`mb-2 rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_40%,transparent)] bg-[var(--surface-critical-weak)] px-3 py-2 text-xs text-[var(--text-on-critical-strong)]`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t.type}),(0,R.jsx)(`div`,{className:`mt-0.5`,children:t.message})]},e)),n.length===0&&t&&r.length===0&&(0,R.jsx)(`div`,{className:`flex items-center gap-2 py-1 text-[var(--font-size-base)] text-[var(--text-weak)] animate-pulse`,children:`thinking…`}),n.map(({key:e,part:t})=>(0,R.jsx)(GP,{stateKey:e,part:t.type===`tool`?A_(t.tool):t},e))]})}function qF({messages:e}){let t=(0,E.useMemo)(()=>e.filter(e=>e.type===`user`),[e]),[n,r]=(0,E.useState)(null);if((0,E.useEffect)(()=>{if(t.length===0)return;let e=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>t.intersectionRatio-e.intersectionRatio);if(t[0]?.target){let e=t[0].target.id.replace(/^msg-/,``);r(e)}},{root:null,rootMargin:`-30% 0px -60% 0px`,threshold:[0,.25,.5,1]}),n=[];for(let r of t){let t=document.getElementById(`msg-${r.id}`);t&&(e.observe(t),n.push(t))}return()=>{for(let t of n)e.unobserve(t);e.disconnect()}},[t]),t.length<3)return null;let i=e=>{let t=document.getElementById(`msg-${e}`);if(t)t.scrollIntoView({behavior:`smooth`,block:`start`});else try{let t=`[data-message-id="${CSS.escape(e)}"]`;document.querySelector(t)?.scrollIntoView({behavior:`smooth`,block:`start`})}catch{}};return(0,R.jsx)(`div`,{className:`pointer-events-none absolute top-1/2 right-3 hidden -translate-y-1/2 flex-col items-center justify-center md:flex`,style:{maxHeight:`min(70vh, 560px)`},children:(0,R.jsxs)(`div`,{className:`pointer-events-auto flex flex-col items-center gap-2 rounded-full border border-[var(--border-weak-base)] bg-[var(--background-base)]/95 px-2 py-3 shadow-md backdrop-blur`,children:[(0,R.jsx)(`div`,{className:`absolute inset-y-3 w-px bg-[var(--border-weak-base)]`}),t.map(e=>{let t=(e.text??``).replace(/\s+/g,` `).slice(0,400)||e.id.slice(0,8),r=e.id===n;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:t,className:`group relative flex size-4 items-center justify-center`,children:[(0,R.jsx)(`span`,{className:`rounded-full ring-1 transition-all ${r?`size-3 bg-[var(--surface-brand-base)] ring-[var(--surface-brand-base)] shadow-sm`:`size-2 bg-[var(--text-weaker)] ring-[var(--border-weak-base)] group-hover:size-2.5 group-hover:bg-[var(--text-strong)]`}`}),(0,R.jsx)(`span`,{className:`pointer-events-none absolute right-full mr-4 hidden max-w-[560px] whitespace-pre-wrap rounded-xl border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] px-4 py-3 text-sm leading-relaxed text-[var(--text-weak)] shadow-xl group-hover:block`,children:t})]},e.id)})]})})}function JF(e,t){return t.type===`tool`?`${e}:tool:${t.tool.id}`:`${e}:${t.type}:${t.ordinal}`}var YF=[[`Enter`,`Send · queue while the agent works`],[`Esc`,`Interrupt the running agent`],[`Tab / Shift+Tab`,`Next / previous agent`],[`↑ / ↓ (input at start/end)`,`Prompt history`],[`↓ (outside input)`,`Subagents & shells dialog`],[`← / → (outside input)`,`Cycle subagent sessions`],[`↑ (outside input)`,`Parent session`],[`Ctrl+B`,`Background synchronous subagents`],[`Ctrl+P`,`Command palette`],[`Ctrl+N`,`New session`],[`⌘F / Ctrl+F`,`Search sessions`],[`/`,`Slash commands & skills`],[`@`,`Reference files`],[`!`,`Shell mode`]];function XF(){let e=J(e=>e.uiSignals.help),[t,n]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{e&&n(!0)},[e]),(0,R.jsx)(Km,{open:t,onOpenChange:n,children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/40`}),(0,R.jsxs)(fs,{className:`fixed top-1/2 left-1/2 z-50 max-h-[80vh] w-[min(24rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 shadow-xl outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95`,children:[(0,R.jsx)(eh,{className:`mb-3 text-sm font-medium text-[var(--text-strong)]`,children:`Keybinds`}),(0,R.jsx)(`dl`,{className:`space-y-1.5 text-xs`,children:YF.map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`dt`,{className:`shrink-0 rounded border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--text-base)]`,children:e}),(0,R.jsx)(`dd`,{className:`text-right text-[var(--text-weak)]`,children:t})]},e))})]})]})})}var ZF=300,QF=4,$F=40,eI=new Map;function tI(e){switch(e.type){case`user`:case`system`:case`synthetic`:case`skill`:return e.text??``;case`shell`:return e.command??``;case`compaction`:return e.summary??``;case`assistant`:{let t=``;for(let n of e.content??[])n?.type===`text`&&(t+=n.text+`
102
- `);return t}default:return``}}function nI(e,t,n){let r=e.toLowerCase().indexOf(t);if(r===-1)return null;let i=Math.max(0,r-$F),a=Math.min(e.length,r+n+$F),o=e.slice(i,a).replace(/\s+/g,` `),s=o.toLowerCase().indexOf(t),c=s===-1?r-i:s,l=c+n;c<0&&(c=0),l>o.length&&(l=o.length);let u=i>0?`… `:``,d=a<e.length?` …`:``;return u&&(o=u+o,c+=u.length,l+=u.length),d&&(o+=d),{snippet:o,matchStart:c,matchEnd:l}}async function rI(e){try{let t=(await G.messages(e,100)).data.map(e=>{let t=tI(e);return t?{id:e.id,text:t,lower:t.toLowerCase()}:null}).filter(e=>!!e),n=t.map(e=>e.lower).join(`
103
- `);eI.set(e,{messages:t,combinedLower:n})}catch{eI.set(e,{messages:[],combinedLower:``})}}function iI(e){let t=new Map,n=e.length;for(let[r,i]of eI){if(!i.combinedLower.includes(e))continue;let a=[];for(let t of i.messages){if(!t.lower.includes(e))continue;let r=nI(t.text,e,n);r&&a.push({messageID:t.id,snippet:r.snippet,matchStart:r.matchStart,matchEnd:r.matchEnd})}a.length>0&&t.set(r,a)}return t}function aI(e,t,n){let r=e.trim().toLowerCase();if(!r)return Promise.resolve(new Map);let i=[...t].sort((e,t)=>t.time.updated-e.time.updated).slice(0,ZF).map(e=>e.id).filter(e=>!eI.has(e));return(async()=>{for(let e=0;e<i.length;e+=QF){let t=i.slice(e,e+QF);await Promise.all(t.map(rI)),n?.(iI(r))}return iI(r)})()}var oI=/mac|iphone|ipad|ipod/i.test(typeof navigator>`u`?``:navigator.userAgent),sI=oI?`⌘F`:`Ctrl F`;function cI({...e}){return(0,R.jsx)(es,{"data-slot":`sheet`,...e})}function lI({...e}){return(0,R.jsx)(os,{"data-slot":`sheet-portal`,...e})}function uI({className:e,...t}){return(0,R.jsx)(cs,{"data-slot":`sheet-overlay`,className:V(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function dI({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,R.jsxs)(lI,{children:[(0,R.jsx)(uI,{}),(0,R.jsxs)(fs,{"data-slot":`sheet-content`,"data-side":n,className:V(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,R.jsx)(xs,{"data-slot":`sheet-close`,asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function fI({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sheet-header`,className:V(`flex flex-col gap-0.5 p-4`,e),...t})}function pI({className:e,...t}){return(0,R.jsx)(_s,{"data-slot":`sheet-title`,className:V(`font-heading text-base font-medium text-foreground`,e),...t})}function mI({className:e,...t}){return(0,R.jsx)(ys,{"data-slot":`sheet-description`,className:V(`text-sm text-muted-foreground`,e),...t})}var hI=e=>e.replace(/\/+$/,``),gI=e=>hI(e).split(`/`).filter(Boolean).pop()??e,_I=e=>e instanceof Error?e.message:String(e);function vI(e,t){let n=hI(e.replace(/^\.\//,``)),r=hI(t.replace(/^\.\//,``));return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function yI(e){return[...e].sort((e,t)=>e.type===t.type?hI(e.path).localeCompare(hI(t.path)):e.type===`directory`?-1:1)}function bI(e){let t=e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,n=`size-3.5 shrink-0 text-[var(--text-weaker)]`;return[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`ico`,`avif`].includes(t)?(0,R.jsx)(be,{className:n}):[`json`,`jsonc`,`yaml`,`yml`,`toml`].includes(t)?(0,R.jsx)(_e,{className:n}):[`zip`,`tar`,`gz`,`tgz`,`bz2`,`xz`,`7z`].includes(t)?(0,R.jsx)(ge,{className:n}):[`txt`,`log`,`csv`,`tsv`,`ini`,`env`,`conf`,`lock`,`gitignore`].includes(t)?(0,R.jsx)(Se,{className:n}):`ts.tsx.js.jsx.mjs.cjs.go.rs.py.rb.java.c.h.hpp.cc.cpp.css.scss.html.vue.svelte.sh.bash.zsh.sql.graphql.gql.md.mdx.zig`.split(`.`).includes(t)?(0,R.jsx)(ye,{className:n}):(0,R.jsx)(Ce,{className:n})}function xI({entry:e,depth:t,nodes:n,selectedPath:r,onToggle:i,onOpen:a}){let o=e.type===`directory`,s=hI(e.path),c=n[s],l=gI(e.path),u=r===s,d=6+t*13,f=()=>o?i(e):a(e);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:f,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},className:V(`flex cursor-pointer items-center gap-1 rounded-sm py-[3px] pr-2`,u?`bg-[var(--surface-raised-base)] text-[var(--text-strong)]`:`text-[var(--text-base)] hover:bg-[var(--surface-base-hover)]`),style:{paddingLeft:d},children:[o?(0,R.jsx)(L,{className:V(`size-3 shrink-0 text-[var(--text-weaker)] transition-transform`,c?.expanded&&`rotate-90`)}):(0,R.jsx)(`span`,{className:`w-3 shrink-0`}),o?(0,R.jsx)(Ee,{className:V(`size-3.5 shrink-0`,c?.expanded?`text-[var(--text-interactive-base)]`:`text-[var(--text-weak)]`)}):bI(l),(0,R.jsx)(`span`,{className:V(`truncate font-mono text-xs`,o?`text-[var(--text-strong)]`:`text-[var(--text-base)]`),children:l}),c?.loading&&(0,R.jsx)(Me,{className:`ml-auto size-3 shrink-0 animate-spin text-[var(--text-weaker)]`}),c?.error&&(0,R.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-[var(--text-on-critical-base)]`,children:`!`})]}),o&&c?.expanded&&(0,R.jsx)(`div`,{children:c.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 py-1`,style:{paddingLeft:d+13},children:[(0,R.jsx)(jF,{className:`h-3 w-3/4`}),(0,R.jsx)(jF,{className:`h-3 w-1/2`})]}):c.error?(0,R.jsx)(`div`,{className:`py-1 text-[11px] text-[var(--text-on-critical-base)]`,style:{paddingLeft:d+13},children:c.error}):c.children&&c.children.length===0?(0,R.jsx)(`div`,{className:`py-0.5 text-[11px] italic text-[var(--text-weaker)]`,style:{paddingLeft:d+13},children:`empty`}):c.children?.map(e=>(0,R.jsx)(xI,{entry:e,depth:t+1,nodes:n,selectedPath:r,onToggle:i,onOpen:a},hI(e.path)))})]})}function SI({count:e,error:t}){return t?(0,R.jsx)(Dx,{variant:`outline`,title:t,className:`border-border/50 text-[var(--text-weaker)]`,children:`vcs n/a`}):e===null?null:e===0?(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-success-base)] text-[var(--text-on-success-base)]`,children:`clean`}):(0,R.jsxs)(Dx,{className:`border-transparent bg-[var(--surface-critical-base)] text-[var(--text-on-critical-base)]`,children:[e,` changed`]})}function CI({open:e,onOpenChange:t}){let n=J(e=>e.sessions.find(t=>t.id===e.currentSessionID)?.location?.directory),[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(null),[l,u]=(0,E.useState)({}),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)({loading:!1}),[h,g]=(0,E.useState)({loading:!1}),[_,v]=(0,E.useState)(null),[y,b]=(0,E.useState)(null),x=(0,E.useRef)(null),S=(0,E.useRef)(null);(0,E.useEffect)(()=>{if(!e)return;let t=!1,r=e=>{t||(S.current!==e&&(S.current=e,o(null),c(null),u({}),v(null),b(null),f(null),x.current=null),i(e),G.fsList({location:e}).then(e=>{t||(o(e.data),c(null))}).catch(e=>{t||c(_I(e))}),G.vcsStatus({directory:e}).then(e=>{t||v(e.data.length)}).catch(e=>{t||b(_I(e))}))};return n?r(n):G.location().then(e=>{t||r(e.directory)}).catch(e=>{t||c(_I(e))}),()=>{t=!0}},[e,n]),(0,E.useEffect)(()=>{e||(f(null),x.current=null,m({loading:!1}),g({loading:!1}))},[e]);let C=e=>{let t=hI(e.path),n=l[t];if(n?.expanded){u(e=>{let n={...e};return delete n[t],n});return}u(e=>({...e,[t]:{expanded:!0,loading:!e[t]?.children,children:e[t]?.children}})),n?.children||G.fsList({location:r??void 0,path:t}).then(e=>u(n=>n[t]?{...n,[t]:{...n[t],children:e.data,loading:!1}}:n)).catch(e=>u(n=>n[t]?{...n,[t]:{...n[t],error:_I(e),loading:!1}}:n))},w=e=>{x.current=e,f(e),m({loading:!0}),g({loading:!0}),G.fsRead(e.path,r??void 0).then(t=>{x.current?.path===e.path&&m({content:t,loading:!1})}).catch(t=>{x.current?.path===e.path&&m({error:_I(t),loading:!1})}),G.vcsDiff(`working`,r?{directory:r}:void 0,3).then(t=>{if(x.current?.path!==e.path)return;let n=t.data.find(t=>vI(t.file,e.path));g({patch:n?.patch,loading:!1})}).catch(t=>{x.current?.path===e.path&&g({error:_I(t),loading:!1})})};return(0,R.jsx)(cI,{open:e,onOpenChange:t,children:(0,R.jsxs)(dI,{side:`left`,className:`w-[min(44rem,calc(100vw-0.5rem))]! gap-0 p-0 sm:max-w-[44rem]!`,children:[(0,R.jsxs)(fI,{className:`border-b border-border px-4 py-3 pr-12`,children:[(0,R.jsxs)(pI,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(Te,{className:`size-4 text-[var(--text-weak)]`}),`Files`,(0,R.jsx)(SI,{count:_,error:y})]}),r&&(0,R.jsx)(mI,{className:`truncate font-mono text-[11px] text-[var(--text-weaker)]`,children:r})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex w-[40%] min-w-56 shrink-0 flex-col border-r border-border`,children:(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(`div`,{className:`p-1.5`,children:s?(0,R.jsx)(`div`,{className:`px-2 py-3 text-xs text-[var(--text-on-critical-base)]`,children:s}):a===null?(0,R.jsx)(`div`,{className:`space-y-1.5 p-1`,children:[0,1,2,3,4].map(e=>(0,R.jsx)(jF,{className:`h-4 w-full`},e))}):a.length===0?(0,R.jsx)(`div`,{className:`px-2 py-3 text-xs text-[var(--text-weak)]`,children:`Empty directory`}):yI(a).map(e=>(0,R.jsx)(xI,{entry:e,depth:0,nodes:l,selectedPath:d?hI(d.path):null,onToggle:C,onOpen:w},hI(e.path)))})})}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:d?(0,R.jsxs)(Xx,{defaultValue:`preview`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-weak)]`,children:d.path}),(0,R.jsxs)(Qx,{variant:`line`,className:`h-6 shrink-0`,children:[(0,R.jsx)($x,{value:`preview`,className:`text-xs`,children:`Preview`}),(0,R.jsx)($x,{value:`diff`,className:`text-xs`,children:`Diff`})]})]}),(0,R.jsx)(eS,{value:`preview`,className:`flex min-h-0 flex-1 flex-col`,children:p.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,R.jsx)(jF,{className:`h-3 w-3/4`}),(0,R.jsx)(jF,{className:`h-3 w-2/3`}),(0,R.jsx)(jF,{className:`h-3 w-5/6`}),(0,R.jsx)(jF,{className:`h-3 w-1/2`})]}):p.error?(0,R.jsx)(`div`,{className:`p-4 text-xs text-[var(--text-on-critical-base)]`,children:p.error}):(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(`pre`,{className:`p-3 font-mono text-xs leading-[1.6] whitespace-pre text-[var(--text-base)]`,children:p.content??``})})}),(0,R.jsx)(eS,{value:`diff`,className:`flex min-h-0 flex-1 flex-col`,children:h.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,R.jsx)(jF,{className:`h-3 w-11/12`}),(0,R.jsx)(jF,{className:`h-3 w-3/4`}),(0,R.jsx)(jF,{className:`h-3 w-2/3`}),(0,R.jsx)(jF,{className:`h-3 w-5/6`})]}):h.error?(0,R.jsxs)(`div`,{className:`p-4 text-xs text-[var(--text-on-critical-base)]`,children:[`Diff unavailable: `,h.error]}):h.patch?(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(jN,{diff:h.patch,className:`p-3`})}):(0,R.jsx)(`div`,{className:`p-4 text-xs text-[var(--text-weak)]`,children:`No uncommitted changes for this file.`})})]}):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-xs text-[var(--text-weak)]`,children:`Select a file to preview`})})]})]})})}var wI=3,TI=20,EI=2,DI=`webui:navigate`,OI=288,kI=240,AI=480,jI=56,MI=0,NI=new Set,PI=!1;function FI(){PI||(PI=!0,pt(()=>{MI++;for(let e of NI)e()}))}function II(e){return FI(),NI.add(e),()=>NI.delete(e)}function LI(){return MI}function RI(){return 0}function zI(){return(0,E.useSyncExternalStore)(II,LI,RI)}function BI({sessionID:e,children:t}){let n=zI(),r=(0,E.useMemo)(()=>Ot(`session`),[n]);return r.length===0?(0,R.jsx)(R.Fragment,{children:t}):(0,R.jsxs)(pP,{children:[(0,R.jsx)(mP,{asChild:!0,children:t}),(0,R.jsx)(hP,{className:`min-w-36`,children:r.map(t=>(0,R.jsx)(gP,{onSelect:()=>{try{t.run({sessionID:e})}catch(e){console.error(`[extensions] contextMenu "${t.id}" crashed:`,e)}},children:t.label},t.id))})]})}function VI(e){return/^\/home\/[^/]+$/.test(e)||/^\/Users\/[^/]+$/.test(e)}function HI(e){let t=new Map;for(let n of e){if(!n)continue;let e=n.replace(/\/+$/,``);VI(e)&&t.set(e,(t.get(e)??0)+1)}let n,r=0;for(let[e,i]of t)i>r&&(n=e,r=i);return n}function UI(e,t){if(!e)return`Other`;let n=e.replace(/\/+$/,``);return t&&VI(t)&&n===t?`~`:t&&VI(t)&&n.startsWith(t+`/`)?`~/`+n.slice(t.length+1):n}function WI(e,t){return!!e&&!!t&&e.replace(/\/+$/,``)===t.replace(/\/+$/,``)}function GI(){let e=J(e=>e.sessions),t=J(e=>e.sessionsCursor),n=J(e=>e.activeIDs),r=J(e=>e.currentSessionID),i=J(e=>e.connected),a=J(e=>e.pendingWorkspace),o=J(e=>e.running),s=J(e=>e.queued),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)([]),[f,p]=(0,E.useState)(new Map),[m,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(new Set),v=(0,E.useRef)(null),[y,b]=(0,E.useState)({}),[x,S]=(0,E.useState)({}),[C,w]=(0,E.useState)(!1),[T,D]=(0,E.useState)(OI),[O,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(!1),M=J(e=>e.uiSignals.explorer);(0,E.useEffect)(()=>{M&&j(!0)},[M]);let N=(0,E.useMemo)(()=>HI(e.map(e=>e.location?.directory)),[e]),ee=e=>!!o[e]||!!s[e],te=(0,E.useMemo)(()=>{let t=new Set;for(let n of e)n.parentID&&ee(n.id)&&t.add(n.parentID);return t},[e,o,s]),P=c.trim(),F=P.toLowerCase();(0,E.useEffect)(()=>{if(P.length<2){d([]);return}let e=!1,t=setTimeout(()=>{G.listSessions({search:P,limit:100}).then(t=>{e||d(t.data.filter(e=>!e.parentID))}).catch(()=>{e||d([])})},250);return()=>{e=!0,clearTimeout(t)}},[P]),(0,E.useEffect)(()=>{if(P.length<2){p(new Map),h(!1);return}let t=!1;h(!0);let n=setTimeout(()=>{aI(P,e,e=>{t||p(new Map(e))}).catch(()=>new Map).then(e=>{t||(p(new Map(e)),h(!1))})},250);return()=>{t=!0,clearTimeout(n)}},[P,e]),(0,E.useEffect)(()=>{if(!a)return;let e=e=>{v.current&&!v.current.contains(e.target)&&Gy(null)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[a]);let ne=(0,E.useMemo)(()=>{let t=new Map,r=new Set;for(let n of e){if(n.parentID||F&&!(n.title??`Untitled session`).toLowerCase().includes(F)&&!UI(n.location?.directory,N).toLowerCase().includes(F)&&!(n.location?.directory??``).toLowerCase().includes(F))continue;r.add(n.id);let e=UI(n.location?.directory,N),i=t.get(e)??[];i.push(n),t.set(e,i)}for(let e of u){if(r.has(e.id))continue;r.add(e.id);let n=UI(e.location?.directory,N),i=t.get(n)??[];i.push(e),t.set(n,i)}let i=e=>!!(o[e]||n.includes(e)),a=[...t.entries()].map(([e,t])=>({name:e,list:[...t].sort((e,t)=>{let n=i(e.id),r=i(t.id);return n===r?t.time.updated-e.time.updated:Number(r)-Number(n)})}));return a.sort((e,n)=>{let r=t.get(e.name)?.some(e=>i(e.id))??!1,a=t.get(n.name)?.some(e=>i(e.id))??!1;return r===a?0:Number(a)-Number(r)}),a},[e,u,F,N,o,n]),re=(0,E.useMemo)(()=>{if(!F||f.size===0)return[];let t=new Set(ne.flatMap(e=>e.list.map(e=>e.id))),n=new Map(e.map(e=>[e.id,e])),r=[];for(let e of f.keys()){if(t.has(e))continue;let i=n.get(e);i&&r.push(i)}return r.sort((e,t)=>t.time.updated-e.time.updated).slice(0,TI)},[e,ne,f,F]),ie=ne.reduce((e,t)=>e+t.list.length,0)+re.length,ae=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},L=(e,t)=>{Ky(e,t),Pv(e)},oe=t!=null,se=e=>{let t=!x[e];S(n=>({...n,[e]:t})),t&&b(t=>({...t,[e]:!1}))},ce=e=>{let t=e??null;Gy(t),r===`__draft__`&&Wy(t)},le=e=>b(t=>({...t,[e]:!t[e]})),ue=e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),k(!0))},de=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&D(Math.min(AI,Math.max(kI,e.clientX)))},fe=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),k(!1)},pe=()=>w(e=>!e);return(0,R.jsxs)(`aside`,{ref:v,className:`relative flex min-w-0 shrink-0 flex-col overflow-hidden border-r border-border bg-background ${O?`select-none`:``}`,style:{width:C?jI:T},children:[(0,R.jsxs)(`div`,{className:`border-b border-border ${C?`flex flex-col items-center gap-2 px-2 py-2.5`:`flex items-center justify-between gap-2 px-3 py-2.5`}`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${i?`bg-[var(--surface-success-strong)]`:`bg-[var(--surface-warning-strong)]`}`}),C?(0,R.jsx)(`span`,{className:`font-mono text-xs font-semibold text-foreground`,title:`OpenCode`,children:`OC`}):(0,R.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:`OpenCode`})]}),C?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(KI,{collapsed:!0}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,onClick:pe,title:`Expand sidebar`,children:(0,R.jsx)(Ie,{})})]}):(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(U,{variant:`ghost`,size:`icon`,onClick:pe,title:`Collapse sidebar`,children:(0,R.jsx)(Fe,{})}),(0,R.jsx)(KI,{})]})]}),C?(0,R.jsx)(qI,{groups:ne,current:r,activeIDs:n,onExpand:pe}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`border-b border-border p-2`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(qe,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(nh,{id:`session-search`,value:c,onChange:e=>l(e.target.value),placeholder:`Search sessions`,className:`h-7 pl-7 ${oI?`pr-8`:`pr-12`}`}),(0,R.jsx)(`kbd`,{"aria-hidden":!0,title:`Focus session search (${oI?`Cmd+F`:`Ctrl+F`})`,className:`pointer-events-none absolute top-1/2 right-1.5 -translate-y-1/2 rounded border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-1 py-px font-mono text-[9px] leading-[1.4] text-[var(--text-weaker)]`,children:sI})]}),P.length>=EI&&(0,R.jsxs)(`p`,{className:`mt-1 px-1 text-[10px] text-[var(--text-weaker)]`,"aria-live":`polite`,children:[ie,` matched`,m?` · searching messages…`:``]})]}),(0,R.jsx)(qx,{className:`min-h-0 min-w-0 flex-1`,children:(0,R.jsxs)(`div`,{className:`w-full min-w-0 max-w-full p-2`,children:[re.length>0&&(0,R.jsxs)(`section`,{className:`mb-4 w-full min-w-0 max-w-full last:mb-1`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex min-w-0 items-center gap-2 border-b border-[var(--border-weak-base)] px-2 py-1.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-medium tracking-wide text-[var(--text-weaker)] uppercase`,children:`Content matches`}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:re.length})]}),re.map(e=>{let t=f.get(e.id)??[],i=g.has(e.id);return(0,R.jsxs)(`div`,{className:`mb-1`,children:[(0,R.jsx)($I,{id:e.id,title:e.title??`Untitled session`,updated:e.time.updated,active:n.includes(e.id),selected:e.id===r,subagentsActive:te.has(e.id),onSelect:()=>void Pv(e.id)}),t.length>0&&(0,R.jsxs)(`div`,{className:`ml-2 border-l border-[var(--border-weak-base)] pl-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`mb-1 flex w-full cursor-pointer items-center gap-1 text-[10px] text-[var(--text-weaker)] hover:text-[var(--text-weak)]`,children:[(0,R.jsx)(I,{className:`size-3 shrink-0 transition-transform ${i?`-rotate-90`:``}`}),t.length,` `,t.length===1?`message`:`messages`,` match`,t.length===1?``:`es`]}),!i&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1`,children:[t.slice(0,5).map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>L(e.id,t.messageID),className:`cursor-pointer rounded-md bg-[var(--surface-inset-base)] px-2 py-1 text-left text-xs leading-relaxed text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,title:`Open session and scroll to message`,children:(0,R.jsxs)(`span`,{className:`line-clamp-2`,children:[t.snippet.slice(0,t.matchStart),(0,R.jsx)(`mark`,{className:`rounded-sm bg-yellow-500/30 px-0.5 font-medium text-[var(--text-strong)]`,children:t.snippet.slice(t.matchStart,t.matchEnd)}),t.snippet.slice(t.matchEnd)]})},t.messageID)),t.length>5&&(0,R.jsxs)(`span`,{className:`px-2 text-[10px] text-[var(--text-weaker)]`,children:[`+`,t.length-5,` more in this session`]})]})]})]},e.id)})]}),ne.length===0&&re.length===0&&(0,R.jsx)(`p`,{className:`px-2.5 py-4 text-xs text-[var(--text-weak)]`,children:e.length===0?`No sessions yet.`:`No matches.`}),ne.map(e=>{let t=!!x[e.name],i=!!y[e.name],o=t?[]:i?e.list:e.list.filter((e,t)=>t<wI||ee(e.id)),s=e.list.length-o.length,c=e.list.find(e=>e.location?.directory)?.location?.directory??null,l=!!a&&!!c&&WI(a,c);return(0,R.jsxs)(`section`,{className:`mb-4 w-full min-w-0 max-w-full last:mb-1`,children:[(0,R.jsxs)(`div`,{onClick:()=>l?se(e.name):ce(c??void 0),"aria-pressed":l,title:l?`Collapse / expand workspace`:`New session here`,className:`mb-1 flex min-w-0 cursor-pointer select-none items-center gap-2 border-b px-2 py-1.5 text-[11px] font-medium uppercase tracking-wide transition-colors ${l?`ring-1 ring-inset ring-[var(--border-selected)] bg-[var(--surface-raised-base)]`:``} ${l?``:`border-[var(--border-weak-base)]`}`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate ${l?`text-[var(--text-weak)]`:`text-[var(--text-weaker)]`}`,children:e.name}),(0,R.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand ${e.name}`:`Collapse ${e.name}`,onClick:t=>{t.stopPropagation(),se(e.name)},title:t?`Expand workspace`:`Collapse workspace`,className:`ml-auto inline-flex shrink-0 cursor-pointer items-center justify-center rounded-sm p-0.5 hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:(0,R.jsx)(I,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${t?`-rotate-90`:``}`})}),l&&(0,R.jsx)(`span`,{className:`shrink-0 cursor-pointer text-[var(--text-weaker)] hover:text-foreground`,title:`New session here`,onClick:e=>{e.stopPropagation(),Wy(c)},children:(0,R.jsx)(He,{className:`size-3.5`})}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:e.list.length})]}),o.map(e=>{let t=n.includes(e.id),i=f.get(e.id)??[],a=g.has(e.id),o=i.length>0&&P.length>=EI;return(0,R.jsxs)(`div`,{className:`mb-0.5`,children:[(0,R.jsx)($I,{id:e.id,title:e.title??`Untitled session`,updated:e.time.updated,active:t,selected:e.id===r,subagentsActive:te.has(e.id),onSelect:()=>void Pv(e.id)}),o&&(0,R.jsxs)(`div`,{className:`ml-2 border-l border-[var(--border-weak-base)] pl-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`mb-1 flex w-full cursor-pointer items-center gap-1 text-[10px] text-[var(--text-weaker)] hover:text-[var(--text-weak)]`,children:[(0,R.jsx)(I,{className:`size-3 shrink-0 transition-transform ${a?`-rotate-90`:``}`}),i.length,` `,i.length===1?`message`:`messages`,` match`,i.length===1?``:`es`]}),!a&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1`,children:[i.slice(0,5).map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>L(e.id,t.messageID),className:`cursor-pointer rounded-md bg-[var(--surface-inset-base)] px-2 py-1 text-left text-xs leading-relaxed text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,title:`Open session and scroll to message`,children:(0,R.jsxs)(`span`,{className:`line-clamp-2`,children:[t.snippet.slice(0,t.matchStart),(0,R.jsx)(`mark`,{className:`rounded-sm bg-yellow-500/30 px-0.5 font-medium text-[var(--text-strong)]`,children:t.snippet.slice(t.matchStart,t.matchEnd)}),t.snippet.slice(t.matchEnd)]})},t.messageID)),i.length>5&&(0,R.jsxs)(`span`,{className:`px-2 text-[10px] text-[var(--text-weaker)]`,children:[`+`,i.length-5,` more in this session`]})]})]})]},e.id)}),!t&&s>0&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>le(e.name),className:`mt-1 w-full cursor-pointer rounded-md px-2.5 py-1.5 text-left text-xs text-[var(--text-weaker)] transition-colors hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:i?`Show less`:`Show ${s} more…`})]},e.name)}),oe&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>void Xg(),className:`w-full cursor-pointer rounded-md px-2.5 py-2 text-center text-xs text-[var(--text-weaker)] transition-colors hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:`Load more sessions`})]})}),(0,R.jsx)(JI,{onFiles:()=>j(!0)})]}),C&&(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-1 border-t border-border p-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>j(!0),className:`inline-flex cursor-pointer rounded-md p-1.5 text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,title:`Files`,children:(0,R.jsx)(Te,{className:`size-4`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>VS(),className:`inline-flex cursor-pointer rounded-md p-1.5 text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,title:`Settings`,children:(0,R.jsx)(Xe,{className:`size-4`})})]}),(0,R.jsx)(Nt,{region:`sidebar`}),(0,R.jsx)(CI,{open:A,onOpenChange:j}),(0,R.jsx)(WS,{}),!C&&(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuemin":kI,"aria-valuemax":AI,"aria-valuenow":T,tabIndex:0,onPointerDown:ue,onPointerMove:de,onPointerUp:fe,onPointerCancel:fe,onDoubleClick:()=>D(OI),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.key===`ArrowRight`?16:-16;D(e=>Math.min(AI,Math.max(kI,e+t)))},className:`absolute top-0 right-0 z-20 h-full w-1 cursor-col-resize touch-none bg-transparent transition-colors hover:bg-[var(--border-hover)] focus:bg-[var(--border-selected)] focus:outline-none`})]})}function KI({collapsed:e=!1}){return(0,R.jsx)(U,{asChild:!0,variant:`default`,size:e?`icon`:`sm`,children:(0,R.jsxs)(`a`,{href:Pg,"aria-label":`New session`,title:e?`New session`:void 0,onClick:e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),Wy(null))},children:[(0,R.jsx)(He,{}),!e&&(0,R.jsx)(`span`,{className:`truncate`,children:`New session`})]})})}function qI({groups:e,current:t,activeIDs:n,onExpand:r}){return(0,R.jsx)(qx,{className:`min-h-0 min-w-0 flex-1`,children:(0,R.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center gap-3 p-2`,children:e.map(e=>(0,R.jsxs)(`section`,{className:`flex w-full flex-col items-center gap-1.5 border-b border-[var(--border-weak-base)] pb-3 last:border-b-0`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:r,title:`${e.name} (${e.list.length} sessions)`,className:`inline-flex size-8 cursor-pointer items-center justify-center rounded-md text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,children:(0,R.jsx)(Te,{className:`size-4`})}),e.list.slice(0,wI).map(e=>(0,R.jsx)(ZI,{id:e.id,title:e.title??`Untitled session`,selected:e.id===t,active:n.includes(e.id),onSelect:()=>void Pv(e.id)},e.id)),e.list.length>wI&&(0,R.jsxs)(`button`,{type:`button`,onClick:r,title:`Open workspace to see ${e.list.length-wI} more sessions`,className:`inline-flex size-8 cursor-pointer items-center justify-center rounded-md text-[10px] text-[var(--text-weaker)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,children:[`+`,e.list.length-wI]})]},e.name))})})}function JI({onFiles:e}){return(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-3 gap-y-1 border-t border-border px-3 py-2 text-xs text-[var(--text-weak)]`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(Te,{className:`size-3`}),`Files`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>VS(),className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(Xe,{className:`size-3`}),`Settings`]}),(0,R.jsx)(XI,{})]})})}function YI(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),e}function XI(){let e=YI(),t=(0,E.useMemo)(()=>Tt(),[e]);return t.length===0?null:(0,R.jsx)(R.Fragment,{children:t.map(e=>(0,R.jsxs)(`a`,{href:`/ext/${e.id}`,title:e.description?`${e.title} — ${e.description}`:e.title,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),window.history.pushState({},``,`/ext/${e.id}`),window.dispatchEvent(new Event(DI)))},className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(We,{className:`size-3`}),e.title]},e.id))})}function ZI({id:e,title:t,selected:n,active:r,onSelect:i}){return(0,R.jsxs)(`a`,{href:Fg(e),title:t,"aria-label":t,"aria-current":n?`page`:void 0,onClick:e=>QI(e,i),onMouseEnter:()=>Xv(e),onFocus:()=>Xv(e),className:`relative inline-flex size-8 items-center justify-center rounded-md text-xs font-medium transition-colors ${n?`bg-[var(--surface-raised-base)] text-foreground`:`text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`}`,children:[(t.trim()[0]??`S`).toUpperCase(),r&&(0,R.jsx)(`span`,{className:`absolute right-0.5 bottom-0.5 size-1.5 rounded-full bg-[var(--surface-success-strong)]`})]})}function QI(e,t){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t())}function $I({id:e,title:t,updated:n,active:r,selected:i,subagentsActive:a,onSelect:o}){let[s,c]=(0,E.useState)(!1);return(0,R.jsxs)(BI,{sessionID:e,children:[(0,R.jsx)(Nt,{region:`sidebar.session.before`,sessionID:e}),(0,R.jsxs)(`div`,{className:`group relative mb-0.5 w-full min-w-0 max-w-full`,children:[(0,R.jsxs)(`a`,{href:Fg(e),title:t,"aria-current":i?`page`:void 0,onClick:e=>QI(e,o),onMouseEnter:()=>Xv(e),onFocus:()=>Xv(e),className:`block w-full min-w-0 max-w-full overflow-hidden rounded-md px-2.5 py-2 pr-12 transition-colors ${i?`bg-[var(--surface-raised-base)]`:`hover:bg-[var(--surface-base-hover)]`}`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2`,children:[a&&(0,R.jsx)(`span`,{title:`Subagents running`,"aria-label":`Subagents running`,className:`size-1.5 shrink-0 animate-pulse rounded-full bg-[var(--surface-success-strong)]`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:t}),r&&(0,R.jsx)(Dx,{className:`shrink-0 border-transparent bg-[var(--surface-success-base)] text-[var(--text-on-success-base)]`,children:`run`})]}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 max-w-full items-center gap-2 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-[var(--text-weaker)]`,children:e.slice(0,12)}),(0,R.jsx)(`span`,{className:`shrink-0`,children:pS(n)})]})]}),(0,R.jsx)(`div`,{className:`invisible absolute right-2 bottom-1.5 flex items-center gap-1 group-hover:visible group-focus-within:visible`,children:s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--text-on-critical-strong)] hover:text-[var(--text-on-critical-base)]`,onClick:()=>{G.deleteSession(e).then(Yg),i&&Pv(null)},children:`yes`}),(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--text-weak)] hover:text-foreground`,onClick:()=>c(!1),children:`no`})]}):(0,R.jsx)(`button`,{type:`button`,title:`Delete session`,"aria-label":`Delete ${t}`,className:`cursor-pointer text-[var(--text-weaker)] hover:text-[var(--text-on-critical-base)]`,onClick:()=>c(!0),children:(0,R.jsx)(at,{className:`size-3.5`})})})]}),(0,R.jsx)(Nt,{region:`sidebar.session.after`,sessionID:e})]})}function eL({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,R.jsx)(rm,{"data-slot":`separator`,decorative:n,orientation:t,className:V(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}var tL=Object.defineProperty,nL=Object.getOwnPropertyDescriptor,rL=(e,t)=>{for(var n in t)tL(e,n,{get:t[n],enumerable:!0})},iL=(e,t,n,r)=>{for(var i=r>1?void 0:r?nL(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&&tL(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),aL=`Terminal input`,oL={get:()=>aL,set:e=>aL=e},sL=`Too much output to announce, navigate to rows manually to read`,cL={get:()=>sL,set:e=>sL=e};function lL(e){return e.replace(/\r?\n/g,`\r`)}function uL(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function dL(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function fL(e,t,n,r){e.stopPropagation(),e.clipboardData&&pL(e.clipboardData.getData(`text/plain`),t,n,r)}function pL(e,t,n,r){e=lL(e),e=uL(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function mL(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 hL(e,t,n,r,i){mL(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function gL(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _L(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 vL=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}},yL=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}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}},bL=``,xL=` `,SL=class e{constructor(){this.fg=0,this.bg=0,this.extended=new CL}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)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},CL=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}},wL=class e extends SL{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new CL,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?gL(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()]}},TL=`di$target`,EL=`di$dependencies`,DL=new Map;function OL(e){return e[EL]||[]}function kL(e){if(DL.has(e))return DL.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);AL(t,e,r)};return t._id=e,DL.set(e,t),t}function AL(e,t,n){t[TL]===t?t[EL].push({id:e,index:n}):(t[EL]=[{id:e,index:n}],t[TL]=t)}var jL=kL(`BufferService`),ML=kL(`CoreMouseService`),NL=kL(`CoreService`),PL=kL(`CharsetService`),FL=kL(`InstantiationService`),IL=kL(`LogService`),LL=kL(`OptionsService`),RL=kL(`OscLinkService`),zL=kL(`UnicodeService`),BL=kL(`DecorationService`),VL=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 wL,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}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):HL(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)}};VL=iL([Z(0,jL),Z(1,LL),Z(2,RL)],VL);function HL(e,t){if(confirm(`Do you want to navigate to ${t}?
100
+ `):[];for(let e of t)e in i.current||(i.current[e]=gF);for(let e of Object.keys(i.current))t.includes(e)||delete i.current[e];if(t.length===0){r({});return}let n=Date.now(),o=setInterval(()=>{let a=Date.now(),o=a-n;if(n=a,typeof document<`u`&&document.hidden)return;let s={},c=[];for(let e of t){let t=Math.max(0,(i.current[e]??gF)-o);i.current[e]=t,s[e]=gF-t,t===0&&c.push(e)}r(s);for(let t of c)G_(e,t)},_F);return()=>clearInterval(o)},[a,e]),n}function SF({sessionID:e}){let t=J(t=>t.runNotices[e]);bF(!!t&&t.length>0);let n=xF(e,t);return!t||t.length===0?null:(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-1 pt-2`,children:(0,R.jsx)(`div`,{className:`mx-auto flex max-h-32 max-w-3xl flex-col gap-1 overflow-y-auto`,children:t.map(t=>{let r=vF[t.kind],i=Math.min(100,(n[t.id]??0)/gF*100);return(0,R.jsxs)(`div`,{className:`relative flex items-start gap-2 rounded-md border-l-2 py-1 pl-2.5 pr-2 pb-1.5 text-xs text-[var(--text-base)] ${r.rowClass}`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 ${r.iconClass}`,children:r.icon}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:r.labelClass,children:r.label}),`: `,t.text]}),(0,R.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[var(--text-weaker)]`,children:yF(t.at)}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>G_(e,t.id),title:`Dismiss`,className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:`✕`}),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-[2px] opacity-40 ${r.barClass}`,style:{width:`${i}%`}})]},t.id)})})})}function CF({sessionID:e}){let t=J(t=>t.sendErrors[e]);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(SF,{sessionID:e}),t?(0,R.jsx)(`div`,{className:`border-t border-[color:var(--border-weak-base)] px-3 pb-2 pt-2`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-start gap-2 rounded-md border-l-2 border-l-[color:var(--surface-critical-strong)] border-y border-r border-[color-mix(in_oklch,var(--surface-critical-strong)_30%,transparent)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_8%,transparent)] py-1.5 pl-2.5 pr-2 text-xs text-[var(--text-base)]`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-[color:var(--surface-warning-strong)]`,children:`⚠`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:`font-medium text-[color:var(--surface-critical-strong)]`,children:t.type}),`: `,t.message]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>vy(e),title:`Dismiss`,className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:`✕`})]})}):null]})}function wF({sessionID:e,onNavigate:t}){let n=J(t=>Ov(t.sessions,e)),r=J(e=>e.running),i=J(e=>e.activeIDs),[a,o]=(0,E.useState)(()=>{try{return localStorage.getItem(`webui.subagentStripCollapsed`)!==`1`}catch{return!1}}),s=e=>t?t(e):void Pv(e);if(n.length===0)return null;let c=n.filter(e=>r[e.id]||i.includes(e.id)).length;return(0,R.jsxs)(`div`,{className:`border-b border-[color:var(--border-weak-base)] px-4 py-1`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>{o(e=>{let t=!e;try{localStorage.setItem(`webui.subagentStripCollapsed`,t?`0`:`1`)}catch{}return t})},className:`flex cursor-pointer items-center gap-1.5 rounded-md px-1 py-0.5 text-[11px] text-[color:var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`,title:`Subagent sessions of this session`,children:[a?(0,R.jsx)(I,{className:`size-3`}):(0,R.jsx)(L,{className:`size-3`}),(0,R.jsxs)(`span`,{className:`font-medium`,children:[`Subagents (`,n.length,`)`]}),c>0&&(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-[color:var(--surface-brand-base)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-[color:var(--surface-brand-base)]`}),c,` running`]})]}),a&&(0,R.jsx)(`div`,{className:`mt-0.5 mb-1 flex flex-col gap-0.5`,children:n.map(e=>(0,R.jsx)(TF,{id:e.id,title:e.title,agent:e.agent,running:!!r[e.id]||i.includes(e.id),onOpen:()=>s(e.id)},e.id))})]})}function TF({id:e,title:t,agent:n,running:r,onOpen:i}){let[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(``),l=()=>{let t=s.trim();t&&(ey(e,t),c(``),o(!1))};return(0,R.jsxs)(`div`,{className:`rounded-md px-1 py-0.5 transition-colors hover:bg-[color:var(--surface-base-hover)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-[color:var(--surface-success-strong)]`:`bg-[color:var(--border-base)]`}`,title:r?`Running`:`Idle`}),(0,R.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 cursor-pointer truncate text-left text-xs text-[color:var(--text-weak)] hover:text-[color:var(--text-strong)]`,title:`Open ${t??e}`,children:[n&&t?`${n} — ${t}`:t||n||`subagent`,(0,R.jsx)(`span`,{className:`ml-2 hidden font-mono text-[10px] text-[color:var(--text-weaker)] sm:inline`,children:e.slice(0,12)})]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:()=>{o(e=>!e),c(``)},title:a?`Cancel`:`Message this subagent`,children:[(0,R.jsx)(Ne,{}),`Message`]}),(0,R.jsx)(U,{variant:`ghost`,size:`xs`,onClick:i,title:`Open session`,children:`Open`})]}),a&&(0,R.jsx)(`input`,{autoFocus:!0,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l()),e.key===`Escape`&&(e.preventDefault(),o(!1))},placeholder:`message this subagent… (enter to send)`,className:`mt-1 w-full rounded-md border border-[color:var(--border-base)] bg-[color:var(--input-base)] px-2 py-1 font-mono text-xs text-[color:var(--text-strong)] outline-none placeholder:text-[color:var(--text-weaker)] focus:border-[color:var(--border-selected)]`})]})}var EF=`webui.theme`,DF=`oc-theme`,OF=[{id:`opencode`,label:`Opencode`,vars:{}},{id:`catppuccin`,label:`Catppuccin`,vars:{"--background-base":`#1e1e2e`,"--surface-float-base":`#181825`,"--background-weak":`#11111b`,"--text-strong":`#cdd6f4`,"--text-weak":`#9399b2`,"--border-selected":`#89b4fa`,"--surface-brand-base":`#f5c2e7`,"--surface-success-strong":`#a6e3a1`,"--surface-critical-strong":`#f38ba8`,"--surface-warning-strong":`#f9e2af`,"--surface-info-strong":`#94e2d5`}},{id:`nord`,label:`Nord`,vars:{"--background-base":`#2e3440`,"--surface-float-base":`#3b4252`,"--background-weak":`#434c5e`,"--text-strong":`#eceff4`,"--text-weak":`#8b95a7`,"--border-selected":`#88c0d0`,"--surface-brand-base":`#8fbcbb`,"--surface-success-strong":`#a3be8c`,"--surface-critical-strong":`#bf616a`,"--surface-warning-strong":`#d08770`,"--surface-info-strong":`#88c0d0`}},{id:`tokyonight`,label:`Tokyo Night`,vars:{"--background-base":`#1a1b26`,"--surface-float-base":`#1e2030`,"--background-weak":`#222436`,"--text-strong":`#c8d3f5`,"--text-weak":`#828bb8`,"--border-selected":`#82aaff`,"--surface-brand-base":`#ff966c`,"--surface-success-strong":`#c3e88d`,"--surface-critical-strong":`#ff757f`,"--surface-warning-strong":`#ffc777`,"--surface-info-strong":`#82aaff`}},{id:`dracula`,label:`Dracula`,vars:{"--background-base":`#282a36`,"--surface-float-base":`#21222c`,"--background-weak":`#44475a`,"--text-strong":`#f8f8f2`,"--text-weak":`#6272a4`,"--border-selected":`#bd93f9`,"--surface-brand-base":`#8be9fd`,"--surface-success-strong":`#50fa7b`,"--surface-critical-strong":`#ff5555`,"--surface-warning-strong":`#f1fa8c`,"--surface-info-strong":`#ffb86c`}},{id:`gruvbox`,label:`Gruvbox`,vars:{"--background-base":`#282828`,"--surface-float-base":`#3c3836`,"--background-weak":`#504945`,"--text-strong":`#ebdbb2`,"--text-weak":`#928374`,"--border-selected":`#83a598`,"--surface-brand-base":`#8ec07c`,"--surface-success-strong":`#b8bb26`,"--surface-critical-strong":`#fb4934`,"--surface-warning-strong":`#fe8019`,"--surface-info-strong":`#fabd2f`}},{id:`github`,label:`GitHub`,vars:{"--background-base":`#0d1117`,"--surface-float-base":`#010409`,"--background-weak":`#161b22`,"--text-strong":`#c9d1d9`,"--text-weak":`#8b949e`,"--border-selected":`#58a6ff`,"--surface-brand-base":`#39c5cf`,"--surface-success-strong":`#3fb950`,"--surface-critical-strong":`#f85149`,"--surface-warning-strong":`#e3b341`,"--surface-info-strong":`#d29922`}}];function kF(){let e=localStorage.getItem(EF);return OF.find(t=>t.id===e)??OF[0]}function AF(e){let t=OF.find(t=>t.id===e)??OF[0],n=document.getElementById(DF);n||(n=document.createElement(`style`),n.id=DF,document.head.appendChild(n));let r=Object.entries(t.vars);return n.textContent=r.length>0?`:root:root {\n ${r.map(([e,t])=>`${e}: ${t};`).join(`
101
+ `)}\n}`:``,localStorage.setItem(EF,t.id),t}AF(kF().id);function jF(){let[e,t]=(0,E.useState)(kF().id),n=J(e=>e.uiSignals.themes),[r,i]=(0,E.useState)(!1);(0,E.useEffect)(()=>{n&&i(!0)},[n]);let a=OF.find(t=>t.id===e)?.label??OF[0].label;return(0,R.jsxs)(_C,{open:r,onOpenChange:i,children:[(0,R.jsx)(vC,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,className:`text-xs text-muted-foreground`,children:[(0,R.jsx)(Pe,{}),a]})}),(0,R.jsx)(yC,{align:`end`,className:`min-w-40`,children:OF.map(n=>(0,R.jsxs)(bC,{className:`justify-between`,onSelect:()=>t(AF(n.id).id),children:[(0,R.jsx)(`span`,{children:n.label}),n.id===e&&(0,R.jsx)(ae,{className:`size-3.5`})]},n.id))})]})}function MF({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`skeleton`,className:V(`animate-pulse rounded-md bg-muted`,e),...t})}function NF(e){let t=e.split(`/`).filter(Boolean);return t.length>0?t[t.length-1]:e}function PF(e){let t=NF(e.directory??e.canonical);return t&&t!==`/`?t:e.id}function FF({sessionID:e}){let t=J(t=>t.sessions.find(t=>t.id===e)),[n,r]=(0,E.useState)(null),[i,a]=(0,E.useState)(null),[o,s]=(0,E.useState)([]),[c,l]=(0,E.useState)(!1),u=t?.location.directory??n?.directory;function d(){l(!0),Promise.all([G.locationInfo(),G.projectCurrent(),G.projectList()]).then(([e,t,n])=>{r(e),a(t),s(n)}).catch(()=>void 0).finally(()=>l(!1))}return(0,R.jsxs)(_C,{onOpenChange:e=>e&&d(),children:[(0,R.jsx)(vC,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,title:u,className:`max-w-44 text-xs text-muted-foreground`,children:[(0,R.jsx)(Ee,{}),(0,R.jsx)(`span`,{className:`truncate font-mono`,children:u||`workspace`})]})}),(0,R.jsxs)(yC,{align:`end`,className:`min-w-56`,children:[(0,R.jsx)(xC,{children:`Location`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 py-1 text-sm text-[var(--text-base)]`,children:[(0,R.jsx)(Ee,{className:`size-3.5 shrink-0 text-[var(--text-weak)]`}),(0,R.jsx)(`span`,{className:`truncate font-mono text-xs`,children:n?.directory??u??`…`})]}),n?.workspaceID&&(0,R.jsx)(`div`,{className:`px-1.5 pb-1 font-mono text-[11px] text-[var(--text-weaker)]`,children:n.workspaceID}),(0,R.jsx)(SC,{}),(0,R.jsx)(xC,{children:`Project`}),c&&o.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-1.5 py-1`,children:[(0,R.jsx)(MF,{className:`h-6 w-full`}),(0,R.jsx)(MF,{className:`h-6 w-full`}),(0,R.jsx)(MF,{className:`h-6 w-3/4`})]}):o.length===0?(0,R.jsx)(`div`,{className:`px-1.5 py-1 text-xs text-[var(--text-weaker)]`,children:`No projects`}):o.map(e=>{let t=i?.id===e.id;return(0,R.jsxs)(bC,{className:`justify-between font-mono text-xs`,onSelect:e=>e.preventDefault(),children:[(0,R.jsx)(`span`,{className:`truncate`,children:PF(e)}),t&&(0,R.jsx)(ae,{className:`size-3.5 text-[var(--text-interactive-base)]`})]},e.id)})]})]})}function IF({sessionID:e,paneKey:t=`main`,focused:n=!0,onClose:r,onNavigate:i}){let a=e=>i?i(e):void Pv(e),o=J(t=>t.sessions.find(t=>t.id===e)??t.sessionDetails[e]),s=J(t=>t.messages[e]??[]),c=J(t=>t.live.filter(t=>t.sessionID===e)),l=J(t=>t.running[e]??!1),u=J(t=>!!t.queued[e]),d=J(e=>e.runsPanelOpen),f=J(e=>e.subagentComposerOpen),p=J(t=>n?Sg(t).some(t=>t.req.sessionID===e):!1),m=J(t=>jv(t,e)),h=(0,E.useMemo)(()=>Av(s,m),[s,m]);(0,E.useEffect)(()=>{Qg(e)},[e]);let g=J(e=>e.highlightMessageID),_=J(e=>e.highlightSessionID);return(0,E.useEffect)(()=>{if(!g||_!==e)return;let t=0,n=()=>{let e=document.getElementById(`msg-${g}`);return e?(e.scrollIntoView({behavior:`smooth`,block:`center`}),e.classList.add(`ring-2`,`ring-[var(--border-selected)]`,`rounded-md`),setTimeout(()=>e.classList.remove(`ring-2`,`ring-[var(--border-selected)]`,`rounded-md`),2e3),!0):!1};if(n())return;let r=setInterval(()=>{t+=1,(n()||t>20)&&clearInterval(r)},150);return()=>clearInterval(r)},[e,g,_,h]),(0,R.jsxs)(`div`,{className:`pane-surface flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(KF,{title:o?.title,sessionID:e,running:l,queued:u,parentID:o?.parentID,go:a,onClose:r}),!Eg(e)&&(0,R.jsx)(wF,{sessionID:e,onNavigate:i}),(0,R.jsx)(Nt,{region:`transcript.above`,sessionID:e}),(0,R.jsx)(bx,{defaultScrollPosition:`end`,autoScroll:!0,children:(0,R.jsxs)(`div`,{className:`relative flex flex-1 flex-col overflow-hidden`,children:[(0,R.jsxs)(xx,{className:`flex-1`,children:[(0,R.jsx)(Sx,{children:(0,R.jsx)(UF,{sessionID:e,messages:h,live:c,running:l})}),(0,R.jsx)(Tx,{direction:`end`}),(0,R.jsx)(LF,{sessionID:e,messages:h})]}),(0,R.jsx)(JF,{messages:s})]})}),(0,R.jsx)(Nt,{region:`transcript.below`,sessionID:e}),(0,R.jsx)(CF,{sessionID:e}),(0,R.jsx)(uF,{sessionID:e}),n?p?(0,R.jsx)(nF,{sessionID:e}):d?(0,R.jsx)(pF,{sessionID:e,paneKey:t}):o?.parentID&&!f?(0,R.jsx)(RF,{sessionID:e,parentID:o.parentID,go:a}):(0,R.jsx)(Nt,{region:`composer.replace`,sessionID:e,fallback:(0,R.jsx)(HC,{sessionID:e,paneKey:t})}):(0,R.jsx)(Nt,{region:`composer.replace`,sessionID:e,fallback:(0,R.jsx)(HC,{sessionID:e,paneKey:t})})]})}function LF({sessionID:e,messages:t}){let{scrollToEnd:n}=fx(),r=(0,E.useRef)(null);return(0,E.useEffect)(()=>{let i=t[t.length-1],a=i?.id??null,o=r.current;r.current={sessionID:e,id:a},!(!o||o.sessionID!==e||o.id===a)&&i?.type===`user`&&n({behavior:`smooth`})},[e,t,n]),null}function RF({sessionID:e,parentID:t,go:n}){let r=J(e=>e.sessions),i=J(e=>e.running),a=J(e=>e.activeIDs),o=J(e=>e.sessions.find(e=>e.id===t)?.title??e.sessionDetails[t]?.title),s=e=>i[e]||a.includes(e),c=[...Ov(r,t)].sort((e,t)=>e.id<t.id?-1:1);return(0,R.jsx)(`div`,{className:`border-t border-[var(--border-base)] px-4 py-1.5`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col gap-1`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-1 gap-y-0.5`,children:c.map(t=>(0,R.jsx)(zF,{id:t.id,label:t.title||t.agent||t.id,current:t.id===e,running:s(t.id),go:n},t.id))}),(0,R.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>Ev(),className:`cursor-pointer rounded-md border border-dashed border-[var(--border-weak-base)] px-1.5 py-0.5 font-mono transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,title:`Show the message composer`,children:`enter`}),(0,R.jsx)(`span`,{children:`to message this subagent`}),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(t),title:`Back to parent${o?`: ${o}`:``}`,className:`flex cursor-pointer items-center gap-1 rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(P,{className:`size-3`}),`back to parent`]}),(0,R.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,R.jsx)(`span`,{className:`font-mono text-[10px]`,children:`←/→ switch`})]})]})})}function zF({id:e,label:t,current:n,running:r,go:i}){let a=(0,E.useRef)(null);return(0,E.useEffect)(()=>{n&&a.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[n]),(0,R.jsxs)(`button`,{ref:a,type:`button`,onClick:()=>i(e),title:n?`Currently open — ←/→ to switch`:t,className:`flex cursor-pointer items-center gap-1 rounded-full px-1.5 py-0.5 font-mono text-[11px] transition-colors ${n?`bg-[color:var(--surface-raised-base-active)] font-medium text-[color:var(--text-strong)]`:`text-[color:var(--text-weaker)] hover:bg-[color:var(--surface-base-hover)] hover:text-[color:var(--text-weak)]`}`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-emerald-500`:`bg-[color:var(--border-base)]`}`}),(0,R.jsx)(`span`,{className:`max-w-44 truncate`,children:t})]})}function BF(e,t){let n=[],r=e=>n.push(String(e));for(let t of e)if(r(t.id),t.type===`assistant`){r(t.content.length),r(t.finish??``);for(let e of t.content)e.type===`tool`?(r(`t${e.id}:${e.state.status}`),e.state.status===`streaming`?r(e.state.input.length):(r(VF(e.state.input)),`metadata`in e.state&&r(VF(e.state.metadata)),`content`in e.state&&e.state.content&&r(e.state.content.length),e.state.status===`error`&&r(VF(e.state.error)))):r(`${e.type}:${e.text.length}`)}else`text`in t&&typeof t.text==`string`?(r(t.text.length),`files`in t&&t.files&&r(t.files.length)):r(VF(t));for(let e of t){r(`live:${e.id}:${e.content.length}`),r(e.error?`${e.error.type}:${VF(e.error.message)}`:``);for(let t of e.content)t.type===`tool`?r(`t${t.tool.id}:${t.tool.status}:${+!!t.tool.executed}:${VF(t.tool.inputText)}:${VF(t.tool.metadata)}:${t.tool.content?.length??0}:${t.tool.error?VF(t.tool.error.message):0}`):r(`${t.type}:${t.ordinal}:${t.text.length}`)}return n.join(`|`)}function VF(e){if(e==null)return 0;if(typeof e==`string`)return e.length;try{return JSON.stringify(e)?.length??0}catch{return-1}}function HF(e,t){return e.sessionID===t.sessionID&&e.running===t.running&&BF(e.messages,e.live)===BF(t.messages,t.live)}var UF=E.memo(function({sessionID:e,messages:t,live:n,running:r}){return(0,R.jsxs)(Cx,{className:`mx-auto w-full max-w-3xl px-4 py-6`,children:[t.length===0&&n.length===0&&!r&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(wx,{children:(0,R.jsx)(WF,{})}),(0,R.jsx)(Nt,{region:`transcript.empty`,sessionID:e})]}),(()=>{let i=!1,a=[];for(let n of t){let t=n.type===`assistant`,r=t&&i;i=t,a.push((0,R.jsx)(wx,{messageId:n.id,id:`msg-${n.id}`,children:(0,R.jsx)(MP,{message:n,compact:r,sessionID:e})},n.id))}return n.length>0&&a.push((0,R.jsx)(wx,{children:(0,R.jsx)(qF,{assistants:n,running:r})},`live`)),a})()]})},HF);function WF(){return(0,R.jsx)(`div`,{className:`flex justify-center pt-16`,children:(0,R.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-1.5 rounded-lg border border-[var(--border-weak-base)] bg-[var(--background-weak)] px-8 py-10 text-center`,children:[(0,R.jsx)(`h1`,{className:`text-[var(--font-size-large)] font-medium text-[var(--text-base)]`,children:`Start a conversation`}),(0,R.jsx)(`p`,{className:`text-[var(--font-size-base)] text-[var(--text-weaker)]`,children:`The agent can read, edit, and run commands in the session workspace.`})]})})}function GF(e){return e.replace(/\/+$/,``).replace(/^\/(home|Users)\/[^/]+/,`~`)}function KF({title:e,sessionID:t,running:n,queued:r,parentID:i,go:a,onClose:o}){let s=J(e=>e.sessionDetails[i??``]?.title),c=Eg(t),l=J(e=>e.draftWorkspace);return(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--border-base)] px-4 py-2.5`,children:[(0,R.jsx)(Nt,{region:`header.session.before`,sessionID:t}),(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>a(i),title:`Back to parent session${s?`: ${s}`:``}`,className:`cursor-pointer rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-xs text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:`↑ Parent`}),(0,R.jsx)(`button`,{type:`button`,className:`mr-1 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)] lg:hidden`,onClick:()=>o?o():a(null),children:`←`}),(0,R.jsx)(`span`,{className:`truncate text-[var(--font-size-base)] font-medium text-[var(--text-strong)]`,children:c?`New session`:e??`Untitled session`}),c?(0,R.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-[var(--text-weaker)] sm:inline`,children:l?GF(l):`default workspace`}):(0,R.jsx)(`span`,{className:`hidden font-mono text-xs text-[var(--text-weaker)] sm:inline`,children:t.slice(0,12)}),r&&!n&&(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-warning-weak)] text-[var(--surface-warning-strong)]`,title:`Message sent — waiting for the agent to start responding`,children:`waiting`}),n&&(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-interactive-weak)] text-[var(--text-interactive-base)]`,children:`working`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(Nt,{region:`header.session.actions`,sessionID:t}),o&&(0,R.jsx)(`button`,{type:`button`,onClick:o,title:`Close split`,className:`flex size-6 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:(0,R.jsx)(at,{className:`size-3.5`})}),(0,R.jsx)(FF,{sessionID:t}),(0,R.jsx)(jF,{}),(0,R.jsx)(CC,{sessionID:t})]})]})}function qF({assistants:e,running:t}){let n=e.flatMap(e=>e.content.map(t=>({key:YF(e.id,t),part:t}))),r=e.filter(e=>e.error).map(e=>({id:e.id,error:e.error}));return n.length===0&&!t&&r.length===0?null:(0,R.jsxs)(`div`,{children:[r.map(({id:e,error:t})=>(0,R.jsxs)(`div`,{className:`mb-2 rounded-md border border-[color-mix(in_oklch,var(--surface-critical-strong)_40%,transparent)] bg-[var(--surface-critical-weak)] px-3 py-2 text-xs text-[var(--text-on-critical-strong)]`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t.type}),(0,R.jsx)(`div`,{className:`mt-0.5`,children:t.message})]},e)),n.length===0&&t&&r.length===0&&(0,R.jsx)(`div`,{className:`flex items-center gap-2 py-1 text-[var(--font-size-base)] text-[var(--text-weak)] animate-pulse`,children:`thinking…`}),n.map(({key:e,part:t})=>(0,R.jsx)(KP,{stateKey:e,part:t.type===`tool`?A_(t.tool):t},e))]})}function JF({messages:e}){let t=(0,E.useMemo)(()=>e.filter(e=>e.type===`user`),[e]),[n,r]=(0,E.useState)(null);if((0,E.useEffect)(()=>{if(t.length===0)return;let e=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>t.intersectionRatio-e.intersectionRatio);if(t[0]?.target){let e=t[0].target.id.replace(/^msg-/,``);r(e)}},{root:null,rootMargin:`-30% 0px -60% 0px`,threshold:[0,.25,.5,1]}),n=[];for(let r of t){let t=document.getElementById(`msg-${r.id}`);t&&(e.observe(t),n.push(t))}return()=>{for(let t of n)e.unobserve(t);e.disconnect()}},[t]),t.length<3)return null;let i=e=>{let t=document.getElementById(`msg-${e}`);if(t)t.scrollIntoView({behavior:`smooth`,block:`start`});else try{let t=`[data-message-id="${CSS.escape(e)}"]`;document.querySelector(t)?.scrollIntoView({behavior:`smooth`,block:`start`})}catch{}};return(0,R.jsx)(`div`,{className:`pointer-events-none absolute top-1/2 right-3 hidden -translate-y-1/2 flex-col items-center justify-center md:flex`,style:{maxHeight:`min(70vh, 560px)`},children:(0,R.jsxs)(`div`,{className:`pointer-events-auto flex flex-col items-center gap-2 rounded-full border border-[var(--border-weak-base)] bg-[var(--background-base)]/95 px-2 py-3 shadow-md backdrop-blur`,children:[(0,R.jsx)(`div`,{className:`absolute inset-y-3 w-px bg-[var(--border-weak-base)]`}),t.map(e=>{let t=(e.text??``).replace(/\s+/g,` `).slice(0,400)||e.id.slice(0,8),r=e.id===n;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:t,className:`group relative flex size-4 items-center justify-center`,children:[(0,R.jsx)(`span`,{className:`rounded-full ring-1 transition-all ${r?`size-3 bg-[var(--surface-brand-base)] ring-[var(--surface-brand-base)] shadow-sm`:`size-2 bg-[var(--text-weaker)] ring-[var(--border-weak-base)] group-hover:size-2.5 group-hover:bg-[var(--text-strong)]`}`}),(0,R.jsx)(`span`,{className:`pointer-events-none absolute right-full mr-4 hidden max-w-[560px] whitespace-pre-wrap rounded-xl border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] px-4 py-3 text-sm leading-relaxed text-[var(--text-weak)] shadow-xl group-hover:block`,children:t})]},e.id)})]})})}function YF(e,t){return t.type===`tool`?`${e}:tool:${t.tool.id}`:`${e}:${t.type}:${t.ordinal}`}var XF=[[`Enter`,`Send · queue while the agent works`],[`Esc`,`Interrupt the running agent`],[`Tab / Shift+Tab`,`Next / previous agent`],[`↑ / ↓ (input at start/end)`,`Prompt history`],[`↓ (outside input)`,`Subagents & shells dialog`],[`← / → (outside input)`,`Cycle subagent sessions`],[`↑ (outside input)`,`Parent session`],[`Ctrl+B`,`Background synchronous subagents`],[`Ctrl+P`,`Command palette`],[`Ctrl+N`,`New session`],[`⌘F / Ctrl+F`,`Search sessions`],[`/`,`Slash commands & skills`],[`@`,`Reference files`],[`!`,`Shell mode`]];function ZF(){let e=J(e=>e.uiSignals.help),[t,n]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{e&&n(!0)},[e]),(0,R.jsx)(Km,{open:t,onOpenChange:n,children:(0,R.jsxs)(Jm,{children:[(0,R.jsx)(Xm,{className:`bg-black/40`}),(0,R.jsxs)(fs,{className:`fixed top-1/2 left-1/2 z-50 max-h-[80vh] w-[min(24rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 shadow-xl outline-none duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95`,children:[(0,R.jsx)(eh,{className:`mb-3 text-sm font-medium text-[var(--text-strong)]`,children:`Keybinds`}),(0,R.jsx)(`dl`,{className:`space-y-1.5 text-xs`,children:XF.map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,R.jsx)(`dt`,{className:`shrink-0 rounded border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--text-base)]`,children:e}),(0,R.jsx)(`dd`,{className:`text-right text-[var(--text-weak)]`,children:t})]},e))})]})]})})}var QF=300,$F=4,eI=40,tI=new Map;function nI(e){switch(e.type){case`user`:case`system`:case`synthetic`:case`skill`:return e.text??``;case`shell`:return e.command??``;case`compaction`:return e.summary??``;case`assistant`:{let t=``;for(let n of e.content??[])n?.type===`text`&&(t+=n.text+`
102
+ `);return t}default:return``}}function rI(e,t,n){let r=e.toLowerCase().indexOf(t);if(r===-1)return null;let i=Math.max(0,r-eI),a=Math.min(e.length,r+n+eI),o=e.slice(i,a).replace(/\s+/g,` `),s=o.toLowerCase().indexOf(t),c=s===-1?r-i:s,l=c+n;c<0&&(c=0),l>o.length&&(l=o.length);let u=i>0?`… `:``,d=a<e.length?` …`:``;return u&&(o=u+o,c+=u.length,l+=u.length),d&&(o+=d),{snippet:o,matchStart:c,matchEnd:l}}async function iI(e){try{let t=(await G.messages(e,100)).data.map(e=>{let t=nI(e);return t?{id:e.id,text:t,lower:t.toLowerCase()}:null}).filter(e=>!!e),n=t.map(e=>e.lower).join(`
103
+ `);tI.set(e,{messages:t,combinedLower:n})}catch{tI.set(e,{messages:[],combinedLower:``})}}function aI(e){let t=new Map,n=e.length;for(let[r,i]of tI){if(!i.combinedLower.includes(e))continue;let a=[];for(let t of i.messages){if(!t.lower.includes(e))continue;let r=rI(t.text,e,n);r&&a.push({messageID:t.id,snippet:r.snippet,matchStart:r.matchStart,matchEnd:r.matchEnd})}a.length>0&&t.set(r,a)}return t}function oI(e,t,n){let r=e.trim().toLowerCase();if(!r)return Promise.resolve(new Map);let i=[...t].sort((e,t)=>t.time.updated-e.time.updated).slice(0,QF).map(e=>e.id).filter(e=>!tI.has(e));return(async()=>{for(let e=0;e<i.length;e+=$F){let t=i.slice(e,e+$F);await Promise.all(t.map(iI)),n?.(aI(r))}return aI(r)})()}var sI=/mac|iphone|ipad|ipod/i.test(typeof navigator>`u`?``:navigator.userAgent),cI=sI?`⌘F`:`Ctrl F`;function lI({...e}){return(0,R.jsx)(es,{"data-slot":`sheet`,...e})}function uI({...e}){return(0,R.jsx)(os,{"data-slot":`sheet-portal`,...e})}function dI({className:e,...t}){return(0,R.jsx)(cs,{"data-slot":`sheet-overlay`,className:V(`fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function fI({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,R.jsxs)(uI,{children:[(0,R.jsx)(dI,{}),(0,R.jsxs)(fs,{"data-slot":`sheet-content`,"data-side":n,className:V(`fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10`,e),...i,children:[t,r&&(0,R.jsx)(xs,{"data-slot":`sheet-close`,asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`,children:[(0,R.jsx)(at,{}),(0,R.jsx)(`span`,{className:`sr-only`,children:`Close`})]})})]})]})}function pI({className:e,...t}){return(0,R.jsx)(`div`,{"data-slot":`sheet-header`,className:V(`flex flex-col gap-0.5 p-4`,e),...t})}function mI({className:e,...t}){return(0,R.jsx)(_s,{"data-slot":`sheet-title`,className:V(`font-heading text-base font-medium text-foreground`,e),...t})}function hI({className:e,...t}){return(0,R.jsx)(ys,{"data-slot":`sheet-description`,className:V(`text-sm text-muted-foreground`,e),...t})}var gI=e=>e.replace(/\/+$/,``),_I=e=>gI(e).split(`/`).filter(Boolean).pop()??e,vI=e=>e instanceof Error?e.message:String(e);function yI(e,t){let n=gI(e.replace(/^\.\//,``)),r=gI(t.replace(/^\.\//,``));return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function bI(e){return[...e].sort((e,t)=>e.type===t.type?gI(e.path).localeCompare(gI(t.path)):e.type===`directory`?-1:1)}function xI(e){let t=e.includes(`.`)?(e.split(`.`).pop()??``).toLowerCase():``,n=`size-3.5 shrink-0 text-[var(--text-weaker)]`;return[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`ico`,`avif`].includes(t)?(0,R.jsx)(be,{className:n}):[`json`,`jsonc`,`yaml`,`yml`,`toml`].includes(t)?(0,R.jsx)(_e,{className:n}):[`zip`,`tar`,`gz`,`tgz`,`bz2`,`xz`,`7z`].includes(t)?(0,R.jsx)(ge,{className:n}):[`txt`,`log`,`csv`,`tsv`,`ini`,`env`,`conf`,`lock`,`gitignore`].includes(t)?(0,R.jsx)(Se,{className:n}):`ts.tsx.js.jsx.mjs.cjs.go.rs.py.rb.java.c.h.hpp.cc.cpp.css.scss.html.vue.svelte.sh.bash.zsh.sql.graphql.gql.md.mdx.zig`.split(`.`).includes(t)?(0,R.jsx)(ye,{className:n}):(0,R.jsx)(Ce,{className:n})}function SI({entry:e,depth:t,nodes:n,selectedPath:r,onToggle:i,onOpen:a}){let o=e.type===`directory`,s=gI(e.path),c=n[s],l=_I(e.path),u=r===s,d=6+t*13,f=()=>o?i(e):a(e);return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:f,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())},className:V(`flex cursor-pointer items-center gap-1 rounded-sm py-[3px] pr-2`,u?`bg-[var(--surface-raised-base)] text-[var(--text-strong)]`:`text-[var(--text-base)] hover:bg-[var(--surface-base-hover)]`),style:{paddingLeft:d},children:[o?(0,R.jsx)(L,{className:V(`size-3 shrink-0 text-[var(--text-weaker)] transition-transform`,c?.expanded&&`rotate-90`)}):(0,R.jsx)(`span`,{className:`w-3 shrink-0`}),o?(0,R.jsx)(Ee,{className:V(`size-3.5 shrink-0`,c?.expanded?`text-[var(--text-interactive-base)]`:`text-[var(--text-weak)]`)}):xI(l),(0,R.jsx)(`span`,{className:V(`truncate font-mono text-xs`,o?`text-[var(--text-strong)]`:`text-[var(--text-base)]`),children:l}),c?.loading&&(0,R.jsx)(Me,{className:`ml-auto size-3 shrink-0 animate-spin text-[var(--text-weaker)]`}),c?.error&&(0,R.jsx)(`span`,{className:`ml-auto shrink-0 text-[10px] text-[var(--text-on-critical-base)]`,children:`!`})]}),o&&c?.expanded&&(0,R.jsx)(`div`,{children:c.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 py-1`,style:{paddingLeft:d+13},children:[(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-1/2`})]}):c.error?(0,R.jsx)(`div`,{className:`py-1 text-[11px] text-[var(--text-on-critical-base)]`,style:{paddingLeft:d+13},children:c.error}):c.children&&c.children.length===0?(0,R.jsx)(`div`,{className:`py-0.5 text-[11px] italic text-[var(--text-weaker)]`,style:{paddingLeft:d+13},children:`empty`}):c.children?.map(e=>(0,R.jsx)(SI,{entry:e,depth:t+1,nodes:n,selectedPath:r,onToggle:i,onOpen:a},gI(e.path)))})]})}function CI({count:e,error:t}){return t?(0,R.jsx)(Dx,{variant:`outline`,title:t,className:`border-border/50 text-[var(--text-weaker)]`,children:`vcs n/a`}):e===null?null:e===0?(0,R.jsx)(Dx,{className:`border-transparent bg-[var(--surface-success-base)] text-[var(--text-on-success-base)]`,children:`clean`}):(0,R.jsxs)(Dx,{className:`border-transparent bg-[var(--surface-critical-base)] text-[var(--text-on-critical-base)]`,children:[e,` changed`]})}function wI({open:e,onOpenChange:t}){let n=J(e=>e.sessions.find(t=>t.id===e.currentSessionID)?.location?.directory),[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(null),[l,u]=(0,E.useState)({}),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)({loading:!1}),[h,g]=(0,E.useState)({loading:!1}),[_,v]=(0,E.useState)(null),[y,b]=(0,E.useState)(null),x=(0,E.useRef)(null),S=(0,E.useRef)(null);(0,E.useEffect)(()=>{if(!e)return;let t=!1,r=e=>{t||(S.current!==e&&(S.current=e,o(null),c(null),u({}),v(null),b(null),f(null),x.current=null),i(e),G.fsList({location:e}).then(e=>{t||(o(e.data),c(null))}).catch(e=>{t||c(vI(e))}),G.vcsStatus({directory:e}).then(e=>{t||v(e.data.length)}).catch(e=>{t||b(vI(e))}))};return n?r(n):G.location().then(e=>{t||r(e.directory)}).catch(e=>{t||c(vI(e))}),()=>{t=!0}},[e,n]),(0,E.useEffect)(()=>{e||(f(null),x.current=null,m({loading:!1}),g({loading:!1}))},[e]);let C=e=>{let t=gI(e.path),n=l[t];if(n?.expanded){u(e=>{let n={...e};return delete n[t],n});return}u(e=>({...e,[t]:{expanded:!0,loading:!e[t]?.children,children:e[t]?.children}})),n?.children||G.fsList({location:r??void 0,path:t}).then(e=>u(n=>n[t]?{...n,[t]:{...n[t],children:e.data,loading:!1}}:n)).catch(e=>u(n=>n[t]?{...n,[t]:{...n[t],error:vI(e),loading:!1}}:n))},w=e=>{x.current=e,f(e),m({loading:!0}),g({loading:!0}),G.fsRead(e.path,r??void 0).then(t=>{x.current?.path===e.path&&m({content:t,loading:!1})}).catch(t=>{x.current?.path===e.path&&m({error:vI(t),loading:!1})}),G.vcsBase(r?{directory:r}:void 0).then(e=>e.data).catch(()=>null).then(e=>G.vcsDiff(`working`,r?{directory:r}:void 0,3,e?.ref??null)).then(t=>{if(x.current?.path!==e.path)return;let n=t.data.find(t=>yI(t.file,e.path));g({patch:n?.patch,loading:!1})}).catch(t=>{x.current?.path===e.path&&g({error:vI(t),loading:!1})})};return(0,R.jsx)(lI,{open:e,onOpenChange:t,children:(0,R.jsxs)(fI,{side:`left`,className:`w-[min(44rem,calc(100vw-0.5rem))]! gap-0 p-0 sm:max-w-[44rem]!`,children:[(0,R.jsxs)(pI,{className:`border-b border-border px-4 py-3 pr-12`,children:[(0,R.jsxs)(mI,{className:`flex items-center gap-2 text-sm`,children:[(0,R.jsx)(Te,{className:`size-4 text-[var(--text-weak)]`}),`Files`,(0,R.jsx)(CI,{count:_,error:y})]}),r&&(0,R.jsx)(hI,{className:`truncate font-mono text-[11px] text-[var(--text-weaker)]`,children:r})]}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`flex w-[40%] min-w-56 shrink-0 flex-col border-r border-border`,children:(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(`div`,{className:`p-1.5`,children:s?(0,R.jsx)(`div`,{className:`px-2 py-3 text-xs text-[var(--text-on-critical-base)]`,children:s}):a===null?(0,R.jsx)(`div`,{className:`space-y-1.5 p-1`,children:[0,1,2,3,4].map(e=>(0,R.jsx)(MF,{className:`h-4 w-full`},e))}):a.length===0?(0,R.jsx)(`div`,{className:`px-2 py-3 text-xs text-[var(--text-weak)]`,children:`Empty directory`}):bI(a).map(e=>(0,R.jsx)(SI,{entry:e,depth:0,nodes:l,selectedPath:d?gI(d.path):null,onToggle:C,onOpen:w},gI(e.path)))})})}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:d?(0,R.jsxs)(Xx,{defaultValue:`preview`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-weak)]`,children:d.path}),(0,R.jsxs)(Qx,{variant:`line`,className:`h-6 shrink-0`,children:[(0,R.jsx)($x,{value:`preview`,className:`text-xs`,children:`Preview`}),(0,R.jsx)($x,{value:`diff`,className:`text-xs`,children:`Diff`})]})]}),(0,R.jsx)(eS,{value:`preview`,className:`flex min-h-0 flex-1 flex-col`,children:p.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-2/3`}),(0,R.jsx)(MF,{className:`h-3 w-5/6`}),(0,R.jsx)(MF,{className:`h-3 w-1/2`})]}):p.error?(0,R.jsx)(`div`,{className:`p-4 text-xs text-[var(--text-on-critical-base)]`,children:p.error}):(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(`pre`,{className:`p-3 font-mono text-xs leading-[1.6] whitespace-pre text-[var(--text-base)]`,children:p.content??``})})}),(0,R.jsx)(eS,{value:`diff`,className:`flex min-h-0 flex-1 flex-col`,children:h.loading?(0,R.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,R.jsx)(MF,{className:`h-3 w-11/12`}),(0,R.jsx)(MF,{className:`h-3 w-3/4`}),(0,R.jsx)(MF,{className:`h-3 w-2/3`}),(0,R.jsx)(MF,{className:`h-3 w-5/6`})]}):h.error?(0,R.jsxs)(`div`,{className:`p-4 text-xs text-[var(--text-on-critical-base)]`,children:[`Diff unavailable: `,h.error]}):h.patch?(0,R.jsx)(qx,{className:`min-h-0 flex-1`,children:(0,R.jsx)(MN,{diff:h.patch,className:`p-3`})}):(0,R.jsx)(`div`,{className:`p-4 text-xs text-[var(--text-weak)]`,children:`No uncommitted changes for this file.`})})]}):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-xs text-[var(--text-weak)]`,children:`Select a file to preview`})})]})]})})}var TI=3,EI=20,DI=2,OI=`webui:navigate`,kI=288,AI=240,jI=480,MI=56,NI=0,PI=new Set,FI=!1;function II(){FI||(FI=!0,pt(()=>{NI++;for(let e of PI)e()}))}function LI(e){return II(),PI.add(e),()=>PI.delete(e)}function RI(){return NI}function zI(){return 0}function BI(){return(0,E.useSyncExternalStore)(LI,RI,zI)}function VI({sessionID:e,children:t}){let n=BI(),r=(0,E.useMemo)(()=>Ot(`session`),[n]);return r.length===0?(0,R.jsx)(R.Fragment,{children:t}):(0,R.jsxs)(mP,{children:[(0,R.jsx)(hP,{asChild:!0,children:t}),(0,R.jsx)(gP,{className:`min-w-36`,children:r.map(t=>(0,R.jsx)(_P,{onSelect:()=>{try{t.run({sessionID:e})}catch(e){console.error(`[extensions] contextMenu "${t.id}" crashed:`,e)}},children:t.label},t.id))})]})}function HI(e){return/^\/home\/[^/]+$/.test(e)||/^\/Users\/[^/]+$/.test(e)}function UI(e){let t=new Map;for(let n of e){if(!n)continue;let e=n.replace(/\/+$/,``);HI(e)&&t.set(e,(t.get(e)??0)+1)}let n,r=0;for(let[e,i]of t)i>r&&(n=e,r=i);return n}function WI(e,t){if(!e)return`Other`;let n=e.replace(/\/+$/,``);return t&&HI(t)&&n===t?`~`:t&&HI(t)&&n.startsWith(t+`/`)?`~/`+n.slice(t.length+1):n}function GI(e,t){return!!e&&!!t&&e.replace(/\/+$/,``)===t.replace(/\/+$/,``)}function KI(){let e=J(e=>e.sessions),t=J(e=>e.sessionsCursor),n=J(e=>e.activeIDs),r=J(e=>e.currentSessionID),i=J(e=>e.connected),a=J(e=>e.pendingWorkspace),o=J(e=>e.running),s=J(e=>e.queued),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)([]),[f,p]=(0,E.useState)(new Map),[m,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(new Set),v=(0,E.useRef)(null),[y,b]=(0,E.useState)({}),[x,S]=(0,E.useState)({}),[C,w]=(0,E.useState)(!1),[T,D]=(0,E.useState)(kI),[O,k]=(0,E.useState)(!1),[A,j]=(0,E.useState)(!1),M=J(e=>e.uiSignals.explorer);(0,E.useEffect)(()=>{M&&j(!0)},[M]);let N=(0,E.useMemo)(()=>UI(e.map(e=>e.location?.directory)),[e]),ee=e=>!!o[e]||!!s[e],te=(0,E.useMemo)(()=>{let t=new Set;for(let n of e)n.parentID&&ee(n.id)&&t.add(n.parentID);return t},[e,o,s]),P=c.trim(),F=P.toLowerCase();(0,E.useEffect)(()=>{if(P.length<2){d([]);return}let e=!1,t=setTimeout(()=>{G.listSessions({search:P,limit:100}).then(t=>{e||d(t.data.filter(e=>!e.parentID))}).catch(()=>{e||d([])})},250);return()=>{e=!0,clearTimeout(t)}},[P]),(0,E.useEffect)(()=>{if(P.length<2){p(new Map),h(!1);return}let t=!1;h(!0);let n=setTimeout(()=>{oI(P,e,e=>{t||p(new Map(e))}).catch(()=>new Map).then(e=>{t||(p(new Map(e)),h(!1))})},250);return()=>{t=!0,clearTimeout(n)}},[P,e]),(0,E.useEffect)(()=>{if(!a)return;let e=e=>{v.current&&!v.current.contains(e.target)&&Gy(null)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[a]);let ne=(0,E.useMemo)(()=>{let t=new Map,r=new Set;for(let n of e){if(n.parentID||F&&!(n.title??`Untitled session`).toLowerCase().includes(F)&&!WI(n.location?.directory,N).toLowerCase().includes(F)&&!(n.location?.directory??``).toLowerCase().includes(F))continue;r.add(n.id);let e=WI(n.location?.directory,N),i=t.get(e)??[];i.push(n),t.set(e,i)}for(let e of u){if(r.has(e.id))continue;r.add(e.id);let n=WI(e.location?.directory,N),i=t.get(n)??[];i.push(e),t.set(n,i)}let i=e=>!!(o[e]||n.includes(e)),a=[...t.entries()].map(([e,t])=>({name:e,list:[...t].sort((e,t)=>{let n=i(e.id),r=i(t.id);return n===r?t.time.updated-e.time.updated:Number(r)-Number(n)})}));return a.sort((e,n)=>{let r=t.get(e.name)?.some(e=>i(e.id))??!1,a=t.get(n.name)?.some(e=>i(e.id))??!1;return r===a?0:Number(a)-Number(r)}),a},[e,u,F,N,o,n]),re=(0,E.useMemo)(()=>{if(!F||f.size===0)return[];let t=new Set(ne.flatMap(e=>e.list.map(e=>e.id))),n=new Map(e.map(e=>[e.id,e])),r=[];for(let e of f.keys()){if(t.has(e))continue;let i=n.get(e);i&&r.push(i)}return r.sort((e,t)=>t.time.updated-e.time.updated).slice(0,EI)},[e,ne,f,F]),ie=ne.reduce((e,t)=>e+t.list.length,0)+re.length,ae=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},L=(e,t)=>{Ky(e,t),Pv(e)},oe=t!=null,se=e=>{let t=!x[e];S(n=>({...n,[e]:t})),t&&b(t=>({...t,[e]:!1}))},ce=e=>{let t=e??null;Gy(t),r===`__draft__`&&Wy(t)},le=e=>b(t=>({...t,[e]:!t[e]})),ue=e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),k(!0))},de=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&D(Math.min(jI,Math.max(AI,e.clientX)))},fe=e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),k(!1)},pe=()=>w(e=>!e);return(0,R.jsxs)(`aside`,{ref:v,className:`relative flex min-w-0 shrink-0 flex-col overflow-hidden border-r border-border bg-background ${O?`select-none`:``}`,style:{width:C?MI:T},children:[(0,R.jsxs)(`div`,{className:`border-b border-border ${C?`flex flex-col items-center gap-2 px-2 py-2.5`:`flex items-center justify-between gap-2 px-3 py-2.5`}`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${i?`bg-[var(--surface-success-strong)]`:`bg-[var(--surface-warning-strong)]`}`}),C?(0,R.jsx)(`span`,{className:`font-mono text-xs font-semibold text-foreground`,title:`OpenCode`,children:`OC`}):(0,R.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:`OpenCode`})]}),C?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(qI,{collapsed:!0}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,onClick:pe,title:`Expand sidebar`,children:(0,R.jsx)(Ie,{})})]}):(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,R.jsx)(U,{variant:`ghost`,size:`icon`,onClick:pe,title:`Collapse sidebar`,children:(0,R.jsx)(Fe,{})}),(0,R.jsx)(qI,{})]})]}),C?(0,R.jsx)(JI,{groups:ne,current:r,activeIDs:n,onExpand:pe}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`border-b border-border p-2`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(qe,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(nh,{id:`session-search`,value:c,onChange:e=>l(e.target.value),placeholder:`Search sessions`,className:`h-7 pl-7 ${sI?`pr-8`:`pr-12`}`}),(0,R.jsx)(`kbd`,{"aria-hidden":!0,title:`Focus session search (${sI?`Cmd+F`:`Ctrl+F`})`,className:`pointer-events-none absolute top-1/2 right-1.5 -translate-y-1/2 rounded border border-[var(--border-weak-base)] bg-[var(--surface-inset-base)] px-1 py-px font-mono text-[9px] leading-[1.4] text-[var(--text-weaker)]`,children:cI})]}),P.length>=DI&&(0,R.jsxs)(`p`,{className:`mt-1 px-1 text-[10px] text-[var(--text-weaker)]`,"aria-live":`polite`,children:[ie,` matched`,m?` · searching messages…`:``]})]}),(0,R.jsx)(qx,{className:`min-h-0 min-w-0 flex-1`,children:(0,R.jsxs)(`div`,{className:`w-full min-w-0 max-w-full p-2`,children:[re.length>0&&(0,R.jsxs)(`section`,{className:`mb-4 w-full min-w-0 max-w-full last:mb-1`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex min-w-0 items-center gap-2 border-b border-[var(--border-weak-base)] px-2 py-1.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11px] font-medium tracking-wide text-[var(--text-weaker)] uppercase`,children:`Content matches`}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:re.length})]}),re.map(e=>{let t=f.get(e.id)??[],i=g.has(e.id);return(0,R.jsxs)(`div`,{className:`mb-1`,children:[(0,R.jsx)(eL,{id:e.id,title:e.title??`Untitled session`,updated:e.time.updated,active:n.includes(e.id),selected:e.id===r,subagentsActive:te.has(e.id),onSelect:()=>void Pv(e.id)}),t.length>0&&(0,R.jsxs)(`div`,{className:`ml-2 border-l border-[var(--border-weak-base)] pl-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`mb-1 flex w-full cursor-pointer items-center gap-1 text-[10px] text-[var(--text-weaker)] hover:text-[var(--text-weak)]`,children:[(0,R.jsx)(I,{className:`size-3 shrink-0 transition-transform ${i?`-rotate-90`:``}`}),t.length,` `,t.length===1?`message`:`messages`,` match`,t.length===1?``:`es`]}),!i&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1`,children:[t.slice(0,5).map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>L(e.id,t.messageID),className:`cursor-pointer rounded-md bg-[var(--surface-inset-base)] px-2 py-1 text-left text-xs leading-relaxed text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,title:`Open session and scroll to message`,children:(0,R.jsxs)(`span`,{className:`line-clamp-2`,children:[t.snippet.slice(0,t.matchStart),(0,R.jsx)(`mark`,{className:`rounded-sm bg-yellow-500/30 px-0.5 font-medium text-[var(--text-strong)]`,children:t.snippet.slice(t.matchStart,t.matchEnd)}),t.snippet.slice(t.matchEnd)]})},t.messageID)),t.length>5&&(0,R.jsxs)(`span`,{className:`px-2 text-[10px] text-[var(--text-weaker)]`,children:[`+`,t.length-5,` more in this session`]})]})]})]},e.id)})]}),ne.length===0&&re.length===0&&(0,R.jsx)(`p`,{className:`px-2.5 py-4 text-xs text-[var(--text-weak)]`,children:e.length===0?`No sessions yet.`:`No matches.`}),ne.map(e=>{let t=!!x[e.name],i=!!y[e.name],o=t?[]:i?e.list:e.list.filter((e,t)=>t<TI||ee(e.id)),s=e.list.length-o.length,c=e.list.find(e=>e.location?.directory)?.location?.directory??null,l=!!a&&!!c&&GI(a,c);return(0,R.jsxs)(`section`,{className:`mb-4 w-full min-w-0 max-w-full last:mb-1`,children:[(0,R.jsxs)(`div`,{onClick:()=>l?se(e.name):ce(c??void 0),"aria-pressed":l,title:l?`Collapse / expand workspace`:`New session here`,className:`mb-1 flex min-w-0 cursor-pointer select-none items-center gap-2 border-b px-2 py-1.5 text-[11px] font-medium uppercase tracking-wide transition-colors ${l?`ring-1 ring-inset ring-[var(--border-selected)] bg-[var(--surface-raised-base)]`:``} ${l?``:`border-[var(--border-weak-base)]`}`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate ${l?`text-[var(--text-weak)]`:`text-[var(--text-weaker)]`}`,children:e.name}),(0,R.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand ${e.name}`:`Collapse ${e.name}`,onClick:t=>{t.stopPropagation(),se(e.name)},title:t?`Expand workspace`:`Collapse workspace`,className:`ml-auto inline-flex shrink-0 cursor-pointer items-center justify-center rounded-sm p-0.5 hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:(0,R.jsx)(I,{className:`size-3 shrink-0 text-[var(--text-weaker)] transition-transform ${t?`-rotate-90`:``}`})}),l&&(0,R.jsx)(`span`,{className:`shrink-0 cursor-pointer text-[var(--text-weaker)] hover:text-foreground`,title:`New session here`,onClick:e=>{e.stopPropagation(),Wy(c)},children:(0,R.jsx)(He,{className:`size-3.5`})}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:e.list.length})]}),o.map(e=>{let t=n.includes(e.id),i=f.get(e.id)??[],a=g.has(e.id),o=i.length>0&&P.length>=DI;return(0,R.jsxs)(`div`,{className:`mb-0.5`,children:[(0,R.jsx)(eL,{id:e.id,title:e.title??`Untitled session`,updated:e.time.updated,active:t,selected:e.id===r,subagentsActive:te.has(e.id),onSelect:()=>void Pv(e.id)}),o&&(0,R.jsxs)(`div`,{className:`ml-2 border-l border-[var(--border-weak-base)] pl-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>ae(e.id),className:`mb-1 flex w-full cursor-pointer items-center gap-1 text-[10px] text-[var(--text-weaker)] hover:text-[var(--text-weak)]`,children:[(0,R.jsx)(I,{className:`size-3 shrink-0 transition-transform ${a?`-rotate-90`:``}`}),i.length,` `,i.length===1?`message`:`messages`,` match`,i.length===1?``:`es`]}),!a&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1`,children:[i.slice(0,5).map(t=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>L(e.id,t.messageID),className:`cursor-pointer rounded-md bg-[var(--surface-inset-base)] px-2 py-1 text-left text-xs leading-relaxed text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,title:`Open session and scroll to message`,children:(0,R.jsxs)(`span`,{className:`line-clamp-2`,children:[t.snippet.slice(0,t.matchStart),(0,R.jsx)(`mark`,{className:`rounded-sm bg-yellow-500/30 px-0.5 font-medium text-[var(--text-strong)]`,children:t.snippet.slice(t.matchStart,t.matchEnd)}),t.snippet.slice(t.matchEnd)]})},t.messageID)),i.length>5&&(0,R.jsxs)(`span`,{className:`px-2 text-[10px] text-[var(--text-weaker)]`,children:[`+`,i.length-5,` more in this session`]})]})]})]},e.id)}),!t&&s>0&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>le(e.name),className:`mt-1 w-full cursor-pointer rounded-md px-2.5 py-1.5 text-left text-xs text-[var(--text-weaker)] transition-colors hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:i?`Show less`:`Show ${s} more…`})]},e.name)}),oe&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>void Xg(),className:`w-full cursor-pointer rounded-md px-2.5 py-2 text-center text-xs text-[var(--text-weaker)] transition-colors hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-weak)]`,children:`Load more sessions`})]})}),(0,R.jsx)(YI,{onFiles:()=>j(!0)})]}),C&&(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-1 border-t border-border p-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>j(!0),className:`inline-flex cursor-pointer rounded-md p-1.5 text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,title:`Files`,children:(0,R.jsx)(Te,{className:`size-4`})}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>XS(),className:`inline-flex cursor-pointer rounded-md p-1.5 text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,title:`Settings`,children:(0,R.jsx)(Xe,{className:`size-4`})})]}),(0,R.jsx)(Nt,{region:`sidebar`}),(0,R.jsx)(wI,{open:A,onOpenChange:j}),(0,R.jsx)($S,{}),!C&&(0,R.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuemin":AI,"aria-valuemax":jI,"aria-valuenow":T,tabIndex:0,onPointerDown:ue,onPointerMove:de,onPointerUp:fe,onPointerCancel:fe,onDoubleClick:()=>D(kI),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=e.key===`ArrowRight`?16:-16;D(e=>Math.min(jI,Math.max(AI,e+t)))},className:`absolute top-0 right-0 z-20 h-full w-1 cursor-col-resize touch-none bg-transparent transition-colors hover:bg-[var(--border-hover)] focus:bg-[var(--border-selected)] focus:outline-none`})]})}function qI({collapsed:e=!1}){return(0,R.jsx)(U,{asChild:!0,variant:`default`,size:e?`icon`:`sm`,children:(0,R.jsxs)(`a`,{href:Pg,"aria-label":`New session`,title:e?`New session`:void 0,onClick:e=>{e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),Wy(null))},children:[(0,R.jsx)(He,{}),!e&&(0,R.jsx)(`span`,{className:`truncate`,children:`New session`})]})})}function JI({groups:e,current:t,activeIDs:n,onExpand:r}){return(0,R.jsx)(qx,{className:`min-h-0 min-w-0 flex-1`,children:(0,R.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center gap-3 p-2`,children:e.map(e=>(0,R.jsxs)(`section`,{className:`flex w-full flex-col items-center gap-1.5 border-b border-[var(--border-weak-base)] pb-3 last:border-b-0`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:r,title:`${e.name} (${e.list.length} sessions)`,className:`inline-flex size-8 cursor-pointer items-center justify-center rounded-md text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,children:(0,R.jsx)(Te,{className:`size-4`})}),e.list.slice(0,TI).map(e=>(0,R.jsx)(QI,{id:e.id,title:e.title??`Untitled session`,selected:e.id===t,active:n.includes(e.id),onSelect:()=>void Pv(e.id)},e.id)),e.list.length>TI&&(0,R.jsxs)(`button`,{type:`button`,onClick:r,title:`Open workspace to see ${e.list.length-TI} more sessions`,className:`inline-flex size-8 cursor-pointer items-center justify-center rounded-md text-[10px] text-[var(--text-weaker)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`,children:[`+`,e.list.length-TI]})]},e.name))})})}function YI({onFiles:e}){return(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-x-3 gap-y-1 border-t border-border px-3 py-2 text-xs text-[var(--text-weak)]`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:e,className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(Te,{className:`size-3`}),`Files`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>XS(),className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(Xe,{className:`size-3`}),`Settings`]}),(0,R.jsx)(ZI,{})]})})}function XI(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),e}function ZI(){let e=XI(),t=(0,E.useMemo)(()=>Tt(),[e]);return t.length===0?null:(0,R.jsx)(R.Fragment,{children:t.map(e=>(0,R.jsxs)(`a`,{href:`/ext/${e.id}`,title:e.description?`${e.title} — ${e.description}`:e.title,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),window.history.pushState({},``,`/ext/${e.id}`),window.dispatchEvent(new Event(OI)))},className:`inline-flex cursor-pointer items-center gap-1.5 hover:text-foreground`,children:[(0,R.jsx)(We,{className:`size-3`}),e.title]},e.id))})}function QI({id:e,title:t,selected:n,active:r,onSelect:i}){return(0,R.jsxs)(`a`,{href:Fg(e),title:t,"aria-label":t,"aria-current":n?`page`:void 0,onClick:e=>$I(e,i),onMouseEnter:()=>Xv(e),onFocus:()=>Xv(e),className:`relative inline-flex size-8 items-center justify-center rounded-md text-xs font-medium transition-colors ${n?`bg-[var(--surface-raised-base)] text-foreground`:`text-[var(--text-weak)] hover:bg-[var(--surface-base-hover)] hover:text-foreground`}`,children:[(t.trim()[0]??`S`).toUpperCase(),r&&(0,R.jsx)(`span`,{className:`absolute right-0.5 bottom-0.5 size-1.5 rounded-full bg-[var(--surface-success-strong)]`})]})}function $I(e,t){e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t())}function eL({id:e,title:t,updated:n,active:r,selected:i,subagentsActive:a,onSelect:o}){let[s,c]=(0,E.useState)(!1);return(0,R.jsxs)(VI,{sessionID:e,children:[(0,R.jsx)(Nt,{region:`sidebar.session.before`,sessionID:e}),(0,R.jsxs)(`div`,{className:`group relative mb-0.5 w-full min-w-0 max-w-full`,children:[(0,R.jsxs)(`a`,{href:Fg(e),title:t,"aria-current":i?`page`:void 0,onClick:e=>$I(e,o),onMouseEnter:()=>Xv(e),onFocus:()=>Xv(e),className:`block w-full min-w-0 max-w-full overflow-hidden rounded-md px-2.5 py-2 pr-12 transition-colors ${i?`bg-[var(--surface-raised-base)]`:`hover:bg-[var(--surface-base-hover)]`}`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2`,children:[a&&(0,R.jsx)(`span`,{title:`Subagents running`,"aria-label":`Subagents running`,className:`size-1.5 shrink-0 animate-pulse rounded-full bg-[var(--surface-success-strong)]`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:t}),r&&(0,R.jsx)(Dx,{className:`shrink-0 border-transparent bg-[var(--surface-success-base)] text-[var(--text-on-success-base)]`,children:`run`})]}),(0,R.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 max-w-full items-center gap-2 text-xs text-[var(--text-weak)]`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-[var(--text-weaker)]`,children:e.slice(0,12)}),(0,R.jsx)(`span`,{className:`shrink-0`,children:pS(n)})]})]}),(0,R.jsx)(`div`,{className:`invisible absolute right-2 bottom-1.5 flex items-center gap-1 group-hover:visible group-focus-within:visible`,children:s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--text-on-critical-strong)] hover:text-[var(--text-on-critical-base)]`,onClick:()=>{G.deleteSession(e).then(Yg),i&&Pv(null)},children:`yes`}),(0,R.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--text-weak)] hover:text-foreground`,onClick:()=>c(!1),children:`no`})]}):(0,R.jsx)(`button`,{type:`button`,title:`Delete session`,"aria-label":`Delete ${t}`,className:`cursor-pointer text-[var(--text-weaker)] hover:text-[var(--text-on-critical-base)]`,onClick:()=>c(!0),children:(0,R.jsx)(at,{className:`size-3.5`})})})]}),(0,R.jsx)(Nt,{region:`sidebar.session.after`,sessionID:e})]})}function tL({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,R.jsx)(rm,{"data-slot":`separator`,decorative:n,orientation:t,className:V(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}var nL=Object.defineProperty,rL=Object.getOwnPropertyDescriptor,iL=(e,t)=>{for(var n in t)nL(e,n,{get:t[n],enumerable:!0})},aL=(e,t,n,r)=>{for(var i=r>1?void 0:r?rL(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&&nL(t,n,i),i},Z=(e,t)=>(n,r)=>t(n,r,e),oL=`Terminal input`,sL={get:()=>oL,set:e=>oL=e},cL=`Too much output to announce, navigate to rows manually to read`,lL={get:()=>cL,set:e=>cL=e};function uL(e){return e.replace(/\r?\n/g,`\r`)}function dL(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function fL(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function pL(e,t,n,r){e.stopPropagation(),e.clipboardData&&mL(e.clipboardData.getData(`text/plain`),t,n,r)}function mL(e,t,n,r){e=uL(e),e=dL(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function hL(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 gL(e,t,n,r,i){hL(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function _L(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function vL(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 yL=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}},bL=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}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}},xL=``,SL=` `,CL=class e{constructor(){this.fg=0,this.bg=0,this.extended=new wL}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)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},wL=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}},TL=class e extends CL{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new wL,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?_L(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()]}},EL=`di$target`,DL=`di$dependencies`,OL=new Map;function kL(e){return e[DL]||[]}function AL(e){if(OL.has(e))return OL.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);jL(t,e,r)};return t._id=e,OL.set(e,t),t}function jL(e,t,n){t[EL]===t?t[DL].push({id:e,index:n}):(t[DL]=[{id:e,index:n}],t[EL]=t)}var ML=AL(`BufferService`),NL=AL(`CoreMouseService`),PL=AL(`CoreService`),FL=AL(`CharsetService`),IL=AL(`InstantiationService`),LL=AL(`LogService`),RL=AL(`OptionsService`),zL=AL(`OscLinkService`),BL=AL(`UnicodeService`),VL=AL(`DecorationService`),HL=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 TL,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}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):UL(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)}};HL=aL([Z(0,ML),Z(1,RL),Z(2,zL)],HL);function UL(e,t){if(confirm(`Do you want to navigate to ${t}?
104
104
 
105
- 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 UL=kL(`CharSizeService`),WL=kL(`CoreBrowserService`),GL=kL(`MouseService`),KL=kL(`RenderService`),qL=kL(`SelectionService`),JL=kL(`CharacterJoinerService`),YL=kL(`ThemeService`),XL=kL(`LinkProviderService`),ZL=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?rR.isErrorNoTelemetry(e)?new rR(e.message+`
105
+ 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 WL=AL(`CharSizeService`),GL=AL(`CoreBrowserService`),KL=AL(`MouseService`),qL=AL(`RenderService`),JL=AL(`SelectionService`),YL=AL(`CharacterJoinerService`),XL=AL(`ThemeService`),ZL=AL(`LinkProviderService`),QL=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?iR.isErrorNoTelemetry(e)?new iR(e.message+`
106
106
 
107
107
  `+e.stack):Error(e.message+`
108
108
 
109
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function QL(e){eR(e)||ZL.onUnexpectedError(e)}var $L=`Canceled`;function eR(e){return e instanceof tR||e instanceof Error&&e.name===$L&&e.message===$L}var tR=class extends Error{constructor(){super($L),this.name=this.message}};function nR(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var rR=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},iR=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function aR(e,t=0){return e[e.length-(1+t)]}var oR;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(oR||={});var sR=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||oR.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};sR.empty=new sR(e=>{});function cR(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var lR;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(lR||={});var uR=null;function dR(e){return uR?.trackDisposable(e),e}function fR(e){uR?.markAsDisposed(e)}function pR(e,t){uR?.setParent(e,t)}function mR(e){return uR?.markAsSingleton(e),e}function hR(e){if(lR.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function gR(...e){return _R(()=>hR(e))}function _R(e){let t=dR({dispose:cR(()=>{fR(t),e()})});return t}var vR=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,dR(this)}dispose(){this._isDisposed||(fR(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{hR(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return pR(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),pR(e,null))}};vR.DISABLE_DISPOSED_WARNING=!1;var yR=vR,bR=class{constructor(){this._store=new yR,dR(this),pR(this._store,this)}dispose(){fR(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};bR.None=Object.freeze({dispose(){}});var xR=class{constructor(){this._isDisposed=!1,dR(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&pR(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,fR(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&pR(e,null),e}},SR=typeof window==`object`?window:globalThis,CR=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};CR.Undefined=new CR(void 0);var wR=CR,TR=class{constructor(){this._first=wR.Undefined,this._last=wR.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===wR.Undefined}clear(){let e=this._first;for(;e!==wR.Undefined;){let t=e.next;e.prev=wR.Undefined,e.next=wR.Undefined,e=t}this._first=wR.Undefined,this._last=wR.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new wR(e);if(this._first===wR.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==wR.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==wR.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==wR.Undefined&&e.next!==wR.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===wR.Undefined&&e.next===wR.Undefined?(this._first=wR.Undefined,this._last=wR.Undefined):e.next===wR.Undefined?(this._last=this._last.prev,this._last.next=wR.Undefined):e.prev===wR.Undefined&&(this._first=this._first.next,this._first.prev=wR.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==wR.Undefined;)yield e.element,e=e.next}},ER=globalThis.performance&&typeof globalThis.performance.now==`function`,DR=class e{static create(t){return new e(t)}constructor(e){this._now=ER&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},OR;(e=>{e.None=()=>bR.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(gR(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Q({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Q({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Q({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Q;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Q(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof yR?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(OR||={});var kR=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new DR,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};kR.all=new Set,kR._idPool=0;var AR=kR,jR=-1,MR=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new FR(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};MR._idPool=1;var NR=MR,PR=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
109
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function $L(e){tR(e)||QL.onUnexpectedError(e)}var eR=`Canceled`;function tR(e){return e instanceof nR||e instanceof Error&&e.name===eR&&e.message===eR}var nR=class extends Error{constructor(){super(eR),this.name=this.message}};function rR(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var iR=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},aR=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function oR(e,t=0){return e[e.length-(1+t)]}var sR;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(sR||={});var cR=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||sR.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};cR.empty=new cR(e=>{});function lR(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var uR;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(uR||={});var dR=null;function fR(e){return dR?.trackDisposable(e),e}function pR(e){dR?.markAsDisposed(e)}function mR(e,t){dR?.setParent(e,t)}function hR(e){return dR?.markAsSingleton(e),e}function gR(e){if(uR.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function _R(...e){return vR(()=>gR(e))}function vR(e){let t=fR({dispose:lR(()=>{pR(t),e()})});return t}var yR=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,fR(this)}dispose(){this._isDisposed||(pR(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{gR(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return mR(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),mR(e,null))}};yR.DISABLE_DISPOSED_WARNING=!1;var bR=yR,xR=class{constructor(){this._store=new bR,fR(this),mR(this._store,this)}dispose(){pR(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};xR.None=Object.freeze({dispose(){}});var SR=class{constructor(){this._isDisposed=!1,fR(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&mR(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,pR(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&mR(e,null),e}},CR=typeof window==`object`?window:globalThis,wR=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};wR.Undefined=new wR(void 0);var TR=wR,ER=class{constructor(){this._first=TR.Undefined,this._last=TR.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===TR.Undefined}clear(){let e=this._first;for(;e!==TR.Undefined;){let t=e.next;e.prev=TR.Undefined,e.next=TR.Undefined,e=t}this._first=TR.Undefined,this._last=TR.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new TR(e);if(this._first===TR.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==TR.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==TR.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==TR.Undefined&&e.next!==TR.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===TR.Undefined&&e.next===TR.Undefined?(this._first=TR.Undefined,this._last=TR.Undefined):e.next===TR.Undefined?(this._last=this._last.prev,this._last.next=TR.Undefined):e.prev===TR.Undefined&&(this._first=this._first.next,this._first.prev=TR.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==TR.Undefined;)yield e.element,e=e.next}},DR=globalThis.performance&&typeof globalThis.performance.now==`function`,OR=class e{static create(t){return new e(t)}constructor(e){this._now=DR&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},kR;(e=>{e.None=()=>xR.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(_R(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Q({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Q({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Q({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Q({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Q;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Q(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof bR?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(kR||={});var AR=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new OR,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};AR.all=new Set,AR._idPool=0;var jR=AR,MR=-1,NR=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new IR(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};NR._idPool=1;var PR=NR,FR=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
110
110
  `).slice(2).join(`
111
- `))}},FR=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},IR=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},LR=0,RR=class{constructor(e){this.value=e,this.id=LR++}},zR=2,BR,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=jR>0||this._options?.leakWarningThreshold?new NR(e?.onListenerError??QL,this._options?.leakWarningThreshold??jR):void 0,this._perfMon=this._options?._profName?new AR(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(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 IR(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||QL)(n),bR.None}if(this._disposed)return bR.None;t&&(e=e.bind(t));let r=new RR(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=PR.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof RR?(this._deliveryQueue??=new VR,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=_R(()=>{BR?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof yR?n.add(a):Array.isArray(n)&&n.push(a),BR){let e=Error().stack.split(`
111
+ `))}},IR=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},LR=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},RR=0,zR=class{constructor(e){this.value=e,this.id=RR++}},BR=2,VR,Q=class{constructor(e){this._size=0,this._options=e,this._leakageMon=MR>0||this._options?.leakWarningThreshold?new PR(e?.onListenerError??$L,this._options?.leakWarningThreshold??MR):void 0,this._perfMon=this._options?._profName?new jR(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(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 LR(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||$L)(n),xR.None}if(this._disposed)return xR.None;t&&(e=e.bind(t));let r=new zR(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=FR.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof zR?(this._deliveryQueue??=new HR,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=vR(()=>{VR?.unregister(a),i?.(),this._removeListener(r)});if(n instanceof bR?n.add(a):Array.isArray(n)&&n.push(a),VR){let e=Error().stack.split(`
112
112
  `).slice(2,3).join(`
113
- `).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);BR.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*zR<=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||QL;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 RR)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}},VR=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}},HR=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};HR.INSTANCE=new HR;var UR=HR;function WR(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}UR.INSTANCE.onDidChangeZoomLevel;function GR(e){return UR.INSTANCE.getZoomFactor(e)}UR.INSTANCE.onDidChangeFullscreen;var KR=typeof navigator==`object`?navigator.userAgent:``,qR=KR.indexOf(`Firefox`)>=0,JR=KR.indexOf(`AppleWebKit`)>=0,YR=KR.indexOf(`Chrome`)>=0,XR=!YR&&KR.indexOf(`Safari`)>=0;KR.indexOf(`Electron/`),KR.indexOf(`Android`);var ZR=!1;if(typeof SR.matchMedia==`function`){let e=SR.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=SR.matchMedia(`(display-mode: fullscreen)`);ZR=e.matches,WR(SR,e,({matches:e})=>{ZR&&t.matches||(ZR=e)})}function QR(){return ZR}var $R=`en`,ez=!1,tz=!1,nz=!1,rz=!1,iz=!1,az=$R,oz,sz=globalThis,cz;typeof sz.vscode<`u`&&typeof sz.vscode.process<`u`?cz=sz.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(cz=process);var lz=typeof cz?.versions?.electron==`string`&&cz?.type===`renderer`;if(typeof cz==`object`){ez=cz.platform===`win32`,tz=cz.platform===`darwin`,nz=cz.platform===`linux`,nz&&cz.env.SNAP&&cz.env.SNAP_REVISION,cz.env.CI||cz.env.BUILD_ARTIFACTSTAGINGDIRECTORY,az=$R;let e=cz.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,az=t.resolvedLanguage||$R,t.languagePack?.translationsConfigFile}catch{}rz=!0}else typeof navigator==`object`&&!lz?(oz=navigator.userAgent,ez=oz.indexOf(`Windows`)>=0,tz=oz.indexOf(`Macintosh`)>=0,(oz.indexOf(`Macintosh`)>=0||oz.indexOf(`iPad`)>=0||oz.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,nz=oz.indexOf(`Linux`)>=0,oz?.indexOf(`Mobi`),iz=!0,az=globalThis._VSCODE_NLS_LANGUAGE||$R,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var uz=ez,dz=tz,fz=nz,pz=rz;iz&&typeof sz.importScripts==`function`&&sz.origin;var mz=oz,hz=az,gz;(e=>{function t(){return hz}e.value=t;function n(){return hz.length===2?hz===`en`:hz.length>=3&&hz[0]===`e`&&hz[1]===`n`&&hz[2]===`-`}e.isDefaultVariant=n;function r(){return hz===`en`}e.isDefault=r})(gz||={});var _z=typeof sz.postMessage==`function`&&!sz.importScripts;(()=>{if(_z){let e=[];sz.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}),sz.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var vz=!!(mz&&mz.indexOf(`Chrome`)>=0);mz&&mz.indexOf(`Firefox`),!vz&&mz&&mz.indexOf(`Safari`),mz&&mz.indexOf(`Edg/`),mz&&mz.indexOf(`Android`);var yz=typeof navigator==`object`?navigator:{};pz||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||yz&&yz.clipboard&&yz.clipboard.writeText,pz||yz&&yz.clipboard&&yz.clipboard.readText,pz||QR()||yz.keyboard,`ontouchstart`in SR||yz.maxTouchPoints,SR.PointerEvent&&(`ontouchstart`in SR||navigator.maxTouchPoints);var bz=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},xz=new bz,Sz=new bz,Cz=new bz,wz=Array(230),Tz;(e=>{function t(e){return xz.keyCodeToStr(e)}e.toString=t;function n(e){return xz.strToKeyCode(e)}e.fromString=n;function r(e){return Sz.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Cz.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Sz.strToKeyCode(e)||Cz.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return xz.keyCodeToStr(e)}e.toElectronAccelerator=o})(Tz||={});var Ez=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Dz([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Dz=class{constructor(e){if(e.length===0)throw nR(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Oz(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return Tz.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(qR)switch(t){case 59:return 85;case 60:if(fz)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(dz)return 57;break}else if(JR&&(dz&&t===93||!dz&&t===92))return 57;return wz[t]||0}var kz=dz?256:2048,Az=512,jz=1024,Mz=dz?2048:256,Nz=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=Oz(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=kz),this.altKey&&(t|=Az),this.shiftKey&&(t|=jz),this.metaKey&&(t|=Mz),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Ez(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Pz=new WeakMap;function Fz(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var Iz=class{static getSameOriginWindowChain(e){let t=Pz.get(e);if(!t){t=[],Pz.set(e,t);let n=e,r;do r=Fz(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},Lz=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=Iz.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Rz=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(YR){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?qR&&!dz?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=XR&&uz?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?qR&&!dz?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},zz=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Bz;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Vz?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:OR.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:zz})})(Bz||={});var Vz=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?zz:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Hz=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new iR(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new iR(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Uz=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new iR(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=_R(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Wz;(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})(Wz||={});var Gz=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 Q,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 OR.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())}};Gz.EMPTY=Gz.fromArray([]);function Kz(e){return qz(e,0)}function qz(e,t){switch(typeof e){case`object`:return e===null?Jz(349,t):Array.isArray(e)?Zz(e,t):Qz(e,t);case`string`:return Xz(e,t);case`boolean`:return Yz(e,t);case`number`:return Jz(e,t);case`undefined`:return Jz(937,t);default:return Jz(617,t)}}function Jz(e,t){return(t<<5)-t+e|0}function Yz(e,t){return Jz(e?433:863,t)}function Xz(e,t){t=Jz(149417,t);for(let n=0,r=e.length;n<r;n++)t=Jz(e.charCodeAt(n),t);return t}function Zz(e,t){return t=Jz(104579,t),e.reduce((e,t)=>qz(t,e),t)}function Qz(e,t){return t=Jz(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Xz(n,t),qz(e[n],t)),t)}var{registerWindow:$z,getWindow:eB,getDocument:tB,getWindows:nB,getWindowsCount:rB,getWindowId:iB,getWindowById:aB,hasWindow:oB,onDidRegisterWindow:sB,onWillUnregisterWindow:cB,onDidUnregisterWindow:lB}=function(){let e=new Map,t={window:SR,disposables:new yR};e.set(SR.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return bR.None;let a=new yR,o={window:t,disposables:a.add(new yR)};return e.set(t.vscodeWindowId,o),a.add(_R(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(dB(t,bB.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:SR},getDocument(e){return eB(e).document}}}(),uB=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function dB(e,t,n,r){return new uB(e,t,n,r)}function fB(e,t){return function(n){return t(new Lz(e,n))}}function pB(e){return function(t){return e(new Nz(t))}}var mB=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=fB(eB(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=pB(n)),dB(e,t,i,r)},hB,gB=class extends Uz{constructor(e){super(),this.defaultTarget=e&&eB(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},_B=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){QL(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(_B.sort),a.shift().execute();r.set(i,!1)};hB=(t,r,a=0)=>{let o=iB(t),s=new _B(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var vB=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};vB.None=new vB(0,0);function yB(e){let t=e.getBoundingClientRect(),n=eB(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Kz(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(_R(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var bB={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:JR?`webkitAnimationStart`:`animationstart`,ANIMATION_END:JR?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:JR?`webkitAnimationIteration`:`animationiteration`},xB=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=SB(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=SB(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=SB(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=SB(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=SB(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=SB(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=SB(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=SB(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=SB(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=SB(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=SB(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=SB(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=SB(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=SB(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function SB(e){return typeof e==`number`?`${e}px`:e}function CB(e){return new xB(e)}var wB=class{constructor(){this._hooks=new yR,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(_R(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=eB(e)}this._hooks.add(dB(a,bB.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(dB(a,bB.POINTER_UP,e=>this.stopMonitoring(!0)))}};function TB(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var EB;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(EB||={});var DB=class e extends bR{constructor(){super(),this.dispatched=!1,this.targets=new TR,this.ignoreTargets=new TR,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(OR.runAndSubscribe(sB,({window:e,disposables:t})=>{t.add(dB(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(dB(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(dB(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:SR,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=mR(new e),_R(e.INSTANCE.targets.push(t))):bR.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=mR(new e),_R(e.INSTANCE.ignoreTargets.push(t))):bR.None}static isTouchDevice(){return`ontouchstart`in SR||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(EB.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-aR(s.rollingPageX))<30&&Math.abs(s.initialPageY-aR(s.rollingPageY))<30){let e=this.newGestureEvent(EB.Tap,s.initialTarget);e.pageX=aR(s.rollingPageX),e.pageY=aR(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-aR(s.rollingPageX))<30&&Math.abs(s.initialPageY-aR(s.rollingPageY))<30){let e=this.newGestureEvent(EB.Contextmenu,s.initialTarget);e.pageX=aR(s.rollingPageX),e.pageY=aR(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=aR(s.rollingPageX),n=aR(s.rollingPageY),i=aR(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(EB.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===EB.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===EB.Change||t.type===EB.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=hB(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(EB.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(EB.Change,i.initialTarget);a.translationX=r.pageX-aR(i.rollingPageX),a.translationY=r.pageY-aR(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};DB.SCROLL_FRICTION=-.005,DB.HOLD_DELAY=700,DB.CLEAR_TAP_COUNT_TIME=400,iL([TB],DB,`isTouchDevice`,1);var OB=DB,kB=class extends bR{onclick(e,t){this._register(dB(e,bB.CLICK,n=>t(new Lz(eB(e),n))))}onmousedown(e,t){this._register(dB(e,bB.MOUSE_DOWN,n=>t(new Lz(eB(e),n))))}onmouseover(e,t){this._register(dB(e,bB.MOUSE_OVER,n=>t(new Lz(eB(e),n))))}onmouseleave(e,t){this._register(dB(e,bB.MOUSE_LEAVE,n=>t(new Lz(eB(e),n))))}onkeydown(e,t){this._register(dB(e,bB.KEY_DOWN,e=>t(new Nz(e))))}onkeyup(e,t){this._register(dB(e,bB.KEY_UP,e=>t(new Nz(e))))}oninput(e,t){this._register(dB(e,bB.INPUT,t))}onblur(e,t){this._register(dB(e,bB.BLUR,t))}onfocus(e,t){this._register(dB(e,bB.FOCUS,t))}onchange(e,t){this._register(dB(e,bB.CHANGE,t))}ignoreGesture(e){return OB.ignoreTarget(e)}},AB=11,jB=class extends kB{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=AB+`px`,this.domNode.style.height=AB+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new wB),this._register(mB(this.bgDomNode,bB.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(mB(this.domNode,bB.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new gB),this._pointerdownScheduleRepeatTimer=this._register(new Hz)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,eB(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},MB=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},NB=class extends bR{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new MB(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new LB(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=LB.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},PB=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function FB(e,t){let n=t-e;return function(t){return e+n*zB(t)}}function IB(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var LB=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),IB(FB(e,r),FB(i,t),.33)}return FB(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new PB(this.scrollLeft(t),this.scrollTop(t),!1):new PB(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function RB(e){return e**3}function zB(e){return 1-RB(1-e)}var BB=class extends bR{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Hz)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},VB=140,HB=class extends kB{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new BB(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new wB),this._shouldRender=!0,this.domNode=CB(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(dB(this.domNode.domNode,bB.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new jB(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=CB(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(dB(this.slider.domNode,bB.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=yB(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(uz&&a>VB){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},UB=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},WB=class extends HB{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new UB(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},GB=class extends HB{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new UB(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},KB=500,qB=50,JB=!0,YB=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},XB=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(YR){let t=GR(eB(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new YB(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};XB.INSTANCE=new XB;var ZB=XB,QB=class extends kB{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=eV(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new GB(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new WB(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=CB(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=CB(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=CB(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new Hz),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=hR(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,dz&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Rz(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=hR(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(dB(this._listenOnDomNode,bB.MOUSE_WHEEL,e=>{this._onMouseWheel(new Rz(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=ZB.INSTANCE;JB&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!dz&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=qB*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=qB*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(JB&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),KB)}},$B=class extends QB{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function eV(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,dz&&(t.className+=` mac`),t}var tV=class extends bR{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new NB({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>hB(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new $B(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(OR.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(_R(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(_R(()=>this._styleElement.remove())),this._register(OR.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
114
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};tV=iL([Z(2,jL),Z(3,WL),Z(4,ML),Z(5,YL),Z(6,LL),Z(7,KL)],tV);var nV=class extends bR{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(_R(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};nV=iL([Z(1,jL),Z(2,WL),Z(3,BL),Z(4,KL)],nV);var rV=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},iV={full:0,left:0,center:0,right:0},aV={full:0,left:0,center:0,right:0},oV={full:0,left:0,center:0,right:0},sV=class extends bR{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new rV,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(_R(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);aV.full=this._canvas.width,aV.left=e,aV.center=t,aV.right=e,this._refreshDrawHeightConstants(),oV.full=1,oV.left=1,oV.center=1+aV.left,oV.right=1+aV.left+aV.center}_refreshDrawHeightConstants(){iV.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);iV.left=t,iV.center=t,iV.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*iV.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*iV.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*iV.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*iV.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(oV[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-iV[e.position||`full`]/2),aV[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+iV[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};sV=iL([Z(2,jL),Z(3,BL),Z(4,KL),Z(5,LL),Z(6,YL),Z(7,WL)],sV);var $;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
115
- `,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var cV;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(cV||={});var lV;(e=>e.ST=`${$.ESC}\\`)(lV||={});var uV=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};uV=iL([Z(2,jL),Z(3,LL),Z(4,NL),Z(5,KL)],uV);var dV=0,fV=0,pV=0,mV=0,hV={css:`#00000000`,rgba:0},gV;(e=>{function t(e,t,n,r){return r===void 0?`#${xV(e)}${xV(t)}${xV(n)}`:`#${xV(e)}${xV(t)}${xV(n)}${xV(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})(gV||={});var _V;(e=>{function t(e,t){if(mV=(t.rgba&255)/255,mV===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 dV=a+Math.round((n-a)*mV),fV=o+Math.round((r-o)*mV),pV=s+Math.round((i-s)*mV),{css:gV.toCss(dV,fV,pV),rgba:gV.toRgba(dV,fV,pV)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=bV.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return gV.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[dV,fV,pV]=bV.toChannels(t),{css:gV.toCss(dV,fV,pV),rgba:t}}e.opaque=i;function a(e,t){return mV=Math.round(t*255),[dV,fV,pV]=bV.toChannels(e.rgba),{css:gV.toCss(dV,fV,pV,mV),rgba:gV.toRgba(dV,fV,pV,mV)}}e.opacity=a;function o(e,t){return mV=e.rgba&255,a(e,mV*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(_V||={});var vV;(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 dV=parseInt(e.slice(1,2).repeat(2),16),fV=parseInt(e.slice(2,3).repeat(2),16),pV=parseInt(e.slice(3,4).repeat(2),16),gV.toColor(dV,fV,pV);case 5:return dV=parseInt(e.slice(1,2).repeat(2),16),fV=parseInt(e.slice(2,3).repeat(2),16),pV=parseInt(e.slice(3,4).repeat(2),16),mV=parseInt(e.slice(4,5).repeat(2),16),gV.toColor(dV,fV,pV,mV);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 dV=parseInt(r[1]),fV=parseInt(r[2]),pV=parseInt(r[3]),mV=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),gV.toColor(dV,fV,pV,mV);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[dV,fV,pV,mV]=t.getImageData(0,0,1,1).data,mV!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:gV.toRgba(dV,fV,pV,mV),css:e}}e.toColor=r})(vV||={});var yV;(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})(yV||={});var bV;(e=>{function t(e,t){if(mV=(t&255)/255,mV===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 dV=a+Math.round((n-a)*mV),fV=o+Math.round((r-o)*mV),pV=s+Math.round((i-s)*mV),gV.toRgba(dV,fV,pV)}e.blend=t;function n(e,t,n){let a=yV.relativeLuminance(e>>8),o=yV.relativeLuminance(t>>8);if(SV(a,o)<n){if(o<a){let o=r(e,t,n),s=SV(a,yV.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>SV(a,yV.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=SV(a,yV.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>SV(a,yV.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=SV(yV.relativeLuminance2(o,s,c),yV.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=SV(yV.relativeLuminance2(o,s,c),yV.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=SV(yV.relativeLuminance2(o,s,c),yV.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=SV(yV.relativeLuminance2(o,s,c),yV.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})(bV||={});function xV(e){let t=e.toString(16);return t.length<2?`0`+t:t}function SV(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var CV=class extends SL{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},wV=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new wL}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||xL.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)wV._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||xL.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};wV=iL([Z(0,jL)],wV);function TV(e){return 57508<=e&&e<=57558}function EV(e){return 9472<=e&&e<=9631}function DV(e){return TV(e)||EV(e)}function OV(){return{css:{canvas:kV(),cell:kV()},device:{canvas:kV(),cell:kV(),char:{width:0,height:0,left:0,top:0}}}}function kV(){return{width:0,height:0}}var AV=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new wL,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new CV(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let ee=this._isCellInSelection(k,t),te=n&&k===a,P=O&&k>=l&&k<=u,F=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{F=!0});let ne=N.getChars()||xL;if(ne===` `&&(N.isUnderline()||N.isOverline())&&(ne=`\xA0`),T=m*s-c.get(ne,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(ee&&w||!ee&&!w&&N.bg===y)&&(ee&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&P===S&&T===C&&!te&&!A&&!F&&j){N.isInvisible()?_+=xL:_+=ne,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=P,C=T,w=ee,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&te&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`);break;default:break}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?xL:N.getChars()||xL,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${SL.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),P&&(h.style.textDecoration=`underline`);let re=N.getFgColor(),ie=N.getFgColorMode(),ae=N.getBgColor(),I=N.getBgColorMode(),L=!!N.isInverse();if(L){let e=re;re=ae,ae=e;let t=ie;ie=I,I=t}let oe,se,ce=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&ce||(e.backgroundColorRGB&&(I=50331648,ae=e.backgroundColorRGB.rgba>>8&16777215,oe=e.backgroundColorRGB),e.foregroundColorRGB&&(ie=50331648,re=e.foregroundColorRGB.rgba>>8&16777215,se=e.foregroundColorRGB),ce=e.options.layer===`top`)}),!ce&&ee&&(oe=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ae=oe.rgba>>8&16777215,I=50331648,ce=!0,p.selectionForeground&&(ie=50331648,re=p.selectionForeground.rgba>>8&16777215,se=p.selectionForeground)),ce&&D.push(`xterm-decoration-top`);let le;switch(I){case 16777216:case 33554432:le=p.ansi[ae],D.push(`xterm-bg-${ae}`);break;case 50331648:le=gV.toColor(ae>>16,ae>>8&255,ae&255),this._addStyle(h,`background-color:#${jV((ae>>>0).toString(16),`0`,6)}`);break;default:L?(le=p.foreground,D.push(`xterm-bg-257`)):le=p.background}switch(oe||N.isDim()&&(oe=_V.multiplyOpacity(le,.5)),ie){case 16777216:case 33554432:N.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(h,le,p.ansi[re],N,oe,void 0)||D.push(`xterm-fg-${re}`);break;case 50331648:let e=gV.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(h,le,e,N,oe,se)||this._addStyle(h,`color:#${jV(re.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,le,p.foreground,N,oe,se)||L&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!te&&!A&&!F&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||DV(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=_V.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};AV=iL([Z(1,JL),Z(2,LL),Z(3,WL),Z(4,NL),Z(5,BL),Z(6,YL)],AV);function jV(e,t,n){for(;e.length<n;)e=t+e;return e}var MV=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},NV=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function PV(){return new NV}var FV=`xterm-dom-renderer-owner-`,IV=`xterm-rows`,LV=`xterm-fg-`,RV=`xterm-bg-`,zV=`xterm-focus`,BV=`xterm-selection`,VV=1,HV=class extends bR{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=VV++,this._rowElements=[],this._selectionRenderModel=PV(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(IV),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(BV),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=OV(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(AV,document),this._element.classList.add(FV+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(_R(()=>{this._element.classList.remove(FV+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new MV(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${IV} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${IV} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${IV} .xterm-dim { color: ${_V.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${IV}.${zV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${IV}.${zV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${IV}.${zV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${IV} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${IV} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${IV} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${IV} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${IV} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${BV} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${BV} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${BV} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${LV}${n} { color: ${r.css}; }${this._terminalSelector} .${LV}${n}.xterm-dim { color: ${_V.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${RV}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${LV}257 { color: ${_V.opaque(e.background).css}; }${this._terminalSelector} .${LV}257.xterm-dim { color: ${_V.multiplyOpacity(_V.opaque(e.background),.5).css}; }${this._terminalSelector} .${RV}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(zV),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(zV),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${FV}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};HV=iL([Z(7,FL),Z(8,UL),Z(9,LL),Z(10,jL),Z(11,NL),Z(12,WL),Z(13,YL)],HV);var UV=class extends bR{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new KV(this._optionsService))}catch{this._measureStrategy=this._register(new GV(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};UV=iL([Z(2,LL)],UV);var WV=class extends bR{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},GV=class extends WV{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},KV=class extends WV{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},qV=class extends bR{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new JV(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(OR.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(dB(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(dB(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},JV=class extends bR{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new xR),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_R(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=dB(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},YV=class extends bR{constructor(){super(),this.linkProviders=[],this._register(_R(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function XV(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function ZV(e,t,n,r,i,a,o,s,c){if(!a)return;let l=XV(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var QV=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return ZV(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=XV(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};QV=iL([Z(0,KL),Z(1,UL)],QV);var $V=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},eH={};rL(eH,{getSafariVersion:()=>sH,isChromeOS:()=>pH,isFirefox:()=>iH,isIpad:()=>lH,isIphone:()=>uH,isLegacyEdge:()=>aH,isLinux:()=>fH,isMac:()=>cH,isNode:()=>tH,isSafari:()=>oH,isWindows:()=>dH});var tH=typeof process<`u`&&`title`in process,nH=tH?`node`:navigator.userAgent,rH=tH?`node`:navigator.platform,iH=nH.includes(`Firefox`),aH=nH.includes(`Edge`),oH=/^((?!chrome|android).)*safari/i.test(nH);function sH(){if(!oH)return 0;let e=nH.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var cH=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(rH),lH=rH===`iPad`,uH=rH===`iPhone`,dH=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(rH),fH=rH.indexOf(`Linux`)>=0,pH=/\bCrOS\b/.test(nH),mH=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},hH=class extends mH{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},gH=class extends mH{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},_H=!tH&&`requestIdleCallback`in window?gH:hH,vH=class{constructor(){this._queue=new _H}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},yH=class extends bR{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new xR),this._pausedResizeTask=new vH,this._observerDisposable=this._register(new xR),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new $V((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new bH(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_R(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=_R(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};yH=iL([Z(2,LL),Z(3,UL),Z(4,NL),Z(5,BL),Z(6,jL),Z(7,WL),Z(8,YL)],yH);var bH=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function xH(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return wH(i,a,e,t,n,r)+TH(a,t,n,r)+EH(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,NH(Math.abs(i-e),MH(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return NH(CH(a>t?e:i,n)+(s-1)*n.cols+1+SH(a>t?i:e,n),MH(o,r))}function SH(e,t){return e-1}function CH(e,t){return t.cols-e}function wH(e,t,n,r,i,a){return TH(t,r,i,a).length===0?``:NH(jH(e,t,e,t-OH(t,i),!1,i).length,MH(`D`,a))}function TH(e,t,n,r){let i=e-OH(e,n),a=t-OH(t,n);return NH(Math.abs(i-a)-DH(e,t,n),MH(AH(e,t),r))}function EH(e,t,n,r,i,a){let o;o=TH(t,r,i,a).length>0?r-OH(r,i):t;let s=r,c=kH(e,t,n,r,i,a);return NH(jH(e,o,n,s,c===`C`,i).length,MH(c,a))}function DH(e,t,n){let r=0,i=e-OH(e,n),a=t-OH(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=AH(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function OH(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function kH(e,t,n,r,i,a){let o;return o=TH(n,r,i,a).length>0?r-OH(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function AH(e,t){return e>t?`A`:`B`}function jH(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function MH(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function NH(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var PH=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function FH(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var IH=50,LH=15,RH=50,zH=500,BH=RegExp(`\xA0`,`g`),VH=class extends bR{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new wL,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new PH(this._bufferService),this._activeSelectionMode=0,this._register(_R(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(BH,` `)).join(dH?`\r
113
+ `).trim(),t=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);VR.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*BR<=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||$L;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 zR)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}},HR=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}},UR=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Q,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Q,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};UR.INSTANCE=new UR;var WR=UR;function GR(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}WR.INSTANCE.onDidChangeZoomLevel;function KR(e){return WR.INSTANCE.getZoomFactor(e)}WR.INSTANCE.onDidChangeFullscreen;var qR=typeof navigator==`object`?navigator.userAgent:``,JR=qR.indexOf(`Firefox`)>=0,YR=qR.indexOf(`AppleWebKit`)>=0,XR=qR.indexOf(`Chrome`)>=0,ZR=!XR&&qR.indexOf(`Safari`)>=0;qR.indexOf(`Electron/`),qR.indexOf(`Android`);var QR=!1;if(typeof CR.matchMedia==`function`){let e=CR.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=CR.matchMedia(`(display-mode: fullscreen)`);QR=e.matches,GR(CR,e,({matches:e})=>{QR&&t.matches||(QR=e)})}function $R(){return QR}var ez=`en`,tz=!1,nz=!1,rz=!1,iz=!1,az=!1,oz=ez,sz,cz=globalThis,lz;typeof cz.vscode<`u`&&typeof cz.vscode.process<`u`?lz=cz.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(lz=process);var uz=typeof lz?.versions?.electron==`string`&&lz?.type===`renderer`;if(typeof lz==`object`){tz=lz.platform===`win32`,nz=lz.platform===`darwin`,rz=lz.platform===`linux`,rz&&lz.env.SNAP&&lz.env.SNAP_REVISION,lz.env.CI||lz.env.BUILD_ARTIFACTSTAGINGDIRECTORY,oz=ez;let e=lz.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,oz=t.resolvedLanguage||ez,t.languagePack?.translationsConfigFile}catch{}iz=!0}else typeof navigator==`object`&&!uz?(sz=navigator.userAgent,tz=sz.indexOf(`Windows`)>=0,nz=sz.indexOf(`Macintosh`)>=0,(sz.indexOf(`Macintosh`)>=0||sz.indexOf(`iPad`)>=0||sz.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,rz=sz.indexOf(`Linux`)>=0,sz?.indexOf(`Mobi`),az=!0,oz=globalThis._VSCODE_NLS_LANGUAGE||ez,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var dz=tz,fz=nz,pz=rz,mz=iz;az&&typeof cz.importScripts==`function`&&cz.origin;var hz=sz,gz=oz,_z;(e=>{function t(){return gz}e.value=t;function n(){return gz.length===2?gz===`en`:gz.length>=3&&gz[0]===`e`&&gz[1]===`n`&&gz[2]===`-`}e.isDefaultVariant=n;function r(){return gz===`en`}e.isDefault=r})(_z||={});var vz=typeof cz.postMessage==`function`&&!cz.importScripts;(()=>{if(vz){let e=[];cz.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}),cz.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var yz=!!(hz&&hz.indexOf(`Chrome`)>=0);hz&&hz.indexOf(`Firefox`),!yz&&hz&&hz.indexOf(`Safari`),hz&&hz.indexOf(`Edg/`),hz&&hz.indexOf(`Android`);var bz=typeof navigator==`object`?navigator:{};mz||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||bz&&bz.clipboard&&bz.clipboard.writeText,mz||bz&&bz.clipboard&&bz.clipboard.readText,mz||$R()||bz.keyboard,`ontouchstart`in CR||bz.maxTouchPoints,CR.PointerEvent&&(`ontouchstart`in CR||navigator.maxTouchPoints);var xz=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Sz=new xz,Cz=new xz,wz=new xz,Tz=Array(230),Ez;(e=>{function t(e){return Sz.keyCodeToStr(e)}e.toString=t;function n(e){return Sz.strToKeyCode(e)}e.fromString=n;function r(e){return Cz.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return wz.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Cz.strToKeyCode(e)||wz.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return Sz.keyCodeToStr(e)}e.toElectronAccelerator=o})(Ez||={});var Dz=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Oz([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Oz=class{constructor(e){if(e.length===0)throw rR(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function kz(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return Ez.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(JR)switch(t){case 59:return 85;case 60:if(pz)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(fz)return 57;break}else if(YR&&(fz&&t===93||!fz&&t===92))return 57;return Tz[t]||0}var Az=fz?256:2048,jz=512,Mz=1024,Nz=fz?2048:256,Pz=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=kz(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=Az),this.altKey&&(t|=jz),this.shiftKey&&(t|=Mz),this.metaKey&&(t|=Nz),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Dz(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Fz=new WeakMap;function Iz(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var Lz=class{static getSameOriginWindowChain(e){let t=Fz.get(e);if(!t){t=[],Fz.set(e,t);let n=e,r;do r=Iz(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},Rz=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=Lz.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},zz=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(XR){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?JR&&!fz?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=ZR&&dz?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?JR&&!fz?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Bz=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Vz;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Hz?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:kR.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Bz})})(Vz||={});var Hz=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?Bz:(this._emitter||=new Q,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},Uz=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new aR(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new aR(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Wz=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new aR(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=vR(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Gz;(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})(Gz||={});var Kz=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 Q,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 kR.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())}};Kz.EMPTY=Kz.fromArray([]);function qz(e){return Jz(e,0)}function Jz(e,t){switch(typeof e){case`object`:return e===null?Yz(349,t):Array.isArray(e)?Qz(e,t):$z(e,t);case`string`:return Zz(e,t);case`boolean`:return Xz(e,t);case`number`:return Yz(e,t);case`undefined`:return Yz(937,t);default:return Yz(617,t)}}function Yz(e,t){return(t<<5)-t+e|0}function Xz(e,t){return Yz(e?433:863,t)}function Zz(e,t){t=Yz(149417,t);for(let n=0,r=e.length;n<r;n++)t=Yz(e.charCodeAt(n),t);return t}function Qz(e,t){return t=Yz(104579,t),e.reduce((e,t)=>Jz(t,e),t)}function $z(e,t){return t=Yz(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Zz(n,t),Jz(e[n],t)),t)}var{registerWindow:eB,getWindow:tB,getDocument:nB,getWindows:rB,getWindowsCount:iB,getWindowId:aB,getWindowById:oB,hasWindow:sB,onDidRegisterWindow:cB,onWillUnregisterWindow:lB,onDidUnregisterWindow:uB}=function(){let e=new Map,t={window:CR,disposables:new bR};e.set(CR.vscodeWindowId,t);let n=new Q,r=new Q,i=new Q;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return xR.None;let a=new bR,o={window:t,disposables:a.add(new bR)};return e.set(t.vscodeWindowId,o),a.add(vR(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(fB(t,xB.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:CR},getDocument(e){return tB(e).document}}}(),dB=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function fB(e,t,n,r){return new dB(e,t,n,r)}function pB(e,t){return function(n){return t(new Rz(e,n))}}function mB(e){return function(t){return e(new Pz(t))}}var hB=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=pB(tB(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=mB(n)),fB(e,t,i,r)},gB,_B=class extends Wz{constructor(e){super(),this.defaultTarget=e&&tB(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},vB=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){$L(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(vB.sort),a.shift().execute();r.set(i,!1)};gB=(t,r,a=0)=>{let o=aB(t),s=new vB(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var yB=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};yB.None=new yB(0,0);function bB(e){let t=e.getBoundingClientRect(),n=tB(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=qz(n),a=r.get(i);if(a)a.users+=1;else{let o=new Q,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(vR(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var xB={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:YR?`webkitAnimationStart`:`animationstart`,ANIMATION_END:YR?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:YR?`webkitAnimationIteration`:`animationiteration`},SB=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=CB(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=CB(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=CB(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=CB(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=CB(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=CB(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=CB(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=CB(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=CB(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=CB(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=CB(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=CB(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=CB(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=CB(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function CB(e){return typeof e==`number`?`${e}px`:e}function wB(e){return new SB(e)}var TB=class{constructor(){this._hooks=new bR,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(vR(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=tB(e)}this._hooks.add(fB(a,xB.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(fB(a,xB.POINTER_UP,e=>this.stopMonitoring(!0)))}};function EB(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var DB;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(DB||={});var OB=class e extends xR{constructor(){super(),this.dispatched=!1,this.targets=new ER,this.ignoreTargets=new ER,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(kR.runAndSubscribe(cB,({window:e,disposables:t})=>{t.add(fB(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(fB(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(fB(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:CR,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=hR(new e),vR(e.INSTANCE.targets.push(t))):xR.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=hR(new e),vR(e.INSTANCE.ignoreTargets.push(t))):xR.None}static isTouchDevice(){return`ontouchstart`in CR||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(DB.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-oR(s.rollingPageX))<30&&Math.abs(s.initialPageY-oR(s.rollingPageY))<30){let e=this.newGestureEvent(DB.Tap,s.initialTarget);e.pageX=oR(s.rollingPageX),e.pageY=oR(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-oR(s.rollingPageX))<30&&Math.abs(s.initialPageY-oR(s.rollingPageY))<30){let e=this.newGestureEvent(DB.Contextmenu,s.initialTarget);e.pageX=oR(s.rollingPageX),e.pageY=oR(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=oR(s.rollingPageX),n=oR(s.rollingPageY),i=oR(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(DB.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===DB.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===DB.Change||t.type===DB.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=gB(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(DB.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(DB.Change,i.initialTarget);a.translationX=r.pageX-oR(i.rollingPageX),a.translationY=r.pageY-oR(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};OB.SCROLL_FRICTION=-.005,OB.HOLD_DELAY=700,OB.CLEAR_TAP_COUNT_TIME=400,aL([EB],OB,`isTouchDevice`,1);var kB=OB,AB=class extends xR{onclick(e,t){this._register(fB(e,xB.CLICK,n=>t(new Rz(tB(e),n))))}onmousedown(e,t){this._register(fB(e,xB.MOUSE_DOWN,n=>t(new Rz(tB(e),n))))}onmouseover(e,t){this._register(fB(e,xB.MOUSE_OVER,n=>t(new Rz(tB(e),n))))}onmouseleave(e,t){this._register(fB(e,xB.MOUSE_LEAVE,n=>t(new Rz(tB(e),n))))}onkeydown(e,t){this._register(fB(e,xB.KEY_DOWN,e=>t(new Pz(e))))}onkeyup(e,t){this._register(fB(e,xB.KEY_UP,e=>t(new Pz(e))))}oninput(e,t){this._register(fB(e,xB.INPUT,t))}onblur(e,t){this._register(fB(e,xB.BLUR,t))}onfocus(e,t){this._register(fB(e,xB.FOCUS,t))}onchange(e,t){this._register(fB(e,xB.CHANGE,t))}ignoreGesture(e){return kB.ignoreTarget(e)}},jB=11,MB=class extends AB{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=jB+`px`,this.domNode.style.height=jB+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new TB),this._register(hB(this.bgDomNode,xB.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(hB(this.domNode,xB.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new _B),this._pointerdownScheduleRepeatTimer=this._register(new Uz)}_arrowPointerDown(e){!e.target||!(e.target instanceof Element)||(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,tB(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},NB=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},PB=class extends xR{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new NB(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new RB(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=RB.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},FB=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function IB(e,t){let n=t-e;return function(t){return e+n*BB(t)}}function LB(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var RB=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),LB(IB(e,r),IB(i,t),.33)}return IB(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new FB(this.scrollLeft(t),this.scrollTop(t),!1):new FB(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function zB(e){return e**3}function BB(e){return 1-zB(1-e)}var VB=class extends xR{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Uz)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},HB=140,UB=class extends AB{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new VB(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new TB),this._shouldRender=!0,this.domNode=wB(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(fB(this.domNode.domNode,xB.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new MB(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=wB(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(fB(this.slider.domNode,xB.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=bB(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(dz&&a>HB){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},WB=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},GB=class extends UB{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new WB(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},KB=class extends UB{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new WB(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},qB=500,JB=50,YB=!0,XB=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},ZB=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(XR){let t=KR(tB(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new XB(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};ZB.INSTANCE=new ZB;var QB=ZB,$B=class extends AB{constructor(e,t,n){super(),this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Q),this.onWillScroll=this._onWillScroll.event,this._options=tV(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new KB(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new GB(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=wB(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=wB(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=wB(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new Uz),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=gR(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,fz&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new zz(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=gR(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(fB(this._listenOnDomNode,xB.MOUSE_WHEEL,e=>{this._onMouseWheel(new zz(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=QB.INSTANCE;YB&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!fz&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=JB*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=JB*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(YB&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),qB)}},eV=class extends $B{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function tV(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,fz&&(t.className+=` mac`),t}var nV=class extends xR{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new PB({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>gB(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new eV(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(kR.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(vR(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(vR(()=>this._styleElement.remove())),this._register(kR.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
114
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};nV=aL([Z(2,ML),Z(3,GL),Z(4,NL),Z(5,XL),Z(6,RL),Z(7,qL)],nV);var rV=class extends xR{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(vR(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};rV=aL([Z(1,ML),Z(2,GL),Z(3,VL),Z(4,qL)],rV);var iV=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},aV={full:0,left:0,center:0,right:0},oV={full:0,left:0,center:0,right:0},sV={full:0,left:0,center:0,right:0},cV=class extends xR{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new iV,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(vR(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);oV.full=this._canvas.width,oV.left=e,oV.center=t,oV.right=e,this._refreshDrawHeightConstants(),sV.full=1,sV.left=1,sV.center=1+oV.left,sV.right=1+oV.left+oV.center}_refreshDrawHeightConstants(){aV.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);aV.left=t,aV.center=t,aV.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*aV.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*aV.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*aV.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*aV.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(sV[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-aV[e.position||`full`]/2),oV[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+aV[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};cV=aL([Z(2,ML),Z(3,VL),Z(4,qL),Z(5,RL),Z(6,XL),Z(7,GL)],cV);var $;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
115
+ `,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))($||={});var lV;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(lV||={});var uV;(e=>e.ST=`${$.ESC}\\`)(uV||={});var dV=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${$.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};dV=aL([Z(2,ML),Z(3,RL),Z(4,PL),Z(5,qL)],dV);var fV=0,pV=0,mV=0,hV=0,gV={css:`#00000000`,rgba:0},_V;(e=>{function t(e,t,n,r){return r===void 0?`#${SV(e)}${SV(t)}${SV(n)}`:`#${SV(e)}${SV(t)}${SV(n)}${SV(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})(_V||={});var vV;(e=>{function t(e,t){if(hV=(t.rgba&255)/255,hV===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 fV=a+Math.round((n-a)*hV),pV=o+Math.round((r-o)*hV),mV=s+Math.round((i-s)*hV),{css:_V.toCss(fV,pV,mV),rgba:_V.toRgba(fV,pV,mV)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=xV.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return _V.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[fV,pV,mV]=xV.toChannels(t),{css:_V.toCss(fV,pV,mV),rgba:t}}e.opaque=i;function a(e,t){return hV=Math.round(t*255),[fV,pV,mV]=xV.toChannels(e.rgba),{css:_V.toCss(fV,pV,mV,hV),rgba:_V.toRgba(fV,pV,mV,hV)}}e.opacity=a;function o(e,t){return hV=e.rgba&255,a(e,hV*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(vV||={});var yV;(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 fV=parseInt(e.slice(1,2).repeat(2),16),pV=parseInt(e.slice(2,3).repeat(2),16),mV=parseInt(e.slice(3,4).repeat(2),16),_V.toColor(fV,pV,mV);case 5:return fV=parseInt(e.slice(1,2).repeat(2),16),pV=parseInt(e.slice(2,3).repeat(2),16),mV=parseInt(e.slice(3,4).repeat(2),16),hV=parseInt(e.slice(4,5).repeat(2),16),_V.toColor(fV,pV,mV,hV);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 fV=parseInt(r[1]),pV=parseInt(r[2]),mV=parseInt(r[3]),hV=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),_V.toColor(fV,pV,mV,hV);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[fV,pV,mV,hV]=t.getImageData(0,0,1,1).data,hV!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:_V.toRgba(fV,pV,mV,hV),css:e}}e.toColor=r})(yV||={});var bV;(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})(bV||={});var xV;(e=>{function t(e,t){if(hV=(t&255)/255,hV===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 fV=a+Math.round((n-a)*hV),pV=o+Math.round((r-o)*hV),mV=s+Math.round((i-s)*hV),_V.toRgba(fV,pV,mV)}e.blend=t;function n(e,t,n){let a=bV.relativeLuminance(e>>8),o=bV.relativeLuminance(t>>8);if(CV(a,o)<n){if(o<a){let o=r(e,t,n),s=CV(a,bV.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>CV(a,bV.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=CV(a,bV.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>CV(a,bV.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=CV(bV.relativeLuminance2(o,s,c),bV.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=CV(bV.relativeLuminance2(o,s,c),bV.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=CV(bV.relativeLuminance2(o,s,c),bV.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=CV(bV.relativeLuminance2(o,s,c),bV.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})(xV||={});function SV(e){let t=e.toString(16);return t.length<2?`0`+t:t}function CV(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var wV=class extends CL{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},TV=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new TL}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||SL.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)TV._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||SL.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};TV=aL([Z(0,ML)],TV);function EV(e){return 57508<=e&&e<=57558}function DV(e){return 9472<=e&&e<=9631}function OV(e){return EV(e)||DV(e)}function kV(){return{css:{canvas:AV(),cell:AV()},device:{canvas:AV(),cell:AV(),char:{width:0,height:0,left:0,top:0}}}}function AV(){return{width:0,height:0}}var jV=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new TL,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new wV(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let ee=this._isCellInSelection(k,t),te=n&&k===a,P=O&&k>=l&&k<=u,F=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{F=!0});let ne=N.getChars()||SL;if(ne===` `&&(N.isUnderline()||N.isOverline())&&(ne=`\xA0`),T=m*s-c.get(ne,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(ee&&w||!ee&&!w&&N.bg===y)&&(ee&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&P===S&&T===C&&!te&&!A&&!F&&j){N.isInvisible()?_+=SL:_+=ne,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=P,C=T,w=ee,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&te&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`);break;default:break}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?SL:N.getChars()||SL,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${CL.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),P&&(h.style.textDecoration=`underline`);let re=N.getFgColor(),ie=N.getFgColorMode(),ae=N.getBgColor(),I=N.getBgColorMode(),L=!!N.isInverse();if(L){let e=re;re=ae,ae=e;let t=ie;ie=I,I=t}let oe,se,ce=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&ce||(e.backgroundColorRGB&&(I=50331648,ae=e.backgroundColorRGB.rgba>>8&16777215,oe=e.backgroundColorRGB),e.foregroundColorRGB&&(ie=50331648,re=e.foregroundColorRGB.rgba>>8&16777215,se=e.foregroundColorRGB),ce=e.options.layer===`top`)}),!ce&&ee&&(oe=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ae=oe.rgba>>8&16777215,I=50331648,ce=!0,p.selectionForeground&&(ie=50331648,re=p.selectionForeground.rgba>>8&16777215,se=p.selectionForeground)),ce&&D.push(`xterm-decoration-top`);let le;switch(I){case 16777216:case 33554432:le=p.ansi[ae],D.push(`xterm-bg-${ae}`);break;case 50331648:le=_V.toColor(ae>>16,ae>>8&255,ae&255),this._addStyle(h,`background-color:#${MV((ae>>>0).toString(16),`0`,6)}`);break;default:L?(le=p.foreground,D.push(`xterm-bg-257`)):le=p.background}switch(oe||N.isDim()&&(oe=vV.multiplyOpacity(le,.5)),ie){case 16777216:case 33554432:N.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(h,le,p.ansi[re],N,oe,void 0)||D.push(`xterm-fg-${re}`);break;case 50331648:let e=_V.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(h,le,e,N,oe,se)||this._addStyle(h,`color:#${MV(re.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,le,p.foreground,N,oe,se)||L&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!te&&!A&&!F&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||OV(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=vV.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};jV=aL([Z(1,YL),Z(2,RL),Z(3,GL),Z(4,PL),Z(5,VL),Z(6,XL)],jV);function MV(e,t,n){for(;e.length<n;)e=t+e;return e}var NV=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},PV=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function FV(){return new PV}var IV=`xterm-dom-renderer-owner-`,LV=`xterm-rows`,RV=`xterm-fg-`,zV=`xterm-bg-`,BV=`xterm-focus`,VV=`xterm-selection`,HV=1,UV=class extends xR{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=HV++,this._rowElements=[],this._selectionRenderModel=FV(),this.onRequestRedraw=this._register(new Q).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(LV),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(VV),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=kV(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(jV,document),this._element.classList.add(IV+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(vR(()=>{this._element.classList.remove(IV+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new NV(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${LV} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${LV} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${LV} .xterm-dim { color: ${vV.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${LV}.${BV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${LV}.${BV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${LV}.${BV} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${LV} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${LV} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${LV} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${LV} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${LV} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${VV} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${VV} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${VV} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${RV}${n} { color: ${r.css}; }${this._terminalSelector} .${RV}${n}.xterm-dim { color: ${vV.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${zV}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${RV}257 { color: ${vV.opaque(e.background).css}; }${this._terminalSelector} .${RV}257.xterm-dim { color: ${vV.multiplyOpacity(vV.opaque(e.background),.5).css}; }${this._terminalSelector} .${zV}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(BV),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(BV),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${IV}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};UV=aL([Z(7,IL),Z(8,WL),Z(9,RL),Z(10,ML),Z(11,PL),Z(12,GL),Z(13,XL)],UV);var WV=class extends xR{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Q),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new qV(this._optionsService))}catch{this._measureStrategy=this._register(new KV(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};WV=aL([Z(2,RL)],WV);var GV=class extends xR{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},KV=class extends GV{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},qV=class extends GV{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},JV=class extends xR{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new YV(this._window)),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Q),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(kR.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(fB(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(fB(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},YV=class extends xR{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new SR),this._onDprChange=this._register(new Q),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vR(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=fB(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},XV=class extends xR{constructor(){super(),this.linkProviders=[],this._register(vR(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function ZV(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function QV(e,t,n,r,i,a,o,s,c){if(!a)return;let l=ZV(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var $V=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return QV(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=ZV(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};$V=aL([Z(0,qL),Z(1,WL)],$V);var eH=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},tH={};iL(tH,{getSafariVersion:()=>cH,isChromeOS:()=>mH,isFirefox:()=>aH,isIpad:()=>uH,isIphone:()=>dH,isLegacyEdge:()=>oH,isLinux:()=>pH,isMac:()=>lH,isNode:()=>nH,isSafari:()=>sH,isWindows:()=>fH});var nH=typeof process<`u`&&`title`in process,rH=nH?`node`:navigator.userAgent,iH=nH?`node`:navigator.platform,aH=rH.includes(`Firefox`),oH=rH.includes(`Edge`),sH=/^((?!chrome|android).)*safari/i.test(rH);function cH(){if(!sH)return 0;let e=rH.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var lH=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(iH),uH=iH===`iPad`,dH=iH===`iPhone`,fH=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(iH),pH=iH.indexOf(`Linux`)>=0,mH=/\bCrOS\b/.test(rH),hH=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},gH=class extends hH{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},_H=class extends hH{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},vH=!nH&&`requestIdleCallback`in window?_H:gH,yH=class{constructor(){this._queue=new vH}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},bH=class extends xR{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new SR),this._pausedResizeTask=new yH,this._observerDisposable=this._register(new SR),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Q),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Q),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Q),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new eH((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new xH(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vR(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=vR(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};bH=aL([Z(2,RL),Z(3,WL),Z(4,PL),Z(5,VL),Z(6,ML),Z(7,GL),Z(8,XL)],bH);var xH=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function SH(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return TH(i,a,e,t,n,r)+EH(a,t,n,r)+DH(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,PH(Math.abs(i-e),NH(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return PH(wH(a>t?e:i,n)+(s-1)*n.cols+1+CH(a>t?i:e,n),NH(o,r))}function CH(e,t){return e-1}function wH(e,t){return t.cols-e}function TH(e,t,n,r,i,a){return EH(t,r,i,a).length===0?``:PH(MH(e,t,e,t-kH(t,i),!1,i).length,NH(`D`,a))}function EH(e,t,n,r){let i=e-kH(e,n),a=t-kH(t,n);return PH(Math.abs(i-a)-OH(e,t,n),NH(jH(e,t),r))}function DH(e,t,n,r,i,a){let o;o=EH(t,r,i,a).length>0?r-kH(r,i):t;let s=r,c=AH(e,t,n,r,i,a);return PH(MH(e,o,n,s,c===`C`,i).length,NH(c,a))}function OH(e,t,n){let r=0,i=e-kH(e,n),a=t-kH(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=jH(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function kH(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function AH(e,t,n,r,i,a){let o;return o=EH(n,r,i,a).length>0?r-kH(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function jH(e,t){return e>t?`A`:`B`}function MH(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function NH(e,t){let n=t?`O`:`[`;return $.ESC+n+e}function PH(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var FH=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function IH(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var LH=50,RH=15,zH=50,BH=500,VH=RegExp(`\xA0`,`g`),HH=class extends xR{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new TL,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Q),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Q),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Q),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new FH(this._bufferService),this._activeSelectionMode=0,this._register(vR(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(VH,` `)).join(fH?`\r
116
116
  `:`
117
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),fH&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=FH(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=XV(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-IH),IH),t/=IH,t/Math.abs(t)+Math.round(t*(LH-1)))}shouldForceSelection(e){return cH?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),RH)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(cH&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<zH&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=xH(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=FH(n,this._bufferService.cols)}};VH=iL([Z(3,jL),Z(4,NL),Z(5,GL),Z(6,LL),Z(7,KL),Z(8,WL)],VH);var HH=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},UH=class{constructor(){this._color=new HH,this._css=new HH}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},WH=Object.freeze((()=>{let e=[vV.toColor(`#2e3436`),vV.toColor(`#cc0000`),vV.toColor(`#4e9a06`),vV.toColor(`#c4a000`),vV.toColor(`#3465a4`),vV.toColor(`#75507b`),vV.toColor(`#06989a`),vV.toColor(`#d3d7cf`),vV.toColor(`#555753`),vV.toColor(`#ef2929`),vV.toColor(`#8ae234`),vV.toColor(`#fce94f`),vV.toColor(`#729fcf`),vV.toColor(`#ad7fa8`),vV.toColor(`#34e2e2`),vV.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:gV.toCss(r,i,a),rgba:gV.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:gV.toCss(n,n,n),rgba:gV.toRgba(n,n,n)})}return e})()),GH=vV.toColor(`#ffffff`),KH=vV.toColor(`#000000`),qH=vV.toColor(`#ffffff`),JH=KH,YH={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},XH=GH,ZH=class extends bR{constructor(e){super(),this._optionsService=e,this._contrastCache=new UH,this._halfContrastCache=new UH,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:GH,background:KH,cursor:qH,cursorAccent:JH,selectionForeground:void 0,selectionBackgroundTransparent:YH,selectionBackgroundOpaque:_V.blend(KH,YH),selectionInactiveBackgroundTransparent:YH,selectionInactiveBackgroundOpaque:_V.blend(KH,YH),scrollbarSliderBackground:_V.opacity(GH,.2),scrollbarSliderHoverBackground:_V.opacity(GH,.4),scrollbarSliderActiveBackground:_V.opacity(GH,.5),overviewRulerBorder:GH,ansi:WH.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=QH(e.foreground,GH),t.background=QH(e.background,KH),t.cursor=_V.blend(t.background,QH(e.cursor,qH)),t.cursorAccent=_V.blend(t.background,QH(e.cursorAccent,JH)),t.selectionBackgroundTransparent=QH(e.selectionBackground,YH),t.selectionBackgroundOpaque=_V.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=QH(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=_V.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?QH(e.selectionForeground,hV):void 0,t.selectionForeground===hV&&(t.selectionForeground=void 0),_V.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=_V.opacity(t.selectionBackgroundTransparent,.3)),_V.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=_V.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=QH(e.scrollbarSliderBackground,_V.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=QH(e.scrollbarSliderHoverBackground,_V.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=QH(e.scrollbarSliderActiveBackground,_V.opacity(t.foreground,.5)),t.overviewRulerBorder=QH(e.overviewRulerBorder,XH),t.ansi=WH.slice(),t.ansi[0]=QH(e.black,WH[0]),t.ansi[1]=QH(e.red,WH[1]),t.ansi[2]=QH(e.green,WH[2]),t.ansi[3]=QH(e.yellow,WH[3]),t.ansi[4]=QH(e.blue,WH[4]),t.ansi[5]=QH(e.magenta,WH[5]),t.ansi[6]=QH(e.cyan,WH[6]),t.ansi[7]=QH(e.white,WH[7]),t.ansi[8]=QH(e.brightBlack,WH[8]),t.ansi[9]=QH(e.brightRed,WH[9]),t.ansi[10]=QH(e.brightGreen,WH[10]),t.ansi[11]=QH(e.brightYellow,WH[11]),t.ansi[12]=QH(e.brightBlue,WH[12]),t.ansi[13]=QH(e.brightMagenta,WH[13]),t.ansi[14]=QH(e.brightCyan,WH[14]),t.ansi[15]=QH(e.brightWhite,WH[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=QH(e.extendedAnsi[r],WH[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};ZH=iL([Z(0,LL)],ZH);function QH(e,t){if(e!==void 0)try{return vV.toColor(e)}catch{}return t}var $H=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},eU=class{constructor(){this._services=new $H,this._services.set(FL,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=OL(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},tU={trace:0,debug:1,info:2,warn:3,error:4,off:5},nU=`xterm.js: `,rU=class extends bR{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),iU=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=tU[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:nU)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};rU=iL([Z(0,LL)],rU);var iU,aU=class extends bR{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},oU=3,sU=Object.freeze(new SL),cU=0,lU=2,uU=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*oU);let r=t||wL.fromCharData([0,bL,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*oU+0],n=t&2097151;return[this._data[e*oU+1],t&2097152?this._combined[e]:n?gL(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*oU+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*oU+0]=e|2097152|t[2]<<22):this._data[e*oU+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*oU+0]>>22}hasWidth(e){return this._data[e*oU+0]&12582912}getFg(e){return this._data[e*oU+1]}getBg(e){return this._data[e*oU+2]}hasContent(e){return this._data[e*oU+0]&4194303}getCodePoint(e){let t=this._data[e*oU+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*oU+0]&2097152}getString(e){let t=this._data[e*oU+0];return t&2097152?this._combined[e]:t&2097151?gL(t&2097151):``}isProtected(e){return this._data[e*oU+2]&536870912}loadCell(e,t){return cU=e*oU,t.content=this._data[cU+0],t.fg=this._data[cU+1],t.bg=this._data[cU+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*oU+0]=t.content,this._data[e*oU+1]=t.fg,this._data[e*oU+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*oU+0]=t|n<<22,this._data[e*oU+1]=r.fg,this._data[e*oU+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*oU+0];r&2097152?this._combined[e]+=gL(t):r&2097151?(this._combined[e]=gL(r&2097151)+gL(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*oU+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new wL;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new wL;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*lU<this._data.buffer.byteLength;let n=e*oU;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*lU<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*lU<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*oU+0]&4194303)return e+(this._data[e*oU+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*oU+0]&4194303||this._data[e*oU+2]&50331648)return e+(this._data[e*oU+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<oU;e++)this._data[(n+i)*oU+e]=a[(t+i)*oU+e];a[(t+i)*oU+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<oU;e++)this._data[(n+i)*oU+e]=a[(t+i)*oU+e];a[(t+i)*oU+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*oU+0],n=e&2097151,a=e&2097152?this._combined[t]:n?gL(n):xL;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function dU(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=hU(u,d,t),p=1,m=0;for(;p<u.length;){let e=hU(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function fU(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function pU(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function mU(e,t,n){let r=[],i=e.map((n,r)=>hU(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=hU(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function hU(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var gU=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),hR(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};gU._nextId=1;var _U=gU,vU={},yU=vU.B;vU[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},vU.A={"#":`£`},vU.B=void 0,vU[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},vU.C=vU[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},vU.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},vU.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},vU.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},vU.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},vU.E=vU[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},vU.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},vU.H=vU[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},vU[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var bU=4294967295,xU=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=sU.clone(),this.savedCharset=yU,this.markers=[],this._nullCell=wL.fromCharData([0,bL,1,0]),this._whitespaceCell=wL.fromCharData([0,xL,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new _H,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new aU(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new CL),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new CL),this._whitespaceCell}getBlankLine(e,t){return new uU(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>bU?bU:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=sU);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new aU(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(sU),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new uU(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new uU(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=dU(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(sU),n);if(r.length>0){let n=fU(this.lines,r);pU(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(sU),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new uU(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(sU),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=mU(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(sU,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=hU(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new _U(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},SU=class extends bR{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new xU(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new xU(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},CU=2,wU=1,TU=class extends bR{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,CU),this.rows=Math.max(e.rawOptions.rows||0,wU),this.buffers=this._register(new SU(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};TU=iL([Z(0,LL)],TU);var EU={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:cH,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},DU=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],OU=class extends bR{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...EU};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(_R(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in EU))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in EU))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=EU[e],!kU(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=EU[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=DU.includes(t)?t:EU[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function kU(e){return e===`block`||e===`underline`||e===`bar`}function AU(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&AU(e[r],t-1);return n}var jU=Object.freeze({insertMode:!1}),MU=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),NU=class extends bR{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=AU(jU),this.decPrivateModes=AU(MU)}reset(){this.modes=AU(jU),this.decPrivateModes=AU(MU)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};NU=iL([Z(0,jL),Z(1,IL),Z(2,LL)],NU);var PU={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function FU(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var IU=String.fromCharCode,LU={DEFAULT:e=>{let t=[FU(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${IU(t[0])}${IU(t[1])}${IU(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${FU(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${FU(e,!0)};${e.x};${e.y}${t}`}},RU=class extends bR{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(PU))this.addProtocol(e,PU[e]);for(let e of Object.keys(LU))this.addEncoding(e,LU[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};RU=iL([Z(0,jL),Z(1,NL),Z(2,LL)],RU);var zU=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],BU=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],VU;function HU(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var UU=class{constructor(){if(this.version=`6`,!VU){VU=new Uint8Array(65536),VU.fill(1),VU[0]=0,VU.fill(0,1,32),VU.fill(0,127,160),VU.fill(2,4352,4448),VU[9001]=2,VU[9002]=2,VU.fill(2,11904,42192),VU[12351]=1,VU.fill(2,44032,55204),VU.fill(2,63744,64256),VU.fill(2,65040,65050),VU.fill(2,65072,65136),VU.fill(2,65280,65377),VU.fill(2,65504,65511);for(let e=0;e<zU.length;++e)VU.fill(0,zU[e][0],zU[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?VU[e]:HU(e,BU)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=WU.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return WU.createPropertyValue(0,n,r)}},WU=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new UU;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},GU=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function KU(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var qU=2147483647,JU=256,YU=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>JU)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>qU?qU:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>qU?qU:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,qU):e}},XU=[],ZU=class{constructor(){this._state=0,this._active=XU,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=XU}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=XU,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||XU,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,_L(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=XU,this._id=-1,this._state=0}}},QU=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=_L(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},$U=[],eW=class{constructor(){this._handlers=Object.create(null),this._active=$U,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=$U}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=$U,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||$U,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,_L(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=$U,this._ident=0}},tW=new YU;tW.addParam(0);var nW=class{constructor(e){this._handler=e,this._data=``,this._params=tW,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():tW,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=_L(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=tW,this._data=``,this._hitLimit=!1,e));return this._params=tW,this._data=``,this._hitLimit=!1,t}},rW=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},iW=160,aW=function(){let e=new rW(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(iW,0,2,0),e.add(iW,8,5,8),e.add(iW,6,0,6),e.add(iW,11,0,11),e.add(iW,13,13,13),e}(),oW=class extends bR{constructor(e=aW){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new YU,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(_R(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ZU),this._dcsParser=this._register(new eW),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:iW)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<iW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<iW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<iW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<iW){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<iW){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<iW){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},sW=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,cW=/^[\da-f]+$/;function lW(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=sW.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),cW.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function uW(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function dW(e,t=16){let[n,r,i]=e;return`rgb:${uW(n,t)}/${uW(r,t)}/${uW(i,t)}`}var fW={"(":0,")":1,"*":2,"+":3,"-":1,".":2},pW=131072,mW=10;function hW(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var gW=5e3,_W=0,vW=class extends bR{constructor(e,t,n,r,i,a,o,s,c=new oW){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new vL,this._utf8Decoder=new yL,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=sU.clone(),this._eraseAttrDataInternal=sU.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new yW(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(cV.IND,()=>this.index()),this._parser.setExecuteHandler(cV.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(cV.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new QU(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new QU(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new QU(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new QU(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new QU(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new QU(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new QU(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new QU(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new QU(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new QU(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new QU(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new QU(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in vU)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new nW((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),gW))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${gW} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>pW&&(a=this._parseStack.position+pW)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<pW&&(this._parseBuffer=new Uint32Array(Math.min(e.length,pW))),o||this._dirtyRowTracker.clearRange(),e.length>pW)for(let t=a;t<e.length;t+=pW){let a=t+pW<e.length?t+pW:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=WU.extractWidth(t);let n=WU.extractShouldJoin(t),m=n?WU.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(gL(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof uU&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!hW(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new nW(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new QU(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(sU));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=WU.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,yU),this._charsetService.setgCharset(1,yU),this._charsetService.setgCharset(2,yU),this._charsetService.setgCharset(3,yU);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=SL.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=sU.fg,e.bg=sU.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=sU.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=sU.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=sU.fg&16777215,r.bg&=-67108864,r.bg|=sU.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=sU.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!hW(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>mW&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>mW&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(bW(n)){if(r===`?`)t.push({type:0,index:n});else{let e=lW(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=lW(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);bW(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,yU),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(fW[e[0]],vU[e[1]]||yU),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=sU.clone(),this._eraseAttrDataInternal=sU.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new wL;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},yW=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(_W=e,e=t,t=_W),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};yW=iL([Z(0,jL)],yW);function bW(e){return 0<=e&&e<256}var xW=5e7,SW=12,CW=50,wW=class extends bR{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>xW)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=SW?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=SW)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>CW&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},TW=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};TW=iL([Z(0,jL)],TW);var EW=!1,DW=class extends bR{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new xR),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new eU,this.optionsService=this._register(new OU(e)),this._instantiationService.setService(LL,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(TU)),this._instantiationService.setService(jL,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(rU)),this._instantiationService.setService(IL,this._logService),this.coreService=this._register(this._instantiationService.createInstance(NU)),this._instantiationService.setService(NL,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(RU)),this._instantiationService.setService(ML,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(WU)),this._instantiationService.setService(zL,this.unicodeService),this._charsetService=this._instantiationService.createInstance(GU),this._instantiationService.setService(PL,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(TW),this._instantiationService.setService(RL,this._oscLinkService),this._inputHandler=this._register(new vW(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(OR.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(OR.forward(this._bufferService.onResize,this._onResize)),this._register(OR.forward(this.coreService.onData,this._onData)),this._register(OR.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new wW((e,t)=>this._inputHandler.parse(e,t))),this._register(OR.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!EW&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),EW=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,CU),t=Math.max(t,wU),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(KU.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(KU(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_R(()=>{for(let t of e)t.dispose()})}}},OW={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function kW(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=OW[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var AW=0,jW=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new _H,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new _H,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(AW=this._search(t),AW===-1)||this._getKey(this._array[AW])!==t)return!1;do if(this._array[AW]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(AW),!0;while(++AW<this._array.length&&this._getKey(this._array[AW])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(AW=this._search(e),!(AW<0||AW>=this._array.length)&&this._getKey(this._array[AW])===e))do yield this._array[AW];while(++AW<this._array.length&&this._getKey(this._array[AW])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(AW=this._search(e),!(AW<0||AW>=this._array.length)&&this._getKey(this._array[AW])===e))do t(this._array[AW]);while(++AW<this._array.length&&this._getKey(this._array[AW])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},MW=0,NW=0,PW=class extends bR{constructor(){super(),this._decorations=new jW(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_R(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new FW(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{MW=t.options.x??0,NW=MW+(t.options.width??1),e>=MW&&e<NW&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},FW=class extends yR{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?vV.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?vV.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},IW=1e3,LW=class{constructor(e,t=IW){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},RW=20,zW=class extends bR{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new LW(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
118
- `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(dB(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(_R(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<RW+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
119
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===RW+1&&(this._liveRegion.textContent+=cL.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};zW=iL([Z(1,FL),Z(2,WL),Z(3,KL)],zW);var BW=class extends bR{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(_R(()=>{hR(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(dB(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(dB(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(dB(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(dB(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&VW(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,hR(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};BW=iL([Z(1,GL),Z(2,KL),Z(3,jL),Z(4,XL)],BW);function VW(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var HW=class extends DW{constructor(e={}){super(e),this._linkifier=this._register(new xR),this.browser=eH,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new xR),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(PW),this._instantiationService.setService(BL,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(YV),this._instantiationService.setService(XL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(VL)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(OR.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(OR.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(OR.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(OR.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(_R(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=_V.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${dW(r)}${lV.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=gV.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=gV.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(zW,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(dB(this.element,`copy`,e=>{this.hasSelection()&&dL(e,this._selectionService)}));let e=e=>fL(e,this.textarea,this.coreService,this.optionsService);this._register(dB(this.textarea,`paste`,e)),this._register(dB(this.element,`paste`,e)),iH?this._register(dB(this.element,`mousedown`,e=>{e.button===2&&hL(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(dB(this.element,`contextmenu`,e=>{hL(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),fH&&this._register(dB(this.element,`auxclick`,e=>{e.button===1&&mL(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(dB(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(dB(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(dB(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(dB(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(dB(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(dB(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(dB(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(dB(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,oL.get()),pH||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(qV,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(WL,this._coreBrowserService),this._register(dB(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(dB(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(UV,this._document,this._helperContainer),this._instantiationService.setService(UL,this._charSizeService),this._themeService=this._instantiationService.createInstance(ZH),this._instantiationService.setService(YL,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(wV),this._instantiationService.setService(JL,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(yH,this.rows,this.screenElement)),this._instantiationService.setService(KL,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(uV,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(QV),this._instantiationService.setService(GL,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(BW,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(tV,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(VH,this.element,this.screenElement,r)),this._instantiationService.setService(qL,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(OR.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(nV,this.screenElement)),this._register(dB(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(zW,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sV,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sV,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(HV,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(dB(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(dB(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){pL(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=kW(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(UW(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(sU));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function UW(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var WW=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},GW=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new wL)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},KW=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new GW(t)}getNullCell(){return new wL}},qW=class extends bR{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new KW(this._core.buffers.normal,`normal`),this._alternate=new KW(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},JW=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},YW=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},XW=[`cols`,`rows`],ZW=0,QW=class extends bR{constructor(e){super(),this._core=this._register(new HW(e)),this._addonManager=this._register(new WW),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(XW.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new JW(this._core),this._parser}get unicode(){return this._checkProposedApi(),new YW(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new qW(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
120
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return oL.get()},set promptLabel(e){oL.set(e)},get tooMuchOutput(){return cL.get()},set tooMuchOutput(e){cL.set(e)}}}_verifyIntegers(...e){for(ZW of e)if(ZW===1/0||isNaN(ZW)||ZW%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(ZW of e)if(ZW&&(ZW===1/0||isNaN(ZW)||ZW%1!=0||ZW<0))throw Error(`This API only accepts positive integers`)}},$W=2,eG=1,tG=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max($W,Math.floor(u/e.css.cell.width)),rows:Math.max(eG,Math.floor(l/e.css.cell.height))}}},nG={background:`#101010`,foreground:`#e6e6e6`,cursor:`#9dbefe`,cursorAccent:`#101010`,selectionBackground:`rgba(157, 190, 254, 0.25)`,black:`#101010`,red:`#fc533a`,green:`#12c905`,yellow:`#fcd53a`,blue:`#9dbefe`,magenta:`#edb2f1`,cyan:`#94e2d5`,white:`#e6e6e6`,brightBlack:`#555555`,brightRed:`#ff8a77`,brightGreen:`#6bff5c`,brightYellow:`#ffe57a`,brightBlue:`#c6dcff`,brightMagenta:`#ffd3f8`,brightCyan:`#b9fff2`,brightWhite:`#ffffff`};function rG({ptyID:e,onClose:t,onError:n}){let r=(0,E.useRef)(null),i=(0,E.useRef)(null),a=(0,E.useRef)(null),o=(0,E.useRef)(null),s=(0,E.useRef)(e);s.current=e;let[c,l]=(0,E.useState)(!1),u=async()=>{if(!c){l(!0);try{await G.ptyDelete(e),a.current?.close()}catch(e){l(!1),n?.(e instanceof Error?e.message:String(e))}}};return(0,E.useEffect)(()=>{let e=r.current;if(!e)return;let c=new QW({fontFamily:`"JetBrainsMono Nerd Font Mono", monospace`,fontSize:13,lineHeight:1.3,cursorBlink:!0,theme:nG,scrollback:5e3}),l=new tG;c.loadAddon(l),c.open(e);try{l.fit()}catch{}i.current=c,o.current=l,c.focus();let u=()=>{try{l.fit()}catch{return}let e=c.cols>0&&c.rows>0?{cols:c.cols,rows:c.rows}:null;e&&G.ptyUpdate(s.current,{size:e}).catch(()=>{})},d=new ResizeObserver(u);d.observe(e);let f=null,p=!1,m=!1,h=async()=>{try{let e=await G.ptyConnectToken(s.current),r=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/api/pty/${s.current}/connect?ticket=${e.data.ticket}`;if(p)return;f=new WebSocket(r),a.current=f,f.onopen=()=>u(),f.onmessage=e=>{typeof e.data==`string`?c.write(e.data):e.data instanceof Blob?e.data.arrayBuffer().then(e=>g(new Uint8Array(e),c)):g(new Uint8Array(e.data),c)},f.onclose=()=>{p||t()},f.onerror=()=>{n?.(`Terminal connection lost`)}}catch(e){n?.(e instanceof Error?e.message:String(e))}},g=(e,t)=>{if(e[0]===0){let t=new TextDecoder().decode(e.subarray(1));try{typeof JSON.parse(t).cursor==`number`&&!m&&(m=!0,u())}catch{}return}t.write(new Uint8Array(e))},_=c.onData(e=>{a.current?.readyState===WebSocket.OPEN&&a.current.send(e)});return h(),()=>{p=!0,_.dispose(),d.disconnect(),a.current?.close(),c.dispose(),i.current=null}},[e]),(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-xs text-[var(--text-weak)]`,children:e}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>void u(),disabled:c,title:`Kill process`,"aria-label":`Kill terminal`,className:`text-[color:var(--surface-critical-strong)]`,children:[(0,R.jsx)(et,{}),`Kill`]}),(0,R.jsx)(U,{variant:`ghost`,size:`sm`,onClick:t,children:`Close`})]})]}),(0,R.jsx)(`div`,{ref:r,className:`min-h-0 flex-1 bg-[var(--background-base)] p-2`})]})}var iG=12e4,aG={running:`blue`,exited:`green`,timeout:`amber`,killed:`red`};function oG(e){let t=e.time.completed??Date.now(),n=Math.max(0,Math.floor((t-e.time.started)/1e3));if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m ${n%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function sG({trigger:e}){let[t,n]=(0,E.useState)(!1),[r,i]=(0,E.useState)(`shell`),a=J(e=>e.shellPanelTick);return(0,E.useEffect)(()=>{a>0&&n(!0)},[a]),(0,R.jsxs)(Km,{open:t,onOpenChange:n,children:[e===void 0?(0,R.jsx)(qm,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,children:[(0,R.jsx)(tt,{}),`Shell`]})}):(0,R.jsx)(qm,{asChild:!0,children:e}),(0,R.jsxs)(Zm,{className:`flex max-h-[85vh] flex-col gap-0 overflow-hidden p-0 sm:max-w-2xl md:max-w-3xl`,children:[(0,R.jsxs)(Qm,{className:`border-b border-(--border-weak-base) px-4 py-3`,children:[(0,R.jsxs)(eh,{className:`flex items-center gap-2`,children:[(0,R.jsx)(tt,{className:`size-4 text-(color:--text-interactive-base)`}),`Shell & Terminals`]}),(0,R.jsx)(th,{children:`Run shell commands and manage PTY sessions.`})]}),(0,R.jsxs)(Xx,{value:r,onValueChange:i,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(Qx,{variant:`line`,className:`mx-4 mt-3`,children:[(0,R.jsx)($x,{value:`shell`,children:`Shell`}),(0,R.jsx)($x,{value:`terminals`,children:`Terminals`})]}),(0,R.jsx)(eS,{value:`shell`,forceMount:!0,className:V(`min-h-0`,r!==`shell`&&`hidden`),children:(0,R.jsx)(cG,{active:r===`shell`})}),(0,R.jsx)(eS,{value:`terminals`,forceMount:!0,className:V(`min-h-0`,r!==`terminals`&&`hidden`),children:(0,R.jsx)(uG,{active:r===`terminals`})})]})]})]})}function cG({active:e}){let[t,n]=(0,E.useState)([]),[r,i]=(0,E.useState)(!0),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(String(iG)),[d,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)({}),_=(0,E.useRef)({}),v=(0,E.useCallback)(async()=>{try{let e=await G.shellList();n(e.data),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}},[]);(0,E.useEffect)(()=>{if(e)return v(),og({name:`shell-panel-list`,minInterval:5e3,run:()=>v()})},[e,v]);let y=(0,E.useCallback)(async e=>{try{let t=(await G.shellOutput(e,{cursor:_.current[e]})).data,n=t.truncated||_.current[e]===void 0;g(r=>({...r,[e]:(n?``:r[e]??``)+t.output})),_.current[e]=t.cursor}catch{g(t=>({...t,[e]:(t[e]??``)+`
121
- [output stream unavailable]`}))}},[]);(0,E.useEffect)(()=>{if(!e||!p)return;let n=t.find(e=>e.id===p);if(!(!n||n.status!==`running`))return og({name:`shell-panel-output`,minInterval:1200,run:()=>y(p)})},[e,p,t,y]);let b=async()=>{if(!(!s.trim()||d)){f(!0),o(null);try{let e=Number(l),t=await G.shellCreate({command:s.trim(),timeout:Number.isFinite(e)&&e>0?e:iG});c(``),await v(),m(t.data.id)}catch(e){o(e instanceof Error?e.message:String(e))}finally{f(!1)}}},x=async e=>{try{await G.shellDelete(e),g(t=>{let n={...t};return delete n[e],n}),delete _.current[e],p===e&&m(null),await v()}catch(e){o(e instanceof Error?e.message:String(e))}},S=async(e,t)=>{let n=Number(t);if(!(!Number.isFinite(n)||n<0))try{await G.shellTimeout(e,n),await v()}catch(e){o(e instanceof Error?e.message:String(e))}};return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(nh,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},placeholder:`command to run`,className:`flex-1 font-mono text-xs`}),(0,R.jsx)(nh,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},placeholder:`timeout ms`,title:`Timeout in milliseconds`,className:`w-24 font-mono text-xs`}),(0,R.jsxs)(U,{onClick:()=>void b(),disabled:!s.trim()||d,children:[(0,R.jsx)(Be,{}),`Run`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,title:`Refresh`,onClick:()=>void v(),children:(0,R.jsx)(Ke,{})})]}),a&&(0,R.jsx)(`p`,{className:`text-xs text-(color:--surface-critical-strong)`,children:a}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto`,children:r?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-(color:--text-weaker)`,children:[(0,R.jsx)(uS,{}),` Loading shells…`]}):t.length===0?(0,R.jsx)(`p`,{className:`px-1 py-2 text-xs text-(color:--text-weaker)`,children:`No shell sessions yet — run a command above.`}):t.map(e=>(0,R.jsx)(lG,{shell:e,expanded:p===e.id,output:h[e.id]??``,onToggle:()=>{m(t=>t===e.id?null:e.id),_.current[e.id]||y(e.id)},onKill:()=>void x(e.id),onSetTimeout:t=>void S(e.id,t)},e.id))})]})}function lG({shell:e,expanded:t,output:n,onToggle:r,onKill:i,onSetTimeout:a}){let[o,s]=(0,E.useState)(``),c=(0,E.useRef)(null);return(0,E.useEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[n]),(0,R.jsxs)(`div`,{className:`rounded-md border border-(--border-weak-base) bg-(--surface-base)`,children:[(0,R.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-2 px-2.5 py-1.5 hover:bg-(--surface-base-hover)`,onClick:r,children:[t?(0,R.jsx)(I,{className:`size-3.5 shrink-0 text-(color:--text-weaker)`}):(0,R.jsx)(L,{className:`size-3.5 shrink-0 text-(color:--text-weaker)`}),(0,R.jsx)(fS,{tone:aG[e.status],children:e.status}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-(color:--text-strong)`,children:e.command}),(0,R.jsx)(`span`,{className:`hidden max-w-40 truncate font-mono text-xs text-(color:--text-weaker) sm:inline`,children:e.cwd}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-(color:--text-weak)`,children:[mS(e.time.started),` · `,oG(e)]}),e.status===`running`&&(0,R.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:`Kill`,"aria-label":`Kill`,onClick:e=>{e.stopPropagation(),i()},className:`text-(color:--surface-critical-strong)`,children:(0,R.jsx)(et,{})})]}),t&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-(--border-weak-base) p-2.5`,children:[(0,R.jsx)(`pre`,{ref:c,className:V(`max-h-56 min-h-10 overflow-auto rounded-md border border-(--border-weak-base) bg-(--surface-inset-base) p-2 font-mono text-xs whitespace-pre-wrap text-(color:--text-base)`,!n&&`text-(color:--text-weaker)`),children:n||`No output yet…`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(nt,{className:`size-3.5 text-(color:--text-weaker)`}),(0,R.jsx)(nh,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(a(o),s(``))},placeholder:`set timeout (ms)`,className:`h-6 w-36 font-mono text-xs`}),(0,R.jsx)(U,{variant:`ghost`,size:`xs`,disabled:!o.trim(),onClick:()=>{a(o),s(``)},children:`Apply`})]})]})]})}function uG({active:e}){let[t,n]=(0,E.useState)([]),[r,i]=(0,E.useState)(!0),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(``),[d,f]=(0,E.useState)(``),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)({}),[_,v]=(0,E.useState)(Date.now()),[y,b]=(0,E.useState)(null),x=(0,E.useCallback)(async()=>{try{let e=await G.ptyList();n(e.data),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}},[]);(0,E.useEffect)(()=>{if(e)return x(),og({name:`pty-panel-list`,minInterval:5e3,run:()=>{x(),v(Date.now())}})},[e,x]);let S=async()=>{if(!(!l.trim()||p)){m(!0),o(null);try{await G.ptyCreate({command:l.trim(),cwd:d.trim()||void 0,title:s.trim()||void 0}),c(``),u(``),f(``),await x()}catch(e){o(e instanceof Error?e.message:String(e))}finally{m(!1)}}},C=async e=>{try{await G.ptyDelete(e),g(t=>{let n={...t};return delete n[e],n}),await x()}catch(e){o(e instanceof Error?e.message:String(e))}},w=async e=>{try{let t=await G.ptyConnectToken(e);g(n=>({...n,[e]:{kind:`connected`,ticket:t.data.ticket,expiresAt:Date.now()+t.data.expires_in*1e3}})),o(null)}catch(t){g(n=>({...n,[e]:{kind:`error`,message:t instanceof Error?t.message:String(t)}}))}};return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:y?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(rG,{ptyID:y,onClose:()=>b(null),onError:e=>o(e)})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(nh,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`title`,className:`w-28 text-xs`}),(0,R.jsx)(nh,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`command (e.g. bash)`,className:`flex-1 font-mono text-xs`}),(0,R.jsx)(nh,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`cwd (optional)`,className:`w-36 font-mono text-xs`}),(0,R.jsxs)(U,{onClick:()=>void S(),disabled:!l.trim()||p,children:[(0,R.jsx)(tt,{}),`Create`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,title:`Refresh`,onClick:()=>void x(),children:(0,R.jsx)(Ke,{})})]}),a&&(0,R.jsx)(`p`,{className:`text-xs text-(color:--surface-critical-strong)`,children:a}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto`,children:r?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-(color:--text-weaker)`,children:[(0,R.jsx)(uS,{}),` Loading terminals…`]}):t.length===0?(0,R.jsx)(`p`,{className:`px-1 py-2 text-xs text-(color:--text-weaker)`,children:`No PTY sessions yet — create one above.`}):t.map(e=>(0,R.jsx)(dG,{pty:e,connection:h[e.id],now:_,onConnect:()=>void w(e.id),onOpen:()=>b(e.id),onDelete:()=>void C(e.id)},e.id))}),(0,R.jsx)(eL,{className:`bg-(--border-weak-base)`}),(0,R.jsx)(`p`,{className:`text-xs text-(color:--text-weaker)`,children:`Live terminals stream over a websocket — open one to interact.`})]})})}function dG({pty:e,connection:t,now:n,onConnect:r,onOpen:i,onDelete:a}){let o=e.args.length>0?` ${e.args.join(` `)}`:``,s=t?.kind===`connected`?Math.max(0,Math.ceil((t.expiresAt-n)/1e3)):0;return(0,R.jsxs)(`div`,{className:`rounded-md border border-(--border-weak-base) bg-(--surface-base) px-2.5 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(fS,{tone:e.status===`running`?`blue`:`neutral`,children:e.status}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-(color:--text-strong)`,children:e.title||e.command}),(0,R.jsxs)(`span`,{className:`hidden shrink-0 text-xs text-(color:--text-weaker) md:inline`,children:[`pid `,e.pid,e.exitCode===void 0?``:` · exit ${e.exitCode}`]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:i,disabled:e.status!==`running`,children:[(0,R.jsx)($e,{}),`Open`]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:r,disabled:e.status!==`running`,children:[(0,R.jsx)(ie,{}),`Connect`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:e.status===`running`?`Kill`:`Delete`,"aria-label":e.status===`running`?`Kill terminal`:`Delete terminal record`,onClick:a,className:`text-(color:--surface-critical-strong)`,children:e.status===`running`?(0,R.jsx)(et,{}):(0,R.jsx)(rt,{})})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 pl-5`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-(color:--text-weak)`,children:[e.command,o,e.cwd?` — ${e.cwd}`:``]}),t?.kind===`connected`?(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs`,children:[(0,R.jsx)(Ve,{className:`size-3 text-(color:--surface-success-strong)`}),(0,R.jsx)(fS,{tone:`green`,children:`connected`}),(0,R.jsxs)(`span`,{className:`hidden font-mono text-(color:--text-weaker) sm:inline`,children:[t.ticket.slice(0,10),`… · `,s,`s`]})]}):t?.kind===`error`?(0,R.jsx)(`span`,{className:`max-w-56 shrink-0 truncate`,title:t.message,children:(0,R.jsx)(fS,{tone:`red`,children:t.message})}):(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-(color:--text-weaker)`,children:`disconnected`})]})]})}var fG=`fixed top-1/2 left-1/2 z-50 flex w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col gap-2 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,pG=`w-full rounded-md border border-[var(--border-base)] bg-[var(--input-base)] px-2.5 py-1.5 text-sm text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)]`,mG=`flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors text-[color:var(--text-base)] hover:bg-[color:var(--surface-base-hover)]`,hG=`flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors bg-[color:var(--surface-raised-base-active)] text-[color:var(--text-strong)]`;function gG(){return J(e=>e.splitPickerOpen)?(0,R.jsx)(_G,{}):null}function _G(){let e=J(e=>e.sessions),t=J(e=>e.panes),n=J(e=>e.running),r=J(e=>e.queued),i=J(e=>e.activeIDs),a=J(e=>e.currentSessionID&&!Eg(e.currentSessionID)?e.sessions.find(t=>t.id===e.currentSessionID)??e.sessionDetails[e.currentSessionID]:void 0),[o,s]=(0,E.useState)(`sessions`),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(0),[f,p]=(0,E.useState)(null),[m,h]=(0,E.useState)([]),[g,_]=(0,E.useState)(!1),[v,y]=(0,E.useState)(null),[b,x]=(0,E.useState)(null),S=(0,E.useRef)(null),C=(0,E.useRef)(!1),w=(0,E.useMemo)(()=>new Set(t.map(e=>e.sessionID)),[t]),T=c.trim().toLowerCase(),D=(0,E.useMemo)(()=>e.filter(e=>!w.has(e.id)&&!e.parentID&&(!T||(e.title??``).toLowerCase().includes(T)||e.id.toLowerCase().includes(T)||e.location.directory.toLowerCase().includes(T))).sort((e,t)=>t.time.updated-e.time.updated),[e,w,T]),O=Math.min(u,Math.max(0,D.length-1));(0,E.useEffect)(()=>d(0),[T]);let k=a?.location?.directory;function A(){s(`workspace`),x(null),!C.current&&(C.current=!0,_(!0),Promise.all([G.locationInfo(),G.projectList()]).then(([e,t])=>{p(e),h(t)}).catch(()=>x(`Could not load workspaces`)).finally(()=>_(!1)))}function j(){s(`sessions`),x(null)}function M(e){Gv(e).then(e=>{e||x(`Already open in a pane, or no free slots`)})}async function N(e,t){if(!v){y(e),x(null);try{await Gv(await Jy(t))||x(`No free split slots`)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(null)}}}let te=(0,E.useMemo)(()=>{let e=new Set;for(let t of m)t.directory&&e.add(t.directory);return[...e]},[m]);return(0,R.jsx)(es,{open:!0,onOpenChange:e=>{e||Wv()},children:(0,R.jsxs)(os,{children:[(0,R.jsx)(cs,{className:`bg-black/60`}),(0,R.jsxs)(fs,{tabIndex:-1,"data-slot":`dialog-content`,className:fG,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),S.current?.focus()},children:[(0,R.jsxs)(_s,{className:`flex items-center gap-2 text-[var(--font-size-large)] font-medium text-[var(--text-strong)]`,children:[(0,R.jsx)(Qe,{className:`size-4 shrink-0 text-[var(--text-interactive-base)]`,"aria-hidden":!0}),`Split view`,(0,R.jsx)(`span`,{className:`truncate text-xs font-normal text-[var(--text-weaker)]`,children:`open a session beside this one`})]}),o===`sessions`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{ref:S,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),d(Math.min(O+1,D.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),d(Math.max(O-1,0));else if(e.key===`Enter`){e.preventDefault();let t=D[O];t&&M(t.id)}},placeholder:`Filter sessions… (title, id, workspace)`,className:pG,autoComplete:`off`,spellCheck:!1}),(0,R.jsxs)(`button`,{type:`button`,onClick:A,disabled:v!==null,className:`flex w-full cursor-pointer items-center gap-2 rounded-md border border-dashed border-[var(--border-weak-base)] px-2 py-1.5 text-left text-sm text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)] disabled:pointer-events-none disabled:opacity-50`,children:[(0,R.jsx)(He,{className:`size-3.5 shrink-0`}),`Start new session`]}),(0,R.jsx)(`div`,{className:`-mx-1 max-h-72 overflow-y-auto px-1`,children:D.length===0?(0,R.jsx)(`p`,{className:`px-2 py-6 text-center text-xs text-[var(--text-weaker)]`,children:T?`No matching sessions`:`Every session is already in a pane`}):D.map((e,t)=>(0,R.jsx)(yG,{title:e.title||`session ${e.id.slice(0,8)}…`,dir:e.location.directory,at:e.time.updated,running:!!n[e.id]||!!r[e.id]||i.includes(e.id),highlighted:t===O,onHover:()=>d(t),onPick:()=>M(e.id)},e.id))})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:j,className:`flex cursor-pointer items-center gap-1 self-start rounded-md px-1 py-0.5 text-xs text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(ee,{className:`size-3`}),` all sessions`]}),(0,R.jsx)(`div`,{className:`-mx-1 max-h-80 overflow-y-auto px-1`,children:g?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-6 text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(uS,{className:`size-3`}),` Loading workspaces…`]}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(bG,{label:`Default workspace`,sub:f?.directory,busy:v==="default",disabled:v!==null,onChoose:()=>N(`default`,null)}),k&&a&&(0,R.jsx)(bG,{label:`same as ${a.title??`current session`}`,sub:k,busy:v===`focused`,disabled:v!==null,onChoose:()=>N(`focused`,k)}),te.map(e=>(0,R.jsx)(bG,{label:vG(e),sub:e,busy:v===e,disabled:v!==null,onChoose:()=>N(e,e)},e)),te.length===0&&!k&&(0,R.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-[var(--text-weaker)]`,children:`No workspaces`})]})})]}),b&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--surface-critical-strong)]`,children:b}),(0,R.jsxs)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`↑↓`}),` select · `,(0,R.jsx)(`span`,{className:`font-mono`,children:`↵`}),` open ·`,` `,(0,R.jsx)(`span`,{className:`font-mono`,children:`esc`}),` close`]}),(0,R.jsx)(xs,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close`,className:`absolute top-2 right-2 flex size-7 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:(0,R.jsx)(at,{className:`size-4`})})})]})]})})}function vG(e){let t=e.split(`/`).filter(Boolean);return t.length>0?t[t.length-1]:e}function yG({title:e,dir:t,at:n,running:r,highlighted:i,onHover:a,onPick:o}){let s=(0,E.useRef)(null);return(0,E.useEffect)(()=>{i&&s.current?.scrollIntoView({block:`nearest`})},[i]),(0,R.jsxs)(`button`,{ref:s,type:`button`,onMouseMove:a,onClick:o,title:t,className:i?hG:mG,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-emerald-500`:`bg-[color:var(--border-base)]`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),(0,R.jsx)(`span`,{className:`max-w-44 shrink-0 truncate font-mono text-[10px] text-[var(--text-weaker)]`,children:t}),r&&(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:`running`}),(0,R.jsx)(`span`,{className:`w-8 shrink-0 text-right font-mono text-[10px] text-[var(--text-weaker)]`,children:pS(n)})]})}function bG({label:e,sub:t,busy:n,disabled:r,onChoose:i}){return(0,R.jsxs)(`button`,{type:`button`,onClick:i,disabled:r,className:n?hG:mG,children:[n?(0,R.jsx)(uS,{className:`size-3.5 shrink-0`}):(0,R.jsx)(Ee,{className:`size-3.5 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`min-w-0 shrink truncate`,children:e}),t&&(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10px] text-[var(--text-weaker)]`,children:t})]})}var xG=`webui.activityStrip.collapsed`,SG=15e3;function CG(e){return e?e.replace(/\/+$/,``).replace(/^\/(home|Users)\/[^/]+/,`~`):``}function wG(e){let t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r?`${n}m ${r}s`:`${n}m`}function TG(e){let t=e.name||`tool`;if(e.status===`streaming`&&e.inputText){let n=e.inputText.replace(/\s+/g,` `).trim().slice(0,80);return n?`${t} ${n}…`:t}let n=e.input;if(n){if(typeof n.path==`string`)return`${t} ${String(n.path).split(`/`).pop()}`;if(typeof n.command==`string`)return`${t} ${String(n.command).slice(0,48)}`;if(typeof n.pattern==`string`)return`${t} "${String(n.pattern).slice(0,32)}"`;if(typeof n.description==`string`)return`${t} ${n.description.slice(0,40)}`;if(typeof n.agent==`string`&&typeof n.description==`string`)return`${t} ${String(n.agent)} — ${String(n.description).slice(0,24)}`}if(e.inputText){try{let n=JSON.parse(e.inputText);if(typeof n.path==`string`)return`${t} ${String(n.path).split(`/`).pop()}`;if(typeof n.command==`string`)return`${t} ${String(n.command).slice(0,48)}`}catch{}let n=e.inputText.replace(/\s+/g,` `).trim().slice(0,80);if(n&&n!==`{}`&&n!==`[]`)return`${t} ${n}`}return t}function EG(e){document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(t=>{e.document.head.appendChild(t.cloneNode(!0))});try{document.adoptedStyleSheets?.length&&(e.document.adoptedStyleSheets=document.adoptedStyleSheets)}catch{}}function DG({tool:e}){let t=e.status===`running`||e.status===`streaming`,n=e.status===`error`,r=n?`✗`:t?`⠋`:e.name===`subagent`?`→`:e.name===`shell`||e.name===`bash`?`$`:e.name===`edit`?`←`:`·`;return(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate py-0.5 text-[11px] ${n?`text-[var(--surface-critical-strong)]`:t?`text-[var(--text-base)]`:`text-[var(--text-weak)]`}`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0 text-center font-mono text-[10px] ${t?`animate-pulse`:``}`,children:t?`●`:r}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:TG(e)}),t&&(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 animate-pulse rounded-full bg-emerald-500`,"aria-hidden":!0})]})}function OG({assistants:e}){if(e.length===0)return(0,R.jsx)(`span`,{className:`text-[11px] italic text-[var(--text-weaker)]`,children:`waiting…`});let t=e.flatMap(e=>e.content),n=t.filter(e=>e.type===`reasoning`).slice(-1),r=t.filter(e=>e.type===`text`).slice(-2),i=t.filter(e=>e.type===`tool`).slice(-6),a=i.filter(e=>e.tool.status===`running`||e.tool.status===`streaming`),o=[...i.filter(e=>e.tool.status!==`running`&&e.tool.status!==`streaming`).slice(-3),...a];return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[n.length>0&&(0,R.jsx)(`div`,{className:`line-clamp-1 truncate text-[11px] italic text-[var(--text-weaker)]`,children:(()=>{let e=n[0].text.replace(/\s+/g,` `).trim();return`thought: ${e.length>140?`…${e.slice(-140)}`:e}`})()}),r.map(e=>{let t=e.text.replace(/\s+/g,` `).trim();if(!t)return null;let n=t.length>220?`…${t.slice(-220)}`:t;return(0,R.jsx)(`div`,{className:`line-clamp-2 break-words text-xs leading-snug text-[var(--text-base)]`,children:n},`t-${e.ordinal}`)}),o.map(e=>(0,R.jsx)(DG,{tool:e.tool},e.tool.id)),t.length===0&&(0,R.jsx)(`span`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`working…`})]})}function kG({session:e,assistants:t,running:n,queued:r,onOpen:i}){let[a,o]=(0,E.useState)(0);(0,E.useEffect)(()=>{if(n)return og({name:`activity-row-elapsed`,minInterval:1e3,run:()=>o(e=>e+1)})},[n]);let s=t[0]?.started??e.time?.updated??Date.now(),c=n?`running`:r?`queued`:`idle`;return(0,R.jsxs)(`div`,{className:`group flex min-w-0 flex-col gap-1 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2 py-1.5 hover:border-[var(--border-base)]`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${c===`running`?`bg-emerald-500 animate-pulse`:c===`queued`?`bg-amber-500 animate-pulse`:`bg-[var(--border-base)]`}`,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-[var(--text-strong)]`,title:e.title??e.id,children:e.title||`Untitled session`}),e.location?.directory&&(0,R.jsx)(`span`,{className:`hidden max-w-[14ch] truncate font-mono text-[10px] text-[var(--text-weaker)] sm:inline`,title:e.location.directory,children:CG(e.location.directory)}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:n?wG(s):r?`queued`:``}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:`Open session`,className:`inline-flex shrink-0 cursor-pointer items-center gap-1 rounded-md border border-transparent px-1 py-0.5 text-[11px] text-[var(--text-weaker)] hover:border-[var(--border-weak-base)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(pe,{className:`size-3`}),` open`]})]}),(0,R.jsx)(`div`,{className:`min-w-0 pl-3`,children:(0,R.jsx)(OG,{assistants:t})})]})}function AG({onOpen:e}){let t=J(e=>e.sessions),n=J(e=>e.running),r=J(e=>e.queued),i=J(e=>e.activeIDs),a=J(e=>e.live),o=(0,E.useMemo)(()=>{let e=new Map;for(let t of a){let n=e.get(t.sessionID)??[];n.push(t),e.set(t.sessionID,n)}for(let t of e.values())t.sort((e,t)=>e.started-t.started);return e},[a]),s=e=>n[e]||r[e]||(o.get(e)??[]).some(e=>e.finish===void 0)?!0:i.includes(e)&&Date.now()-Jg(e)<SG,c=(0,E.useMemo)(()=>{let e=t.filter(e=>!e.parentID),r=[];for(let n of e){let e=Ov(t,n.id).filter(e=>s(e.id)),i=s(n.id);(i||e.length>0)&&r.push({parent:n,parentLive:i,children:e})}let i=new Set(r.flatMap(e=>e.children.map(e=>e.id))),a=t.filter(e=>!!e.parentID&&s(e.id)&&!i.has(e.id));for(let e of a){let n=t.find(t=>t.id===e.parentID)??{id:e.parentID,title:`Parent`,time:{updated:0}};r.find(t=>t.parent.id===e.parentID)||r.push({parent:n,parentLive:!1,children:[e]})}return r.sort((e,t)=>{let r=e.parentLive&&n[e.parent.id]?1:+!!e.children.some(e=>!!n[e.id]),i=t.parentLive&&n[t.parent.id]?1:+!!t.children.some(e=>!!n[e.id]);return r===i?(t.parent.time?.updated??0)-(e.parent.time?.updated??0):i-r}),r},[t,n,r,i,a,o]);return c.length===0?(0,R.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--text-weaker)]`,children:`No active agents.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(t=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t.parentLive?(0,R.jsx)(kG,{session:t.parent,assistants:o.get(t.parent.id)??[],running:!!n[t.parent.id],queued:!!r[t.parent.id],onOpen:e}):(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1 text-[11px] font-medium text-[var(--text-weaker)]`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t.parent.title||CG(t.parent.location?.directory)||t.parent.id.slice(0,8)}),(0,R.jsxs)(`span`,{className:`font-mono text-[10px]`,children:[`· `,t.children.length,` subagent`,t.children.length===1?``:`s`]})]}),t.children.length>0&&(0,R.jsx)(`div`,{className:`ml-3 flex flex-col gap-1 border-l border-[var(--border-weak-base)] pl-2`,children:t.children.map(t=>(0,R.jsx)(kG,{session:t,assistants:o.get(t.id)??[],running:!!n[t.id],queued:!!r[t.id],onOpen:e},t.id))})]},t.parent.id))})}function jG(){let e=J(e=>e.running),t=J(e=>e.queued),n=J(e=>e.live),r=J(e=>e.activeIDs),[,i]=(0,E.useState)(0),a=(0,E.useMemo)(()=>{let e=new Map;for(let t of n){let n=e.get(t.sessionID)??[];n.push(t),e.set(t.sessionID,n)}return e},[n]),o=n=>e[n]||t[n]||(a.get(n)??[]).some(e=>e.finish===void 0)?!0:r.includes(n)&&Date.now()-Jg(n)<SG,s=(0,E.useMemo)(()=>{let i=new Set([...Object.keys(e),...Object.keys(t),...r,...n.map(e=>e.sessionID)]);for(let e of i)if(o(e))return!0;return!1},[e,t,r,n,a]);(0,E.useEffect)(()=>{if(s)return og({name:`activity-strip-tick`,minInterval:1e3,run:()=>i(e=>e+1)})},[s]);let[c,l]=(0,E.useState)(()=>{try{return localStorage.getItem(xG)===`1`}catch{return!1}}),[u,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(null),m=typeof window<`u`&&`documentPictureInPicture`in window;(0,E.useEffect)(()=>{try{localStorage.setItem(xG,c?`1`:`0`)}catch{}},[c]);let h=(0,E.useMemo)(()=>{let i=new Set([...Object.keys(e),...Object.keys(t),...r,...n.map(e=>e.sessionID)]),a=0;for(let e of i)o(e)&&a++;return a},[e,t,r,n,a]);if(!s)return null;let g=e=>void Jv(e),_=async()=>{if(u){u.close(),d(null),p(null);return}try{let e=await window.documentPictureInPicture.requestWindow({width:380,height:560});EG(e),e.document.body.style.margin=`0`,e.document.documentElement.style.background=`var(--background-base)`,e.document.body.style.background=`var(--background-base)`,e.document.body.style.fontFamily=getComputedStyle(document.body).fontFamily;let t=e.document.createElement(`div`);t.id=`activity-strip-pip-root`,t.style.height=`100vh`,t.style.overflow=`auto`,t.style.background=`var(--background-base)`,e.document.body.appendChild(t),p(t),d(e),e.addEventListener(`pagehide`,()=>{d(null),p(null)})}catch(e){console.warn(`PiP failed`,e)}};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-[var(--border-base)] bg-[var(--background-base)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-[var(--text-strong)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-500`,"aria-hidden":!0}),h,` active`,(0,R.jsx)(`span`,{className:`font-normal text-[var(--text-weaker)]`,children:`· streaming`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[m&&(0,R.jsxs)(`button`,{type:`button`,onClick:_,title:u?`Close picture-in-picture`:`Pop out — always on top outside Chrome`,className:`inline-flex cursor-pointer items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] ${u?`border-[var(--border-selected)] bg-[var(--surface-interactive-weak)] text-[var(--text-interactive-base)]`:`border-[var(--border-weak-base)] text-[var(--text-weaker)] hover:text-[var(--text-strong)]`}`,children:[(0,R.jsx)(ze,{className:`size-3`}),` `,u?`popped`:`pop out`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),title:c?`Expand`:`Collapse`,className:`flex size-6 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:c?(0,R.jsx)(I,{className:`size-3.5`}):(0,R.jsx)(oe,{className:`size-3.5`})})]})]}),c?null:(0,R.jsx)(`div`,{className:`max-h-[42vh] overflow-auto px-2 pb-2`,children:(0,R.jsx)(AG,{onOpen:g})})]}),u&&f?(0,jr.createPortal)((0,R.jsxs)(`div`,{className:`min-h-screen bg-[var(--background-base)] p-2`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium text-[var(--text-strong)]`,children:[`Live — `,h,` active`]}),(0,R.jsx)(`button`,{type:`button`,onClick:_,className:`rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-[11px] text-[var(--text-weaker)]`,children:`close`})]}),(0,R.jsx)(AG,{onOpen:e=>{Jv(e);try{window.focus()}catch{}}})]}),f):null]})}function MG(e){let t=e.toLowerCase().split(`+`).map(e=>e.trim()).filter(Boolean),n=!1,r=!1,i=!1,a=!1,o=``;for(let e of t)e===`ctrl`||e===`control`?n=!0:e===`meta`||e===`cmd`||e===`command`||e===`super`?r=!0:e===`shift`?i=!0:e===`alt`||e===`option`?a=!0:o=e;return{ctrl:n,meta:r,shift:i,alt:a,key:o}}function NG(e,t){let n=MG(e);return!n.key||n.ctrl!==t.ctrlKey||n.meta!==t.metaKey||n.shift!==t.shiftKey||n.alt!==t.altKey?!1:t.key.toLowerCase()===n.key.toLowerCase()}function PG(e){let t=e;return t?t.isContentEditable||t.closest?.(`input, textarea, select, [contenteditable=true]`)?!0:t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`:!1}function FG(){return(0,E.useEffect)(()=>{let e=St(),t=pt(()=>{e=St()}),n=t=>{if(!t.repeat&&!PG(t.target)&&!document.querySelector(`[role="dialog"], [cmdk-root], [data-radix-popper-content-wrapper], [role="menu"], [role="listbox"]`))for(let n of e){let e=n.keybind;if(e&&NG(e,t)){t.preventDefault();try{let e=Ng().currentSessionID??void 0;n.run({sessionID:e})}catch(e){console.error(`[extensions] command "${n.id}" keybind failed:`,e)}break}}};return window.addEventListener(`keydown`,n),()=>{t(),window.removeEventListener(`keydown`,n)}},[]),null}function IG(){let e=(0,E.useSyncExternalStore)(wN,TN,TN);return e.length===0?null:(0,R.jsx)(`div`,{className:`pointer-events-none fixed right-4 bottom-4 z-50 flex w-[min(22rem,calc(100vw-2rem))] flex-col gap-2`,children:e.map(e=>(0,R.jsxs)(`div`,{role:`status`,className:`pointer-events-auto flex flex-col gap-0.5 rounded-md border px-3 py-2.5 shadow-lg backdrop-blur-sm transition-all ${e.variant===`destructive`?`border-[color:var(--surface-critical-strong)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_12%,var(--surface-float-base))] text-[var(--text-strong)]`:`border-[var(--border-weak-base)] bg-[var(--surface-float-base)] text-[var(--text-strong)]`}`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium leading-tight`,children:e.title}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>EN(e.id),className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,"aria-label":`Dismiss`,children:`✕`})]}),e.description?(0,R.jsx)(`span`,{className:`text-xs leading-snug text-[var(--text-weak)]`,children:e.description}):null]},e.id))})}function LG(e,t=`main`){let n=Ng();if(n.currentSessionID&&Sg(n).some(e=>e.req.sessionID===n.currentSessionID))return;wv();let r=document.getElementById(`composer-input-${t}`);if(r){r.focus({preventScroll:!0});return}RG(e,t)}function RG(e,t){let n=0,r=()=>{let i=document.getElementById(`composer-input-${t}`);if(!i){n++===2&&Ev(),n<30&&requestAnimationFrame(r);return}i.focus({preventScroll:!0});let a=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set;if(a){a.call(i,i.value+e),i.dispatchEvent(new Event(`input`,{bubbles:!0}));let t=i.value.length;i.setSelectionRange(t,t)}};requestAnimationFrame(r)}var zG=/^\/ext\/([A-Za-z0-9_-]+)$/,BG=`webui:navigate`;function VG(){let[e,t]=(0,E.useState)(()=>window.location.pathname);return(0,E.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),window.addEventListener(BG,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(BG,e)}},[]),e}function HG(){let e=J(e=>e.currentSessionID),t=J(e=>e.connected),n=J(e=>e.currentSessionID?e.sessions.find(t=>t.id===e.currentSessionID)??e.sessionDetails[e.currentSessionID]:void 0),r=J(e=>e.sessions),i=J(e=>e.runsPanelOpen),a=J(t=>kv(t,e)),o=J(e=>e.panes[0]?.sessionID??null),s=J(e=>e.panes.slice(1)),c=J(e=>e.focusedPane),l=VG(),u=zG.exec(l)?.[1]??null,d=(u?At(u):void 0)?.title;(0,E.useEffect)(()=>{if(d!==void 0){document.title=d;return}document.title=e?`${a?`● `:``}${Eg(e)?`New session`:n?.title??`Untitled session`}`:`OpenCode Web`},[e,n?.title,a,d]);function f(){return!!document.querySelector(`[role="dialog"]`)||i}let p=e=>void Jv(e);function m(t){if(!e||!n?.parentID||f())return;let i=Ov(r,n.parentID).slice().sort((e,t)=>e.id<t.id?-1:1);if(i.length===0)return;let a=i.findIndex(t=>t.id===e),o=(((a===-1?0:a)+t)%i.length+i.length)%i.length;p(i[o].id)}(0,E.useEffect)(()=>{let e=e=>{if(e.key.length!==1||e.metaKey)return;let t=e.ctrlKey&&e.altKey;if(e.ctrlKey&&!t||e.altKey&&!t)return;let n=e.target;n&&(n.isContentEditable||n.closest(`input, textarea, select, [contenteditable=true]`))||document.querySelector(`[role="dialog"], [cmdk-root], [data-radix-popper-content-wrapper], [role="menu"], [role="listbox"]`)||LG(e.key,Yv())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);function h(){if(f())return;let e=document.getElementById(`session-search`);e&&(e.focus(),e.select())}hb({arrowup:()=>{!n?.parentID||!e||f()||p(n.parentID)},arrowdown:()=>{!e||f()||Cv()},arrowleft:()=>m(-1),arrowright:()=>m(1),enter:()=>{!n?.parentID||!e||f()||Ev()},backspace:()=>{if(!n?.parentID||!e||f())return;let t=document.getElementById(`composer-input-${Yv()}`);t&&t.value!==``||p(n.parentID)},"ctrl+n":()=>Wy(null),"ctrl+\\":()=>Uv(),"meta+f":h,"ctrl+f":h,escape:e=>{let t=e?.target;document.querySelector(`[role="dialog"]`)||t&&(t.id.startsWith(`composer-input`)||t.closest(`[data-radix-popper-content-wrapper], [cmdk-root], [data-slot="command"]`))||Iy()}});let g=e=>()=>void Hv(e);return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden`,children:[(0,R.jsx)(Nt,{region:`app.header`,sessionID:e??void 0}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(GI,{}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto`,children:[(0,R.jsx)(`section`,{className:`flex min-w-0 flex-1 flex-col`,onPointerDownCapture:g(wg),onFocusCapture:g(wg),children:u?(0,R.jsx)(GG,{id:u}):o?(0,R.jsx)(FF,{sessionID:o,paneKey:`main`,focused:c===wg,onNavigate:p},o):(0,R.jsx)(WG,{connected:t})}),s.map(e=>(0,R.jsx)(`section`,{className:`pane-surface hidden min-w-0 border-l border-[var(--border-base)] lg:flex`,style:{flex:`1 1 0`,maxWidth:`50%`},onPointerDownCapture:g(e.id),onFocusCapture:g(e.id),children:e.sessionID?(0,R.jsx)(FF,{sessionID:e.sessionID,paneKey:e.id,focused:c===e.id,onClose:()=>void Kv(e.id),onNavigate:p},`${e.id}:${e.sessionID}`):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-[var(--text-weaker)]`,children:`Empty pane`})},e.id)),(0,R.jsx)(`div`,{className:`hidden w-9 shrink-0 flex-col items-center border-l border-[var(--border-base)] pt-2 lg:flex`,children:(0,R.jsx)(`button`,{type:`button`,onClick:Uv,disabled:s.length>=3,title:`Split view — open a session beside this one`,className:`flex size-7 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)] disabled:pointer-events-none disabled:opacity-40`,children:(0,R.jsx)(le,{className:`size-4`})})})]})]}),(0,R.jsx)(jG,{}),(0,R.jsx)(Nt,{region:`footer`}),(0,R.jsx)(UG,{}),(0,R.jsx)(gG,{}),(0,R.jsx)(yb,{}),(0,R.jsx)(FG,{}),(0,R.jsx)(IG,{}),(0,R.jsx)(XF,{}),(0,R.jsx)(sG,{trigger:(0,R.jsx)(`span`,{className:`hidden`})})]})}function UG(){let e=J(e=>Sg(e).filter(t=>t.req.sessionID!==e.currentSessionID)),t=e.map(e=>e.req.id).join(`,`);return(0,E.useEffect)(()=>{t&&Hh(`chip`,`foreign waiting: ${t}`)},[t]),e.length===0?null:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void Pv(e[0].req.sessionID,{history:`push`}),title:e.map(e=>`${e.kind} — ${e.req.sessionID}`).join(`
122
- `),className:`fixed right-4 bottom-10 z-40 flex items-center gap-1.5 rounded-full border border-[color-mix(in_oklch,var(--surface-warning-strong)_45%,transparent)] bg-[var(--surface-float-base)] px-2.5 py-1 text-xs text-[var(--text-weak)] shadow-md transition-colors hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-[color:var(--surface-warning-strong)]`,"aria-hidden":!0}),e.length,` waiting in other session`,e.length>1?`s`:``,` — switch`]})}function WG({connected:e}){return(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-neutral-500`,children:[(0,R.jsx)(`div`,{className:`size-2.5 rounded-full ${e?`bg-emerald-500`:`bg-amber-500`}`}),(0,R.jsx)(`p`,{className:`text-sm`,children:e?`Select or create a session on the left`:`Connecting to the opencode service…`})]})}function GG({id:e}){KG();let t=At(e),n=Tt();return(0,R.jsx)(`div`,{className:`pane-surface flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto`,children:(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6`,children:[(0,R.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>window.history.back(),title:`Go back`,className:`inline-flex cursor-pointer items-center gap-1 rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-xs text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(ee,{className:`size-3`}),`Back`]}),(0,R.jsx)(`h1`,{className:`truncate text-[var(--font-size-large)] font-medium text-[var(--text-strong)]`,children:t?t.title:`Unknown extension page`})]}),t?.description&&(0,R.jsx)(`p`,{className:`mt-1 text-sm text-[var(--text-weaker)]`,children:t.description})]})}),(0,R.jsx)(`div`,{className:`mt-4`,children:t?t.render({}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm text-[var(--text-weak)]`,children:[(0,R.jsxs)(`p`,{children:[`No extension registered “`,e,`”. Available pages:`]}),n.length===0?(0,R.jsx)(`p`,{className:`text-[var(--text-weaker)]`,children:`No extension pages are registered.`}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:`/ext/${e.id}`,title:e.description??e.title,className:`text-[var(--text-interactive-base)] underline underline-offset-2`,children:[`/ext/`,e.id,` — `,e.title]})},e.id))})]})})]})})}function KG(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),[e]}var qG=class extends E.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error(`[app] render error:`,e)}render(){return this.state.error?(0,R.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:`The UI hit a render error.`}),(0,R.jsx)(`pre`,{className:`max-h-48 max-w-full overflow-auto rounded-md border border-border bg-muted p-3 font-mono text-xs whitespace-pre-wrap text-muted-foreground`,children:this.state.error.message}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`cursor-pointer rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-muted`,children:`Retry`})]}):this.props.children}},JG=Object.assign({"./report/index.tsx":()=>ug(()=>import(`./report-R1enHhQU.js`),[]),"./runtime-status/index.tsx":()=>ug(()=>import(`./runtime-status-CWjwBTFm.js`),[])});async function YG(){let e=new Set;await Promise.all(Object.values(JG).map(async t=>{let n=await t();n&&typeof n.id==`string`&&e.add(n.id)})),ht(e)}YG();var XG=new Map,ZG=8e3;function QG(){let e=window,t=e.__opencodeUI??{};t.notify||=DN,t.getHooks||=kt,t.register||=yt,e.__opencodeUI=t}var $G=!1;async function eK(e){if(QG(),!e?.force&&$G&&document.hidden)return;let t;try{let e=await fetch(`/api/webui/extensions`);if(!e.ok)return;let n=(await e.json())?.data;t=Array.isArray(n)?n:[]}catch{return}let n=new Set;for(let e of t)if(typeof e?.id==`string`&&typeof e?.url==`string`&&!aS(e.id)&&(n.add(e.id),gt([e.id]),XG.get(e.id)!==e.url))try{await ug(()=>import(e.url),[]),XG.set(e.id,e.url)}catch{}let r=[];for(let e of XG.keys())n.has(e)||(r.push(e),XG.delete(e));r.length>0&&_t(r)}function tK(){$G||($G=!0,QG(),eK({force:!0}),og({name:`extensions-manifest`,minInterval:ZG,run:()=>eK()}))}var nK=typeof localStorage<`u`&&localStorage.getItem(`webui.debug`)===`1`;window.__WEBUI_DEBUG_CONSOLE__=nK,window.__opencodeUI={version:1,register:yt,react:E,jsxRuntime:R,useStore:J,api:G,notify:DN,getHooks:kt},tK(),mv(),Hh(`boot`,`app render (console mirror: ${nK?`on`:`off`})`),(0,ot.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(E.StrictMode,{children:(0,R.jsx)(qG,{children:(0,R.jsx)(HG,{})})}));export{ey as a,st as c,Yy as i,p as l,Ng as n,J as o,Eg as r,yt as s,DN as t,l as u};
117
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),pH&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=IH(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ZV(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-LH),LH),t/=LH,t/Math.abs(t)+Math.round(t*(RH-1)))}shouldForceSelection(e){return lH?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),zH)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(lH&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<BH&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=SH(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(!(!t&&o.slice(s,c).trim()===``)){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=IH(n,this._bufferService.cols)}};HH=aL([Z(3,ML),Z(4,PL),Z(5,KL),Z(6,RL),Z(7,qL),Z(8,GL)],HH);var UH=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},WH=class{constructor(){this._color=new UH,this._css=new UH}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},GH=Object.freeze((()=>{let e=[yV.toColor(`#2e3436`),yV.toColor(`#cc0000`),yV.toColor(`#4e9a06`),yV.toColor(`#c4a000`),yV.toColor(`#3465a4`),yV.toColor(`#75507b`),yV.toColor(`#06989a`),yV.toColor(`#d3d7cf`),yV.toColor(`#555753`),yV.toColor(`#ef2929`),yV.toColor(`#8ae234`),yV.toColor(`#fce94f`),yV.toColor(`#729fcf`),yV.toColor(`#ad7fa8`),yV.toColor(`#34e2e2`),yV.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:_V.toCss(r,i,a),rgba:_V.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:_V.toCss(n,n,n),rgba:_V.toRgba(n,n,n)})}return e})()),KH=yV.toColor(`#ffffff`),qH=yV.toColor(`#000000`),JH=yV.toColor(`#ffffff`),YH=qH,XH={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},ZH=KH,QH=class extends xR{constructor(e){super(),this._optionsService=e,this._contrastCache=new WH,this._halfContrastCache=new WH,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:KH,background:qH,cursor:JH,cursorAccent:YH,selectionForeground:void 0,selectionBackgroundTransparent:XH,selectionBackgroundOpaque:vV.blend(qH,XH),selectionInactiveBackgroundTransparent:XH,selectionInactiveBackgroundOpaque:vV.blend(qH,XH),scrollbarSliderBackground:vV.opacity(KH,.2),scrollbarSliderHoverBackground:vV.opacity(KH,.4),scrollbarSliderActiveBackground:vV.opacity(KH,.5),overviewRulerBorder:KH,ansi:GH.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=$H(e.foreground,KH),t.background=$H(e.background,qH),t.cursor=vV.blend(t.background,$H(e.cursor,JH)),t.cursorAccent=vV.blend(t.background,$H(e.cursorAccent,YH)),t.selectionBackgroundTransparent=$H(e.selectionBackground,XH),t.selectionBackgroundOpaque=vV.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=$H(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=vV.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?$H(e.selectionForeground,gV):void 0,t.selectionForeground===gV&&(t.selectionForeground=void 0),vV.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=vV.opacity(t.selectionBackgroundTransparent,.3)),vV.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=vV.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=$H(e.scrollbarSliderBackground,vV.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=$H(e.scrollbarSliderHoverBackground,vV.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=$H(e.scrollbarSliderActiveBackground,vV.opacity(t.foreground,.5)),t.overviewRulerBorder=$H(e.overviewRulerBorder,ZH),t.ansi=GH.slice(),t.ansi[0]=$H(e.black,GH[0]),t.ansi[1]=$H(e.red,GH[1]),t.ansi[2]=$H(e.green,GH[2]),t.ansi[3]=$H(e.yellow,GH[3]),t.ansi[4]=$H(e.blue,GH[4]),t.ansi[5]=$H(e.magenta,GH[5]),t.ansi[6]=$H(e.cyan,GH[6]),t.ansi[7]=$H(e.white,GH[7]),t.ansi[8]=$H(e.brightBlack,GH[8]),t.ansi[9]=$H(e.brightRed,GH[9]),t.ansi[10]=$H(e.brightGreen,GH[10]),t.ansi[11]=$H(e.brightYellow,GH[11]),t.ansi[12]=$H(e.brightBlue,GH[12]),t.ansi[13]=$H(e.brightMagenta,GH[13]),t.ansi[14]=$H(e.brightCyan,GH[14]),t.ansi[15]=$H(e.brightWhite,GH[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=$H(e.extendedAnsi[r],GH[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};QH=aL([Z(0,RL)],QH);function $H(e,t){if(e!==void 0)try{return yV.toColor(e)}catch{}return t}var eU=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},tU=class{constructor(){this._services=new eU,this._services.set(IL,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=kL(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},nU={trace:0,debug:1,info:2,warn:3,error:4,off:5},rU=`xterm.js: `,iU=class extends xR{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),aU=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=nU[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:rU)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};iU=aL([Z(0,RL)],iU);var aU,oU=class extends xR{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},sU=3,cU=Object.freeze(new CL),lU=0,uU=2,dU=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*sU);let r=t||TL.fromCharData([0,xL,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*sU+0],n=t&2097151;return[this._data[e*sU+1],t&2097152?this._combined[e]:n?_L(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*sU+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*sU+0]=e|2097152|t[2]<<22):this._data[e*sU+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*sU+0]>>22}hasWidth(e){return this._data[e*sU+0]&12582912}getFg(e){return this._data[e*sU+1]}getBg(e){return this._data[e*sU+2]}hasContent(e){return this._data[e*sU+0]&4194303}getCodePoint(e){let t=this._data[e*sU+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*sU+0]&2097152}getString(e){let t=this._data[e*sU+0];return t&2097152?this._combined[e]:t&2097151?_L(t&2097151):``}isProtected(e){return this._data[e*sU+2]&536870912}loadCell(e,t){return lU=e*sU,t.content=this._data[lU+0],t.fg=this._data[lU+1],t.bg=this._data[lU+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*sU+0]=t.content,this._data[e*sU+1]=t.fg,this._data[e*sU+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*sU+0]=t|n<<22,this._data[e*sU+1]=r.fg,this._data[e*sU+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*sU+0];r&2097152?this._combined[e]+=_L(t):r&2097151?(this._combined[e]=_L(r&2097151)+_L(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*sU+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new TL;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new TL;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*uU<this._data.buffer.byteLength;let n=e*sU;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*uU<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*uU<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*sU+0]&4194303)return e+(this._data[e*sU+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*sU+0]&4194303||this._data[e*sU+2]&50331648)return e+(this._data[e*sU+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<sU;e++)this._data[(n+i)*sU+e]=a[(t+i)*sU+e];a[(t+i)*sU+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<sU;e++)this._data[(n+i)*sU+e]=a[(t+i)*sU+e];a[(t+i)*sU+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*sU+0],n=e&2097151,a=e&2097152?this._combined[t]:n?_L(n):SL;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function fU(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=gU(u,d,t),p=1,m=0;for(;p<u.length;){let e=gU(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function pU(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function mU(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function hU(e,t,n){let r=[],i=e.map((n,r)=>gU(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=gU(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function gU(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var _U=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),gR(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};_U._nextId=1;var vU=_U,yU={},bU=yU.B;yU[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},yU.A={"#":`£`},yU.B=void 0,yU[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},yU.C=yU[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},yU.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},yU.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},yU.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},yU.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},yU.E=yU[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},yU.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},yU.H=yU[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},yU[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var xU=4294967295,SU=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=cU.clone(),this.savedCharset=bU,this.markers=[],this._nullCell=TL.fromCharData([0,xL,1,0]),this._whitespaceCell=TL.fromCharData([0,SL,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new vH,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new oU(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new wL),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new wL),this._whitespaceCell}getBlankLine(e,t){return new dU(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>xU?xU:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=cU);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new oU(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(cU),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new dU(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new dU(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=fU(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(cU),n);if(r.length>0){let n=pU(this.lines,r);mU(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(cU),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new dU(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(cU),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=hU(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(cU,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=gU(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new vU(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},CU=class extends xR{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new SU(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new SU(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},wU=2,TU=1,EU=class extends xR{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,wU),this.rows=Math.max(e.rawOptions.rows||0,TU),this.buffers=this._register(new CU(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};EU=aL([Z(0,RL)],EU);var DU={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:lH,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},OU=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],kU=class extends xR{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...DU};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(vR(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in DU))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in DU))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=DU[e],!AU(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=DU[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=OU.includes(t)?t:DU[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function AU(e){return e===`block`||e===`underline`||e===`bar`}function jU(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&jU(e[r],t-1);return n}var MU=Object.freeze({insertMode:!1}),NU=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),PU=class extends xR{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=jU(MU),this.decPrivateModes=jU(NU)}reset(){this.modes=jU(MU),this.decPrivateModes=jU(NU)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};PU=aL([Z(0,ML),Z(1,LL),Z(2,RL)],PU);var FU={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function IU(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var LU=String.fromCharCode,RU={DEFAULT:e=>{let t=[IU(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${LU(t[0])}${LU(t[1])}${LU(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${IU(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${IU(e,!0)};${e.x};${e.y}${t}`}},zU=class extends xR{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(FU))this.addProtocol(e,FU[e]);for(let e of Object.keys(RU))this.addEncoding(e,RU[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};zU=aL([Z(0,ML),Z(1,PL),Z(2,RL)],zU);var BU=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],VU=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],HU;function UU(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var WU=class{constructor(){if(this.version=`6`,!HU){HU=new Uint8Array(65536),HU.fill(1),HU[0]=0,HU.fill(0,1,32),HU.fill(0,127,160),HU.fill(2,4352,4448),HU[9001]=2,HU[9002]=2,HU.fill(2,11904,42192),HU[12351]=1,HU.fill(2,44032,55204),HU.fill(2,63744,64256),HU.fill(2,65040,65050),HU.fill(2,65072,65136),HU.fill(2,65280,65377),HU.fill(2,65504,65511);for(let e=0;e<BU.length;++e)HU.fill(0,BU[e][0],BU[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?HU[e]:UU(e,VU)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=GU.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return GU.createPropertyValue(0,n,r)}},GU=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new WU;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},KU=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function qU(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var JU=2147483647,YU=256,XU=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>YU)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>JU?JU:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>JU?JU:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,JU):e}},ZU=[],QU=class{constructor(){this._state=0,this._active=ZU,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ZU}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ZU,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ZU,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,vL(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=ZU,this._id=-1,this._state=0}}},$U=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=vL(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},eW=[],tW=class{constructor(){this._handlers=Object.create(null),this._active=eW,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=eW}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=eW,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||eW,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,vL(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=eW,this._ident=0}},nW=new XU;nW.addParam(0);var rW=class{constructor(e){this._handler=e,this._data=``,this._params=nW,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():nW,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=vL(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=nW,this._data=``,this._hitLimit=!1,e));return this._params=nW,this._data=``,this._hitLimit=!1,t}},iW=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},aW=160,oW=function(){let e=new iW(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(aW,0,2,0),e.add(aW,8,5,8),e.add(aW,6,0,6),e.add(aW,11,0,11),e.add(aW,13,13,13),e}(),sW=class extends xR{constructor(e=oW){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new XU,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(vR(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new QU),this._dcsParser=this._register(new tW),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:aW)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<aW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<aW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<aW){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<aW){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<aW){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<aW){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},cW=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,lW=/^[\da-f]+$/;function uW(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=cW.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),lW.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function dW(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function fW(e,t=16){let[n,r,i]=e;return`rgb:${dW(n,t)}/${dW(r,t)}/${dW(i,t)}`}var pW={"(":0,")":1,"*":2,"+":3,"-":1,".":2},mW=131072,hW=10;function gW(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var _W=5e3,vW=0,yW=class extends xR{constructor(e,t,n,r,i,a,o,s,c=new sW){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new yL,this._utf8Decoder=new bL,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=cU.clone(),this._eraseAttrDataInternal=cU.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new bW(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(lV.IND,()=>this.index()),this._parser.setExecuteHandler(lV.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(lV.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new $U(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new $U(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new $U(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new $U(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new $U(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new $U(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new $U(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new $U(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new $U(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new $U(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new $U(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new $U(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in yU)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new rW((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),_W))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${_W} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>mW&&(a=this._parseStack.position+mW)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<mW&&(this._parseBuffer=new Uint32Array(Math.min(e.length,mW))),o||this._dirtyRowTracker.clearRange(),e.length>mW)for(let t=a;t<e.length;t+=mW){let a=t+mW<e.length?t+mW:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=GU.extractWidth(t);let n=GU.extractShouldJoin(t),m=n?GU.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(_L(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof dU&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!gW(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new rW(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new $U(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(cU));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=GU.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,bU),this._charsetService.setgCharset(1,bU),this._charsetService.setgCharset(2,bU),this._charsetService.setgCharset(3,bU);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=CL.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=cU.fg,e.bg=cU.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=cU.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=cU.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=cU.fg&16777215,r.bg&=-67108864,r.bg|=cU.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=cU.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!gW(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>hW&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>hW&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(xW(n)){if(r===`?`)t.push({type:0,index:n});else{let e=uW(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=uW(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);xW(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,bU),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(pW[e[0]],yU[e[1]]||bU),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=cU.clone(),this._eraseAttrDataInternal=cU.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new TL;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},bW=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(vW=e,e=t,t=vW),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};bW=aL([Z(0,ML)],bW);function xW(e){return 0<=e&&e<256}var SW=5e7,CW=12,wW=50,TW=class extends xR{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>SW)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=CW?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=CW)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>wW&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},EW=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};EW=aL([Z(0,ML)],EW);var DW=!1,OW=class extends xR{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new SR),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new tU,this.optionsService=this._register(new kU(e)),this._instantiationService.setService(RL,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(EU)),this._instantiationService.setService(ML,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(iU)),this._instantiationService.setService(LL,this._logService),this.coreService=this._register(this._instantiationService.createInstance(PU)),this._instantiationService.setService(PL,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(zU)),this._instantiationService.setService(NL,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(GU)),this._instantiationService.setService(BL,this.unicodeService),this._charsetService=this._instantiationService.createInstance(KU),this._instantiationService.setService(FL,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(EW),this._instantiationService.setService(zL,this._oscLinkService),this._inputHandler=this._register(new yW(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(kR.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(kR.forward(this._bufferService.onResize,this._onResize)),this._register(kR.forward(this.coreService.onData,this._onData)),this._register(kR.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new TW((e,t)=>this._inputHandler.parse(e,t))),this._register(kR.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!DW&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),DW=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,wU),t=Math.max(t,TU),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(qU.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(qU(this._bufferService),!1))),this._windowsWrappingHeuristics.value=vR(()=>{for(let t of e)t.dispose()})}}},kW={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function AW(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=kW[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var jW=0,MW=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new vH,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new vH,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(jW=this._search(t),jW===-1)||this._getKey(this._array[jW])!==t)return!1;do if(this._array[jW]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(jW),!0;while(++jW<this._array.length&&this._getKey(this._array[jW])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jW=this._search(e),!(jW<0||jW>=this._array.length)&&this._getKey(this._array[jW])===e))do yield this._array[jW];while(++jW<this._array.length&&this._getKey(this._array[jW])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jW=this._search(e),!(jW<0||jW>=this._array.length)&&this._getKey(this._array[jW])===e))do t(this._array[jW]);while(++jW<this._array.length&&this._getKey(this._array[jW])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},NW=0,PW=0,FW=class extends xR{constructor(){super(),this._decorations=new MW(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(vR(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new IW(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{NW=t.options.x??0,PW=NW+(t.options.width??1),e>=NW&&e<PW&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},IW=class extends bR{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?yV.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?yV.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},LW=1e3,RW=class{constructor(e,t=LW){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},zW=20,BW=class extends xR{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new RW(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
118
+ `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(fB(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(vR(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<zW+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
119
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===zW+1&&(this._liveRegion.textContent+=lL.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(!(!a||!o)){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};BW=aL([Z(1,IL),Z(2,GL),Z(3,qL)],BW);var VW=class extends xR{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(vR(()=>{gR(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(fB(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(fB(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(fB(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(fB(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&HW(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,gR(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};VW=aL([Z(1,KL),Z(2,qL),Z(3,ML),Z(4,ZL)],VW);function HW(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var UW=class extends OW{constructor(e={}){super(e),this._linkifier=this._register(new SR),this.browser=tH,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new SR),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(FW),this._instantiationService.setService(VL,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(XV),this._instantiationService.setService(ZL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(HL)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(kR.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(kR.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(kR.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(kR.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(vR(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=vV.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${fW(r)}${uV.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=_V.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=_V.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(BW,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(fB(this.element,`copy`,e=>{this.hasSelection()&&fL(e,this._selectionService)}));let e=e=>pL(e,this.textarea,this.coreService,this.optionsService);this._register(fB(this.textarea,`paste`,e)),this._register(fB(this.element,`paste`,e)),aH?this._register(fB(this.element,`mousedown`,e=>{e.button===2&&gL(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(fB(this.element,`contextmenu`,e=>{gL(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),pH&&this._register(fB(this.element,`auxclick`,e=>{e.button===1&&hL(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(fB(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(fB(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(fB(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(fB(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(fB(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(fB(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(fB(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(fB(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,sL.get()),mH||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(JV,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(GL,this._coreBrowserService),this._register(fB(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(fB(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(WV,this._document,this._helperContainer),this._instantiationService.setService(WL,this._charSizeService),this._themeService=this._instantiationService.createInstance(QH),this._instantiationService.setService(XL,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(TV),this._instantiationService.setService(YL,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(bH,this.rows,this.screenElement)),this._instantiationService.setService(qL,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(dV,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance($V),this._instantiationService.setService(KL,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(VW,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(nV,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(HH,this.element,this.screenElement,r)),this._instantiationService.setService(JL,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(kR.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(rV,this.screenElement)),this._register(fB(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(BW,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(cV,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(cV,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(UV,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(fB(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(fB(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){mL(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=AW(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(WW(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(cU));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function WW(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var GW=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},KW=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new TL)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},qW=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new KW(t)}getNullCell(){return new TL}},JW=class extends xR{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new qW(this._core.buffers.normal,`normal`),this._alternate=new qW(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},YW=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},XW=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},ZW=[`cols`,`rows`],QW=0,$W=class extends xR{constructor(e){super(),this._core=this._register(new UW(e)),this._addonManager=this._register(new GW),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(ZW.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new YW(this._core),this._parser}get unicode(){return this._checkProposedApi(),new XW(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new JW(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
120
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return sL.get()},set promptLabel(e){sL.set(e)},get tooMuchOutput(){return lL.get()},set tooMuchOutput(e){lL.set(e)}}}_verifyIntegers(...e){for(QW of e)if(QW===1/0||isNaN(QW)||QW%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(QW of e)if(QW&&(QW===1/0||isNaN(QW)||QW%1!=0||QW<0))throw Error(`This API only accepts positive integers`)}},eG=2,tG=1,nG=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(eG,Math.floor(u/e.css.cell.width)),rows:Math.max(tG,Math.floor(l/e.css.cell.height))}}},rG={background:`#101010`,foreground:`#e6e6e6`,cursor:`#9dbefe`,cursorAccent:`#101010`,selectionBackground:`rgba(157, 190, 254, 0.25)`,black:`#101010`,red:`#fc533a`,green:`#12c905`,yellow:`#fcd53a`,blue:`#9dbefe`,magenta:`#edb2f1`,cyan:`#94e2d5`,white:`#e6e6e6`,brightBlack:`#555555`,brightRed:`#ff8a77`,brightGreen:`#6bff5c`,brightYellow:`#ffe57a`,brightBlue:`#c6dcff`,brightMagenta:`#ffd3f8`,brightCyan:`#b9fff2`,brightWhite:`#ffffff`};function iG({ptyID:e,onClose:t,onError:n}){let r=(0,E.useRef)(null),i=(0,E.useRef)(null),a=(0,E.useRef)(null),o=(0,E.useRef)(null),s=(0,E.useRef)(e);s.current=e;let[c,l]=(0,E.useState)(!1),u=async()=>{if(!c){l(!0);try{await G.ptyDelete(e),a.current?.close()}catch(e){l(!1),n?.(e instanceof Error?e.message:String(e))}}};return(0,E.useEffect)(()=>{let e=r.current;if(!e)return;let c=new $W({fontFamily:`"JetBrainsMono Nerd Font Mono", monospace`,fontSize:13,lineHeight:1.3,cursorBlink:!0,theme:rG,scrollback:5e3}),l=new nG;c.loadAddon(l),c.open(e);try{l.fit()}catch{}i.current=c,o.current=l,c.focus();let u=()=>{try{l.fit()}catch{return}let e=c.cols>0&&c.rows>0?{cols:c.cols,rows:c.rows}:null;e&&G.ptyUpdate(s.current,{size:e}).catch(()=>{})},d=new ResizeObserver(u);d.observe(e);let f=null,p=!1,m=!1,h=async()=>{try{let e=await G.ptyConnectToken(s.current),r=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/api/pty/${s.current}/connect?ticket=${e.data.ticket}`;if(p)return;f=new WebSocket(r),a.current=f,f.onopen=()=>u(),f.onmessage=e=>{typeof e.data==`string`?c.write(e.data):e.data instanceof Blob?e.data.arrayBuffer().then(e=>g(new Uint8Array(e),c)):g(new Uint8Array(e.data),c)},f.onclose=()=>{p||t()},f.onerror=()=>{n?.(`Terminal connection lost`)}}catch(e){n?.(e instanceof Error?e.message:String(e))}},g=(e,t)=>{if(e[0]===0){let t=new TextDecoder().decode(e.subarray(1));try{typeof JSON.parse(t).cursor==`number`&&!m&&(m=!0,u())}catch{}return}t.write(new Uint8Array(e))},_=c.onData(e=>{a.current?.readyState===WebSocket.OPEN&&a.current.send(e)});return h(),()=>{p=!0,_.dispose(),d.disconnect(),a.current?.close(),c.dispose(),i.current=null}},[e]),(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-mono text-xs text-[var(--text-weak)]`,children:e}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>void u(),disabled:c,title:`Kill process`,"aria-label":`Kill terminal`,className:`text-[color:var(--surface-critical-strong)]`,children:[(0,R.jsx)(et,{}),`Kill`]}),(0,R.jsx)(U,{variant:`ghost`,size:`sm`,onClick:t,children:`Close`})]})]}),(0,R.jsx)(`div`,{ref:r,className:`min-h-0 flex-1 bg-[var(--background-base)] p-2`})]})}var aG=12e4,oG={running:`blue`,exited:`green`,timeout:`amber`,killed:`red`};function sG(e){let t=e.time.completed??Date.now(),n=Math.max(0,Math.floor((t-e.time.started)/1e3));if(n<60)return`${n}s`;let r=Math.floor(n/60);return r<60?`${r}m ${n%60}s`:`${Math.floor(r/60)}h ${r%60}m`}function cG({trigger:e}){let[t,n]=(0,E.useState)(!1),[r,i]=(0,E.useState)(`shell`),a=J(e=>e.shellPanelTick);return(0,E.useEffect)(()=>{a>0&&n(!0)},[a]),(0,R.jsxs)(Km,{open:t,onOpenChange:n,children:[e===void 0?(0,R.jsx)(qm,{asChild:!0,children:(0,R.jsxs)(U,{variant:`ghost`,size:`sm`,children:[(0,R.jsx)(tt,{}),`Shell`]})}):(0,R.jsx)(qm,{asChild:!0,children:e}),(0,R.jsxs)(Zm,{className:`flex max-h-[85vh] flex-col gap-0 overflow-hidden p-0 sm:max-w-2xl md:max-w-3xl`,children:[(0,R.jsxs)(Qm,{className:`border-b border-(--border-weak-base) px-4 py-3`,children:[(0,R.jsxs)(eh,{className:`flex items-center gap-2`,children:[(0,R.jsx)(tt,{className:`size-4 text-(color:--text-interactive-base)`}),`Shell & Terminals`]}),(0,R.jsx)(th,{children:`Run shell commands and manage PTY sessions.`})]}),(0,R.jsxs)(Xx,{value:r,onValueChange:i,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsxs)(Qx,{variant:`line`,className:`mx-4 mt-3`,children:[(0,R.jsx)($x,{value:`shell`,children:`Shell`}),(0,R.jsx)($x,{value:`terminals`,children:`Terminals`})]}),(0,R.jsx)(eS,{value:`shell`,forceMount:!0,className:V(`min-h-0`,r!==`shell`&&`hidden`),children:(0,R.jsx)(lG,{active:r===`shell`})}),(0,R.jsx)(eS,{value:`terminals`,forceMount:!0,className:V(`min-h-0`,r!==`terminals`&&`hidden`),children:(0,R.jsx)(dG,{active:r===`terminals`})})]})]})]})}function lG({active:e}){let[t,n]=(0,E.useState)([]),[r,i]=(0,E.useState)(!0),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(String(aG)),[d,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)({}),_=(0,E.useRef)({}),v=(0,E.useCallback)(async()=>{try{let e=await G.shellList();n(e.data),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}},[]);(0,E.useEffect)(()=>{if(e)return v(),og({name:`shell-panel-list`,minInterval:5e3,run:()=>v()})},[e,v]);let y=(0,E.useCallback)(async e=>{try{let t=(await G.shellOutput(e,{cursor:_.current[e]})).data,n=t.truncated||_.current[e]===void 0;g(r=>({...r,[e]:(n?``:r[e]??``)+t.output})),_.current[e]=t.cursor}catch{g(t=>({...t,[e]:(t[e]??``)+`
121
+ [output stream unavailable]`}))}},[]);(0,E.useEffect)(()=>{if(!e||!p)return;let n=t.find(e=>e.id===p);if(!(!n||n.status!==`running`))return og({name:`shell-panel-output`,minInterval:1200,run:()=>y(p)})},[e,p,t,y]);let b=async()=>{if(!(!s.trim()||d)){f(!0),o(null);try{let e=Number(l),t=await G.shellCreate({command:s.trim(),timeout:Number.isFinite(e)&&e>0?e:aG});c(``),await v(),m(t.data.id)}catch(e){o(e instanceof Error?e.message:String(e))}finally{f(!1)}}},x=async e=>{try{await G.shellDelete(e),g(t=>{let n={...t};return delete n[e],n}),delete _.current[e],p===e&&m(null),await v()}catch(e){o(e instanceof Error?e.message:String(e))}},S=async(e,t)=>{let n=Number(t);if(!(!Number.isFinite(n)||n<0))try{await G.shellTimeout(e,n),await v()}catch(e){o(e instanceof Error?e.message:String(e))}};return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(nh,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},placeholder:`command to run`,className:`flex-1 font-mono text-xs`}),(0,R.jsx)(nh,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&b()},placeholder:`timeout ms`,title:`Timeout in milliseconds`,className:`w-24 font-mono text-xs`}),(0,R.jsxs)(U,{onClick:()=>void b(),disabled:!s.trim()||d,children:[(0,R.jsx)(Be,{}),`Run`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,title:`Refresh`,onClick:()=>void v(),children:(0,R.jsx)(Ke,{})})]}),a&&(0,R.jsx)(`p`,{className:`text-xs text-(color:--surface-critical-strong)`,children:a}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto`,children:r?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-(color:--text-weaker)`,children:[(0,R.jsx)(uS,{}),` Loading shells…`]}):t.length===0?(0,R.jsx)(`p`,{className:`px-1 py-2 text-xs text-(color:--text-weaker)`,children:`No shell sessions yet — run a command above.`}):t.map(e=>(0,R.jsx)(uG,{shell:e,expanded:p===e.id,output:h[e.id]??``,onToggle:()=>{m(t=>t===e.id?null:e.id),_.current[e.id]||y(e.id)},onKill:()=>void x(e.id),onSetTimeout:t=>void S(e.id,t)},e.id))})]})}function uG({shell:e,expanded:t,output:n,onToggle:r,onKill:i,onSetTimeout:a}){let[o,s]=(0,E.useState)(``),c=(0,E.useRef)(null);return(0,E.useEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[n]),(0,R.jsxs)(`div`,{className:`rounded-md border border-(--border-weak-base) bg-(--surface-base)`,children:[(0,R.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-2 px-2.5 py-1.5 hover:bg-(--surface-base-hover)`,onClick:r,children:[t?(0,R.jsx)(I,{className:`size-3.5 shrink-0 text-(color:--text-weaker)`}):(0,R.jsx)(L,{className:`size-3.5 shrink-0 text-(color:--text-weaker)`}),(0,R.jsx)(fS,{tone:oG[e.status],children:e.status}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-(color:--text-strong)`,children:e.command}),(0,R.jsx)(`span`,{className:`hidden max-w-40 truncate font-mono text-xs text-(color:--text-weaker) sm:inline`,children:e.cwd}),(0,R.jsxs)(`span`,{className:`shrink-0 text-xs text-(color:--text-weak)`,children:[mS(e.time.started),` · `,sG(e)]}),e.status===`running`&&(0,R.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:`Kill`,"aria-label":`Kill`,onClick:e=>{e.stopPropagation(),i()},className:`text-(color:--surface-critical-strong)`,children:(0,R.jsx)(et,{})})]}),t&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-(--border-weak-base) p-2.5`,children:[(0,R.jsx)(`pre`,{ref:c,className:V(`max-h-56 min-h-10 overflow-auto rounded-md border border-(--border-weak-base) bg-(--surface-inset-base) p-2 font-mono text-xs whitespace-pre-wrap text-(color:--text-base)`,!n&&`text-(color:--text-weaker)`),children:n||`No output yet…`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(nt,{className:`size-3.5 text-(color:--text-weaker)`}),(0,R.jsx)(nh,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(a(o),s(``))},placeholder:`set timeout (ms)`,className:`h-6 w-36 font-mono text-xs`}),(0,R.jsx)(U,{variant:`ghost`,size:`xs`,disabled:!o.trim(),onClick:()=>{a(o),s(``)},children:`Apply`})]})]})]})}function dG({active:e}){let[t,n]=(0,E.useState)([]),[r,i]=(0,E.useState)(!0),[a,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)(``),[d,f]=(0,E.useState)(``),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)({}),[_,v]=(0,E.useState)(Date.now()),[y,b]=(0,E.useState)(null),x=(0,E.useCallback)(async()=>{try{let e=await G.ptyList();n(e.data),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}},[]);(0,E.useEffect)(()=>{if(e)return x(),og({name:`pty-panel-list`,minInterval:5e3,run:()=>{x(),v(Date.now())}})},[e,x]);let S=async()=>{if(!(!l.trim()||p)){m(!0),o(null);try{await G.ptyCreate({command:l.trim(),cwd:d.trim()||void 0,title:s.trim()||void 0}),c(``),u(``),f(``),await x()}catch(e){o(e instanceof Error?e.message:String(e))}finally{m(!1)}}},C=async e=>{try{await G.ptyDelete(e),g(t=>{let n={...t};return delete n[e],n}),await x()}catch(e){o(e instanceof Error?e.message:String(e))}},w=async e=>{try{let t=await G.ptyConnectToken(e);g(n=>({...n,[e]:{kind:`connected`,ticket:t.data.ticket,expiresAt:Date.now()+t.data.expires_in*1e3}})),o(null)}catch(t){g(n=>({...n,[e]:{kind:`error`,message:t instanceof Error?t.message:String(t)}}))}};return(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:y?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(iG,{ptyID:y,onClose:()=>b(null),onError:e=>o(e)})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(nh,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`title`,className:`w-28 text-xs`}),(0,R.jsx)(nh,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`command (e.g. bash)`,className:`flex-1 font-mono text-xs`}),(0,R.jsx)(nh,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()},placeholder:`cwd (optional)`,className:`w-36 font-mono text-xs`}),(0,R.jsxs)(U,{onClick:()=>void S(),disabled:!l.trim()||p,children:[(0,R.jsx)(tt,{}),`Create`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon`,title:`Refresh`,onClick:()=>void x(),children:(0,R.jsx)(Ke,{})})]}),a&&(0,R.jsx)(`p`,{className:`text-xs text-(color:--surface-critical-strong)`,children:a}),(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto`,children:r?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-(color:--text-weaker)`,children:[(0,R.jsx)(uS,{}),` Loading terminals…`]}):t.length===0?(0,R.jsx)(`p`,{className:`px-1 py-2 text-xs text-(color:--text-weaker)`,children:`No PTY sessions yet — create one above.`}):t.map(e=>(0,R.jsx)(fG,{pty:e,connection:h[e.id],now:_,onConnect:()=>void w(e.id),onOpen:()=>b(e.id),onDelete:()=>void C(e.id)},e.id))}),(0,R.jsx)(tL,{className:`bg-(--border-weak-base)`}),(0,R.jsx)(`p`,{className:`text-xs text-(color:--text-weaker)`,children:`Live terminals stream over a websocket — open one to interact.`})]})})}function fG({pty:e,connection:t,now:n,onConnect:r,onOpen:i,onDelete:a}){let o=e.args.length>0?` ${e.args.join(` `)}`:``,s=t?.kind===`connected`?Math.max(0,Math.ceil((t.expiresAt-n)/1e3)):0;return(0,R.jsxs)(`div`,{className:`rounded-md border border-(--border-weak-base) bg-(--surface-base) px-2.5 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(fS,{tone:e.status===`running`?`blue`:`neutral`,children:e.status}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-(color:--text-strong)`,children:e.title||e.command}),(0,R.jsxs)(`span`,{className:`hidden shrink-0 text-xs text-(color:--text-weaker) md:inline`,children:[`pid `,e.pid,e.exitCode===void 0?``:` · exit ${e.exitCode}`]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:i,disabled:e.status!==`running`,children:[(0,R.jsx)($e,{}),`Open`]}),(0,R.jsxs)(U,{variant:`ghost`,size:`xs`,onClick:r,disabled:e.status!==`running`,children:[(0,R.jsx)(ie,{}),`Connect`]}),(0,R.jsx)(U,{variant:`ghost`,size:`icon-xs`,title:e.status===`running`?`Kill`:`Delete`,"aria-label":e.status===`running`?`Kill terminal`:`Delete terminal record`,onClick:a,className:`text-(color:--surface-critical-strong)`,children:e.status===`running`?(0,R.jsx)(et,{}):(0,R.jsx)(rt,{})})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 pl-5`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-(color:--text-weak)`,children:[e.command,o,e.cwd?` — ${e.cwd}`:``]}),t?.kind===`connected`?(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs`,children:[(0,R.jsx)(Ve,{className:`size-3 text-(color:--surface-success-strong)`}),(0,R.jsx)(fS,{tone:`green`,children:`connected`}),(0,R.jsxs)(`span`,{className:`hidden font-mono text-(color:--text-weaker) sm:inline`,children:[t.ticket.slice(0,10),`… · `,s,`s`]})]}):t?.kind===`error`?(0,R.jsx)(`span`,{className:`max-w-56 shrink-0 truncate`,title:t.message,children:(0,R.jsx)(fS,{tone:`red`,children:t.message})}):(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-(color:--text-weaker)`,children:`disconnected`})]})]})}var pG=`fixed top-1/2 left-1/2 z-50 flex w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 flex-col gap-2 rounded-lg border border-[var(--border-weak-base)] bg-[var(--surface-float-base)] p-4 text-sm text-popover-foreground duration-100 outline-none sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,mG=`w-full rounded-md border border-[var(--border-base)] bg-[var(--input-base)] px-2.5 py-1.5 text-sm text-[var(--text-strong)] outline-none transition-colors placeholder:text-[var(--text-weaker)] focus:border-[var(--border-selected)]`,hG=`flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors text-[color:var(--text-base)] hover:bg-[color:var(--surface-base-hover)]`,gG=`flex w-full cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors bg-[color:var(--surface-raised-base-active)] text-[color:var(--text-strong)]`;function _G(){return J(e=>e.splitPickerOpen)?(0,R.jsx)(vG,{}):null}function vG(){let e=J(e=>e.sessions),t=J(e=>e.panes),n=J(e=>e.running),r=J(e=>e.queued),i=J(e=>e.activeIDs),a=J(e=>e.currentSessionID&&!Eg(e.currentSessionID)?e.sessions.find(t=>t.id===e.currentSessionID)??e.sessionDetails[e.currentSessionID]:void 0),[o,s]=(0,E.useState)(`sessions`),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(0),[f,p]=(0,E.useState)(null),[m,h]=(0,E.useState)([]),[g,_]=(0,E.useState)(!1),[v,y]=(0,E.useState)(null),[b,x]=(0,E.useState)(null),S=(0,E.useRef)(null),C=(0,E.useRef)(!1),w=(0,E.useMemo)(()=>new Set(t.map(e=>e.sessionID)),[t]),T=c.trim().toLowerCase(),D=(0,E.useMemo)(()=>e.filter(e=>!w.has(e.id)&&!e.parentID&&(!T||(e.title??``).toLowerCase().includes(T)||e.id.toLowerCase().includes(T)||e.location.directory.toLowerCase().includes(T))).sort((e,t)=>t.time.updated-e.time.updated),[e,w,T]),O=Math.min(u,Math.max(0,D.length-1));(0,E.useEffect)(()=>d(0),[T]);let k=a?.location?.directory;function A(){s(`workspace`),x(null),!C.current&&(C.current=!0,_(!0),Promise.all([G.locationInfo(),G.projectList()]).then(([e,t])=>{p(e),h(t)}).catch(()=>x(`Could not load workspaces`)).finally(()=>_(!1)))}function j(){s(`sessions`),x(null)}function M(e){Gv(e).then(e=>{e||x(`Already open in a pane, or no free slots`)})}async function N(e,t){if(!v){y(e),x(null);try{await Gv(await Jy(t))||x(`No free split slots`)}catch(e){x(e instanceof Error?e.message:String(e))}finally{y(null)}}}let te=(0,E.useMemo)(()=>{let e=new Set;for(let t of m)t.directory&&e.add(t.directory);return[...e]},[m]);return(0,R.jsx)(es,{open:!0,onOpenChange:e=>{e||Wv()},children:(0,R.jsxs)(os,{children:[(0,R.jsx)(cs,{className:`bg-black/60`}),(0,R.jsxs)(fs,{tabIndex:-1,"data-slot":`dialog-content`,className:pG,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),S.current?.focus()},children:[(0,R.jsxs)(_s,{className:`flex items-center gap-2 text-[var(--font-size-large)] font-medium text-[var(--text-strong)]`,children:[(0,R.jsx)(Qe,{className:`size-4 shrink-0 text-[var(--text-interactive-base)]`,"aria-hidden":!0}),`Split view`,(0,R.jsx)(`span`,{className:`truncate text-xs font-normal text-[var(--text-weaker)]`,children:`open a session beside this one`})]}),o===`sessions`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{ref:S,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),d(Math.min(O+1,D.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),d(Math.max(O-1,0));else if(e.key===`Enter`){e.preventDefault();let t=D[O];t&&M(t.id)}},placeholder:`Filter sessions… (title, id, workspace)`,className:mG,autoComplete:`off`,spellCheck:!1}),(0,R.jsxs)(`button`,{type:`button`,onClick:A,disabled:v!==null,className:`flex w-full cursor-pointer items-center gap-2 rounded-md border border-dashed border-[var(--border-weak-base)] px-2 py-1.5 text-left text-sm text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)] disabled:pointer-events-none disabled:opacity-50`,children:[(0,R.jsx)(He,{className:`size-3.5 shrink-0`}),`Start new session`]}),(0,R.jsx)(`div`,{className:`-mx-1 max-h-72 overflow-y-auto px-1`,children:D.length===0?(0,R.jsx)(`p`,{className:`px-2 py-6 text-center text-xs text-[var(--text-weaker)]`,children:T?`No matching sessions`:`Every session is already in a pane`}):D.map((e,t)=>(0,R.jsx)(bG,{title:e.title||`session ${e.id.slice(0,8)}…`,dir:e.location.directory,at:e.time.updated,running:!!n[e.id]||!!r[e.id]||i.includes(e.id),highlighted:t===O,onHover:()=>d(t),onPick:()=>M(e.id)},e.id))})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:j,className:`flex cursor-pointer items-center gap-1 self-start rounded-md px-1 py-0.5 text-xs text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(ee,{className:`size-3`}),` all sessions`]}),(0,R.jsx)(`div`,{className:`-mx-1 max-h-80 overflow-y-auto px-1`,children:g?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-6 text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(uS,{className:`size-3`}),` Loading workspaces…`]}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(xG,{label:`Default workspace`,sub:f?.directory,busy:v==="default",disabled:v!==null,onChoose:()=>N(`default`,null)}),k&&a&&(0,R.jsx)(xG,{label:`same as ${a.title??`current session`}`,sub:k,busy:v===`focused`,disabled:v!==null,onChoose:()=>N(`focused`,k)}),te.map(e=>(0,R.jsx)(xG,{label:yG(e),sub:e,busy:v===e,disabled:v!==null,onChoose:()=>N(e,e)},e)),te.length===0&&!k&&(0,R.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-[var(--text-weaker)]`,children:`No workspaces`})]})})]}),b&&(0,R.jsx)(`p`,{className:`text-xs text-[var(--surface-critical-strong)]`,children:b}),(0,R.jsxs)(`p`,{className:`text-xs text-[var(--text-weaker)]`,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:`↑↓`}),` select · `,(0,R.jsx)(`span`,{className:`font-mono`,children:`↵`}),` open ·`,` `,(0,R.jsx)(`span`,{className:`font-mono`,children:`esc`}),` close`]}),(0,R.jsx)(xs,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close`,className:`absolute top-2 right-2 flex size-7 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:(0,R.jsx)(at,{className:`size-4`})})})]})]})})}function yG(e){let t=e.split(`/`).filter(Boolean);return t.length>0?t[t.length-1]:e}function bG({title:e,dir:t,at:n,running:r,highlighted:i,onHover:a,onPick:o}){let s=(0,E.useRef)(null);return(0,E.useEffect)(()=>{i&&s.current?.scrollIntoView({block:`nearest`})},[i]),(0,R.jsxs)(`button`,{ref:s,type:`button`,onMouseMove:a,onClick:o,title:t,className:i?gG:hG,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${r?`animate-pulse bg-emerald-500`:`bg-[color:var(--border-base)]`}`}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),(0,R.jsx)(`span`,{className:`max-w-44 shrink-0 truncate font-mono text-[10px] text-[var(--text-weaker)]`,children:t}),r&&(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:`running`}),(0,R.jsx)(`span`,{className:`w-8 shrink-0 text-right font-mono text-[10px] text-[var(--text-weaker)]`,children:pS(n)})]})}function xG({label:e,sub:t,busy:n,disabled:r,onChoose:i}){return(0,R.jsxs)(`button`,{type:`button`,onClick:i,disabled:r,className:n?gG:hG,children:[n?(0,R.jsx)(uS,{className:`size-3.5 shrink-0`}):(0,R.jsx)(Ee,{className:`size-3.5 shrink-0 text-[var(--text-weaker)]`}),(0,R.jsx)(`span`,{className:`min-w-0 shrink truncate`,children:e}),t&&(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[10px] text-[var(--text-weaker)]`,children:t})]})}var SG=`webui.activityStrip.collapsed`,CG=15e3;function wG(e){return e?e.replace(/\/+$/,``).replace(/^\/(home|Users)\/[^/]+/,`~`):``}function TG(e){let t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r?`${n}m ${r}s`:`${n}m`}function EG(e){let t=e.name||`tool`;if(e.status===`streaming`&&e.inputText){let n=e.inputText.replace(/\s+/g,` `).trim().slice(0,80);return n?`${t} ${n}…`:t}let n=e.input;if(n){if(typeof n.path==`string`)return`${t} ${String(n.path).split(`/`).pop()}`;if(typeof n.command==`string`)return`${t} ${String(n.command).slice(0,48)}`;if(typeof n.pattern==`string`)return`${t} "${String(n.pattern).slice(0,32)}"`;if(typeof n.description==`string`)return`${t} ${n.description.slice(0,40)}`;if(typeof n.agent==`string`&&typeof n.description==`string`)return`${t} ${String(n.agent)} — ${String(n.description).slice(0,24)}`}if(e.inputText){try{let n=JSON.parse(e.inputText);if(typeof n.path==`string`)return`${t} ${String(n.path).split(`/`).pop()}`;if(typeof n.command==`string`)return`${t} ${String(n.command).slice(0,48)}`}catch{}let n=e.inputText.replace(/\s+/g,` `).trim().slice(0,80);if(n&&n!==`{}`&&n!==`[]`)return`${t} ${n}`}return t}function DG(e){document.querySelectorAll(`link[rel="stylesheet"], style`).forEach(t=>{e.document.head.appendChild(t.cloneNode(!0))});try{document.adoptedStyleSheets?.length&&(e.document.adoptedStyleSheets=document.adoptedStyleSheets)}catch{}}function OG({tool:e}){let t=e.status===`running`||e.status===`streaming`,n=e.status===`error`,r=n?`✗`:t?`⠋`:e.name===`subagent`?`→`:e.name===`shell`||e.name===`bash`?`$`:e.name===`edit`?`←`:`·`;return(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate py-0.5 text-[11px] ${n?`text-[var(--surface-critical-strong)]`:t?`text-[var(--text-base)]`:`text-[var(--text-weak)]`}`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0 text-center font-mono text-[10px] ${t?`animate-pulse`:``}`,children:t?`●`:r}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:EG(e)}),t&&(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 animate-pulse rounded-full bg-emerald-500`,"aria-hidden":!0})]})}function kG({assistants:e}){if(e.length===0)return(0,R.jsx)(`span`,{className:`text-[11px] italic text-[var(--text-weaker)]`,children:`waiting…`});let t=e.flatMap(e=>e.content),n=t.filter(e=>e.type===`reasoning`).slice(-1),r=t.filter(e=>e.type===`text`).slice(-2),i=t.filter(e=>e.type===`tool`).slice(-6),a=i.filter(e=>e.tool.status===`running`||e.tool.status===`streaming`),o=[...i.filter(e=>e.tool.status!==`running`&&e.tool.status!==`streaming`).slice(-3),...a];return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[n.length>0&&(0,R.jsx)(`div`,{className:`line-clamp-1 truncate text-[11px] italic text-[var(--text-weaker)]`,children:(()=>{let e=n[0].text.replace(/\s+/g,` `).trim();return`thought: ${e.length>140?`…${e.slice(-140)}`:e}`})()}),r.map(e=>{let t=e.text.replace(/\s+/g,` `).trim();if(!t)return null;let n=t.length>220?`…${t.slice(-220)}`:t;return(0,R.jsx)(`div`,{className:`line-clamp-2 break-words text-xs leading-snug text-[var(--text-base)]`,children:n},`t-${e.ordinal}`)}),o.map(e=>(0,R.jsx)(OG,{tool:e.tool},e.tool.id)),t.length===0&&(0,R.jsx)(`span`,{className:`text-[11px] text-[var(--text-weaker)]`,children:`working…`})]})}function AG({session:e,assistants:t,running:n,queued:r,onOpen:i}){let[a,o]=(0,E.useState)(0);(0,E.useEffect)(()=>{if(n)return og({name:`activity-row-elapsed`,minInterval:1e3,run:()=>o(e=>e+1)})},[n]);let s=t[0]?.started??e.time?.updated??Date.now(),c=n?`running`:r?`queued`:`idle`;return(0,R.jsxs)(`div`,{className:`group flex min-w-0 flex-col gap-1 rounded-md border border-[var(--border-weak-base)] bg-[var(--surface-base)] px-2 py-1.5 hover:border-[var(--border-base)]`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full ${c===`running`?`bg-emerald-500 animate-pulse`:c===`queued`?`bg-amber-500 animate-pulse`:`bg-[var(--border-base)]`}`,"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-[var(--text-strong)]`,title:e.title??e.id,children:e.title||`Untitled session`}),e.location?.directory&&(0,R.jsx)(`span`,{className:`hidden max-w-[14ch] truncate font-mono text-[10px] text-[var(--text-weaker)] sm:inline`,title:e.location.directory,children:wG(e.location.directory)}),(0,R.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-[var(--text-weaker)]`,children:n?TG(s):r?`queued`:``}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),title:`Open session`,className:`inline-flex shrink-0 cursor-pointer items-center gap-1 rounded-md border border-transparent px-1 py-0.5 text-[11px] text-[var(--text-weaker)] hover:border-[var(--border-weak-base)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(pe,{className:`size-3`}),` open`]})]}),(0,R.jsx)(`div`,{className:`min-w-0 pl-3`,children:(0,R.jsx)(kG,{assistants:t})})]})}function jG({onOpen:e}){let t=J(e=>e.sessions),n=J(e=>e.running),r=J(e=>e.queued),i=J(e=>e.activeIDs),a=J(e=>e.live),o=(0,E.useMemo)(()=>{let e=new Map;for(let t of a){let n=e.get(t.sessionID)??[];n.push(t),e.set(t.sessionID,n)}for(let t of e.values())t.sort((e,t)=>e.started-t.started);return e},[a]),s=e=>n[e]||r[e]||(o.get(e)??[]).some(e=>e.finish===void 0)?!0:i.includes(e)&&Date.now()-Jg(e)<CG,c=(0,E.useMemo)(()=>{let e=t.filter(e=>!e.parentID),r=[];for(let n of e){let e=Ov(t,n.id).filter(e=>s(e.id)),i=s(n.id);(i||e.length>0)&&r.push({parent:n,parentLive:i,children:e})}let i=new Set(r.flatMap(e=>e.children.map(e=>e.id))),a=t.filter(e=>!!e.parentID&&s(e.id)&&!i.has(e.id));for(let e of a){let n=t.find(t=>t.id===e.parentID)??{id:e.parentID,title:`Parent`,time:{updated:0}};r.find(t=>t.parent.id===e.parentID)||r.push({parent:n,parentLive:!1,children:[e]})}return r.sort((e,t)=>{let r=e.parentLive&&n[e.parent.id]?1:+!!e.children.some(e=>!!n[e.id]),i=t.parentLive&&n[t.parent.id]?1:+!!t.children.some(e=>!!n[e.id]);return r===i?(t.parent.time?.updated??0)-(e.parent.time?.updated??0):i-r}),r},[t,n,r,i,a,o]);return c.length===0?(0,R.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--text-weaker)]`,children:`No active agents.`}):(0,R.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(t=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t.parentLive?(0,R.jsx)(AG,{session:t.parent,assistants:o.get(t.parent.id)??[],running:!!n[t.parent.id],queued:!!r[t.parent.id],onOpen:e}):(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1 text-[11px] font-medium text-[var(--text-weaker)]`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t.parent.title||wG(t.parent.location?.directory)||t.parent.id.slice(0,8)}),(0,R.jsxs)(`span`,{className:`font-mono text-[10px]`,children:[`· `,t.children.length,` subagent`,t.children.length===1?``:`s`]})]}),t.children.length>0&&(0,R.jsx)(`div`,{className:`ml-3 flex flex-col gap-1 border-l border-[var(--border-weak-base)] pl-2`,children:t.children.map(t=>(0,R.jsx)(AG,{session:t,assistants:o.get(t.id)??[],running:!!n[t.id],queued:!!r[t.id],onOpen:e},t.id))})]},t.parent.id))})}function MG(){let e=J(e=>e.running),t=J(e=>e.queued),n=J(e=>e.live),r=J(e=>e.activeIDs),[,i]=(0,E.useState)(0),a=(0,E.useMemo)(()=>{let e=new Map;for(let t of n){let n=e.get(t.sessionID)??[];n.push(t),e.set(t.sessionID,n)}return e},[n]),o=n=>e[n]||t[n]||(a.get(n)??[]).some(e=>e.finish===void 0)?!0:r.includes(n)&&Date.now()-Jg(n)<CG,s=(0,E.useMemo)(()=>{let i=new Set([...Object.keys(e),...Object.keys(t),...r,...n.map(e=>e.sessionID)]);for(let e of i)if(o(e))return!0;return!1},[e,t,r,n,a]);(0,E.useEffect)(()=>{if(s)return og({name:`activity-strip-tick`,minInterval:1e3,run:()=>i(e=>e+1)})},[s]);let[c,l]=(0,E.useState)(()=>{try{return localStorage.getItem(SG)===`1`}catch{return!1}}),[u,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(null),m=typeof window<`u`&&`documentPictureInPicture`in window;(0,E.useEffect)(()=>{try{localStorage.setItem(SG,c?`1`:`0`)}catch{}},[c]);let h=(0,E.useMemo)(()=>{let i=new Set([...Object.keys(e),...Object.keys(t),...r,...n.map(e=>e.sessionID)]),a=0;for(let e of i)o(e)&&a++;return a},[e,t,r,n,a]);if(!s)return null;let g=e=>void Jv(e),_=async()=>{if(u){u.close(),d(null),p(null);return}try{let e=await window.documentPictureInPicture.requestWindow({width:380,height:560});DG(e),e.document.body.style.margin=`0`,e.document.documentElement.style.background=`var(--background-base)`,e.document.body.style.background=`var(--background-base)`,e.document.body.style.fontFamily=getComputedStyle(document.body).fontFamily;let t=e.document.createElement(`div`);t.id=`activity-strip-pip-root`,t.style.height=`100vh`,t.style.overflow=`auto`,t.style.background=`var(--background-base)`,e.document.body.appendChild(t),p(t),d(e),e.addEventListener(`pagehide`,()=>{d(null),p(null)})}catch(e){console.warn(`PiP failed`,e)}};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-[var(--border-base)] bg-[var(--background-base)]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-[var(--text-strong)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-emerald-500`,"aria-hidden":!0}),h,` active`,(0,R.jsx)(`span`,{className:`font-normal text-[var(--text-weaker)]`,children:`· streaming`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[m&&(0,R.jsxs)(`button`,{type:`button`,onClick:_,title:u?`Close picture-in-picture`:`Pop out — always on top outside Chrome`,className:`inline-flex cursor-pointer items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] ${u?`border-[var(--border-selected)] bg-[var(--surface-interactive-weak)] text-[var(--text-interactive-base)]`:`border-[var(--border-weak-base)] text-[var(--text-weaker)] hover:text-[var(--text-strong)]`}`,children:[(0,R.jsx)(ze,{className:`size-3`}),` `,u?`popped`:`pop out`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),title:c?`Expand`:`Collapse`,className:`flex size-6 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] hover:bg-[var(--surface-base-hover)] hover:text-[var(--text-strong)]`,children:c?(0,R.jsx)(I,{className:`size-3.5`}):(0,R.jsx)(oe,{className:`size-3.5`})})]})]}),c?null:(0,R.jsx)(`div`,{className:`max-h-[42vh] overflow-auto px-2 pb-2`,children:(0,R.jsx)(jG,{onOpen:g})})]}),u&&f?(0,jr.createPortal)((0,R.jsxs)(`div`,{className:`min-h-screen bg-[var(--background-base)] p-2`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium text-[var(--text-strong)]`,children:[`Live — `,h,` active`]}),(0,R.jsx)(`button`,{type:`button`,onClick:_,className:`rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-[11px] text-[var(--text-weaker)]`,children:`close`})]}),(0,R.jsx)(jG,{onOpen:e=>{Jv(e);try{window.focus()}catch{}}})]}),f):null]})}function NG(e){let t=e.toLowerCase().split(`+`).map(e=>e.trim()).filter(Boolean),n=!1,r=!1,i=!1,a=!1,o=``;for(let e of t)e===`ctrl`||e===`control`?n=!0:e===`meta`||e===`cmd`||e===`command`||e===`super`?r=!0:e===`shift`?i=!0:e===`alt`||e===`option`?a=!0:o=e;return{ctrl:n,meta:r,shift:i,alt:a,key:o}}function PG(e,t){let n=NG(e);return!n.key||n.ctrl!==t.ctrlKey||n.meta!==t.metaKey||n.shift!==t.shiftKey||n.alt!==t.altKey?!1:t.key.toLowerCase()===n.key.toLowerCase()}function FG(e){let t=e;return t?t.isContentEditable||t.closest?.(`input, textarea, select, [contenteditable=true]`)?!0:t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`:!1}function IG(){return(0,E.useEffect)(()=>{let e=St(),t=pt(()=>{e=St()}),n=t=>{if(!t.repeat&&!FG(t.target)&&!document.querySelector(`[role="dialog"], [cmdk-root], [data-radix-popper-content-wrapper], [role="menu"], [role="listbox"]`))for(let n of e){let e=n.keybind;if(e&&PG(e,t)){t.preventDefault();try{let e=Ng().currentSessionID??void 0;n.run({sessionID:e})}catch(e){console.error(`[extensions] command "${n.id}" keybind failed:`,e)}break}}};return window.addEventListener(`keydown`,n),()=>{t(),window.removeEventListener(`keydown`,n)}},[]),null}function LG(){let e=(0,E.useSyncExternalStore)(DS,OS,OS);return e.length===0?null:(0,R.jsx)(`div`,{className:`pointer-events-none fixed right-4 bottom-4 z-50 flex w-[min(22rem,calc(100vw-2rem))] flex-col gap-2`,children:e.map(e=>(0,R.jsxs)(`div`,{role:`status`,className:`pointer-events-auto flex flex-col gap-0.5 rounded-md border px-3 py-2.5 shadow-lg backdrop-blur-sm transition-all ${e.variant===`destructive`?`border-[color:var(--surface-critical-strong)] bg-[color-mix(in_oklch,var(--surface-critical-strong)_12%,var(--surface-float-base))] text-[var(--text-strong)]`:`border-[var(--border-weak-base)] bg-[var(--surface-float-base)] text-[var(--text-strong)]`}`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium leading-tight`,children:e.title}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>kS(e.id),className:`shrink-0 cursor-pointer text-[var(--text-weaker)] transition-colors hover:text-[var(--text-strong)]`,"aria-label":`Dismiss`,children:`✕`})]}),e.description?(0,R.jsx)(`span`,{className:`text-xs leading-snug text-[var(--text-weak)]`,children:e.description}):null]},e.id))})}function RG(e,t=`main`){let n=Ng();if(n.currentSessionID&&Sg(n).some(e=>e.req.sessionID===n.currentSessionID))return;wv();let r=document.getElementById(`composer-input-${t}`);if(r){r.focus({preventScroll:!0});return}zG(e,t)}function zG(e,t){let n=0,r=()=>{let i=document.getElementById(`composer-input-${t}`);if(!i){n++===2&&Ev(),n<30&&requestAnimationFrame(r);return}i.focus({preventScroll:!0});let a=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set;if(a){a.call(i,i.value+e),i.dispatchEvent(new Event(`input`,{bubbles:!0}));let t=i.value.length;i.setSelectionRange(t,t)}};requestAnimationFrame(r)}var BG=/^\/ext\/([A-Za-z0-9_-]+)$/,VG=`webui:navigate`;function HG(){let[e,t]=(0,E.useState)(()=>window.location.pathname);return(0,E.useEffect)(()=>{let e=()=>t(window.location.pathname);return window.addEventListener(`popstate`,e),window.addEventListener(VG,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(VG,e)}},[]),e}function UG(){let e=J(e=>e.currentSessionID),t=J(e=>e.connected),n=J(e=>e.currentSessionID?e.sessions.find(t=>t.id===e.currentSessionID)??e.sessionDetails[e.currentSessionID]:void 0),r=J(e=>e.sessions),i=J(e=>e.runsPanelOpen),a=J(t=>kv(t,e)),o=J(e=>e.panes[0]?.sessionID??null),s=J(e=>e.panes.slice(1)),c=J(e=>e.focusedPane),l=HG(),u=BG.exec(l)?.[1]??null,d=(u?At(u):void 0)?.title;(0,E.useEffect)(()=>{if(d!==void 0){document.title=d;return}document.title=e?`${a?`● `:``}${Eg(e)?`New session`:n?.title??`Untitled session`}`:`OpenCode Web`},[e,n?.title,a,d]);function f(){return!!document.querySelector(`[role="dialog"]`)||i}let p=e=>void Jv(e);function m(t){if(!e||!n?.parentID||f())return;let i=Ov(r,n.parentID).slice().sort((e,t)=>e.id<t.id?-1:1);if(i.length===0)return;let a=i.findIndex(t=>t.id===e),o=(((a===-1?0:a)+t)%i.length+i.length)%i.length;p(i[o].id)}(0,E.useEffect)(()=>{let e=e=>{if(e.key.length!==1||e.metaKey)return;let t=e.ctrlKey&&e.altKey;if(e.ctrlKey&&!t||e.altKey&&!t)return;let n=e.target;n&&(n.isContentEditable||n.closest(`input, textarea, select, [contenteditable=true]`))||document.querySelector(`[role="dialog"], [cmdk-root], [data-radix-popper-content-wrapper], [role="menu"], [role="listbox"]`)||RG(e.key,Yv())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);function h(){if(f())return;let e=document.getElementById(`session-search`);e&&(e.focus(),e.select())}hb({arrowup:()=>{!n?.parentID||!e||f()||p(n.parentID)},arrowdown:()=>{!e||f()||Cv()},arrowleft:()=>m(-1),arrowright:()=>m(1),enter:()=>{!n?.parentID||!e||f()||Ev()},backspace:()=>{if(!n?.parentID||!e||f())return;let t=document.getElementById(`composer-input-${Yv()}`);t&&t.value!==``||p(n.parentID)},"ctrl+n":()=>Wy(null),"ctrl+\\":()=>Uv(),"meta+f":h,"ctrl+f":h,escape:e=>{let t=e?.target;document.querySelector(`[role="dialog"]`)||t&&(t.id.startsWith(`composer-input`)||t.closest(`[data-radix-popper-content-wrapper], [cmdk-root], [data-slot="command"]`))||Iy()}});let g=e=>()=>void Hv(e);return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden`,children:[(0,R.jsx)(Nt,{region:`app.header`,sessionID:e??void 0}),(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,R.jsx)(KI,{}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto`,children:[(0,R.jsx)(`section`,{className:`flex min-w-0 flex-1 flex-col`,onPointerDownCapture:g(wg),onFocusCapture:g(wg),children:u?(0,R.jsx)(KG,{id:u}):o?(0,R.jsx)(IF,{sessionID:o,paneKey:`main`,focused:c===wg,onNavigate:p},o):(0,R.jsx)(GG,{connected:t})}),s.map(e=>(0,R.jsx)(`section`,{className:`pane-surface hidden min-w-0 border-l border-[var(--border-base)] lg:flex`,style:{flex:`1 1 0`,maxWidth:`50%`},onPointerDownCapture:g(e.id),onFocusCapture:g(e.id),children:e.sessionID?(0,R.jsx)(IF,{sessionID:e.sessionID,paneKey:e.id,focused:c===e.id,onClose:()=>void Kv(e.id),onNavigate:p},`${e.id}:${e.sessionID}`):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-[var(--text-weaker)]`,children:`Empty pane`})},e.id)),(0,R.jsx)(`div`,{className:`hidden w-9 shrink-0 flex-col items-center border-l border-[var(--border-base)] pt-2 lg:flex`,children:(0,R.jsx)(`button`,{type:`button`,onClick:Uv,disabled:s.length>=3,title:`Split view — open a session beside this one`,className:`flex size-7 cursor-pointer items-center justify-center rounded-md text-[var(--text-weaker)] transition-colors hover:bg-[color:var(--surface-base-hover)] hover:text-[var(--text-strong)] disabled:pointer-events-none disabled:opacity-40`,children:(0,R.jsx)(le,{className:`size-4`})})})]})]}),(0,R.jsx)(MG,{}),(0,R.jsx)(Nt,{region:`footer`}),(0,R.jsx)(WG,{}),(0,R.jsx)(_G,{}),(0,R.jsx)(yb,{}),(0,R.jsx)(IG,{}),(0,R.jsx)(LG,{}),(0,R.jsx)(ZF,{}),(0,R.jsx)(cG,{trigger:(0,R.jsx)(`span`,{className:`hidden`})})]})}function WG(){let e=J(e=>Sg(e).filter(t=>t.req.sessionID!==e.currentSessionID)),t=e.map(e=>e.req.id).join(`,`);return(0,E.useEffect)(()=>{t&&Hh(`chip`,`foreign waiting: ${t}`)},[t]),e.length===0?null:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void Pv(e[0].req.sessionID,{history:`push`}),title:e.map(e=>`${e.kind} — ${e.req.sessionID}`).join(`
122
+ `),className:`fixed right-4 bottom-10 z-40 flex items-center gap-1.5 rounded-full border border-[color-mix(in_oklch,var(--surface-warning-strong)_45%,transparent)] bg-[var(--surface-float-base)] px-2.5 py-1 text-xs text-[var(--text-weak)] shadow-md transition-colors hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-[color:var(--surface-warning-strong)]`,"aria-hidden":!0}),e.length,` waiting in other session`,e.length>1?`s`:``,` — switch`]})}function GG({connected:e}){return(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-neutral-500`,children:[(0,R.jsx)(`div`,{className:`size-2.5 rounded-full ${e?`bg-emerald-500`:`bg-amber-500`}`}),(0,R.jsx)(`p`,{className:`text-sm`,children:e?`Select or create a session on the left`:`Connecting to the opencode service…`})]})}function KG({id:e}){qG();let t=At(e),n=Tt();return(0,R.jsx)(`div`,{className:`pane-surface flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto`,children:(0,R.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6`,children:[(0,R.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>window.history.back(),title:`Go back`,className:`inline-flex cursor-pointer items-center gap-1 rounded-md border border-[var(--border-weak-base)] px-1.5 py-0.5 text-xs text-[var(--text-weak)] transition-colors hover:border-[var(--border-selected)] hover:text-[var(--text-strong)]`,children:[(0,R.jsx)(ee,{className:`size-3`}),`Back`]}),(0,R.jsx)(`h1`,{className:`truncate text-[var(--font-size-large)] font-medium text-[var(--text-strong)]`,children:t?t.title:`Unknown extension page`})]}),t?.description&&(0,R.jsx)(`p`,{className:`mt-1 text-sm text-[var(--text-weaker)]`,children:t.description})]})}),(0,R.jsx)(`div`,{className:`mt-4`,children:t?t.render({}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm text-[var(--text-weak)]`,children:[(0,R.jsxs)(`p`,{children:[`No extension registered “`,e,`”. Available pages:`]}),n.length===0?(0,R.jsx)(`p`,{className:`text-[var(--text-weaker)]`,children:`No extension pages are registered.`}):(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:n.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`a`,{href:`/ext/${e.id}`,title:e.description??e.title,className:`text-[var(--text-interactive-base)] underline underline-offset-2`,children:[`/ext/`,e.id,` — `,e.title]})},e.id))})]})})]})})}function qG(){let[e,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>pt(()=>t(e=>e+1)),[]),[e]}var JG=class extends E.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){console.error(`[app] render error:`,e)}render(){return this.state.error?(0,R.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[(0,R.jsx)(`p`,{className:`text-sm text-foreground`,children:`The UI hit a render error.`}),(0,R.jsx)(`pre`,{className:`max-h-48 max-w-full overflow-auto rounded-md border border-border bg-muted p-3 font-mono text-xs whitespace-pre-wrap text-muted-foreground`,children:this.state.error.message}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`cursor-pointer rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-muted`,children:`Retry`})]}):this.props.children}},YG=Object.assign({"./report/index.tsx":()=>ug(()=>import(`./report-bjdxXk2S.js`),[]),"./runtime-status/index.tsx":()=>ug(()=>import(`./runtime-status-DGOzOYuv.js`),[])});async function XG(){let e=new Set;await Promise.all(Object.values(YG).map(async t=>{let n=await t();n&&typeof n.id==`string`&&e.add(n.id)})),ht(e)}XG();var ZG=new Map,QG=8e3;function $G(){let e=window,t=e.__opencodeUI??{};t.notify||=AS,t.getHooks||=kt,t.register||=yt,e.__opencodeUI=t}var eK=!1;async function tK(e){if($G(),!e?.force&&eK&&document.hidden)return;let t;try{let e=await fetch(`/api/webui/extensions`);if(!e.ok)return;let n=(await e.json())?.data;t=Array.isArray(n)?n:[]}catch{return}let n=new Set;for(let e of t)if(typeof e?.id==`string`&&typeof e?.url==`string`&&!aS(e.id)&&(n.add(e.id),gt([e.id]),ZG.get(e.id)!==e.url))try{await ug(()=>import(e.url),[]),ZG.set(e.id,e.url)}catch{}let r=[];for(let e of ZG.keys())n.has(e)||(r.push(e),ZG.delete(e));r.length>0&&_t(r)}function nK(){eK||(eK=!0,$G(),tK({force:!0}),og({name:`extensions-manifest`,minInterval:QG,run:()=>tK()}))}var rK=typeof localStorage<`u`&&localStorage.getItem(`webui.debug`)===`1`;window.__WEBUI_DEBUG_CONSOLE__=rK,window.__opencodeUI={version:1,register:yt,react:E,jsxRuntime:R,useStore:J,api:G,notify:AS,getHooks:kt},nK(),mv(),Hh(`boot`,`app render (console mirror: ${rK?`on`:`off`})`),(0,ot.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(E.StrictMode,{children:(0,R.jsx)(JG,{children:(0,R.jsx)(UG,{})})}));export{ey as a,st as c,Yy as i,p as l,Ng as n,J as o,Eg as r,yt as s,AS as t,l as u};